zink: isolate gfx stage bits when updating shader modules

ensure that we don't overflow the array here

Fixes: b2247a3724 ("zink: add compute programs and pipelines")

Acked-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9798>
This commit is contained in:
Mike Blumenkrantz 2021-03-24 07:39:07 -04:00 committed by Marge Bot
parent 50b5a9a4a0
commit cce1f22ef3

View file

@ -352,12 +352,13 @@ update_shader_modules(struct zink_context *ctx, struct zink_shader *stages[ZINK_
{
struct zink_shader *dirty[ZINK_SHADER_COUNT] = {NULL};
if (!ctx->dirty_shader_stages)
unsigned gfx_bits = u_bit_consecutive(PIPE_SHADER_VERTEX, 5);
unsigned dirty_shader_stages = ctx->dirty_shader_stages & gfx_bits;
if (!dirty_shader_stages)
return;
/* we need to map pipe_shader_type -> gl_shader_stage so we can ensure that we're compiling
* the shaders in pipeline order and have builtin input/output locations match up after being compacted
*/
unsigned dirty_shader_stages = ctx->dirty_shader_stages;
while (dirty_shader_stages) {
unsigned type = u_bit_scan(&dirty_shader_stages);
dirty[tgsi_processor_to_shader_stage(type)] = stages[type];