diff options
author | Matt Turner <[email protected]> | 2017-06-22 16:43:24 -0700 |
---|---|---|
committer | Matt Turner <[email protected]> | 2017-07-20 16:56:49 -0700 |
commit | 636fe4d1c6b21e9efecd4bce1cedd67afa33343a (patch) | |
tree | 51bd27f34222120a09b51aad495d2d9cee9e6718 /src/compiler/glsl/glsl_to_nir.cpp | |
parent | 41437f1b770101647d009529dd1f7b61c29a1ba8 (diff) |
nir: Add intrinsics from ARB_shader_ballot
Reviewed-by: Connor Abbott <[email protected]>
Reviewed-by: Kenneth Graunke <[email protected]>
Diffstat (limited to 'src/compiler/glsl/glsl_to_nir.cpp')
-rw-r--r-- | src/compiler/glsl/glsl_to_nir.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/compiler/glsl/glsl_to_nir.cpp b/src/compiler/glsl/glsl_to_nir.cpp index 01166f68655..4b3dbcff17b 100644 --- a/src/compiler/glsl/glsl_to_nir.cpp +++ b/src/compiler/glsl/glsl_to_nir.cpp @@ -808,6 +808,15 @@ nir_visitor::visit(ir_call *ir) case ir_intrinsic_vote_eq: op = nir_intrinsic_vote_eq; break; + case ir_intrinsic_ballot: + op = nir_intrinsic_ballot; + break; + case ir_intrinsic_read_invocation: + op = nir_intrinsic_read_invocation; + break; + case ir_intrinsic_read_first_invocation: + op = nir_intrinsic_read_first_invocation; + break; default: unreachable("not reached"); } @@ -1157,6 +1166,42 @@ nir_visitor::visit(ir_call *ir) nir_builder_instr_insert(&b, &instr->instr); break; } + + case nir_intrinsic_ballot: { + nir_ssa_dest_init(&instr->instr, &instr->dest, + ir->return_deref->type->vector_elements, 64, NULL); + + ir_rvalue *value = (ir_rvalue *) ir->actual_parameters.get_head(); + instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value)); + + nir_builder_instr_insert(&b, &instr->instr); + break; + } + case nir_intrinsic_read_invocation: { + nir_ssa_dest_init(&instr->instr, &instr->dest, + ir->return_deref->type->vector_elements, 32, NULL); + instr->num_components = ir->return_deref->type->vector_elements; + + ir_rvalue *value = (ir_rvalue *) ir->actual_parameters.get_head(); + instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value)); + + ir_rvalue *invocation = (ir_rvalue *) ir->actual_parameters.get_head()->next; + instr->src[1] = nir_src_for_ssa(evaluate_rvalue(invocation)); + + nir_builder_instr_insert(&b, &instr->instr); + break; + } + case nir_intrinsic_read_first_invocation: { + nir_ssa_dest_init(&instr->instr, &instr->dest, + ir->return_deref->type->vector_elements, 32, NULL); + instr->num_components = ir->return_deref->type->vector_elements; + + ir_rvalue *value = (ir_rvalue *) ir->actual_parameters.get_head(); + instr->src[0] = nir_src_for_ssa(evaluate_rvalue(value)); + + nir_builder_instr_insert(&b, &instr->instr); + break; + } default: unreachable("not reached"); } |