[Mesa-dev] [PATCH 1/2] nir: add const_index parameters to system value builder function

Karol Herbst kherbst at redhat.com
Mon Jul 23 17:15:09 UTC 2018


On Mon, Jul 23, 2018 at 7:02 PM, Eric Anholt <eric at anholt.net> wrote:
> Karol Herbst <kherbst at redhat.com> writes:
>
>> this allows to replace some nir_load_system_value calls with the specific
>> system value constructor
>>
>> Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
>> Signed-off-by: Karol Herbst <kherbst at redhat.com>
>> ---
>>  src/compiler/nir/nir_builder_opcodes_h.py | 21 +++++++++++++++++++--
>>  1 file changed, 19 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/compiler/nir/nir_builder_opcodes_h.py b/src/compiler/nir/nir_builder_opcodes_h.py
>> index 72cf5b4549d..0440875dade 100644
>> --- a/src/compiler/nir/nir_builder_opcodes_h.py
>> +++ b/src/compiler/nir/nir_builder_opcodes_h.py
>> @@ -55,11 +55,28 @@ nir_load_system_value(nir_builder *build, nir_intrinsic_op op, int index)
>>     return &load->dest.ssa;
>>  }
>>
>> +<%
>> +def sysval_decl_list(opcode):
>> +   res = ''
>> +   if opcode.indices:
>> +      res += ', unsigned ' + opcode.indices[0].lower()
>> +   return res
>> +
>> +def sysval_arg_list(opcode):
>> +   args = []
>> +   if opcode.indices:
>> +      args.append(opcode.indices[0].lower())
>> +   else:
>> +      args.append('0')
>> +   return ', '.join(args)
>> +%>
>
> I was confused why only indices[0] was used, but it looks like system
> values can only have one index.  Maybe assert(len(opcode.indices) <= 1)?
> Other than that, these are:
>
> Reviewed-by: Eric Anholt <eric at anholt.net>

maybe a static assert that verifies this instead? We could put it
inside nir_intrinsics_c.py and add a note that nir_load_system_value
needs to be adjusted in case we want more.


More information about the mesa-dev mailing list