radeonsi: clamp indirect index to the number of declared shader resources
We'll do partial uploads of descriptor arrays, so we need to clamp against what shaders declare. Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
This commit is contained in:
parent
f07c15ef80
commit
b8f8d9e46c
|
@ -1763,7 +1763,7 @@ static LLVMValueRef fetch_constant(
|
|||
LLVMValueRef index;
|
||||
index = si_get_bounded_indirect_index(ctx, ®->DimIndirect,
|
||||
reg->Dimension.Index,
|
||||
SI_NUM_CONST_BUFFERS);
|
||||
ctx->num_const_buffers);
|
||||
index = LLVMBuildAdd(ctx->gallivm.builder, index,
|
||||
LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS, 0), "");
|
||||
bufp = ac_build_indexed_load_const(&ctx->ac, ptr, index);
|
||||
|
|
|
@ -57,6 +57,12 @@ struct si_shader_context {
|
|||
|
||||
unsigned type; /* PIPE_SHADER_* specifies the type of shader. */
|
||||
|
||||
/* For clamping the non-constant index in resource indexing: */
|
||||
unsigned num_const_buffers;
|
||||
unsigned num_shader_buffers;
|
||||
unsigned num_images;
|
||||
unsigned num_samplers;
|
||||
|
||||
/* Whether the prolog will be compiled separately. */
|
||||
bool separate_prolog;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ shader_buffer_fetch_rsrc(struct si_shader_context *ctx,
|
|||
} else {
|
||||
index = si_get_bounded_indirect_index(ctx, ®->Indirect,
|
||||
reg->Register.Index,
|
||||
SI_NUM_SHADER_BUFFERS);
|
||||
ctx->num_shader_buffers);
|
||||
index = LLVMBuildSub(ctx->gallivm.builder,
|
||||
LLVMConstInt(ctx->i32, SI_NUM_SHADER_BUFFERS - 1, 0),
|
||||
index, "");
|
||||
|
@ -208,7 +208,7 @@ image_fetch_rsrc(
|
|||
*/
|
||||
index = si_get_bounded_indirect_index(ctx, &image->Indirect,
|
||||
image->Register.Index,
|
||||
SI_NUM_IMAGES);
|
||||
ctx->num_images);
|
||||
index = LLVMBuildSub(ctx->gallivm.builder,
|
||||
LLVMConstInt(ctx->i32, SI_NUM_IMAGES - 1, 0),
|
||||
index, "");
|
||||
|
@ -1199,7 +1199,7 @@ static void tex_fetch_ptrs(
|
|||
index = si_get_bounded_indirect_index(ctx,
|
||||
®->Indirect,
|
||||
reg->Register.Index,
|
||||
SI_NUM_SAMPLERS);
|
||||
ctx->num_samplers);
|
||||
index = LLVMBuildAdd(ctx->gallivm.builder, index,
|
||||
LLVMConstInt(ctx->i32, SI_NUM_IMAGES / 2, 0), "");
|
||||
} else {
|
||||
|
|
|
@ -1354,6 +1354,11 @@ void si_llvm_context_set_tgsi(struct si_shader_context *ctx,
|
|||
ctx->bld_base.emit_fetch_funcs[TGSI_FILE_TEMPORARY] = si_llvm_emit_fetch;
|
||||
ctx->bld_base.emit_fetch_funcs[TGSI_FILE_OUTPUT] = si_llvm_emit_fetch;
|
||||
ctx->bld_base.emit_fetch_funcs[TGSI_FILE_SYSTEM_VALUE] = fetch_system_value;
|
||||
|
||||
ctx->num_const_buffers = util_last_bit(info->const_buffers_declared);
|
||||
ctx->num_shader_buffers = util_last_bit(info->shader_buffers_declared);
|
||||
ctx->num_samplers = util_last_bit(info->samplers_declared);
|
||||
ctx->num_images = util_last_bit(info->images_declared);
|
||||
}
|
||||
|
||||
void si_llvm_create_func(struct si_shader_context *ctx,
|
||||
|
|
Loading…
Reference in New Issue