Mesa (master): broadcom/vc5: Set up a vertex position if the shader doesn't.

Eric Anholt anholt at kemper.freedesktop.org
Thu Mar 22 22:12:29 UTC 2018


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

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Mar 21 14:18:08 2018 -0700

broadcom/vc5: Set up a vertex position if the shader doesn't.

Our backend needs some sort of vertex position value to emit the scaled
viewport values and such.  Fixes potential segfaults in
KHR-GLES3.copy_tex_image_conversions.required.cubemap_negx_cubemap_negx

---

 src/broadcom/compiler/nir_to_vir.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/broadcom/compiler/nir_to_vir.c b/src/broadcom/compiler/nir_to_vir.c
index 75e35067f2..893dfa160a 100644
--- a/src/broadcom/compiler/nir_to_vir.c
+++ b/src/broadcom/compiler/nir_to_vir.c
@@ -1103,9 +1103,31 @@ emit_vpm_write_setup(struct v3d_compile *c)
         v3d33_vir_vpm_write_setup(c);
 }
 
+/**
+ * Sets up c->outputs[c->output_position_index] for the vertex shader
+ * epilogue, if an output vertex position wasn't specified in the user's
+ * shader.  This may be the case for transform feedback with rasterizer
+ * discard enabled.
+ */
+static void
+setup_default_position(struct v3d_compile *c)
+{
+        if (c->output_position_index != -1)
+                return;
+
+        c->output_position_index = c->outputs_array_size;
+        for (int i = 0; i < 4; i++) {
+                add_output(c,
+                           c->output_position_index + i,
+                           VARYING_SLOT_POS, i);
+        }
+}
+
 static void
 emit_vert_end(struct v3d_compile *c)
 {
+        setup_default_position(c);
+
         uint32_t vpm_index = 0;
         struct qreg rcp_w = vir_SFU(c, V3D_QPU_WADDR_RECIP,
                                     c->outputs[c->output_position_index + 3]);




More information about the mesa-commit mailing list