mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 04:48:08 +02:00
glsl: order indices for images inside a struct array
ARB_bindless_texture allows images to be declared inside structures. This is similar to samplers. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
f87416f62d
commit
4aa4e17f4e
1 changed files with 17 additions and 11 deletions
|
|
@ -441,6 +441,7 @@ public:
|
||||||
current_var = var;
|
current_var = var;
|
||||||
field_counter = 0;
|
field_counter = 0;
|
||||||
this->record_next_sampler = new string_to_uint_map;
|
this->record_next_sampler = new string_to_uint_map;
|
||||||
|
this->record_next_image = new string_to_uint_map;
|
||||||
|
|
||||||
buffer_block_index = -1;
|
buffer_block_index = -1;
|
||||||
if (var->is_in_buffer_block()) {
|
if (var->is_in_buffer_block()) {
|
||||||
|
|
@ -501,6 +502,7 @@ public:
|
||||||
process(var);
|
process(var);
|
||||||
}
|
}
|
||||||
delete this->record_next_sampler;
|
delete this->record_next_sampler;
|
||||||
|
delete this->record_next_image;
|
||||||
}
|
}
|
||||||
|
|
||||||
int buffer_block_index;
|
int buffer_block_index;
|
||||||
|
|
@ -593,27 +595,26 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_images(const glsl_type *base_type,
|
void handle_images(const glsl_type *base_type,
|
||||||
struct gl_uniform_storage *uniform)
|
struct gl_uniform_storage *uniform, const char *name)
|
||||||
{
|
{
|
||||||
if (base_type->is_image()) {
|
if (base_type->is_image()) {
|
||||||
uniform->opaque[shader_type].index = this->next_image;
|
|
||||||
uniform->opaque[shader_type].active = true;
|
uniform->opaque[shader_type].active = true;
|
||||||
|
|
||||||
|
if (!set_opaque_indices(base_type, uniform, name, this->next_image,
|
||||||
|
this->record_next_image))
|
||||||
|
return;
|
||||||
|
|
||||||
/* Set image access qualifiers */
|
/* Set image access qualifiers */
|
||||||
const GLenum access =
|
const GLenum access =
|
||||||
(current_var->data.memory_read_only ? GL_READ_ONLY :
|
(current_var->data.memory_read_only ? GL_READ_ONLY :
|
||||||
current_var->data.memory_write_only ? GL_WRITE_ONLY :
|
current_var->data.memory_write_only ? GL_WRITE_ONLY :
|
||||||
GL_READ_WRITE);
|
GL_READ_WRITE);
|
||||||
|
|
||||||
const unsigned first = this->next_image;
|
for (unsigned i = uniform->opaque[shader_type].index;
|
||||||
|
i < MIN2(this->next_image, MAX_IMAGE_UNIFORMS);
|
||||||
/* Increment the image index by 1 for non-arrays and by the
|
i++) {
|
||||||
* number of array elements for arrays.
|
|
||||||
*/
|
|
||||||
this->next_image += MAX2(1, uniform->array_elements);
|
|
||||||
|
|
||||||
for (unsigned i = first; i < MIN2(next_image, MAX_IMAGE_UNIFORMS); i++)
|
|
||||||
prog->_LinkedShaders[shader_type]->Program->sh.ImageAccess[i] = access;
|
prog->_LinkedShaders[shader_type]->Program->sh.ImageAccess[i] = access;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -705,7 +706,7 @@ private:
|
||||||
|
|
||||||
/* This assigns uniform indices to sampler and image uniforms. */
|
/* This assigns uniform indices to sampler and image uniforms. */
|
||||||
handle_samplers(base_type, &this->uniforms[id], name);
|
handle_samplers(base_type, &this->uniforms[id], name);
|
||||||
handle_images(base_type, &this->uniforms[id]);
|
handle_images(base_type, &this->uniforms[id], name);
|
||||||
handle_subroutines(base_type, &this->uniforms[id]);
|
handle_subroutines(base_type, &this->uniforms[id]);
|
||||||
|
|
||||||
/* For array of arrays or struct arrays the base location may have
|
/* For array of arrays or struct arrays the base location may have
|
||||||
|
|
@ -852,6 +853,11 @@ private:
|
||||||
*/
|
*/
|
||||||
struct string_to_uint_map *record_next_sampler;
|
struct string_to_uint_map *record_next_sampler;
|
||||||
|
|
||||||
|
/* Map for temporarily storing next imager index when handling images in
|
||||||
|
* struct arrays.
|
||||||
|
*/
|
||||||
|
struct string_to_uint_map *record_next_image;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
union gl_constant_value *values;
|
union gl_constant_value *values;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue