<div dir="ltr"><div>Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></div><div><br></div><div>Marek<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 2, 2019 at 7:49 PM Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This mirrors the intrinsics in the GLSL IR. One could imagine an<br>
alternate definition where reading the semantic would account for the<br>
READ_HELPER functionality, but that feels potentially dodgy and could be<br>
subject to CSE unpleasantness.<br>
<br>
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu" target="_blank">imirkin@alum.mit.edu</a>><br>
---<br>
.../auxiliary/tgsi/tgsi_info_opcodes.h | 4 ++--<br>
src/gallium/docs/source/tgsi.rst | 21 +++++++++++++++++++<br>
src/gallium/include/pipe/p_shader_tokens.h | 4 ++--<br>
src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 7 +++++--<br>
4 files changed, 30 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h b/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h<br>
index 0b9b264bc53..7aecda44b82 100644<br>
--- a/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h<br>
+++ b/src/gallium/auxiliary/tgsi/tgsi_info_opcodes.h<br>
@@ -29,11 +29,11 @@ OPCODE(1, 1, COMP, ROUND)<br>
OPCODE(1, 1, REPL, EX2)<br>
OPCODE(1, 1, REPL, LG2)<br>
OPCODE(1, 2, REPL, POW)<br>
-OPCODE_GAP(31) /* removed */<br>
+OPCODE(0, 0, NONE, DEMOTE)<br>
OPCODE(1, 1, COMP, U2I64)<br>
OPCODE(1, 0, OTHR, CLOCK)<br>
OPCODE(1, 1, COMP, I2I64)<br>
-OPCODE_GAP(35) /* removed */<br>
+OPCODE(1, 0, COMP, READ_HELPER)<br>
OPCODE(1, 1, REPL, COS)<br>
OPCODE(1, 1, COMP, DDX)<br>
OPCODE(1, 1, COMP, DDY)<br>
diff --git a/src/gallium/docs/source/tgsi.rst b/src/gallium/docs/source/tgsi.rst<br>
index 287f4b72729..d58b23f024b 100644<br>
--- a/src/gallium/docs/source/tgsi.rst<br>
+++ b/src/gallium/docs/source/tgsi.rst<br>
@@ -681,6 +681,27 @@ This instruction replicates its result.<br>
Unconditional discard. Allowed in fragment shaders only.<br>
<br>
<br>
+.. opcode:: DEMOTE - Demote Invocation to a Helper<br>
+<br>
+ This demotes the current invocation to a helper, but continues<br>
+ execution (while KILL may or may not terminate the<br>
+ invocation). After this runs, all the usual helper invocation rules<br>
+ apply about discarding buffer and render target writes. This is<br>
+ useful for having accurate derivatives in the other invocations<br>
+ which have not been demoted.<br>
+<br>
+ Allowed in fragment shaders only.<br>
+<br>
+<br>
+.. opcode:: READ_HELPER - Reads Invocation Helper Status<br>
+<br>
+ This is identical to ``TGSI_SEMANTIC_HELPER_INVOCATION``, except<br>
+ this will read the current value, which might change as a result of<br>
+ a ``DEMOTE`` instruction.<br>
+<br>
+ Allowed in fragment shaders only.<br>
+<br>
+<br>
.. opcode:: TXB - Texture Lookup With Bias<br>
<br>
for cube map array textures and shadow cube maps, the bias value<br>
diff --git a/src/gallium/include/pipe/p_shader_tokens.h b/src/gallium/include/pipe/p_shader_tokens.h<br>
index b30a257df2f..5770eba0837 100644<br>
--- a/src/gallium/include/pipe/p_shader_tokens.h<br>
+++ b/src/gallium/include/pipe/p_shader_tokens.h<br>
@@ -376,11 +376,11 @@ enum tgsi_opcode {<br>
TGSI_OPCODE_EX2 = 28,<br>
TGSI_OPCODE_LG2 = 29,<br>
TGSI_OPCODE_POW = 30,<br>
- /* gap */<br>
+ TGSI_OPCODE_DEMOTE = 31,<br>
TGSI_OPCODE_U2I64 = 32,<br>
TGSI_OPCODE_CLOCK = 33,<br>
TGSI_OPCODE_I2I64 = 34,<br>
- /* gap */<br>
+ TGSI_OPCODE_READ_HELPER = 35,<br>
TGSI_OPCODE_COS = 36,<br>
TGSI_OPCODE_DDX = 37,<br>
TGSI_OPCODE_DDY = 38,<br>
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
index 799c161cfaf..be582f5f01c 100644<br>
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp<br>
@@ -4107,6 +4107,10 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)<br>
visit_generic_intrinsic(ir, TGSI_OPCODE_READ_INVOC);<br>
return;<br>
<br>
+ case ir_intrinsic_helper_invocation:<br>
+ visit_generic_intrinsic(ir, TGSI_OPCODE_READ_HELPER);<br>
+ return;<br>
+<br>
case ir_intrinsic_invalid:<br>
case ir_intrinsic_generic_load:<br>
case ir_intrinsic_generic_store:<br>
@@ -4120,7 +4124,6 @@ glsl_to_tgsi_visitor::visit(ir_call *ir)<br>
case ir_intrinsic_generic_atomic_comp_swap:<br>
case ir_intrinsic_begin_invocation_interlock:<br>
case ir_intrinsic_end_invocation_interlock:<br>
- case ir_intrinsic_helper_invocation:<br>
unreachable("Invalid intrinsic");<br>
}<br>
}<br>
@@ -4631,7 +4634,7 @@ glsl_to_tgsi_visitor::visit(ir_discard *ir)<br>
void<br>
glsl_to_tgsi_visitor::visit(ir_demote *ir)<br>
{<br>
- assert(!"demote statement unsupported");<br>
+ emit_asm(ir, TGSI_OPCODE_DEMOTE);<br>
}<br>
<br>
void<br>
-- <br>
2.21.0<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org" target="_blank">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/mailman/listinfo/mesa-dev</a></blockquote></div>