[Mesa-dev] [RFC PATCH 11/65] mesa: add infrastructure for bindless samplers/images bound to units

Nicolai Hähnle nhaehnle at gmail.com
Wed May 24 10:36:10 UTC 2017


On 24.05.2017 12:28, Nicolai Hähnle wrote:
> On 19.05.2017 18:52, Samuel Pitoiset wrote:
>> Yes, ARB_bindless_texture allows to do this. In other words, in
>> a situation like:
>>
>> layout (bindless_sampler) uniform sampler2D tex;
>>
>> The 'tex' sampler uniform can be either set with glUniform1()
>> (old-style bound samplers) or with glUniformHandleui() (resident
>> handles).
>>
>> When glUniform1() is used, we have to somehow make the texture
>> resident "under the hood". This is done by requesting a texture
>> handle to the driver, making the handle resident in the current
>> context and overwriting the value directly in the constant buffer.
>>
>> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
>> ---
>>   src/mesa/main/mtypes.h | 52 
>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>   1 file changed, 52 insertions(+)
>>
>> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
>> index 70865b373d..1d168e8c68 100644
>> --- a/src/mesa/main/mtypes.h
>> +++ b/src/mesa/main/mtypes.h
>> @@ -1988,6 +1988,42 @@ struct gl_perf_query_state
>>   /**
>> + * A bindless sampler object.
>> + */
>> +struct gl_bindless_sampler
>> +{
>> +   /** Texture unit (set by glUniform1()). */
>> +   GLubyte unit;
>> +
>> +   /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
>> +   gl_texture_index target;
>> +
>> +   /** Whether this bindless sampler is bound to a unit. */
>> +   GLboolean bound;
>> +
>> +   /** Pointer to the base of the data. */
>> +   GLvoid *data;
>> +};
>> +
>> +/**
>> + * A bindless image object.
>> + */
>> +struct gl_bindless_image
>> +{
>> +   /** Image unit (set by glUniform1()). */
>> +   GLubyte unit;
>> +
>> +   /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
>> +   GLenum access;
>> +
>> +   /** Whether this bindless image is bound to a unit. */
>> +   GLboolean bound;
>> +
>> +   /** Pointer to the base of the data. */
>> +   GLvoid *data;
>> +};
>> +
>> +/**
>>    * Names of the various vertex/fragment program register files, etc.
>>    *
>>    * NOTE: first four tokens must fit into 2 bits (see t_vb_arbprogram.c)
>> @@ -2121,6 +2157,22 @@ struct gl_program
>>             */
>>            gl_texture_index SamplerTargets[MAX_SAMPLERS];
>> +         /**
>> +          * Number of samplers declared with the bindless_sampler layout
>> +          * qualifier as specified by ARB_bindless_texture.
>> +          */
>> +         GLuint NumBindlessSamplers;
>> +         GLboolean HasBoundBindlessSampler;
>> +         struct gl_bindless_sampler *BindlessSamplers;
>> +
>> +         /**
>> +          * Number of images declared with the bindless_image layout 
>> qualifier
>> +          * as specified by ARB_bindless_texture.
>> +          */
>> +         GLuint NumBindlessImages;
>> +         GLboolean HasBoundBindlessImage;
>> +         struct gl_bindless_image *BindlessImages;
>> +
> 
> This could go into the sh part of the union below, couldn't it?

Ah, that's where it already is. Never mind my confusion...


> Cheers,
> Nicolai
> 
> 
>>            union {
>>               struct {
>>                  /**
>>
> 
> 


-- 
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.


More information about the mesa-dev mailing list