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);
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;
} 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, "");
*/
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, "");
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 {
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,