OpenGL 无绑定纹理函数 glMakeTextureHandleNonResident 实际上做了什么?
What does OpenGL Bindless Texture function glMakeTextureHandleNonResident ACTUALLY do?
我有一个测试无绑定纹理的工作原型。我有一台相机可以平移超过 6 GB 的纹理,而我只有 2 GB 的 VRAM。我有一个内部平截头体,用于获取视口中的对象列表以进行渲染,还有一个外部平截头体,用于排队(使驻留)即将渲染的纹理,所有其他纹理,如果它们是常驻的, 使用函数 glMakeTextureHandleNonResident 使之非常驻。
程序运行,但 gpu 的 VRAM 表现得好像它有一个 GC 步骤,它以随机时间间隔清除 VRAM。当它执行此操作时,我的渲染完全冻结,但随后跳到正确的帧,最终恢复到 60 FPS。我很好奇 glMakeTextureHandleNonResident 实际上并没有将纹理从它调用的 VRAM "when" 中拉出来。有谁确切地知道 GPU 对该调用做了什么?
GPU:英伟达 750GT M
Bindless 纹理本质上在硬件上公开了一个转换 table,这样您就可以在着色器中使用任意整数(句柄)而不是 GL 的传统绑定到图像单元机制来引用纹理;它们不允许您直接控制 GPU 内存驻留。
Sparse textures 实际上听起来更像你想要的。请注意,这两个东西可以一起使用。
使 句柄 非常驻并不一定会从 VRAM 中逐出纹理内存,它只是从所述翻译中删除句柄 table。纹理内存的逐出可以推迟到将来某个时间,正如您所发现的那样。
您可以在 GL_ARB_bindless_texture
的扩展规范中阅读更多相关信息。
void glMakeImageHandleResidentARB(GLuint64 句柄,GLenum 访问):
"When an image handle is resident, the texture it references is not necessarily considered resident for the purposes of the AreTexturesResident command."
问题:
(18) Texture and image handles may be made resident or non-resident. How
does handle residency interact with texture residency queries from
OpenGL 1.1 (glAreTexturesResident
or GL_TEXTURE_RESIDENT
)?
RESOLVED:
The residency state for texture and image handles in this
extension is completely independent from OpenGL 1.1's GL_TEXTURE_RESIDENT
query. Residency for texture handles is a function of whether the
glMakeTextureHandleResidentARB
has been called for the handle. OpenGL 1.1
residency is typically a function of whether the texture data are
resident in GPU-accessible memory.
When a texture handle is not made resident, the texture that it refers
to may or may not be stored in GPU-accessible memory. The
GL_TEXTURE_RESIDENT
query may return GL_TRUE
in this case. However, it does
not guarantee that the texture handle may be used safely.
When a texture handle is made resident, the texture that it refers to is
also considered resident for the purposes of the old GL_TEXTURE_RESIDENT
query. When an image handle is resident, the texture that it refers to
may or may not be considered resident for the query -- the resident
image handle may refer only to a single layer of a single mipmap level
of the full texture.
我有一个测试无绑定纹理的工作原型。我有一台相机可以平移超过 6 GB 的纹理,而我只有 2 GB 的 VRAM。我有一个内部平截头体,用于获取视口中的对象列表以进行渲染,还有一个外部平截头体,用于排队(使驻留)即将渲染的纹理,所有其他纹理,如果它们是常驻的, 使用函数 glMakeTextureHandleNonResident 使之非常驻。
程序运行,但 gpu 的 VRAM 表现得好像它有一个 GC 步骤,它以随机时间间隔清除 VRAM。当它执行此操作时,我的渲染完全冻结,但随后跳到正确的帧,最终恢复到 60 FPS。我很好奇 glMakeTextureHandleNonResident 实际上并没有将纹理从它调用的 VRAM "when" 中拉出来。有谁确切地知道 GPU 对该调用做了什么?
GPU:英伟达 750GT M
Bindless 纹理本质上在硬件上公开了一个转换 table,这样您就可以在着色器中使用任意整数(句柄)而不是 GL 的传统绑定到图像单元机制来引用纹理;它们不允许您直接控制 GPU 内存驻留。
Sparse textures 实际上听起来更像你想要的。请注意,这两个东西可以一起使用。
使 句柄 非常驻并不一定会从 VRAM 中逐出纹理内存,它只是从所述翻译中删除句柄 table。纹理内存的逐出可以推迟到将来某个时间,正如您所发现的那样。
您可以在 GL_ARB_bindless_texture
的扩展规范中阅读更多相关信息。
void glMakeImageHandleResidentARB(GLuint64 句柄,GLenum 访问):
"When an image handle is resident, the texture it references is not necessarily considered resident for the purposes of the AreTexturesResident command."
问题:
(18) Texture and image handles may be made resident or non-resident. How does handle residency interact with texture residency queries from OpenGL 1.1 (
glAreTexturesResident
orGL_TEXTURE_RESIDENT
)?RESOLVED:
The residency state for texture and image handles in this extension is completely independent from OpenGL 1.1's
GL_TEXTURE_RESIDENT
query. Residency for texture handles is a function of whether theglMakeTextureHandleResidentARB
has been called for the handle. OpenGL 1.1 residency is typically a function of whether the texture data are resident in GPU-accessible memory.When a texture handle is not made resident, the texture that it refers to may or may not be stored in GPU-accessible memory. The
GL_TEXTURE_RESIDENT
query may returnGL_TRUE
in this case. However, it does not guarantee that the texture handle may be used safely.When a texture handle is made resident, the texture that it refers to is also considered resident for the purposes of the old
GL_TEXTURE_RESIDENT
query. When an image handle is resident, the texture that it refers to may or may not be considered resident for the query -- the resident image handle may refer only to a single layer of a single mipmap level of the full texture.