anv: Remove FS executables when applying the null FS optimization

If the executables are still hanging out,
anv_GetPipelineExecutableStatisticsKHR will try to dereference NULL
pointers in pipeline->shaders[MESA_SHADER_FRAGMENT].

At least in terms of fossil-db output, this matches the behavior from
before 73b3efcd59.

Fixes: 73b3efcd59 ("anv: Handle the null FS optimization after compiling shaders")
Closes: #6590
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Jason Ekstrand <jason.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16898>
(cherry picked from commit 65d6708bc3)
This commit is contained in:
Ian Romanick 2022-06-06 15:50:53 -07:00 committed by Dylan Baker
parent c9981574c1
commit 9ff1f30d45
2 changed files with 20 additions and 1 deletions

View file

@ -1147,7 +1147,7 @@
"description": "anv: Remove FS executables when applying the null FS optimization",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "73b3efcd59ade6b9dc8c4cce994d7fbe5c1f0cac"
},

View file

@ -1868,6 +1868,25 @@ done:
anv_shader_bin_unref(pipeline->base.device, fs);
pipeline->shaders[MESA_SHADER_FRAGMENT] = NULL;
pipeline->active_stages &= ~VK_SHADER_STAGE_FRAGMENT_BIT;
/* The per-SIMD size fragment shaders should be last in the
* executables array. Remove all of them.
*/
ASSERTED unsigned removed = 0;
util_dynarray_foreach_reverse(&pipeline->base.executables,
struct anv_pipeline_executable,
tail) {
/* There must be at least one fragment shader. */
assert(removed > 0 || tail->stage == MESA_SHADER_FRAGMENT);
if (tail->stage != MESA_SHADER_FRAGMENT)
break;
(void) util_dynarray_pop(&pipeline->base.executables,
struct anv_pipeline_executable);
removed++;
}
}
}