radeonsi: handle an out-of-bounds sampler/image index better

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15965>
This commit is contained in:
Marek Olšák 2022-03-22 05:08:35 -04:00 committed by Marge Bot
parent 7341cb7654
commit 80bc6f9e28

View file

@ -280,7 +280,10 @@ static LLVMValueRef si_nir_load_sampler_desc(struct ac_shader_abi *abi, unsigned
}
unsigned num_slots = image ? ctx->num_images : ctx->num_samplers;
assert(const_index < num_slots || dynamic_index);
/* Redirect invalid resource indices to the first array element. */
if (const_index >= num_slots)
const_index = base_index;
LLVMValueRef list = ac_get_arg(&ctx->ac, ctx->samplers_and_images);
LLVMValueRef index = LLVMConstInt(ctx->ac.i32, const_index, false);