radeonsi: move SI.vs.load.input building into amd/common
authorMarek Olšák <marek.olsak@amd.com>
Sat, 25 Feb 2017 22:40:52 +0000 (23:40 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 3 Mar 2017 16:30:07 +0000 (17:30 +0100)
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader.c

index 9435b189de4d4b603f19d8809f60f4c94714de38..8fac89ccd7bf64a7e0b02c7dfd59d91453ca236e 100644 (file)
@@ -730,6 +730,23 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
        }
 }
 
+LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
+                                        LLVMValueRef rsrc,
+                                        LLVMValueRef vindex,
+                                        LLVMValueRef voffset,
+                                        bool readonly_memory)
+{
+       LLVMValueRef args[] = {
+               rsrc,
+               voffset,
+               vindex,
+       };
+       return ac_emit_llvm_intrinsic(ctx, "llvm.SI.vs.load.input",
+                                     ctx->v4f32, args, 3,
+                                     AC_FUNC_ATTR_READNONE |
+                                     AC_FUNC_ATTR_LEGACY);
+}
+
 /**
  * Set range metadata on an instruction.  This can only be used on load and
  * call instructions.  If you know an instruction can only produce the values
index aa99e92e2567c8067895a9f3332b8d24b092c71b..ae96d56abb9b3a6e659ff5e66d07ceb9581d49ab 100644 (file)
@@ -145,6 +145,12 @@ ac_build_buffer_load(struct ac_llvm_context *ctx,
                     unsigned slc,
                     bool readonly_memory);
 
+LLVMValueRef ac_build_buffer_load_format(struct ac_llvm_context *ctx,
+                                        LLVMValueRef rsrc,
+                                        LLVMValueRef vindex,
+                                        LLVMValueRef voffset,
+                                        bool readonly_memory);
+
 LLVMValueRef
 ac_get_thread_id(struct ac_llvm_context *ctx);
 
index face59997d7cf19334710dca97091c492990398b..01acbc63bfcaeb47ad90ea372e73b59f394e7b98 100644 (file)
@@ -352,7 +352,6 @@ static void declare_input_vs(
        LLVMValueRef t_offset;
        LLVMValueRef t_list;
        LLVMValueRef vertex_index;
-       LLVMValueRef args[3];
        LLVMValueRef input[3];
 
        /* Load the T list */
@@ -393,16 +392,12 @@ static void declare_input_vs(
                fetch_stride = 0;
        }
 
-       args[0] = t_list;
-       args[2] = vertex_index;
-
        for (unsigned i = 0; i < num_fetches; i++) {
-               args[1] = LLVMConstInt(ctx->i32, fetch_stride * i, 0);
+               LLVMValueRef voffset = LLVMConstInt(ctx->i32, fetch_stride * i, 0);
 
-               input[i] = lp_build_intrinsic(gallivm->builder,
-                       "llvm.SI.vs.load.input", ctx->v4f32, args, 3,
-                       LP_FUNC_ATTR_READNONE |
-                       LP_FUNC_ATTR_LEGACY);
+               input[i] = ac_build_buffer_load_format(&ctx->ac, t_list,
+                                                      vertex_index, voffset,
+                                                      true);
        }
 
        /* Break up the vec4 into individual components */
@@ -4763,18 +4758,18 @@ static void build_tex_intrinsic(const struct lp_build_tgsi_action *action,
                                struct lp_build_emit_data *emit_data)
 {
        struct si_shader_context *ctx = si_shader_context(bld_base);
-       struct lp_build_context *base = &bld_base->base;
        const struct tgsi_full_instruction *inst = emit_data->inst;
        struct ac_image_args args;
        unsigned opcode = inst->Instruction.Opcode;
        unsigned target = inst->Texture.Texture;
 
        if (target == TGSI_TEXTURE_BUFFER) {
-               emit_data->output[emit_data->chan] = lp_build_intrinsic(
-                       base->gallivm->builder,
-                       "llvm.SI.vs.load.input", emit_data->dst_type,
-                       emit_data->args, emit_data->arg_count,
-                       LP_FUNC_ATTR_READNONE | LP_FUNC_ATTR_LEGACY);
+               emit_data->output[emit_data->chan] =
+                       ac_build_buffer_load_format(&ctx->ac,
+                                                   emit_data->args[0],
+                                                   emit_data->args[2],
+                                                   emit_data->args[1],
+                                                   true);
                return;
        }