gallium/tgsi: add support for DEMOTE and READ_HELPER opcodes

This mirrors the intrinsics in the GLSL IR. One could imagine an
alternate definition where reading the semantic would account for the
READ_HELPER functionality, but that feels potentially dodgy and could be
subject to CSE unpleasantness.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Ilia Mirkin 2019-10-02 19:39:30 -04:00
parent eec7b0a865
commit 71c34a51c3
4 changed files with 30 additions and 6 deletions

View File

@ -29,11 +29,11 @@ OPCODE(1, 1, COMP, ROUND)
OPCODE(1, 1, REPL, EX2)
OPCODE(1, 1, REPL, LG2)
OPCODE(1, 2, REPL, POW)
OPCODE_GAP(31) /* removed */
OPCODE(0, 0, NONE, DEMOTE)
OPCODE(1, 1, COMP, U2I64)
OPCODE(1, 0, OTHR, CLOCK)
OPCODE(1, 1, COMP, I2I64)
OPCODE_GAP(35) /* removed */
OPCODE(1, 0, COMP, READ_HELPER)
OPCODE(1, 1, REPL, COS)
OPCODE(1, 1, COMP, DDX)
OPCODE(1, 1, COMP, DDY)

View File

@ -681,6 +681,27 @@ This instruction replicates its result.
Unconditional discard. Allowed in fragment shaders only.
.. opcode:: DEMOTE - Demote Invocation to a Helper
This demotes the current invocation to a helper, but continues
execution (while KILL may or may not terminate the
invocation). After this runs, all the usual helper invocation rules
apply about discarding buffer and render target writes. This is
useful for having accurate derivatives in the other invocations
which have not been demoted.
Allowed in fragment shaders only.
.. opcode:: READ_HELPER - Reads Invocation Helper Status
This is identical to ``TGSI_SEMANTIC_HELPER_INVOCATION``, except
this will read the current value, which might change as a result of
a ``DEMOTE`` instruction.
Allowed in fragment shaders only.
.. opcode:: TXB - Texture Lookup With Bias
for cube map array textures and shadow cube maps, the bias value

View File

@ -376,11 +376,11 @@ enum tgsi_opcode {
TGSI_OPCODE_EX2 = 28,
TGSI_OPCODE_LG2 = 29,
TGSI_OPCODE_POW = 30,
/* gap */
TGSI_OPCODE_DEMOTE = 31,
TGSI_OPCODE_U2I64 = 32,
TGSI_OPCODE_CLOCK = 33,
TGSI_OPCODE_I2I64 = 34,
/* gap */
TGSI_OPCODE_READ_HELPER = 35,
TGSI_OPCODE_COS = 36,
TGSI_OPCODE_DDX = 37,
TGSI_OPCODE_DDY = 38,

View File

@ -4107,6 +4107,10 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
visit_generic_intrinsic(ir, TGSI_OPCODE_READ_INVOC);
return;
case ir_intrinsic_helper_invocation:
visit_generic_intrinsic(ir, TGSI_OPCODE_READ_HELPER);
return;
case ir_intrinsic_invalid:
case ir_intrinsic_generic_load:
case ir_intrinsic_generic_store:
@ -4120,7 +4124,6 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)
case ir_intrinsic_generic_atomic_comp_swap:
case ir_intrinsic_begin_invocation_interlock:
case ir_intrinsic_end_invocation_interlock:
case ir_intrinsic_helper_invocation:
unreachable("Invalid intrinsic");
}
}
@ -4631,7 +4634,7 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)
void
glsl_to_tgsi_visitor::visit(ir_demote *ir)
{
assert(!"demote statement unsupported");
emit_asm(ir, TGSI_OPCODE_DEMOTE);
}
void