nir: Add intrinsics from ARB_shader_ballot
Reviewed-by: Connor Abbott <cwabbott0@gmail.com> Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
@@ -808,6 +808,15 @@ nir_visitor::visit(ir_call *ir)
|
|||||||
case ir_intrinsic_vote_eq:
|
case ir_intrinsic_vote_eq:
|
||||||
op = nir_intrinsic_vote_eq;
|
op = nir_intrinsic_vote_eq;
|
||||||
break;
|
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:
|
default:
|
||||||
unreachable("not reached");
|
unreachable("not reached");
|
||||||
}
|
}
|
||||||
@@ -1157,6 +1166,42 @@ nir_visitor::visit(ir_call *ir)
|
|||||||
nir_builder_instr_insert(&b, &instr->instr);
|
nir_builder_instr_insert(&b, &instr->instr);
|
||||||
break;
|
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:
|
default:
|
||||||
unreachable("not reached");
|
unreachable("not reached");
|
||||||
}
|
}
|
||||||
|
@@ -93,6 +93,19 @@ BARRIER(memory_barrier)
|
|||||||
*/
|
*/
|
||||||
INTRINSIC(shader_clock, 0, ARR(0), true, 2, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
|
INTRINSIC(shader_clock, 0, ARR(0), true, 2, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Shader ballot intrinsics with semantics analogous to the
|
||||||
|
*
|
||||||
|
* ballotARB()
|
||||||
|
* readInvocationARB()
|
||||||
|
* readFirstInvocationARB()
|
||||||
|
*
|
||||||
|
* GLSL functions from ARB_shader_ballot.
|
||||||
|
*/
|
||||||
|
INTRINSIC(ballot, 1, ARR(1), true, 1, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
|
||||||
|
INTRINSIC(read_invocation, 2, ARR(0, 1), true, 0, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
|
||||||
|
INTRINSIC(read_first_invocation, 1, ARR(0), true, 0, 0, 0, xx, xx, xx, NIR_INTRINSIC_CAN_ELIMINATE)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Memory barrier with semantics analogous to the compute shader
|
* Memory barrier with semantics analogous to the compute shader
|
||||||
* groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
|
* groupMemoryBarrier(), memoryBarrierAtomicCounter(), memoryBarrierBuffer(),
|
||||||
|
Reference in New Issue
Block a user