gpt4 book ai didi

c++ - OpenGL 无绑定(bind)纹理函数 glMakeTextureHandleNonResident 实际上做了什么?

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:09:34 27 4
gpt4 key购买 nike

我有一个测试无绑定(bind)纹理的工作原型(prototype)。我有一台相机可以平移超过 6 GB 的纹理,而我只有 2 GB 的 VRAM。我有一个内部平截头体,用于获取视口(viewport)中的对象列表以进行渲染,还有一个外部平截头体,用于排队(使驻留)即将渲染的纹理,所有其他纹理,如果它们是常驻的, 使用函数 glMakeTextureHandleNonResident 使之非常驻。

程序运行,但 gpu 的 VRAM 表现得好像它有一个 GC 步骤,它以随机时间间隔清除 VRAM。当它执行此操作时,我的渲染完全卡住,但随后跳到正确的帧,最终恢复到 60 FPS。我很好奇 glMakeTextureHandleNonResident 实际上并没有在“调用时”将纹理从 VRAM 中拉出。有谁确切地知道 GPU 对该调用做了什么?

显卡:英伟达 750GT M

最佳答案

无限制纹理实质上在硬件上公开了一个转换表,因此您可以在着色器中使用任意整数(句柄)而不是 GL 的传统绑定(bind)到图像单元机制来引用纹理;它们不允许您直接控制 GPU 内存驻留。

Sparse textures实际上听起来更像你想要的。请注意,这两个东西可以一起使用。


使句柄成为非常驻不一定会从 VRAM 中逐出纹理内存,它只是从所述转换表中删除句柄。纹理内存的逐出可以推迟到将来某个时间,正如您所发现的那样。

您可以在 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.

关于c++ - OpenGL 无绑定(bind)纹理函数 glMakeTextureHandleNonResident 实际上做了什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28377011/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com