Mesa (master): turnip: Execute ir3_nir_lower_gs pass again

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue May 12 21:16:53 UTC 2020


Module: Mesa
Branch: master
Commit: a43e9740646a42e3c2d914ad7e0eb20f4113d153
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a43e9740646a42e3c2d914ad7e0eb20f4113d153

Author: Brian Ho <brian at brkho.com>
Date:   Mon May  4 13:55:06 2020 -0700

turnip: Execute ir3_nir_lower_gs pass again

This commit fixes a GS regression introduced in !4562 where
ir3's GS lowering pass was moved from common code (ir3_nir) to
freedreno-specific code (ir3_shader). For GS support in turnip, we
need to add the GS lowering pass back in, this time in tu_shader.

As for the nir_gather_info change, the GS lowering pass has always
introduced a discard_if intrinsic into the GS. Previously, we simply
ran nir_shader_gather_info before GS lowering, but now since we lower
the GS before we need to remove the assertion that only a FS can use
the discard_if intrinsic.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4892>

---

 src/compiler/nir/nir_gather_info.c | 7 +++++--
 src/freedreno/vulkan/tu_shader.c   | 3 +++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/compiler/nir/nir_gather_info.c b/src/compiler/nir/nir_gather_info.c
index e80a65f19fd..f62adb6e1f4 100644
--- a/src/compiler/nir/nir_gather_info.c
+++ b/src/compiler/nir/nir_gather_info.c
@@ -290,8 +290,11 @@ gather_intrinsic_info(nir_intrinsic_instr *instr, nir_shader *shader,
    /* fallthrough: quads with helper lanes only might be discarded entirely */
    case nir_intrinsic_discard:
    case nir_intrinsic_discard_if:
-      assert(shader->info.stage == MESA_SHADER_FRAGMENT);
-      shader->info.fs.uses_discard = true;
+      /* Freedreno uses the discard_if intrinsic to end GS invocations that
+       * don't produce a vertex, so we only set uses_discard if executing on
+       * a fragment shader. */
+      if (shader->info.stage == MESA_SHADER_FRAGMENT)
+         shader->info.fs.uses_discard = true;
       break;
 
    case nir_intrinsic_interp_deref_at_centroid:
diff --git a/src/freedreno/vulkan/tu_shader.c b/src/freedreno/vulkan/tu_shader.c
index 4fda6538fdf..f6cf0b75761 100644
--- a/src/freedreno/vulkan/tu_shader.c
+++ b/src/freedreno/vulkan/tu_shader.c
@@ -567,6 +567,9 @@ tu_shader_create(struct tu_device *dev,
    if (stage == MESA_SHADER_FRAGMENT)
       NIR_PASS_V(nir, nir_lower_input_attachments, true);
 
+   if (stage == MESA_SHADER_GEOMETRY)
+      NIR_PASS_V(nir, ir3_nir_lower_gs);
+
    NIR_PASS_V(nir, tu_lower_io, shader, layout);
 
    NIR_PASS_V(nir, nir_lower_io, nir_var_all, ir3_glsl_type_size, 0);



More information about the mesa-commit mailing list