[Mesa-dev] [PATCH 6/7] radeonsi/nir: add initial bindless image support
Timothy Arceri
tarceri at itsqueeze.com
Tue Feb 20 03:42:32 UTC 2018
---
src/gallium/drivers/radeonsi/si_shader_nir.c | 41 +++++++++++++++++++++++-----
1 file changed, 34 insertions(+), 7 deletions(-)
diff --git a/src/gallium/drivers/radeonsi/si_shader_nir.c b/src/gallium/drivers/radeonsi/si_shader_nir.c
index c2036a1509..e3e71c6eb6 100644
--- a/src/gallium/drivers/radeonsi/si_shader_nir.c
+++ b/src/gallium/drivers/radeonsi/si_shader_nir.c
@@ -771,6 +771,21 @@ 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, LLVMValueRef index)
+{
+ LLVMValueRef offset =
+ LLVMBuildMul(ctx->ac.builder, index, LLVMConstInt(ctx->i32, 16, 0), "");
+
+ index = abi->load_ubo(abi, ctx->ac.i32_0);
+
+ LLVMValueRef ret = ac_build_buffer_load(&ctx->ac, 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,
@@ -780,8 +795,10 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi,
{
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
LLVMBuilderRef builder = ctx->ac.builder;
- LLVMValueRef list = LLVMGetParam(ctx->main_fn, ctx->param_samplers_and_images);
LLVMValueRef index = dynamic_index;
+ LLVMValueRef list = bindless ?
+ LLVMGetParam(ctx->main_fn, ctx->param_bindless_samplers_and_images) :
+ LLVMGetParam(ctx->main_fn, ctx->param_samplers_and_images);
assert(!descriptor_set);
@@ -794,14 +811,24 @@ si_nir_load_sampler_desc(struct ac_shader_abi *abi,
if (image) {
assert(desc_type == AC_DESC_IMAGE || desc_type == AC_DESC_BUFFER);
- assert(base_index + constant_index < ctx->num_images);
- if (dynamic_index)
- index = si_llvm_bound_index(ctx, index, ctx->num_images);
+ if (bindless) {
+ LLVMValueRef ret = get_bindless_index(abi, ctx, index);
- index = LLVMBuildSub(ctx->gallivm.builder,
- LLVMConstInt(ctx->i32, SI_NUM_IMAGES - 1, 0),
- index, "");
+ /* For simplicity, bindless image descriptors use fixed
+ * 16-dword slots for now.
+ */
+ index = LLVMBuildMul(ctx->ac.builder, ret,
+ LLVMConstInt(ctx->i32, 2, 0), "");
+ } else {
+ assert(base_index + constant_index < ctx->num_images);
+ if (dynamic_index)
+ index = si_llvm_bound_index(ctx, index, ctx->num_images);
+
+ index = LLVMBuildSub(ctx->gallivm.builder,
+ LLVMConstInt(ctx->i32, SI_NUM_IMAGES - 1, 0),
+ index, "");
+ }
/* TODO: be smarter about when we use dcc_off */
return si_load_image_desc(ctx, list, index, desc_type, write);
--
2.14.3
More information about the mesa-dev
mailing list