[Mesa-dev] [PATCH][RFC] i965: allocate a SGVS element when VertexID or InstanceID are read in gen9+

Iago Toral Quiroga itoral at igalia.com
Wed Jan 3 09:20:39 UTC 2018


Although in theory this should not be necessary it seems that doing this
fixes a spurious low rate failure of ~1% in a CTS test that seems to happen
in some gen9+ platforms only.

Fixes flakyness in:
KHR-GL45.vertex_attrib_64bit.limits_test

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104335
---

I am not sure why this fixes the spurious fails, but it clearly does, at least for
me. I have not seen any workarounds related to this in the PRMs so maybe
this is just papering over some other problem in the end. It would be great if
someone else could test this and verify that it fixes the spurious fails for them
as well and I'd also appreciate any thoughts on what could be causing this problem
and why this seems to fix it. There is more detail in the bug report.

 src/mesa/drivers/dri/i965/genX_state_upload.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 50ac5bc59f..523e9688a6 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -494,12 +494,25 @@ genX(emit_vertices)(struct brw_context *brw)
     * values.  Additionally if there is an edge flag element then the SGVS
     * can't be inserted past that so we need a dummy element to ensure that
     * the edge flag is the last one.
+    *
+    * In gen9+, the CTS test KHR-GL45.vertex_attrib_64bit.limits_test fails
+    * with a fail rate of ~1% for the cases where it reads gl_InstanceID but no
+    * SGVS element is programmed. Programming the SGVS element in this case
+    * seems to make the problem go away.
     */
+#if GEN_GEN >= 9
+   const bool needs_sgvs_element = (vs_prog_data->uses_basevertex ||
+                                    vs_prog_data->uses_baseinstance ||
+                                    vs_prog_data->uses_instanceid ||
+                                    vs_prog_data->uses_vertexid);
+#else
    const bool needs_sgvs_element = (vs_prog_data->uses_basevertex ||
                                     vs_prog_data->uses_baseinstance ||
                                     ((vs_prog_data->uses_instanceid ||
                                       vs_prog_data->uses_vertexid)
                                      && uses_edge_flag));
+#endif
+
 #else
    const bool needs_sgvs_element = (vs_prog_data->uses_basevertex ||
                                     vs_prog_data->uses_baseinstance ||
-- 
2.11.0



More information about the mesa-dev mailing list