Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does OpenGL Bindless Texture function glMakeTextureHandleNonResident ACTUALLY do?

I have a working prototype that tests bindless textures. I have a camera that pans over 6 gigs of texture, while i only have 2 gigs of VRAM. I have an inner frustum that is used to get the list of objects in the viewport for rendering, and an outer frustum that is used to Queue in (make resident) the textures that will soon be rendered, all other textures, if they are resident, are made non resident using the function glMakeTextureHandleNonResident.

The program runs, but the VRAM of the gpu behaves as if it has a GC step where it clears VRAM at random intervals of time. When it does this, my rendering is completely frozen, but then skips to the proper frame, eventually getting back to up 60 FPS. Im curious that glMakeTextureHandleNonResident doesnt actually pull the texture out of VRAM "when" it is called. Does anyone know EXACTLY what the GPU is doing with that call?

GPU: Nvidia 750GT M

like image 658
Joe Avatar asked Oct 19 '22 17:10

Joe


1 Answers

Bindless textures essentially expose a translation table on the hardware so that you can reference textures using an arbitrary integer (handle) in a shader rather than GL's traditional bind-to-image-unit mechanics; they don't allow you to directly control GPU memory residency.

Sparse textures actually sound more like what you want. Note that both of these things can be used together.


Making a handle non-resident does not necessarily evict the texture memory from VRAM, it just removes the handle from said translation table. Eviction of texture memory can be deferred until some future time, exactly as you have discovered.

You can read more about this in the extension specification for GL_ARB_bindless_texture.

void glMakeImageHandleResidentARB (GLuint64 handle, GLenum access):

"When an image handle is resident, the texture it references is not necessarily considered resident for the purposes of the AreTexturesResident command."

Issues:

(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.

like image 196
Andon M. Coleman Avatar answered Nov 10 '22 01:11

Andon M. Coleman