[Mesa-dev] [PATCH 5/5] radeonsi/nir: add missing pieces for bindless image/sampler support

Timothy Arceri tarceri at itsqueeze.com
Wed Jan 16 23:33:31 UTC 2019


On 17/1/19 9:41 am, Marek Olšák wrote:
> A bindless handle is a temporary (coming from a shader input, UBO, SSBO, 
> image, or inline constant), so the bindless code shouldn't have any 
> awareness of where it's coming from.

This is a far point, I should move this to nir_to_llvm where we know 
what type of handle we are dealing with. I'll rework this.

> 
> Patches 1-4:
> 
> Reviewed-by: Marek Olšák <marek.olsak at amd.com <mailto:marek.olsak at amd.com>>

Thanks!

> 
> Marek
> 
> On Wed, Jan 9, 2019 at 3:54 AM Timothy Arceri <tarceri at itsqueeze.com 
> <mailto:tarceri at itsqueeze.com>> wrote:
> 
>     ---
>       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
> 
>     _______________________________________________
>     mesa-dev mailing list
>     mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
>     https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list