From c03247bae010dfd81a08572a32067e9ea8637f63 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Mon, 13 Jul 2015 18:01:13 +0100 Subject: [PATCH] i965/bdw: Fix setting the instancing state for the SGVS element When gl_VertexID or gl_InstanceID is used a 3DSTATE_VF_SGVS instruction is sent to create a sort of element to store the generated values. The last instruction in this chunk of code looks like it was trying to set the instancing state for the element using the 3DSTATE_VF_INSTANCING instruction. However it was sending brw->vb.nr_buffers instead of the element index. This instruction is supposed to take an element index and that is how it is used further down in the function so the previous code looks wrong. Perhaps previously the number of buffers coincidentally matched the number of enabled elements so the value was generally correct anyway. In a subsequent patch I want to change a bit how it chooses the SGVS element index so this needs to be fixed. v2 [by Ben] Remove stable 10.5 stable tag (it's too late now) Commit update as follows: The number of vertex buffers emitted is always <= the number of vertex elements. To maximize reuse (actually, to minimize relocations - according to the code comments), a vertex buffer is only emitted once, even when we setup multiple components (3DSTATE_VERTEX_ELEMENT) from that buffer. This meant that the previous code would use the wrong indexed element for these reuse cases. This patch by itself prevents hangs on BSW in the linked bug. It doesn't make the test pass, the remaining patches are needed for that. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91610 Signed-off-by: Ben Widawsky Reviewed-by: Ben Widawsky Tested-by: Mark Janes Cc: --- src/mesa/drivers/dri/i965/gen8_draw_upload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/i965/gen8_draw_upload.c b/src/mesa/drivers/dri/i965/gen8_draw_upload.c index 1af90ec..f7d9952 100644 --- a/src/mesa/drivers/dri/i965/gen8_draw_upload.c +++ b/src/mesa/drivers/dri/i965/gen8_draw_upload.c @@ -74,7 +74,7 @@ gen8_emit_vertices(struct brw_context *brw) BEGIN_BATCH(3); OUT_BATCH(_3DSTATE_VF_INSTANCING << 16 | (3 - 2)); - OUT_BATCH(brw->vb.nr_buffers | GEN8_VF_INSTANCING_ENABLE); + OUT_BATCH(vue | GEN8_VF_INSTANCING_ENABLE); OUT_BATCH(0); ADVANCE_BATCH(); } else { -- 2.7.4