Module: Mesa
Branch: main
Commit: daf5d30b598b7a83bafa41b3d932d6bcb59101bd
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=daf5d30b598b7a83bafa41b3d932d6bcb59101bd

Author: Qiang Yu <[email protected]>
Date:   Wed Aug 10 23:28:11 2022 +0800

ac/llvm,radeonsi: lower nir_load_user_clip_plane in abi

Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Signed-off-by: Qiang Yu <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18010>

---

 src/amd/llvm/ac_nir_to_llvm.c                   |  3 ---
 src/amd/llvm/ac_shader_abi.h                    |  2 --
 src/gallium/drivers/radeonsi/si_nir_lower_abi.c |  6 ++++++
 src/gallium/drivers/radeonsi/si_shader_llvm.c   | 12 ------------
 4 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c
index 9294608bcc3..5bda4fff405 100644
--- a/src/amd/llvm/ac_nir_to_llvm.c
+++ b/src/amd/llvm/ac_nir_to_llvm.c
@@ -3625,9 +3625,6 @@ static bool visit_intrinsic(struct ac_nir_context *ctx, 
nir_intrinsic_instr *ins
    case nir_intrinsic_load_lds_ngg_gs_out_vertex_base_amd:
       result = ctx->abi->intrinsic_load(ctx->abi, instr->intrinsic);
       break;
-   case nir_intrinsic_load_user_clip_plane:
-      result = ctx->abi->load_user_clip_plane(ctx->abi, 
nir_intrinsic_ucp_id(instr));
-      break;
    case nir_intrinsic_load_streamout_buffer_amd:
       result = ctx->abi->load_streamout_buffer(ctx->abi, 
nir_intrinsic_base(instr));
       break;
diff --git a/src/amd/llvm/ac_shader_abi.h b/src/amd/llvm/ac_shader_abi.h
index 1268669a5f5..d20a6982329 100644
--- a/src/amd/llvm/ac_shader_abi.h
+++ b/src/amd/llvm/ac_shader_abi.h
@@ -116,8 +116,6 @@ struct ac_shader_abi {
 
    LLVMValueRef (*load_sample_position)(struct ac_shader_abi *abi, 
LLVMValueRef sample_id);
 
-   LLVMValueRef (*load_user_clip_plane)(struct ac_shader_abi *abi, unsigned 
ucp_id);
-
    LLVMValueRef (*load_streamout_buffer)(struct ac_shader_abi *abi, unsigned 
buffer);
 
    LLVMValueRef (*emit_fbfetch)(struct ac_shader_abi *abi);
diff --git a/src/gallium/drivers/radeonsi/si_nir_lower_abi.c 
b/src/gallium/drivers/radeonsi/si_nir_lower_abi.c
index 0668f0cb2d9..5de88dd151b 100644
--- a/src/gallium/drivers/radeonsi/si_nir_lower_abi.c
+++ b/src/gallium/drivers/radeonsi/si_nir_lower_abi.c
@@ -222,6 +222,12 @@ static bool lower_abi_instr(nir_builder *b, nir_instr 
*instr, struct lower_abi_s
    case nir_intrinsic_load_clamp_vertex_color_amd:
       replacement = nir_i2b(b, GET_FIELD_NIR(VS_STATE_CLAMP_VERTEX_COLOR));
       break;
+   case nir_intrinsic_load_user_clip_plane: {
+      nir_ssa_def *buf = load_internal_binding(b, args, 
SI_VS_CONST_CLIP_PLANES);
+      unsigned offset = nir_intrinsic_ucp_id(intrin) * 16;
+      replacement = nir_load_smem_buffer_amd(b, 4, buf, nir_imm_int(b, 
offset));
+      break;
+   }
    default:
       return false;
    }
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index a04327a0462..971ffd516d3 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -761,17 +761,6 @@ static LLVMValueRef si_llvm_load_intrinsic(struct 
ac_shader_abi *abi, nir_intrin
    }
 }
 
-static LLVMValueRef si_llvm_load_user_clip_plane(struct ac_shader_abi *abi, 
unsigned ucp_id)
-{
-   struct si_shader_context *ctx = si_shader_context_from_abi(abi);
-   struct ac_llvm_pointer ptr = ac_get_ptr_arg(&ctx->ac, &ctx->args->ac, 
ctx->args->internal_bindings);
-   LLVMValueRef constbuf_index = LLVMConstInt(ctx->ac.i32, 
SI_VS_CONST_CLIP_PLANES, 0);
-   LLVMValueRef const_resource = ac_build_load_to_sgpr(&ctx->ac, ptr, 
constbuf_index);
-   LLVMValueRef addr = LLVMConstInt(ctx->ac.i32, ucp_id * 16, 0);
-   return ac_build_buffer_load(&ctx->ac, const_resource, 4, NULL, addr, NULL,
-                               ctx->ac.f32, 0, true, true);
-}
-
 static LLVMValueRef si_llvm_load_streamout_buffer(struct ac_shader_abi *abi, 
unsigned buffer)
 {
    struct si_shader_context *ctx = si_shader_context_from_abi(abi);
@@ -797,7 +786,6 @@ bool si_llvm_translate_nir(struct si_shader_context *ctx, 
struct si_shader *shad
    ctx->num_images = info->base.num_images;
 
    ctx->abi.intrinsic_load = si_llvm_load_intrinsic;
-   ctx->abi.load_user_clip_plane = si_llvm_load_user_clip_plane;
    ctx->abi.load_streamout_buffer = si_llvm_load_streamout_buffer;
    ctx->abi.export_vertex = gfx10_ngg_export_vertex;
    ctx->abi.atomic_add_prim_count = gfx10_ngg_atomic_add_prim_count;

Reply via email to