c – OpenGL Bindless纹理函数glMakeTextureHandleNonResident实际上做了什么?

我有一个测试无边框纹理的工作原型.我有一台摄像机,可以播放超过6演出的纹理,而我只有2演出的VRAM.我有一个内截头体,用于获取视口中用于渲染的对象列表,以及一个外截头体用于队列(驻留)即将渲染的纹理,所有其他纹理,如果它们是居民,使用函数glMakeTextureHandleNonResident进行非常驻.

该程序运行,但是gpu的VRAM表现得好像它有一个GC步骤,它以随机的时间间隔清除VRAM.当它这样做时,我的渲染完全冻结,但随后跳到正确的帧,最终回到60 FPS.我很好奇glMakeTextureHandleNonResident实际上并没有在“调用”时将纹理拉出VRAM.有没有人知道GPU正在通过该调用做什么?

GPU:Nvidia 750GT M.

最佳答案 无边纹理基本上在硬件上显示转换表,以便您可以在着色器中使用任意整数(句柄)而不是GL的传统绑定到图像单元机制来引用纹理;它们不允许您直接控制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.

点赞