[Mesa-dev] [PATCH 08/78] i965/nir/vec4: Add setup for system values
Alejandro Piñeiro
apinheiro at igalia.com
Tue Jun 30 00:25:16 PDT 2015
On 30/06/15 01:34, Jason Ekstrand wrote:
> On Fri, Jun 26, 2015 at 1:06 AM, Eduardo Lima Mitev <elima at igalia.com> wrote:
>> From: Alejandro Piñeiro <apinheiro at igalia.com>
>>
>> Similar to other variable setups, system values will initialize the
>> corresponding register inside a 'nir_system_values' map, which will then
>> be queried later when processing the different system value intrinsics
>> for the appropriate register.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89580
>> ---
>> src/mesa/drivers/dri/i965/brw_vec4.h | 1 +
>> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 43 +++++++++++++++++++++++++++++-
>> 2 files changed, 43 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_vec4.h b/src/mesa/drivers/dri/i965/brw_vec4.h
>> index 2a53d9a..e531d60 100644
>> --- a/src/mesa/drivers/dri/i965/brw_vec4.h
>> +++ b/src/mesa/drivers/dri/i965/brw_vec4.h
>> @@ -419,6 +419,7 @@ public:
>> brw_reg_type *nir_output_types;
>> unsigned *nir_uniform_offset;
>> unsigned *nir_uniform_driver_location;
>> + dst_reg *nir_system_values;
>>
>> protected:
>> void emit_vertex();
>> diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
>> index 40ec66f..6c2a046 100644
>> --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp
>> @@ -54,13 +54,54 @@ vec4_visitor::emit_nir_code()
>> static bool
>> setup_system_values_block(nir_block *block, void *void_visitor)
>> {
>> - /* @TODO: Not yet implemented */
>> + vec4_visitor *v = (vec4_visitor *)void_visitor;
>> + dst_reg *reg;
>> +
>> + nir_foreach_instr(block, instr) {
>> + if (instr->type != nir_instr_type_intrinsic)
>> + continue;
>> +
>> + nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr);
>> +
>> + switch (intrin->intrinsic) {
>> + case nir_intrinsic_load_vertex_id:
>> + unreachable("should be lowered by lower_vertex_id().");
>> +
>> + case nir_intrinsic_load_vertex_id_zero_base:
>> + reg = &v->nir_system_values[SYSTEM_VALUE_VERTEX_ID_ZERO_BASE];
>> + if (reg->file == BAD_FILE)
>> + *reg =
>> + *v->make_reg_for_system_value(SYSTEM_VALUE_VERTEX_ID_ZERO_BASE,
>> + NULL);
> I know the type isn't actually used for VX, but you know what it is so
> you might as well pass it in here.
Ok
>
>> + break;
>> +
>> + case nir_intrinsic_load_base_vertex:
>> + reg = &v->nir_system_values[SYSTEM_VALUE_BASE_VERTEX];
>> + if (reg->file == BAD_FILE)
>> + *reg = *v->make_reg_for_system_value(SYSTEM_VALUE_BASE_VERTEX,
>> + NULL);
> Same here.
Ok
>
>> + break;
>> +
>> + case nir_intrinsic_load_instance_id:
>> + reg = &v->nir_system_values[SYSTEM_VALUE_INSTANCE_ID];
>> + if (reg->file == BAD_FILE)
>> + *reg = *v->make_reg_for_system_value(SYSTEM_VALUE_INSTANCE_ID,
>> + NULL);
> And here.
Ok
> --Jason
>
>> + break;
>> +
>> + default:
>> + break;
>> + }
>> + }
>> +
>> return true;
>> }
>>
>> void
>> vec4_visitor::nir_setup_system_values(nir_shader *shader)
>> {
>> + nir_system_values = ralloc_array(mem_ctx, dst_reg, SYSTEM_VALUE_MAX);
>> +
>> nir_foreach_overload(shader, overload) {
>> assert(strcmp(overload->function->name, "main") == 0);
>> assert(overload->impl);
>> --
>> 2.1.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
--
Alejandro Piñeiro (apinheiro at igalia.com)
More information about the mesa-dev
mailing list