[Mesa-dev] [PATCH 5/5] radeonsi/nir: add missing pieces for bindless image/sampler support
Timothy Arceri
tarceri at itsqueeze.com
Wed Jan 9 08:53:57 UTC 2019
---
src/gallium/drivers/radeonsi/si_shader_nir.c | 33 +++++++++++++++++++-
1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index 2c95c62d99..256ef28bb1 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -912,6 +912,28 @@ si_nir_lookup_interp_param(struct ac_shader_abi *abi,
LLVMGetParam(ctx->main_fn, interp_param_idx) : NULL;
}
+static LLVMValueRef
+get_bindless_index(struct ac_shader_abi *abi,
+ struct si_shader_context *ctx, unsigned base_index,
+ unsigned constant_index, LLVMValueRef dynamic_index)
+{
+ LLVMValueRef offset = LLVMConstInt(ctx->i32, base_index * 4, 0);
+ LLVMValueRef index = LLVMBuildAdd(ctx->ac.builder, dynamic_index,
+ LLVMConstInt(ctx->ac.i32, constant_index, 0), "");
+
+ /* Bindless uniforms are 64bit so multiple index by 8 */
+ index = LLVMBuildMul(ctx->ac.builder, index, LLVMConstInt(ctx->i32, 8, 0), "");
+ offset = LLVMBuildAdd(ctx->ac.builder, offset, index, "");
+
+ LLVMValueRef ubo_index = abi->load_ubo(abi, ctx->ac.i32_0);
+
+ LLVMValueRef ret = ac_build_buffer_load(&ctx->ac, ubo_index, 1, NULL, offset,
+ NULL, 0, false, false, true, true);
+
+ return LLVMBuildBitCast(ctx->ac.builder, ret, ctx->i32, "");
+}
+
+
static LLVMValueRef
si_nir_load_sampler_desc(struct ac_shader_abi *abi,
unsigned descriptor_set, unsigned base_index,
@@ -937,8 +959,17 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi,
LLVMValueRef list =
LLVMGetParam(ctx->main_fn, ctx->param_bindless_samplers_and_images);
- /* dynamic_index is the bindless handle */
+ dynamic_index = dynamic_index ? dynamic_index : ctx->ac.i32_0;
+ dynamic_index = get_bindless_index(abi, ctx, base_index,
+ constant_index, dynamic_index);
+
if (image) {
+ /* For simplicity, bindless image descriptors use fixed
+ * 16-dword slots for now.
+ */
+ dynamic_index = LLVMBuildMul(ctx->ac.builder, dynamic_index,
+ LLVMConstInt(ctx->i32, 2, 0), "");
+
return si_load_image_desc(ctx, list, dynamic_index, desc_type,
dcc_off, true);
}
--
2.20.1
More information about the mesa-dev
mailing list