Non Power of Two Textures 无二次幂限制的纹理
2015-09-04 14:40
369 查看
无二次幂限制的纹理(Non-Power-of-Two
Textures)
OpenGL仅支持分辨率为2mx2n的纹理。但现在我们可以使用“无二次幂限制”的纹理。
OpenGL only supports textures with 2m x 2n resolution.But "Non-Power-of-Two" textures can be useful.
与之匹配的屏幕分辨率或包围区域不一定等于二次幂(800x600)
Matching some screen resolution or bounding region that is not necessarily a power of two (800x600)
消除限制的w/WGL_NV_render_texture_rectangle扩展指令:
Restriction lifted w/ WGL_NV_render_texture_rectangle extension:
无二次幂限制的纹理仅有少许差异
Non-power-of-two textures BUT some differences
纹理坐标贴图的差异
Texture coordinates map differently
Support for non power of two (“NPOT”, i.e. arbitrary sized) textures has been in GPUs for quite a while, but the state of support can be confusing. Recent question from@rygorous
:
Lazyweb, <…> GL question: <…> ARB NPOT textures is fairly demanding, and texture rectangle are awkward. Is there an equivalent to ES2-style semantics in regular GL? Bonus Q: Is there something like the Unity HW survey, but listing supported GL extensions?
:)
There are generally three big types of texture size support:
Full support for arbitrary texture sizes. This includes mipmaps, all texture wrap & filtering modes, and most often compressed texture formats as well.
“Limited” support for non-power-of-two sizes. No mipmaps, texture wrap mode has to be Clamp, but does allow texture filtering. This makes such textures not generally useful in 3D space, but just good enough for anything in screen space (UI, 2D, postprocessing).
No support, texture sizes have to be powers of two (16,32,64,128,…). If you’re running on really,really old GPU then textures might also need to be square (width = height).
Direct3D 9
Things are quite simple here.
D3DCAPS9.TextureCaps has capability bits,
support for NPOT texture sizes. When both
on , then you have limited NPOT support.
I’ve no idea what would it mean if NONPOW2CONDITIONAL bit is set, but POW2 bit is not.
Hardware wise, limited NPOT has been generally available since 2002-2004, and full NPOT since 2006 or so.
Direct3D 11
Very simple; feature level 10_0 and up has full support for NPOT sizes; while feature level 9_x has limited support for NPOT.MSDN link .
OpenGL
Support for NPOT textures has been a core OpenGL feature since 2.0; promoted from earlierARB_texture_non_power_of_two extension. The extension specifies “full”
support for NPOT, including mipmaps & wrapping modes. There’s no practical way to detect hardware that can only do “limited” NPOT textures.
However, in traditional OpenGL spirit, presence of something in the API does not mean it can run on the GPU… E.g. Mac OS X withRadeon X1600 GPU is an OpenGL 2.1+
system, and as such pretends there’s full support for NPOT textures. In practice, as soon as you have NPOT size with mipmaps or a non-clamp wrap mode, you drop into software rendering.
Ouch.
A rule of thumb that seems to work: try to detect “DX10+” level GPU, and in that case assume full NPOT support isactually there. Otherwise, in GL2.0+ or when
Then the question of course is, how to detect DX10+ level GPU in OpenGL? If you’re using OpenGL 3+, then you are on DX10+ GPU. In earlier GL versions, you’d have to use some heuristics. For example, if you have
and
, lower than 8192 is a good indicator for pre-DX10.
OpenGL ES
OpenGL ES 3.0 has full NPOT support in core; ES 2.0 has limited NPOT support (no mipmaps, no Repeat wrap mode) in core; and ES 1.1 has no NPOT support.
For ES 1.1 and 2.0, full NPOT support comes with
don’t support this; and on Android side there’s support on Qualcomm Adreno and ARM Mali. Possibly some others.
For ES 1.1, limited NPOT support comes with
devices I guess).
WebGL and Native Client currently are pretty much OpenGL ES 2.0, and thus support limited NPOT textures.
Flash Stage3D
Sad situation here; current version of Stage3D (as of Flash Player 11.4) has no NPOT support whatsoever. Not even for render targets.
Consoles
I wouldn’t be allowed to say anything about them, now would I? :) Check documentation that comes with your developer access on each console.
Is there something like the Unity HW survey, but listing supported GL extensions?
Not a single good resource, but there are various bits and pieces:
Unity Web Player hardware stats - no GL extensions, but we do map GPUs to “DX-like” levels and from there you can sort of infer things.
Steam Hardware Survey - likewise.
Apple OpenGL Capabilities - tables of detailed GL info for recent OS X versions and all GPUs supported by Apple. Excellent resource for Mac programmers! Apple
does remove pages of old OS X versions from there, you’d have to use
archive.org to get them back.
GLBenchmark Results - results database of GLBenchmark, has list of OpenGL ES extensions and some caps bits for each result (“GL config.” tab).
Realtech VR GLView - OpenGL & OpenGL ES extensions and capabilities viewer, for Windows, Mac, iOS & Android.
Omni Software Update Statistics - Mac specific, but does list some OpenGL stats from “Graphics” dropdown.
Textures)
OpenGL仅支持分辨率为2mx2n的纹理。但现在我们可以使用“无二次幂限制”的纹理。
OpenGL only supports textures with 2m x 2n resolution.But "Non-Power-of-Two" textures can be useful.
与之匹配的屏幕分辨率或包围区域不一定等于二次幂(800x600)
Matching some screen resolution or bounding region that is not necessarily a power of two (800x600)
消除限制的w/WGL_NV_render_texture_rectangle扩展指令:
Restriction lifted w/ WGL_NV_render_texture_rectangle extension:
无二次幂限制的纹理仅有少许差异
Non-power-of-two textures BUT some differences
纹理坐标贴图的差异
Texture coordinates map differently
Support for non power of two (“NPOT”, i.e. arbitrary sized) textures has been in GPUs for quite a while, but the state of support can be confusing. Recent question from@rygorous
:
Lazyweb, <…> GL question: <…> ARB NPOT textures is fairly demanding, and texture rectangle are awkward. Is there an equivalent to ES2-style semantics in regular GL? Bonus Q: Is there something like the Unity HW survey, but listing supported GL extensions?
:)
There are generally three big types of texture size support:
Full support for arbitrary texture sizes. This includes mipmaps, all texture wrap & filtering modes, and most often compressed texture formats as well.
“Limited” support for non-power-of-two sizes. No mipmaps, texture wrap mode has to be Clamp, but does allow texture filtering. This makes such textures not generally useful in 3D space, but just good enough for anything in screen space (UI, 2D, postprocessing).
No support, texture sizes have to be powers of two (16,32,64,128,…). If you’re running on really,really old GPU then textures might also need to be square (width = height).
Direct3D 9
Things are quite simple here.
D3DCAPS9.TextureCaps has capability bits,
D3DPTEXTURECAPS_POW2and
D3DPTEXTURECAPS_NONPOW2CONDITIONALboth beingoff indicates full
support for NPOT texture sizes. When both
D3DPTEXTURECAPS_POW2and
D3DPTEXTURECAPS_NONPOW2CONDITIONALbits are
on , then you have limited NPOT support.
I’ve no idea what would it mean if NONPOW2CONDITIONAL bit is set, but POW2 bit is not.
Hardware wise, limited NPOT has been generally available since 2002-2004, and full NPOT since 2006 or so.
Direct3D 11
Very simple; feature level 10_0 and up has full support for NPOT sizes; while feature level 9_x has limited support for NPOT.MSDN link .
OpenGL
Support for NPOT textures has been a core OpenGL feature since 2.0; promoted from earlierARB_texture_non_power_of_two extension. The extension specifies “full”
support for NPOT, including mipmaps & wrapping modes. There’s no practical way to detect hardware that can only do “limited” NPOT textures.
However, in traditional OpenGL spirit, presence of something in the API does not mean it can run on the GPU… E.g. Mac OS X withRadeon X1600 GPU is an OpenGL 2.1+
system, and as such pretends there’s full support for NPOT textures. In practice, as soon as you have NPOT size with mipmaps or a non-clamp wrap mode, you drop into software rendering.
Ouch.
A rule of thumb that seems to work: try to detect “DX10+” level GPU, and in that case assume full NPOT support isactually there. Otherwise, in GL2.0+ or when
ARB_texture_non_power_of_twois present, only assumelimited NPOT support.
Then the question of course is, how to detect DX10+ level GPU in OpenGL? If you’re using OpenGL 3+, then you are on DX10+ GPU. In earlier GL versions, you’d have to use some heuristics. For example, if you have
ARB_fragment_program
and
GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARBis less than 4096 is a pretty good indicator of pre-DX10 hardware, on Mac OS X at least. Likewise, you could query
MAX_TEXTURE_SIZE
, lower than 8192 is a good indicator for pre-DX10.
OpenGL ES
OpenGL ES 3.0 has full NPOT support in core; ES 2.0 has limited NPOT support (no mipmaps, no Repeat wrap mode) in core; and ES 1.1 has no NPOT support.
For ES 1.1 and 2.0, full NPOT support comes with
GL_ARB_texture_non_power_of_twoor
GL_OES_texture_npotextension. In practice, iOS devices
don’t support this; and on Android side there’s support on Qualcomm Adreno and ARM Mali. Possibly some others.
For ES 1.1, limited NPOT support comes with
GL_APPLE_texture_2D_limited_npot(all iOS devices) or
GL_IMG_texture_npot(some ImgTec Android
devices I guess).
WebGL and Native Client currently are pretty much OpenGL ES 2.0, and thus support limited NPOT textures.
Flash Stage3D
Sad situation here; current version of Stage3D (as of Flash Player 11.4) has no NPOT support whatsoever. Not even for render targets.
Consoles
I wouldn’t be allowed to say anything about them, now would I? :) Check documentation that comes with your developer access on each console.
Is there something like the Unity HW survey, but listing supported GL extensions?
Not a single good resource, but there are various bits and pieces:
Unity Web Player hardware stats - no GL extensions, but we do map GPUs to “DX-like” levels and from there you can sort of infer things.
Steam Hardware Survey - likewise.
Apple OpenGL Capabilities - tables of detailed GL info for recent OS X versions and all GPUs supported by Apple. Excellent resource for Mac programmers! Apple
does remove pages of old OS X versions from there, you’d have to use
archive.org to get them back.
GLBenchmark Results - results database of GLBenchmark, has list of OpenGL ES extensions and some caps bits for each result (“GL config.” tab).
Realtech VR GLView - OpenGL & OpenGL ES extensions and capabilities viewer, for Windows, Mac, iOS & Android.
Omni Software Update Statistics - Mac specific, but does list some OpenGL stats from “Graphics” dropdown.
相关文章推荐
- wampserver You don't have permission to access / on this server. 解决 方法
- B+树索引结构
- Oracle 模式
- 变频器主要功率元器件损耗分析
- Milk Patterns - poj 3261 (求重复k次的最长子串)
- Hibernate之主键的映射
- OnItemClickListener和OnItemSelectedListener的区别
- centos 下挂在硬盘流程以及开机自动挂载
- Anntation(注解)-----Java之辅助工具(大有前途)
- 浅拷贝——C++编译器默认提供的拷贝构造函数
- php预定义$_SERVER实例,所有$_SERVER开头的都是预定义服务变量。
- IP地址处理模块IPy之IP地址、网段基本处理
- Android开发中高效的数据结构用SparseArray代替HashMap
- CoreAnimation-09-模拟时钟
- 不容忽略的——CSS规范
- 特殊权限详解
- 有关sizeof strlen typedef define的面试题
- .tar.gz和.rpm包的区别与使用
- 使用FTP(IOS FTP客户端开发教程)
- C++中的单例模式