[Mesa-dev] [PATCH 4/7] glsl: set image access qualifiers for AoA
Timothy Arceri
t_arceri at yahoo.com.au
Wed Oct 21 03:26:32 PDT 2015
On Wed, 2015-10-21 at 13:06 +0300, Francisco Jerez wrote:
> Timothy Arceri <t_arceri at yahoo.com.au> writes:
>
> > On Fri, 2015-10-16 at 10:28 +1100, Timothy Arceri wrote:
> > > Cc: Francisco Jerez <currojerez at riseup.net>
> >
> > Hi Curro,
> >
> > Just pinging you on this patch and patch 5. These are the final two
> > patches remaining unreviewed before I can enable arrays of arrays.
> >
> > If your not able to review these can you let me know so I can chase
> > this upvwith someone else as I'd like to enable this as soon as
> > possible to limit breakage.
> >
>
> Depends when you want them reviewed, doesn't seem like the kind of
> thing
> I could convince myself is correct during a break. I'm unlikely to
> have
> time to review it this week. I might next week but I cannot give you
> any guarantees. If that's not acceptable for you feel free to look
> for
> someone else to review them.
Not a problem. I thought you must have been back from your break as
I've seen alot of email from you. No need to look at this while your
meant to be on break, if no one has looked at it before you get back
then it would be great if you could take a look :)
Thanks,
Tim
>
> > Thanks,
> > Tim
> >
> >
> > > ---
> > > src/glsl/link_uniforms.cpp | 77 +++++++++++++++++++++++++++++---
> > > ----
> > > ----------
> > > 1 file changed, 49 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/src/glsl/link_uniforms.cpp
> > > b/src/glsl/link_uniforms.cpp
> > > index 647aa2b..2a1da07 100644
> > > --- a/src/glsl/link_uniforms.cpp
> > > +++ b/src/glsl/link_uniforms.cpp
> > > @@ -1008,38 +1008,37 @@
> > > link_update_uniform_buffer_variables(struct
> > > gl_shader *shader)
> > > }
> > > }
> > >
> > > -/**
> > > - * Scan the program for image uniforms and store image unit
> > > access
> > > - * information into the gl_shader data structure.
> > > - */
> > > static void
> > > -link_set_image_access_qualifiers(struct gl_shader_program *prog)
> > > +link_set_image_access_qualifiers(struct gl_shader_program *prog,
> > > + gl_shader *sh, unsigned
> > > shader_stage,
> > > + ir_variable *var, const
> > > glsl_type
> > > *type,
> > > + char **name, size_t
> > > name_length)
> > > {
> > > - for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> > > - gl_shader *sh = prog->_LinkedShaders[i];
> > > -
> > > - if (sh == NULL)
> > > - continue;
> > > + /* Handle arrays of arrays */
> > > + if (type->is_array() && type->fields.array->is_array()) {
> > > + for (unsigned i = 0; i < type->length; i++) {
> > > + size_t new_length = name_length;
> > >
> > > - foreach_in_list(ir_instruction, node, sh->ir) {
> > > - ir_variable *var = node->as_variable();
> > > + /* Append the subscript to the current variable name */
> > > + ralloc_asprintf_rewrite_tail(name, &new_length, "[%u]",
> > > i);
> > >
> > > - if (var && var->data.mode == ir_var_uniform &&
> > > - var->type->contains_image()) {
> > > - unsigned id = 0;
> > > - bool found = prog->UniformHash->get(id, var->name);
> > > - assert(found);
> > > - (void) found;
> > > - const gl_uniform_storage *storage = &prog
> > > ->UniformStorage[id];
> > > - const unsigned index = storage->opaque[i].index;
> > > - const GLenum access = (var->data.image_read_only ?
> > > GL_READ_ONLY :
> > > - var->data.image_write_only ?
> > > GL_WRITE_ONLY :
> > > - GL_READ_WRITE);
> > > -
> > > - for (unsigned j = 0; j < MAX2(1, storage
> > > ->array_elements); ++j)
> > > - sh->ImageAccess[index + j] = access;
> > > - }
> > > + link_set_image_access_qualifiers(prog, sh,
> > > shader_stage,
> > > var,
> > > + type->fields.array,
> > > name,
> > > + new_length);
> > > }
> > > + } else {
> > > + unsigned id = 0;
> > > + bool found = prog->UniformHash->get(id, *name);
> > > + assert(found);
> > > + (void) found;
> > > + const gl_uniform_storage *storage = &prog
> > > ->UniformStorage[id];
> > > + const unsigned index = storage
> > > ->opaque[shader_stage].index;
> > > + const GLenum access = (var->data.image_read_only ?
> > > GL_READ_ONLY :
> > > + var->data.image_write_only ?
> > > GL_WRITE_ONLY :
> > > + GL_READ_WRITE);
> > > +
> > > + for (unsigned j = 0; j < MAX2(1, storage->array_elements);
> > > ++j)
> > > + sh->ImageAccess[index + j] = access;
> > > }
> > > }
> > >
> > > @@ -1300,7 +1299,29 @@ link_assign_uniform_locations(struct
> > > gl_shader_program *prog,
> > > prog->NumHiddenUniforms = hidden_uniforms;
> > > prog->UniformStorage = uniforms;
> > >
> > > - link_set_image_access_qualifiers(prog);
> > > + /**
> > > + * Scan the program for image uniforms and store image unit
> > > access
> > > + * information into the gl_shader data structure.
> > > + */
> > > + for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
> > > + gl_shader *sh = prog->_LinkedShaders[i];
> > > +
> > > + if (sh == NULL)
> > > + continue;
> > > +
> > > + foreach_in_list(ir_instruction, node, sh->ir) {
> > > + ir_variable *var = node->as_variable();
> > > +
> > > + if (var && var->data.mode == ir_var_uniform &&
> > > + var->type->contains_image()) {
> > > + char *name_copy = ralloc_strdup(NULL, var->name);
> > > + link_set_image_access_qualifiers(prog, sh, i, var,
> > > var
> > > ->type,
> > > + &name_copy,
> > > strlen(var
> > > ->name));
> > > + ralloc_free(name_copy);
> > > + }
> > > + }
> > > + }
> > > +
> > > link_set_uniform_initializers(prog, boolean_true);
> > >
> > > return;
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list