[Mesa-dev] [PATCH v2 24/42] nir: Translate glsl shared var load intrinsic to nir intrinsic
Connor Abbott
cwabbott0 at gmail.com
Wed Nov 25 07:17:29 PST 2015
On Wed, Nov 25, 2015 at 4:48 AM, Iago Toral <itoral at igalia.com> wrote:
> On Tue, 2015-11-17 at 21:54 -0800, Jordan Justen wrote:
>> Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
>> ---
>> src/glsl/nir/glsl_to_nir.cpp | 29 +++++++++++++++++++++++++++++
>> src/glsl/nir/nir_intrinsics.h | 1 +
>> 2 files changed, 30 insertions(+)
>>
>> diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp
>> index 6d24341..a59d09c 100644
>> --- a/src/glsl/nir/glsl_to_nir.cpp
>> +++ b/src/glsl/nir/glsl_to_nir.cpp
>> @@ -727,6 +727,8 @@ nir_visitor::visit(ir_call *ir)
>> op = nir_intrinsic_memory_barrier_image;
>> } else if (strcmp(ir->callee_name(), "__intrinsic_memory_barrier_shared") == 0) {
>> op = nir_intrinsic_memory_barrier_shared;
>> + } else if (strcmp(ir->callee_name(), "__intrinsic_load_shared") == 0) {
>> + op = nir_intrinsic_load_shared;
>> } else {
>> unreachable("not reached");
>> }
>> @@ -974,6 +976,33 @@ nir_visitor::visit(ir_call *ir)
>> nir_builder_instr_insert(&b, &instr->instr);
>> break;
>> }
>> + case nir_intrinsic_load_shared: {
>> + exec_node *param = ir->actual_parameters.get_head();
>> + ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue();
>> +
>> + /* Check if we need the indirect version */
>> + ir_constant *const_offset = offset->as_constant();
>> + if (!const_offset) {
>> + op = nir_intrinsic_load_shared_indirect;
>> + ralloc_free(instr);
>> + instr = nir_intrinsic_instr_create(shader, op);
>> + instr->src[0] = nir_src_for_ssa(evaluate_rvalue(offset));
>> + instr->const_index[0] = 0;
>> + dest = &instr->dest;
>> + } else {
>> + instr->const_index[0] = const_offset->value.u[0];
>> + }
>> +
>> + const glsl_type *type = ir->return_deref->var->type;
>> + instr->num_components = type->vector_elements;
>> +
>> + /* Setup destination register */
>> + nir_ssa_dest_init(&instr->instr, &instr->dest,
>> + type->vector_elements, NULL);
>> +
>> + nir_builder_instr_insert(&b, &instr->instr);
>
> In ubos and ssbo loads we need to fixup bool types, it looks like you
> would need to do the same here, right?
I don't think that's necessary, because shared variables are never
read/written on the CPU, so we just always use ~0/0 for true/false and
never have to convert to what the API expects.
>
>> + break;
>> + }
>> default:
>> unreachable("not reached");
>> }
>> diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h
>> index b8d7d6c..de15128 100644
>> --- a/src/glsl/nir/nir_intrinsics.h
>> +++ b/src/glsl/nir/nir_intrinsics.h
>> @@ -257,6 +257,7 @@ LOAD(per_vertex_input, 1, 1, NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REO
>> LOAD(ssbo, 1, 1, NIR_INTRINSIC_CAN_ELIMINATE)
>> LOAD(output, 0, 1, NIR_INTRINSIC_CAN_ELIMINATE)
>> LOAD(per_vertex_output, 1, 1, NIR_INTRINSIC_CAN_ELIMINATE)
>> +LOAD(shared, 0, 1, NIR_INTRINSIC_CAN_ELIMINATE)
>>
>> /*
>> * Stores work the same way as loads, except now the first register input is
>
>
> _______________________________________________
> 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