[Mesa-dev] [PATCH 13/16] glsl: export accessor for builtin-uniform descriptors

Jason Ekstrand jason at jlekstrand.net
Fri Apr 1 18:27:39 UTC 2016


On Fri, Apr 1, 2016 at 11:24 AM, Rob Clark <robdclark at gmail.com> wrote:

> On Fri, Apr 1, 2016 at 2:04 PM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> >
> >
> > On Sat, Mar 26, 2016 at 2:02 PM, Rob Clark <robdclark at gmail.com> wrote:
> >>
> >> From: Rob Clark <robclark at freedesktop.org>
> >>
> >> We'll need this for a nir pass to lower builtin-uniform access.
> >>
> >> Signed-off-by: Rob Clark <robclark at freedesktop.org>
> >> ---
> >>  src/compiler/glsl/builtin_variables.cpp | 24 +++++++++++++++---------
> >>  src/compiler/glsl/ir.h                  |  3 +++
> >>  2 files changed, 18 insertions(+), 9 deletions(-)
> >>
> >> diff --git a/src/compiler/glsl/builtin_variables.cpp
> >> b/src/compiler/glsl/builtin_variables.cpp
> >> index 4e2de37..994a122 100644
> >> --- a/src/compiler/glsl/builtin_variables.cpp
> >> +++ b/src/compiler/glsl/builtin_variables.cpp
> >> @@ -524,23 +524,29 @@ builtin_variable_generator::add_variable(const
> char
> >> *name,
> >>     return var;
> >>  }
> >>
> >> -
> >> -ir_variable *
> >> -builtin_variable_generator::add_uniform(const glsl_type *type,
> >> -                                        const char *name)
> >> +extern "C" {
> >> +const struct gl_builtin_uniform_desc *
> >> +_mesa_glsl_get_builtin_uniform_desc(const char *name)
> >>  {
> >> -   ir_variable *const uni = add_variable(name, type, ir_var_uniform,
> -1);
> >> -
> >>     unsigned i;
> >
> >
> > You can pull this inside the loop now.  Otherwise, looks good.
>
> I didn't quite understand that comment.. pull what inside the loop?
>

The loop counter variable.  Sorry, that was incredibly unclear.
--Jason


>
> BR,
> -R
>
> > Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
> >
> >>
> >>     for (i = 0; _mesa_builtin_uniform_desc[i].name != NULL; i++) {
> >>        if (strcmp(_mesa_builtin_uniform_desc[i].name, name) == 0) {
> >> -        break;
> >> +         return &_mesa_builtin_uniform_desc[i];
> >>        }
> >>     }
> >> +   return NULL;
> >> +}
> >> +}
> >> +
> >> +ir_variable *
> >> +builtin_variable_generator::add_uniform(const glsl_type *type,
> >> +                                        const char *name)
> >> +{
> >> +   ir_variable *const uni = add_variable(name, type, ir_var_uniform,
> -1);
> >>
> >> -   assert(_mesa_builtin_uniform_desc[i].name != NULL);
> >>     const struct gl_builtin_uniform_desc* const statevar =
> >> -      &_mesa_builtin_uniform_desc[i];
> >> +      _mesa_glsl_get_builtin_uniform_desc(name);
> >> +   assert(statevar != NULL);
> >>
> >>     const unsigned array_count = type->is_array() ? type->length : 1;
> >>
> >> diff --git a/src/compiler/glsl/ir.h b/src/compiler/glsl/ir.h
> >> index b74d68a..4c27f1c 100644
> >> --- a/src/compiler/glsl/ir.h
> >> +++ b/src/compiler/glsl/ir.h
> >> @@ -2608,6 +2608,9 @@ extern void _mesa_print_ir(FILE *f, struct
> exec_list
> >> *instructions,
> >>  extern void
> >>  fprint_ir(FILE *f, const void *instruction);
> >>
> >> +extern const struct gl_builtin_uniform_desc *
> >> +_mesa_glsl_get_builtin_uniform_desc(const char *name);
> >> +
> >>  #ifdef __cplusplus
> >>  } /* extern "C" */
> >>  #endif
> >> --
> >> 2.5.5
> >>
> >> _______________________________________________
> >> mesa-dev mailing list
> >> mesa-dev at lists.freedesktop.org
> >> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160401/0cbdf228/attachment.html>


More information about the mesa-dev mailing list