Module: Mesa Branch: main Commit: 80bc6f9e28dfa2058187162d60aaf068b5bb9e42 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=80bc6f9e28dfa2058187162d60aaf068b5bb9e42
Author: Marek Olšák <[email protected]> Date: Tue Mar 22 05:08:35 2022 -0400 radeonsi: handle an out-of-bounds sampler/image index better Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15965> --- src/gallium/drivers/radeonsi/si_shader_llvm_resources.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c index 0ded858ad91..1ea0f9560e9 100644 --- a/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c +++ b/src/gallium/drivers/radeonsi/si_shader_llvm_resources.c @@ -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);
