diff options
author | Jordan Justen <[email protected]> | 2015-07-28 15:17:34 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2015-12-09 23:50:38 -0800 |
commit | aa12a926260532075a402940ec195a7b9a7339f2 (patch) | |
tree | 44dc8df5d37401950ebf5fbe19adbb9cf817c36e | |
parent | 03b043993834573c69fb08ad74ef485cb0dd310b (diff) |
nir: Translate glsl shared var store intrinsic to nir intrinsic
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Iago Toral Quiroga <[email protected]>
Reviewed-by: Kristian Høgsberg <[email protected]>
-rw-r--r-- | src/glsl/nir/glsl_to_nir.cpp | 33 | ||||
-rw-r--r-- | src/glsl/nir/nir_intrinsics.h | 3 |
2 files changed, 35 insertions, 1 deletions
diff --git a/src/glsl/nir/glsl_to_nir.cpp b/src/glsl/nir/glsl_to_nir.cpp index 38f980465b6..779364b9abc 100644 --- a/src/glsl/nir/glsl_to_nir.cpp +++ b/src/glsl/nir/glsl_to_nir.cpp @@ -729,6 +729,8 @@ nir_visitor::visit(ir_call *ir) op = nir_intrinsic_memory_barrier_shared; } else if (strcmp(ir->callee_name(), "__intrinsic_load_shared") == 0) { op = nir_intrinsic_load_shared; + } else if (strcmp(ir->callee_name(), "__intrinsic_store_shared") == 0) { + op = nir_intrinsic_store_shared; } else { unreachable("not reached"); } @@ -1003,6 +1005,37 @@ nir_visitor::visit(ir_call *ir) nir_builder_instr_insert(&b, &instr->instr); break; } + case nir_intrinsic_store_shared: { + exec_node *param = ir->actual_parameters.get_head(); + ir_rvalue *offset = ((ir_instruction *)param)->as_rvalue(); + + param = param->get_next(); + ir_rvalue *val = ((ir_instruction *)param)->as_rvalue(); + + param = param->get_next(); + ir_constant *write_mask = ((ir_instruction *)param)->as_constant(); + assert(write_mask); + + /* Check if we need the indirect version */ + ir_constant *const_offset = offset->as_constant(); + if (!const_offset) { + op = nir_intrinsic_store_shared_indirect; + ralloc_free(instr); + instr = nir_intrinsic_instr_create(shader, op); + instr->src[1] = nir_src_for_ssa(evaluate_rvalue(offset)); + instr->const_index[0] = 0; + } else { + instr->const_index[0] = const_offset->value.u[0]; + } + + instr->const_index[1] = write_mask->value.u[0]; + + instr->src[0] = nir_src_for_ssa(evaluate_rvalue(val)); + instr->num_components = val->type->vector_elements; + + nir_builder_instr_insert(&b, &instr->instr); + break; + } default: unreachable("not reached"); } diff --git a/src/glsl/nir/nir_intrinsics.h b/src/glsl/nir/nir_intrinsics.h index 011b95db9d6..cf9aa888561 100644 --- a/src/glsl/nir/nir_intrinsics.h +++ b/src/glsl/nir/nir_intrinsics.h @@ -278,5 +278,6 @@ LOAD(shared, 0, 1, NIR_INTRINSIC_CAN_ELIMINATE) STORE(output, 0, 0, 0, 0) STORE(per_vertex_output, 1, 1, 0, 0) STORE(ssbo, 1, 1, 1, 0) +STORE(shared, 0, 0, 1, 0) -LAST_INTRINSIC(store_ssbo_indirect) +LAST_INTRINSIC(store_shared_indirect) |