Mesa (master): v3d/compiler: request fragment shader clip lowering to be vulkan compatible.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jul 27 07:00:18 UTC 2020


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

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Wed Jul 22 08:15:10 2020 +0200

v3d/compiler: request fragment shader clip lowering to be vulkan compatible.

Vulkan allows fragment shaders to read gl_ClipDistance[], in which case
the SPIR-V compiler will inject a compact array variable at
VARYING_SLOT_CLIP_DIST0. Request the lowering to always work in terms
of a compact array variable so we don't have to care about the API
in use.

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6022>

---

 src/broadcom/compiler/vir.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/broadcom/compiler/vir.c b/src/broadcom/compiler/vir.c
index 940d3402ec7..749a38f6028 100644
--- a/src/broadcom/compiler/vir.c
+++ b/src/broadcom/compiler/vir.c
@@ -954,9 +954,15 @@ v3d_nir_lower_fs_late(struct v3d_compile *c)
                            false, NULL);
         }
 
+        /* In OpenGL the fragment shader can't read gl_ClipDistance[], but
+         * Vulkan allows it, in which case the SPIR-V compiler will declare
+         * VARING_SLOT_CLIP_DIST0 as compact array variable. Pass true as
+         * the last parameter to always operate with a compact array in both
+         * OpenGL and Vulkan so we do't have to care about the API we
+         * are using.
+         */
         if (c->key->ucp_enables)
-                NIR_PASS_V(c->s, nir_lower_clip_fs, c->key->ucp_enables,
-                           false);
+                NIR_PASS_V(c->s, nir_lower_clip_fs, c->key->ucp_enables, true);
 
         /* Note: FS input scalarizing must happen after
          * nir_lower_two_sided_color, which only handles a vec4 at a time.



More information about the mesa-commit mailing list