radeonsi: clean up image_fetch_rsrc
authorMarek Olšák <marek.olsak@amd.com>
Fri, 13 Sep 2019 01:39:31 +0000 (21:39 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 9 Oct 2019 21:12:33 +0000 (17:12 -0400)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
src/gallium/drivers/radeonsi/si_shader_tgsi_mem.c

index 10fbb808e9bbabe297e7368eb073a6952b8f3f9a..d3a4dc48485a0e00dde7823ccd23221d36a67ced 100644 (file)
@@ -214,48 +214,42 @@ image_fetch_rsrc(
        LLVMValueRef *rsrc)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
-       LLVMValueRef rsrc_ptr = LLVMGetParam(ctx->main_fn,
-                                            ctx->param_samplers_and_images);
-       LLVMValueRef index;
-
-       if (!image->Register.Indirect) {
-               index = LLVMConstInt(ctx->i32,
-                                    si_get_image_slot(image->Register.Index), 0);
-       } else {
-               /* From the GL_ARB_shader_image_load_store extension spec:
-                *
-                *    If a shader performs an image load, store, or atomic
-                *    operation using an image variable declared as an array,
-                *    and if the index used to select an individual element is
-                *    negative or greater than or equal to the size of the
-                *    array, the results of the operation are undefined but may
-                *    not lead to termination.
-                */
-               index = si_get_bounded_indirect_index(ctx, &image->Indirect,
-                                                     image->Register.Index,
-                                                     ctx->num_images);
-               index = LLVMBuildSub(ctx->ac.builder,
-                                    LLVMConstInt(ctx->i32, SI_NUM_IMAGE_SLOTS - 1, 0),
-                                    index, "");
-       }
-
-       bool bindless = false;
+       bool bindless = image->Register.File != TGSI_FILE_IMAGE;
+       LLVMValueRef rsrc_ptr, index;
 
-       if (image->Register.File != TGSI_FILE_IMAGE) {
+       if (bindless) {
                /* Bindless descriptors are accessible from a different pair of
                 * user SGPR indices.
                 */
                rsrc_ptr = LLVMGetParam(ctx->main_fn,
                                        ctx->param_bindless_samplers_and_images);
-               index = lp_build_emit_fetch_src(bld_base, image,
-                                               TGSI_TYPE_UNSIGNED, 0);
+               index = lp_build_emit_fetch_src(bld_base, image, TGSI_TYPE_UNSIGNED, 0);
 
-               /* For simplicity, bindless image descriptors use fixed
-                * 16-dword slots for now.
-                */
+               /* Bindless image descriptors use 16-dword slots. */
                index = LLVMBuildMul(ctx->ac.builder, index,
                                     LLVMConstInt(ctx->i32, 2, 0), "");
-               bindless = true;
+       } else {
+               rsrc_ptr = LLVMGetParam(ctx->main_fn, ctx->param_samplers_and_images);
+
+               if (!image->Register.Indirect) {
+                       index = LLVMConstInt(ctx->i32, image->Register.Index, 0);
+               } else {
+                       /* From the GL_ARB_shader_image_load_store extension spec:
+                        *
+                        *    If a shader performs an image load, store, or atomic
+                        *    operation using an image variable declared as an array,
+                        *    and if the index used to select an individual element is
+                        *    negative or greater than or equal to the size of the
+                        *    array, the results of the operation are undefined but may
+                        *    not lead to termination.
+                        */
+                       index = si_get_bounded_indirect_index(ctx, &image->Indirect,
+                                                             image->Register.Index,
+                                                             ctx->num_images);
+               }
+               index = LLVMBuildSub(ctx->ac.builder,
+                                    LLVMConstInt(ctx->i32, SI_NUM_IMAGE_SLOTS - 1, 0),
+                                    index, "");
        }
 
        *rsrc = si_load_image_desc(ctx, rsrc_ptr, index,