From: Marek Olšák <marek.ol...@amd.com>

---
 src/gallium/drivers/radeonsi/si_shader.c | 64 ++++++++++----------------------
 1 file changed, 19 insertions(+), 45 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index af031c7..887e6a4 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1065,22 +1065,21 @@ static LLVMValueRef fetch_input_gs(
        struct lp_build_tgsi_context *bld_base,
        const struct tgsi_full_src_register *reg,
        enum tgsi_opcode_type type,
        unsigned swizzle)
 {
        struct lp_build_context *base = &bld_base->base;
        struct si_shader_context *ctx = si_shader_context(bld_base);
        struct si_shader *shader = ctx->shader;
        struct lp_build_context *uint = &ctx->bld_base.uint_bld;
        struct gallivm_state *gallivm = base->gallivm;
-       LLVMValueRef vtx_offset;
-       LLVMValueRef args[9];
+       LLVMValueRef vtx_offset, soffset;
        unsigned vtx_offset_param;
        struct tgsi_shader_info *info = &shader->selector->info;
        unsigned semantic_name = info->input_semantic_name[reg->Register.Index];
        unsigned semantic_index = 
info->input_semantic_index[reg->Register.Index];
        unsigned param;
        LLVMValueRef value;
 
        if (swizzle != ~0 && semantic_name == TGSI_SEMANTIC_PRIMID)
                return get_primitive_id(bld_base, swizzle);
 
@@ -1104,43 +1103,31 @@ static LLVMValueRef fetch_input_gs(
        } else {
                assert(vtx_offset_param < 6);
                vtx_offset_param += SI_PARAM_VTX2_OFFSET - 2;
        }
        vtx_offset = lp_build_mul_imm(uint,
                                      LLVMGetParam(ctx->main_fn,
                                                   vtx_offset_param),
                                      4);
 
        param = si_shader_io_get_unique_index(semantic_name, semantic_index);
-       args[0] = ctx->esgs_ring;
-       args[1] = vtx_offset;
-       args[2] = lp_build_const_int32(gallivm, (param * 4 + swizzle) * 256);
-       args[3] = uint->zero;
-       args[4] = uint->one;  /* OFFEN */
-       args[5] = uint->zero; /* IDXEN */
-       args[6] = uint->one;  /* GLC */
-       args[7] = uint->zero; /* SLC */
-       args[8] = uint->zero; /* TFE */
-
-       value = lp_build_intrinsic(gallivm->builder,
-                                  "llvm.SI.buffer.load.dword.i32.i32",
-                                  ctx->i32, args, 9,
-                                  LP_FUNC_ATTR_READONLY |
-                                  LP_FUNC_ATTR_LEGACY);
+       soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle) * 256, 0);
+
+       value = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1, uint->zero,
+                                    vtx_offset, soffset, 0, 1, 0);
        if (tgsi_type_is_64bit(type)) {
                LLVMValueRef value2;
-               args[2] = lp_build_const_int32(gallivm, (param * 4 + swizzle + 
1) * 256);
-               value2 = lp_build_intrinsic(gallivm->builder,
-                                           "llvm.SI.buffer.load.dword.i32.i32",
-                                           ctx->i32, args, 9,
-                                           LP_FUNC_ATTR_READONLY |
-                                           LP_FUNC_ATTR_LEGACY);
+               soffset = LLVMConstInt(ctx->i32, (param * 4 + swizzle + 1) * 
256, 0);
+
+               value2 = ac_build_buffer_load(&ctx->ac, ctx->esgs_ring, 1,
+                                             uint->zero, vtx_offset, soffset,
+                                             0, 1, 0);
                return si_llvm_emit_fetch_64bit(bld_base, type,
                                                value, value2);
        }
        return LLVMBuildBitCast(gallivm->builder,
                                value,
                                tgsi2llvmtype(bld_base, type), "");
 }
 
 static int lookup_interp_param_index(unsigned interpolate, unsigned location)
 {
@@ -6138,21 +6125,20 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
                           struct pipe_debug_callback *debug)
 {
        struct si_shader_context ctx;
        struct si_shader *shader;
        struct gallivm_state *gallivm = &ctx.gallivm;
        LLVMBuilderRef builder;
        struct lp_build_tgsi_context *bld_base = &ctx.bld_base;
        struct lp_build_context *uint = &bld_base->uint_bld;
        struct si_shader_output_values *outputs;
        struct tgsi_shader_info *gsinfo = &gs_selector->info;
-       LLVMValueRef args[9];
        int i, r;
 
        outputs = MALLOC(gsinfo->num_outputs * sizeof(outputs[0]));
 
        if (!outputs)
                return NULL;
 
        shader = CALLOC_STRUCT(si_shader);
        if (!shader) {
                FREE(outputs);
@@ -6164,31 +6150,23 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
        shader->is_gs_copy_shader = true;
 
        si_init_shader_ctx(&ctx, sscreen, shader, tm);
        ctx.type = PIPE_SHADER_VERTEX;
 
        builder = gallivm->builder;
 
        create_function(&ctx);
        preload_ring_buffers(&ctx);
 
-       args[0] = ctx.gsvs_ring[0];
-       args[1] = lp_build_mul_imm(uint,
-                                  LLVMGetParam(ctx.main_fn,
-                                               ctx.param_vertex_id),
-                                  4);
-       args[3] = uint->zero;
-       args[4] = uint->one;  /* OFFEN */
-       args[5] = uint->zero; /* IDXEN */
-       args[6] = uint->one;  /* GLC */
-       args[7] = uint->one;  /* SLC */
-       args[8] = uint->zero; /* TFE */
+       LLVMValueRef voffset =
+               lp_build_mul_imm(uint, LLVMGetParam(ctx.main_fn,
+                                                   ctx.param_vertex_id), 4);
 
        /* Fetch the vertex stream ID.*/
        LLVMValueRef stream_id;
 
        if (gs_selector->so.num_outputs)
                stream_id = unpack_param(&ctx, ctx.param_streamout_config, 24, 
2);
        else
                stream_id = uint->zero;
 
        /* Fill in output information. */
@@ -6225,33 +6203,29 @@ si_generate_gs_copy_shader(struct si_screen *sscreen,
                /* Fetch vertex data from GSVS ring */
                offset = 0;
                for (i = 0; i < gsinfo->num_outputs; ++i) {
                        for (unsigned chan = 0; chan < 4; chan++) {
                                if (!(gsinfo->output_usagemask[i] & (1 << 
chan)) ||
                                    outputs[i].vertex_stream[chan] != stream) {
                                        outputs[i].values[chan] = 
ctx.bld_base.base.undef;
                                        continue;
                                }
 
-                               args[2] = lp_build_const_int32(
-                                       gallivm,
-                                       offset * 
gs_selector->gs_max_out_vertices * 16 * 4);
+                               LLVMValueRef soffset = LLVMConstInt(ctx.i32,
+                                       offset * 
gs_selector->gs_max_out_vertices * 16 * 4, 0);
                                offset++;
 
                                outputs[i].values[chan] =
-                                       LLVMBuildBitCast(gallivm->builder,
-                                                
lp_build_intrinsic(gallivm->builder,
-                                                                   
"llvm.SI.buffer.load.dword.i32.i32",
-                                                                   ctx.i32, 
args, 9,
-                                                                   
LP_FUNC_ATTR_READONLY |
-                                                                   
LP_FUNC_ATTR_LEGACY),
-                                                ctx.f32, "");
+                                       ac_build_buffer_load(&ctx.ac,
+                                                            ctx.gsvs_ring[0], 
1,
+                                                            uint->zero, 
voffset,
+                                                            soffset, 0, 1, 1);
                        }
                }
 
                /* Streamout and exports. */
                if (gs_selector->so.num_outputs) {
                        si_llvm_emit_streamout(&ctx, outputs,
                                               gsinfo->num_outputs,
                                               stream);
                }
 
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to