fen*_*fen 9 opengl textures opengl-4
ARB_texture_storage被引入OpenGL 4.2核心.
你能解释一下纹理对象的不变性意味着什么吗?
为什么从以前的纹理使用情况来看更好,这个功能的缺点是什么?
我知道我可以阅读这个扩展的规范(我做了:)),但我想看一些例子或其他解释.
pep*_*ppe 16
只需阅读扩展本身的介绍:
The texture image specification commands in OpenGL allow each level
to be separately specified with different sizes, formats, types and
so on, and only imposes consistency checks at draw time. This adds
overhead for implementations.
This extension provides a mechanism for specifying the entire
structure of a texture in a single call, allowing certain
consistency checks and memory allocations to be done up front. Once
specified, the format and dimensions of the image array become
immutable, to simplify completeness checks in the implementation.
When using this extension, it is no longer possible to supply texture
data using TexImage*. Instead, data can be uploaded using TexSubImage*,
or produced by other means (such as render-to-texture, mipmap generation,
or rendering to a sibling EGLImage).
This extension has complicated interactions with other extensions.
The goal of most of these interactions is to ensure that a texture
is always mipmap complete (and cube complete for cubemap textures).
Run Code Online (Sandbox Code Playgroud)
显而易见的优点是实现可以在运行时删除完整性/一致性检查,并且您的代码更加健壮,因为您不会意外地创建错误的纹理.
详细说明:"不可变"在这里意味着纹理存储(纹理的三个组成部分之一:存储,采样,参数)被分配一次并且它已经完成.请注意,存储并不意味着存储内容 - 它们可以随时更改; 它指的是为这些内容获取资源的逻辑过程(例如,malloc).
使用非不可变纹理,您可以通过glTexImage<N>D调用随时更改存储.通过这种方式射击自己有很多方法:
既然你可以调用glTexImage<N>D在任何时候,实现必须经常检查,在绘制时,你的质地是合法的.通过使用正确的格式一次性分配所有内容(所有mipmap级别,所有立方体图面等),不可变存储始终为您做正确的事情.因此,您不能再轻松搞砸一个纹理,并且实现可以删除一些检查,从而加快速度.每个人都很开心:)
| 归档时间: |
|
| 查看次数: |
2697 次 |
| 最近记录: |