[Mesa-dev] Question: How to handle 64-bit sampler/image handles added by ARB_bindless_texture?

Samuel Pitoiset samuel.pitoiset at gmail.com
Thu Feb 23 19:37:05 UTC 2017


Hi there,

I started to work on ARB_bindless_texture which is an important missing 
feature in Mesa. Some games, at least Deus Ex: Mankind Divided, would 
benefit of this extension. As the spec says:

"The ability to access textures without having to bind and/or
re-bind them is similar to the capability provided by the
NV_shader_buffer_load extension that allows shaders to access buffer
objects without binding them.  In both cases, these extensions
significantly reduce the amount of API and internal GL driver overhead
needed to manage resource bindings."[1]

I wonder if "significantly" is the right term there, but 
ARB_bindless_texture should definitely reduce CPU usage in some 
scenarios. I would be happy to provide numbers when the extension is 
done, hopefully a good news is going to happen. Anyways, that not the 
main topic.

Basically, ARB_bindless_texture allows to access texture objects in 
shaders without first binding each texture to one of a limited number of
texture image units. A texture like this is called 'resident'. The steps 
are pretty simple:

1) create a texture object
2) get a texture handle which references the object
3) make the texture handle resident
4) use it directly in your shaders

The problem is: texture handles are 64-bit and sampler/image uniforms 
are considered 64-bit as well. But the extension doesn't introduce any 
new data types to GLSL.

Also note that GLSL 440 added restrictions about opaque types (samplers, 
images, atomic counters) but ARB_bindless_texture allows to declare 
sampler/image types as temporary variables, as inputs/outputs, inside 
interface blocks and more.

Now, the question: how to implement this in our GLSL compiler? :)

I wonder if introducing GLSL_TYPE_SAMPLER64 and GLSL_TYPE_IMAGE64 (to be 
used only if ARB_bindless_texture is enabled) is the right solution, but 
it has some advantages.

- easy to make GLSL_TYPE_SAMPLER64/GLSL_TYPE_IMAGE64 64-bit types
- easy to mark GLSL_TYPE_SAMPLER64/GLSL_TYPE_IMAGE64 as non-opaque types
- should not break anything if bindless is not enabled/supported

To sump up, the general idea would be to use the "old" 
GLSL_TYPE_SAMPLER/IMAGE types by default and only the 64-bit variants 
for bindless.

Does it make sense? Any thoughts?

Thanks!
Samuel.

[1] 
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_bindless_texture.txt


More information about the mesa-dev mailing list