Mesa (main): ac/llvm: remove inst_offset parameter from ac_build_buffer_load
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sat Apr 23 02:09:39 UTC 2022
Module: Mesa
Branch: main
Commit: c888e77dfc0b3b2557814c0dfc84de02e2eef937
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=c888e77dfc0b3b2557814c0dfc84de02e2eef937
Author: Marek Olšák <marek.olsak at amd.com>
Date: Fri Apr 15 01:25:32 2022 -0400
ac/llvm: remove inst_offset parameter from ac_build_buffer_load
Reviewed-by: Mihai Preda <mhpreda at gmail.com>
Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15966>
---
src/amd/llvm/ac_llvm_build.c | 11 ++++-------
src/amd/llvm/ac_llvm_build.h | 4 ++--
src/amd/llvm/ac_nir_to_llvm.c | 13 +++++++------
src/amd/vulkan/radv_nir_to_llvm.c | 2 +-
src/gallium/drivers/radeonsi/si_shader_llvm.c | 2 +-
src/gallium/drivers/radeonsi/si_shader_llvm_gs.c | 4 ++--
src/gallium/drivers/radeonsi/si_shader_llvm_tess.c | 4 ++--
7 files changed, 19 insertions(+), 21 deletions(-)
diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c
index d214fa582c3..9d4134edb2c 100644
--- a/src/amd/llvm/ac_llvm_build.c
+++ b/src/amd/llvm/ac_llvm_build.c
@@ -1233,19 +1233,16 @@ 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, LLVMTypeRef channel_type,
- unsigned cache_policy, bool can_speculate, bool allow_smem)
+ LLVMTypeRef channel_type, unsigned cache_policy,
+ bool can_speculate, bool allow_smem)
{
- LLVMValueRef offset = LLVMConstInt(ctx->i32, inst_offset, 0);
- if (voffset)
- offset = LLVMBuildAdd(ctx->builder, offset, voffset, "");
-
if (allow_smem && !(cache_policy & ac_slc) &&
(!(cache_policy & ac_glc) || ctx->chip_class >= GFX8)) {
assert(vindex == NULL);
LLVMValueRef result[8];
+ LLVMValueRef offset = voffset ? voffset : ctx->i32_0;
if (soffset)
offset = LLVMBuildAdd(ctx->builder, offset, soffset, "");
@@ -1269,7 +1266,7 @@ 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, soffset, num_channels,
+ return ac_build_buffer_load_common(ctx, rsrc, vindex, voffset, soffset, num_channels,
channel_type, cache_policy, can_speculate, false, false);
}
diff --git a/src/amd/llvm/ac_llvm_build.h b/src/amd/llvm/ac_llvm_build.h
index cf0e3f07c45..585705700fa 100644
--- a/src/amd/llvm/ac_llvm_build.h
+++ b/src/amd/llvm/ac_llvm_build.h
@@ -263,8 +263,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, LLVMTypeRef channel_type,
- unsigned cache_policy, bool can_speculate, bool allow_smem);
+ 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,
diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index d8cc4e6786a..81700ec4c93 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -2093,7 +2093,7 @@ static LLVMValueRef visit_load_buffer(struct ac_nir_context *ctx, nir_intrinsic_
int num_channels = util_next_power_of_two(load_bytes) / 4;
bool can_speculate = access & ACCESS_CAN_REORDER;
- ret = ac_build_buffer_load(&ctx->ac, rsrc, num_channels, vindex, offset, immoffset, 0,
+ ret = ac_build_buffer_load(&ctx->ac, rsrc, num_channels, vindex, offset, immoffset,
ctx->ac.f32, cache_policy, can_speculate, false);
}
@@ -2310,7 +2310,7 @@ 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,
+ ac_build_buffer_load(&ctx->ac, rsrc, num_components, NULL, offset, NULL,
ctx->ac.f32, 0, true, true);
/* Convert to the original type. */
@@ -4267,9 +4267,10 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
else
unreachable("Unsupported channel type for load_buffer_amd");
- result = ac_build_buffer_load(&ctx->ac, descriptor, num_components, NULL,
- addr_voffset, addr_soffset, const_offset,
- channel_type, cache_policy, reorder, false);
+ LLVMValueRef voffset = LLVMBuildAdd(ctx->ac.builder, addr_voffset,
+ LLVMConstInt(ctx->ac.i32, const_offset, 0), "");
+ result = ac_build_buffer_load(&ctx->ac, descriptor, num_components, NULL, voffset,
+ addr_soffset, channel_type, cache_policy, reorder, false);
result = ac_to_integer(&ctx->ac, ac_trim_vector(&ctx->ac, result, num_components));
break;
}
@@ -4426,7 +4427,7 @@ static LLVMValueRef get_bindless_index_from_uniform(struct ac_nir_context *ctx,
LLVMValueRef ubo_index = ctx->abi->load_ubo(ctx->abi, ctx->ac.i32_0);
LLVMValueRef ret =
- ac_build_buffer_load(&ctx->ac, ubo_index, 1, NULL, offset, NULL, 0, ctx->ac.f32, 0, true, true);
+ ac_build_buffer_load(&ctx->ac, ubo_index, 1, NULL, offset, NULL, ctx->ac.f32, 0, true, true);
return LLVMBuildBitCast(ctx->ac.builder, ret, ctx->ac.i32, "");
}
diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c
index 01e8f0c9b29..782e66298fa 100644
--- a/src/amd/vulkan/radv_nir_to_llvm.c
+++ b/src/amd/vulkan/radv_nir_to_llvm.c
@@ -2396,7 +2396,7 @@ ac_gs_copy_shader_emit(struct radv_shader_context *ctx)
offset++;
value = ac_build_buffer_load(&ctx->ac, ctx->gsvs_ring[0], 1, ctx->ac.i32_0, vtx_offset,
- soffset, 0, ctx->ac.f32, ac_glc | ac_slc, true, false);
+ soffset, 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) {
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index 1c26e82842d..c6b31b540b8 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -272,7 +272,7 @@ 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, ctx->ac.f32,
+ return ac_build_buffer_load(&ctx->ac, resource, 1, NULL, offset, NULL, ctx->ac.f32,
0, true, true);
}
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c
index 7655223e7cc..d5759026866 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm_gs.c
@@ -74,7 +74,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,
+ value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, ctx->ac.i32_0, vtx_offset, soffset,
ctx->ac.f32, ac_glc, true, false);
return LLVMBuildBitCast(ctx->ac.builder, value, type, "");
}
@@ -531,7 +531,7 @@ struct si_shader *si_generate_gs_copy_shader(struct si_screen *sscreen,
offset++;
outputs[i].values[chan] =
- ac_build_buffer_load(&ctx.ac, ctx.gsvs_ring[0], 1, ctx.ac.i32_0, voffset, soffset, 0,
+ ac_build_buffer_load(&ctx.ac, ctx.gsvs_ring[0], 1, ctx.ac.i32_0, voffset, soffset,
ctx.ac.f32, ac_glc | ac_slc, true, false);
}
}
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c
index 4e52f488296..c4fe3fd311c 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm_tess.c
@@ -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, type, ac_glc,
+ value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, 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, type, ac_glc,
+ value = ac_build_buffer_load(&ctx->ac, buffer, 4, NULL, base, offset, type, ac_glc,
can_speculate, false);
value = LLVMBuildBitCast(ctx->ac.builder, value, vec_type, "");
More information about the mesa-commit
mailing list