NVIDIA GTX 680 OpenGL Bindless Textures Demo

1 – Bindless Textures Overview

I spent some time last week to add into GeeXLab the support of bindless textures. Bindless textures is the very cool feature introduced with the GeForce GTX 680.

But what are bindless textures? In 3D programming (OpenGL or Direct3D), to use a texture, you have to bind it to a texture unit. In OpenGL for example, a GeForce GTX 680 has 32 texture units you can use in your GLSL shader programs. That means you can do multi-texturing with a max of 32 textures (which is enough for most cases). If you need more textures, you must re-think your algorithm.

With bindless textures, there’s no longer need to bind a texture to a texture unit. Just create your textures and, quickly said, enable their bindless status (read: make them resident textures). Now you can have more than 32 textures to make your greedy shaders happy.

Here’s the slide for explaining the bindless texture concept:

Currently, bindless textures are only available in OpenGL applications (like GeeXLab). If you want to dive into bindless texture programming, check out this OpenGL extension: GL_NV_bindless_texture.

2 – Bindless Textures Demo

So what kind of simple demo could I do to show the use of bindless textures? After some tests, I ended up on this mosaic-like demo:

This demo simply loads a bunch of textures (here 1024 textures on the screenshot), makes them resident (with glMakeTextureHandleResidentNV()) and draws a simple quad with all textures, using one render call only. An uniform buffer is used to pass all texture handles (a texture handle is an 64-bit unsigned int or uint64_t, NVIDIA extension provides some functions to manage uint64_t uniform variables) to the pixel shader. In this particular demo and thanks to bindless textures, it’s like if the GTX 680 had virtually 1024 texture units…

@Leith Bade
No, since D3D10 textures and sample units are not the same. Textures are just shader resource views, maximum number of SRVs are 128(according to MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/bb173606(v=vs.85).aspx). So you pass SRVs and sampler states to the shader, inside your shader you just take sampler state and use it for SRV sampling. That’s all. ARB_sampler_objects are the same as method proposed in D3D10.