nir: Add demote and is_helper_invocation intrinsics
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Sat, 8 Jun 2019 00:29:05 +0000 (17:29 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 8 Jul 2019 15:57:25 +0000 (08:57 -0700)
From SPV_EXT_demote_to_helper_invocation.  Demote will be implemented
as a variant of discard, so mark uses_discard if it is used.

v2: Add CAN_ELIMINATE flag to the new intrinsic.  (Jason)

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_gather_info.c
src/compiler/nir/nir_intrinsics.py

index 36d0d23bda491856e56204aba5f3acfc7862ff22..3093a03536867ca524c8c70da16078001a3610d4 100644 (file)
@@ -198,6 +198,7 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
                       void *dead_ctx)
 {
    switch (instr->intrinsic) {
+   case nir_intrinsic_demote:
    case nir_intrinsic_discard:
    case nir_intrinsic_discard_if:
       assert(shader->info.stage == MESA_SHADER_FRAGMENT);
index 70ff1b99de00b19b066593c693426fd4671f08a5..e4f94257acd8cf46383fe0fc473f855fea54606e 100644 (file)
@@ -190,6 +190,16 @@ def barrier(name):
 barrier("barrier")
 barrier("discard")
 
+# Demote fragment shader invocation to a helper invocation.  Any stores to
+# memory after this instruction are suppressed and the fragment does not write
+# outputs to the framebuffer.  Unlike discard, demote needs to ensure that
+# derivatives will still work for invocations that were not demoted.
+#
+# As specified by SPV_EXT_demote_to_helper_invocation.
+barrier("demote")
+intrinsic("is_helper_invocation", dest_comp=1, flags=[CAN_ELIMINATE])
+
+
 # Memory barrier with semantics analogous to the memoryBarrier() GLSL
 # intrinsic.
 barrier("memory_barrier")