ac/llvm: add type parameter into ac_build_buffer_load to fix 16-bit TES inputs
authorMarek Olšák <marek.olsak@amd.com>
Mon, 15 Feb 2021 06:25:25 +0000 (01:25 -0500)
committerMarge Bot <eric+marge@anholt.net>
Wed, 3 Mar 2021 20:06:09 +0000 (20:06 +0000)
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9395>

src/amd/llvm/ac_llvm_build.c
src/amd/llvm/ac_llvm_build.h
src/amd/llvm/ac_nir_to_llvm.c
src/amd/vulkan/radv_nir_to_llvm.c
src/gallium/drivers/radeonsi/si_shader_llvm.c
src/gallium/drivers/radeonsi/si_shader_llvm_gs.c
src/gallium/drivers/radeonsi/si_shader_llvm_tess.c

index e7b82fa..52044ef 100644 (file)
@@ -1222,8 +1222,8 @@ static LLVMValueRef ac_build_buffer_load_common(struct ac_llvm_context *ctx, LLV
 
 LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
                                   LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
-                                  unsigned inst_offset, unsigned cache_policy, bool can_speculate,
-                                  bool allow_smem)
+                                  unsigned inst_offset, LLVMTypeRef channel_type,
+                                  unsigned cache_policy, bool can_speculate, bool allow_smem)
 {
    LLVMValueRef offset = LLVMConstInt(ctx->i32, inst_offset, 0);
    if (voffset)
@@ -1257,8 +1257,8 @@ LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc
       return ac_build_gather_values(ctx, result, num_channels);
    }
 
-   return ac_build_buffer_load_common(ctx, rsrc, vindex, offset, ctx->i32_0, num_channels, ctx->f32,
-                                      cache_policy, can_speculate, false, false);
+   return ac_build_buffer_load_common(ctx, rsrc, vindex, offset, ctx->i32_0, num_channels,
+                                      channel_type, cache_policy, can_speculate, false, false);
 }
 
 LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
index 5763276..fa82f52 100644 (file)
@@ -260,8 +260,8 @@ void ac_build_buffer_store_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc
 
 LLVMValueRef ac_build_buffer_load(struct ac_llvm_context *ctx, LLVMValueRef rsrc, int num_channels,
                                   LLVMValueRef vindex, LLVMValueRef voffset, LLVMValueRef soffset,
-                                  unsigned inst_offset, unsigned cache_policy, bool can_speculate,
-                                  bool allow_smem);
+                                  unsigned inst_offset, LLVMTypeRef channel_type,
+                                  unsigned cache_policy, bool can_speculate, bool allow_smem);
 
 LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx, LLVMValueRef rsrc,
                                          LLVMValueRef vindex, LLVMValueRef voffset,
index 4037962..a3e8402 100644 (file)
@@ -1984,7 +1984,7 @@ static LLVMValueRef visit_load_buffer(struct ac_nir_context *ctx, nir_intrinsic_
          bool can_speculate = access & ACCESS_CAN_REORDER;
 
          ret = ac_build_buffer_load(&ctx->ac, rsrc, num_channels, vindex, offset, immoffset, 0,
-                                    cache_policy, can_speculate, false);
+                                    ctx->ac.f32, cache_policy, can_speculate, false);
       }
 
       LLVMTypeRef byte_vec = LLVMVectorType(ctx->ac.i8, ac_get_type_size(LLVMTypeOf(ret)));
