On Wed, 2015-08-05 at 12:24 -0700, Connor Abbott wrote: > On Wed, Aug 5, 2015 at 1:30 AM, Iago Toral Quiroga <ito...@igalia.com> wrote: > > The original GLSL IR intrinsics have been lowered to an internal > > version that accepts a block index and an offset instead of a > > SSBO reference. > > --- > > src/glsl/nir/glsl_to_nir.cpp | 55 > > +++++++++++++++++++++++++++++++++++++++++++ > > src/glsl/nir/nir_intrinsics.h | 12 ++++++++++ > > 2 files changed, 67 insertions(+) > > > > diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp > > index aa96e40..4450e7a 100644 > > --- a/src/glsl/nir/glsl_to_nir.cpp > > +++ b/src/glsl/nir/glsl_to_nir.cpp > > @@ -645,6 +645,22 @@ nir_visitor::visit(ir_call *ir) > > op = nir_intrinsic_store_ssbo; > > } else if (strcmp(ir->callee_name(), "__intrinsic_load_ssbo") == 0) { > > op = nir_intrinsic_load_ssbo; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_add_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_add; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_and_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_and; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_or_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_or; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_xor_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_xor; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_min_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_min; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_max_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_max; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_exchange_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_exchange; > > + } else if (strcmp(ir->callee_name(), > > "__intrinsic_ssbo_atomic_comp_swap_internal") == 0) { > > + op = nir_intrinsic_ssbo_atomic_comp_swap; > > } else { > > unreachable("not reached"); > > } > > @@ -826,7 +842,46 @@ nir_visitor::visit(ir_call *ir) > > > > nir_instr_insert_after_cf_list(this->cf_node_list, > > &compare->instr); > > } > > + break; > > + } > > + case nir_intrinsic_ssbo_atomic_add: > > + case nir_intrinsic_ssbo_atomic_min: > > + case nir_intrinsic_ssbo_atomic_max: > > + case nir_intrinsic_ssbo_atomic_and: > > + case nir_intrinsic_ssbo_atomic_or: > > + case nir_intrinsic_ssbo_atomic_xor: > > + case nir_intrinsic_ssbo_atomic_exchange: > > + case nir_intrinsic_ssbo_atomic_comp_swap: { > > + int param_count = ir->actual_parameters.length(); > > + assert(param_count == 3 || param_count == 4); > > + > > + /* Block index */ > > + exec_node *param = ir->actual_parameters.get_head(); > > + ir_instruction *inst = (ir_instruction *) param; > > + instr->src[0] = evaluate_rvalue(inst->as_rvalue()); > > > > + /* Offset */ > > + param = param->get_next(); > > + inst = (ir_instruction *) param; > > + instr->src[1] = evaluate_rvalue(inst->as_rvalue()); > > + > > + /* data1 parameter (this is always present) */ > > + param = param->get_next(); > > + inst = (ir_instruction *) param; > > + instr->src[2] = evaluate_rvalue(inst->as_rvalue()); > > + > > + /* data2 parameter (only with atomic_comp_swap) */ > > + if (param_count == 4) { > > + assert(op == nir_intrinsic_ssbo_atomic_comp_swap); > > + param = param->get_next(); > > + inst = (ir_instruction *) param; > > + instr->src[3] = evaluate_rvalue(inst->as_rvalue()); > > + } > > + > > + /* Atomic result */ > > + assert(ir->return_deref); > > + nir_ssa_dest_init(&instr->instr, &instr->dest, > > + ir->return_deref->type->vector_elements, NULL); > > break; > > } > > default: > > diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h > > index 9877ea4..a1351d1 100644 > > --- a/src/glsl/nir/nir_intrinsics.h > > +++ b/src/glsl/nir/nir_intrinsics.h > > @@ -133,6 +133,18 @@ INTRINSIC(image_atomic_xor, 3, ARR(4, 1, 1), true, 1, > > 1, 0, 0) > > INTRINSIC(image_atomic_exchange, 3, ARR(4, 1, 1), true, 1, 1, 0, 0) > > INTRINSIC(image_atomic_comp_swap, 4, ARR(4, 1, 1, 1), true, 1, 1, 0, 0) > > > > +/* > > + * SSBO atomic intrinsics > > + */ > > Could you add a bit here explaining what the sources are?
How about this?: /* * SSBO atomic intrinsics * * All of the SSBO atomic memory operations read a value from memory, * compute a new value using one of the operations below, write the new * value to memory, and return the original value read. * * All operations take 3 sources except CompSwap that takes 4. These * sources represent: * * 0: The SSBO buffer index. * 1: The offset into the SSBO buffer of the variable that the atomic * operation will operate on. * 2: The data parameter to the atomic function (i.e. the value to add * in ssbo_atomic_add, etc). * 3: For CompSwap only: the second data parameter. */ > > +INTRINSIC(ssbo_atomic_add, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_min, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_max, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_and, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_or, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_xor, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_exchange, 3, ARR(1, 1, 1), true, 1, 0, 0, 0) > > +INTRINSIC(ssbo_atomic_comp_swap, 4, ARR(1, 1, 1, 1), true, 1, 0, 0, 0) > > + > > #define SYSTEM_VALUE(name, components) \ > > INTRINSIC(load_##name, 0, ARR(), true, components, 0, 0, \ > > NIR_INTRINSIC_CAN_ELIMINATE | NIR_INTRINSIC_CAN_REORDER) > > -- > > 1.9.1 > > > > _______________________________________________ > > mesa-dev mailing list > > mesa-dev@lists.freedesktop.org > > http://lists.freedesktop.org/mailman/listinfo/mesa-dev > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev