zink: reorder fbfetch flag-setting to avoid null deref

this avoids dereferencing pg->dd which is allocated a few lines later

Fixes: 417477f60e ("zink: always use lazy (non-push) updating for fbfetch descriptors")

fixes (radv):
dEQP-GLES31.functional.blend_equation_advanced.basic.multiply

Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14718>
(cherry picked from commit 8747715aec)
This commit is contained in:
Mike Blumenkrantz 2022-01-25 11:25:24 -05:00 committed by Eric Engestrom
parent 5a106c47d7
commit 343f9f52a1
2 changed files with 8 additions and 8 deletions

View file

@ -4648,7 +4648,7 @@
"description": "zink: reorder fbfetch flag-setting to avoid null deref",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "417477f60ede0fab0a5a601c872731fc9c612da1"
},

View file

@ -140,20 +140,20 @@ zink_descriptor_program_init_lazy(struct zink_context *ctx, struct zink_program
struct zink_shader **stages;
if (pg->is_compute)
stages = &((struct zink_compute_program*)pg)->shader;
else {
else
stages = ((struct zink_gfx_program*)pg)->shaders;
if (stages[PIPE_SHADER_FRAGMENT]->nir->info.fs.uses_fbfetch_output) {
zink_descriptor_util_init_fbfetch(ctx);
push_count = 1;
pg->dd->fbfetch = true;
}
}
if (!pg->dd)
pg->dd = (void*)rzalloc(pg, struct zink_program_descriptor_data);
if (!pg->dd)
return false;
if (!pg->is_compute && stages[PIPE_SHADER_FRAGMENT]->nir->info.fs.uses_fbfetch_output) {
zink_descriptor_util_init_fbfetch(ctx);
push_count = 1;
pg->dd->fbfetch = true;
}
unsigned entry_idx[ZINK_DESCRIPTOR_TYPES] = {0};
unsigned num_shaders = pg->is_compute ? 1 : ZINK_SHADER_COUNT;