@@ -2151,7 +2151,8 @@ static LLVMValueRef visit_load_ubo_buffer(struct ac_nir_context *ctx, nir_intrin
       num_components = DIV_ROUND_UP(num_components, 4);
 
    ret =
-      ac_build_buffer_load(&ctx->ac, rsrc, num_components, NULL, offset, NULL, 0, 0, true, true);
+      ac_build_buffer_load(&ctx->ac, rsrc, num_components, NULL, offset, NULL, 0,
+                           ctx->ac.f32, 0, true, true);
 
    /* Convert to the original type. */
    if (instr->dest.ssa.bit_size == 64) {
@@ -3958,7 +3959,7 @@ static LLVMValueRef get_bindless_index_from_uniform(struct ac_nir_context *ctx,
    LLVMValueRef ubo_index = ctx->abi->load_ubo(ctx->abi, 0, 0, false, ctx->ac.i32_0);
 
    LLVMValueRef ret =
-      ac_build_buffer_load(&ctx->ac, ubo_index, 1, NULL, offset, NULL, 0, 0, true, true);
+      ac_build_buffer_load(&ctx->ac, ubo_index, 1, NULL, offset, NULL, 0, ctx->ac.f32, 0, true, true);
 
    return LLVMBuildBitCast(ctx->ac.builder, ret, ctx->ac.i32, "");
 }
index b16bc53..dc69cae 100644 (file)
@@ -633,7 +633,7 @@ load_tes_input(struct ac_shader_abi *abi,
        buf_addr = LLVMBuildAdd(ctx->ac.builder, buf_addr, comp_offset, "");
 
        result = ac_build_buffer_load(&ctx->ac, ctx->hs_ring_tess_offchip, num_components, NULL,
-                                     buf_addr, oc_lds, 0, ac_glc, true, false);
+                                     buf_addr, oc_lds, 0, ctx->ac.f32, ac_glc, true, false);
        result = ac_trim_vector(&ctx->ac, result, num_components);
        return result;
 }
@@ -673,7 +673,7 @@ load_gs_input(struct ac_shader_abi *abi,
                                                        ctx->esgs_ring, 1,
                                                        ctx->ac.i32_0,
                                                        vtx_offset, soffset,
-                                                       0, ac_glc, true, false);
+                                                       0, ctx->ac.f32, ac_glc, true, false);
                }
 
                if (ac_get_type_size(type) == 2) {
@@ -4318,7 +4318,7 @@ ac_gs_copy_shader_emit(struct radv_shader_context *ctx)
                                                             ctx->gsvs_ring[0],
                                                             1, ctx->ac.i32_0,
                                                             vtx_offset, soffset,
-                                                            0, ac_glc | ac_slc, true, false);
+                                                            0, ctx->ac.f32, ac_glc | ac_slc, true, false);
 
                                LLVMTypeRef type = LLVMGetAllocatedType(ctx->abi.outputs[ac_llvm_reg_index_soa(i, j)]);
                                if (ac_get_type_size(type) == 2) {
index 6bf934b..c558ca3 100644 (file)
@@ -270,7 +270,8 @@ void si_llvm_dispose(struct si_shader_context *ctx)
 LLVMValueRef si_buffer_load_const(struct si_shader_context *ctx, LLVMValueRef resource,
                                   LLVMValueRef offset)
 {
-   return ac_build_buffer_load(&ctx->ac, resource, 1, NULL, offset, NULL, 0, 0, true, true);
+   return ac_build_buffer_load(&ctx->ac, resource, 1, NULL, offset, NULL, 0, ctx->ac.f32,
+                               0, true, true);
 }
 
 void si_llvm_build_ret(struct si_shader_context *ctx, LLVMValueRef ret)
index f1ab3cb..ec64ed7 100644 (file)
@@ -91,7 +91,7 @@ static LLVMValueRef si_llvm_load_input_gs(struct ac_shader_abi *abi, unsigned in
    soffset = LLVMConstInt(ctx->ac.i32, (param * 4 + swizzle) * 256, 0);
 
    value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, ctx->ac.i32_0, vtx_offset, soffset, 0,
-                                ac_glc, true, false);
+                                ctx->ac.f32, ac_glc, true, false);
    return LLVMBuildBitCast(ctx->ac.builder, value, type, "");
 }
 
@@ -512,7 +512,7 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen,
 
             outputs[i].values[chan] =
                ac_build_buffer_load(&ctx.ac, ctx.gsvs_ring[0], 1, ctx.ac.i32_0, voffset, soffset, 0,
-                                    ac_glc | ac_slc, true, false);
+                                    ctx.ac.f32, ac_glc | ac_slc, true, false);
          }
       }
 
index 217b6c8..e1a5a21 100644 (file)
@@ -275,13 +275,13 @@ static LLVMValueRef buffer_load(struct si_shader_context *ctx, LLVMTypeRef type,
    LLVMTypeRef vec_type = LLVMVectorType(type, 4);
 
    if (swizzle == ~0) {
-      value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, 0, ac_glc,
+      value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, 0, type, ac_glc,
                                    can_speculate, false);
 
       return LLVMBuildBitCast(ctx->ac.builder, value, vec_type, "");
    }
 
-   value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, 0, ac_glc,
+   value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, 0, type, ac_glc,
                                 can_speculate, false);
 
    value = LLVMBuildBitCast(ctx->ac.builder, value, vec_type, "");