radeonsi/gfx10: unbind NGG shaders when destroyed
authorMarek Olšák <marek.olsak@amd.com>
Wed, 29 May 2019 02:29:08 +0000 (22:29 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 3 Jul 2019 19:51:13 +0000 (15:51 -0400)
This fixes glsl-max-varyings, which creates shaders, draws, and then
destroys them.

Acked-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/gallium/drivers/radeonsi/si_state_shaders.c

index 7922ced414d6c8827b6c5fcd95a7dded3414bf57..aa98a209cecc5300ce6b2e0d439989dd59a22b2d 100644 (file)
@@ -3040,6 +3040,11 @@ static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
        util_queue_fence_destroy(&shader->ready);
 
        if (shader->pm4) {
+               /* If destroyed shaders were not unbound, the next compiled
+                * shader variant could get the same pointer address and so
+                * binding it to the same shader stage would be considered
+                * a no-op, causing random behavior.
+                */
                switch (shader->selector->type) {
                case PIPE_SHADER_VERTEX:
                        if (shader->key.as_ls) {
@@ -3048,6 +3053,8 @@ static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
                        } else if (shader->key.as_es) {
                                assert(sctx->chip_class <= GFX8);
                                si_pm4_delete_state(sctx, es, shader->pm4);
+                       } else if (shader->key.as_ngg) {
+                               si_pm4_delete_state(sctx, gs, shader->pm4);
                        } else {
                                si_pm4_delete_state(sctx, vs, shader->pm4);
                        }
@@ -3059,6 +3066,8 @@ static void si_delete_shader(struct si_context *sctx, struct si_shader *shader)
                        if (shader->key.as_es) {
                                assert(sctx->chip_class <= GFX8);
                                si_pm4_delete_state(sctx, es, shader->pm4);
+                       } else if (shader->key.as_ngg) {
+                               si_pm4_delete_state(sctx, gs, shader->pm4);
                        } else {
                                si_pm4_delete_state(sctx, vs, shader->pm4);
                        }