radeonsi: fix gl_PrimitiveID in tessellation with instanced draws on SI
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Wed, 3 May 2017 09:26:27 +0000 (11:26 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 8 May 2017 15:42:17 +0000 (17:42 +0200)
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_state_draw.c

index 5f1371a14336fdb6e46875e23cf833fff7ac5742..f0ed898cfb0333db157e113edd9ac73a09c2f071 100644 (file)
@@ -188,6 +188,20 @@ static void si_emit_derived_tess_state(struct si_context *sctx,
        if (sctx->b.chip_class == SI) {
                unsigned one_wave = 64 / MAX2(num_tcs_input_cp, num_tcs_output_cp);
                *num_patches = MIN2(*num_patches, one_wave);
+
+               if (sctx->screen->b.info.max_se == 1) {
+                       /* The VGT HS block increments the patch ID unconditionally
+                        * within a single threadgroup. This results in incorrect
+                        * patch IDs when instanced draws are used.
+                        *
+                        * The intended solution is to restrict threadgroups to
+                        * a single instance by setting SWITCH_ON_EOI, which
+                        * should cause IA to split instances up. However, this
+                        * doesn't work correctly on SI when there is no other
+                        * SE to switch to.
+                        */
+                       *num_patches = 1;
+               }
        }
 
        sctx->last_num_patches = *num_patches;