[Mesa-dev] [PATCH 2/4] nir/lower_io: Make variable location assignment a manual operation

Jason Ekstrand jason at jlekstrand.net
Wed Mar 18 19:26:41 PDT 2015


On Wed, Mar 18, 2015 at 7:11 PM, Connor Abbott <cwabbott0 at gmail.com> wrote:
> Given that the way we pack inputs/outputs/uniforms is probably only
> going to be useful for scalar backends, can we rename this to
> nir_assign_var_locations_scalar() and in the next patch
> nir_assign_var_locations_scalar_direct_first()? That makes more sense
> to me than "packed," since on vec4 "packed" means a different thing
> usually. Otherwise, the series is

Sure.  I'm not attached to it.

> Reviewed-by: Connor Abbott <cwabbott0 at gmail.com>

Thanks!
--Jason

> On Wed, Mar 18, 2015 at 7:45 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>> Previously, we just assigned variable locations in nir_lower_io.  Now, we
>> force the user to assign variable locations for us.  This gives the backend
>> a bit more control over where variables are placed.
>> ---
>>  src/glsl/nir/nir.h                       |  3 +++
>>  src/glsl/nir/nir_lower_io.c              | 14 ++------------
>>  src/mesa/drivers/dri/i965/brw_fs_nir.cpp |  4 ++++
>>  3 files changed, 9 insertions(+), 12 deletions(-)
>>
>> diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
>> index 6b42df9..0015ec2 100644
>> --- a/src/glsl/nir/nir.h
>> +++ b/src/glsl/nir/nir.h
>> @@ -1577,6 +1577,9 @@ void nir_lower_global_vars_to_local(nir_shader *shader);
>>
>>  void nir_lower_locals_to_regs(nir_shader *shader);
>>
>> +void nir_assign_var_locations_packed(struct exec_list *var_list,
>> +                                     unsigned *size);
>> +
>>  void nir_lower_io(nir_shader *shader);
>>
>>  void nir_lower_vars_to_ssa(nir_shader *shader);
>> diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
>> index 37c357e..d57b5b1 100644
>> --- a/src/glsl/nir/nir_lower_io.c
>> +++ b/src/glsl/nir/nir_lower_io.c
>> @@ -76,8 +76,8 @@ type_size(const struct glsl_type *type)
>>     return 0;
>>  }
>>
>> -static void
>> -assign_var_locations(struct exec_list *var_list, unsigned *size)
>> +void
>> +nir_assign_var_locations_packed(struct exec_list *var_list, unsigned *size)
>>  {
>>     unsigned location = 0;
>>
>> @@ -96,14 +96,6 @@ assign_var_locations(struct exec_list *var_list, unsigned *size)
>>     *size = location;
>>  }
>>
>> -static void
>> -assign_var_locations_shader(nir_shader *shader)
>> -{
>> -   assign_var_locations(&shader->inputs, &shader->num_inputs);
>> -   assign_var_locations(&shader->outputs, &shader->num_outputs);
>> -   assign_var_locations(&shader->uniforms, &shader->num_uniforms);
>> -}
>> -
>>  static bool
>>  deref_has_indirect(nir_deref_var *deref)
>>  {
>> @@ -304,8 +296,6 @@ nir_lower_io_impl(nir_function_impl *impl)
>>  void
>>  nir_lower_io(nir_shader *shader)
>>  {
>> -   assign_var_locations_shader(shader);
>> -
>>     nir_foreach_overload(shader, overload) {
>>        if (overload->impl)
>>           nir_lower_io_impl(overload->impl);
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> index 777914e..c316088 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp
>> @@ -106,6 +106,10 @@ fs_visitor::emit_nir_code()
>>     /* Get rid of split copies */
>>     nir_optimize(nir);
>>
>> +   nir_assign_var_locations_packed(&nir->uniforms, &nir->num_uniforms);
>> +   nir_assign_var_locations_packed(&nir->inputs, &nir->num_inputs);
>> +   nir_assign_var_locations_packed(&nir->outputs, &nir->num_outputs);
>> +
>>     nir_lower_io(nir);
>>     nir_validate_shader(nir);
>>
>> --
>> 2.3.2
>>
>> _______________________________________________
>> 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