iris: don't emit IRIS_DIRTY_VF depending on trash in restart_index
authorAndrii Simiklit <andrii.simiklit@globallogic.com>
Fri, 8 Jan 2021 11:34:34 +0000 (13:34 +0200)
committerMarge Bot <eric+marge@anholt.net>
Tue, 2 Feb 2021 13:16:07 +0000 (13:16 +0000)
The `restart_index` field can be uninitialized if `primitive_restart`
is false so we have to track `restart_index` changes
only if `primitive_restart` is true

Here is a valgrind warning:
Conditional jump or move depends on uninitialised value(s)
==52021==    at 0x6D44968: iris_update_draw_info (iris_draw.c:102)
==52021==    by 0x6D450B5: iris_draw_vbo (iris_draw.c:273)
==52021==    by 0x642FD8E: cso_multi_draw (cso_context.c:1708)
==52021==    by 0x5C434D3: st_draw_gallium (st_draw.c:271)
==52021==    by 0x5DF5F1B: _mesa_draw_arrays (draw.c:554)
==52021==    by 0x5DF68F7: _mesa_DrawArrays (draw.c:768)
==52021==    by 0x49011F2: stub_glDrawArrays (piglit-dispatch-gen.c:12181)
==52021==    by 0x11C611: piglit_display (shader_runner.c:4549)
==52021==    by 0x4994D83: process_next_event (piglit_x11_framework.c:137)
==52021==    by 0x4994E47: enter_event_loop (piglit_x11_framework.c:153)
==52021==    by 0x49939A4: run_test (piglit_winsys_framework.c:88)
==52021==    by 0x49821A9: piglit_gl_test_run (piglit-framework-gl.c:229)

v2: - don't propagate trash to state->cut_index
    (Kenneth Graunke <kenneth@whitecape.org>)

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8409>

src/gallium/drivers/iris/iris_draw.c

index 8c05c1e..581d306 100644 (file)
@@ -98,11 +98,14 @@ iris_update_draw_info(struct iris_context *ice,
       }
    }
 
+   /* Track restart_index changes only if primitive_restart is true */
+   const unsigned cut_index = info->primitive_restart ? info->restart_index :
+                                                        ice->state.cut_index;
    if (ice->state.primitive_restart != info->primitive_restart ||
-       ice->state.cut_index != info->restart_index) {
+       ice->state.cut_index != cut_index) {
       ice->state.dirty |= IRIS_DIRTY_VF;
       ice->state.primitive_restart = info->primitive_restart;
-      ice->state.cut_index = info->restart_index;
+      ice->state.cut_index = cut_index;
    }
 }