On 11.12.2017 03:43, Timothy Arceri wrote:
---
  src/gallium/drivers/radeonsi/si_shader.c | 47 ++++++++++++++++++++++++++++++++
  1 file changed, 47 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index ba8301b3deb..0561d2ee9b5 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1200,20 +1200,66 @@ static LLVMValueRef fetch_input_tcs(
        struct si_shader_context *ctx = si_shader_context(bld_base);
        LLVMValueRef dw_addr, stride;
stride = get_tcs_in_vertex_dw_stride(ctx);
        dw_addr = get_tcs_in_current_patch_offset(ctx);
        dw_addr = get_dw_address(ctx, NULL, reg, stride, dw_addr);
return lds_load(bld_base, tgsi2llvmtype(bld_base, type), swizzle, dw_addr);
  }
+static LLVMValueRef si_nir_load_input_tcs(struct ac_shader_abi *abi,
+                                         LLVMValueRef vertex_index,
+                                         LLVMValueRef param_index,
+                                         unsigned const_index,
+                                         unsigned location,
+                                         unsigned driver_location,
+                                         LLVMTypeRef type,
+                                         unsigned component,
+                                         unsigned num_components,
+                                         bool is_patch,
+                                         bool is_compact)
+{
+       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+       struct tgsi_shader_info *info = &ctx->shader->selector->info;
+       struct lp_build_tgsi_context *bld_base = &ctx->bld_base;
+       LLVMValueRef dw_addr, stride;
+
+       driver_location = driver_location / 4;
+
+       stride = get_tcs_in_vertex_dw_stride(ctx);
+       dw_addr = get_tcs_in_current_patch_offset(ctx);
+
+       if (param_index) {
+               /* Add the constant index to the indirect index */
+               param_index = LLVMBuildAdd(ctx->ac.builder, param_index,
+                                          LLVMConstInt(ctx->i32, const_index, 0), 
"");
+       } else {
+               if (const_index != 0)
+                       param_index = LLVMConstInt(ctx->i32, const_index, 0);

I generally think it's nicer to keep the driver code and simple, even if it means we end up generating an extra LLVM IR instruction that ends up being trivially optimized away, so I'd make that unconditional here.

Not a big deal, though.

Cheers,
Nicolai


+       }
+
+       dw_addr = get_dw_address_from_generic_indices(ctx, stride, dw_addr,
+                                                     vertex_index, param_index,
+                                                     driver_location,
+                                                     info->input_semantic_name,
+                                                     
info->input_semantic_index,
+                                                     is_patch);
+
+       LLVMValueRef value[4];
+       for (unsigned i = 0; i < num_components + component; i++) {
+               value[i] = lds_load(bld_base, type, i, dw_addr);
+       }
+
+       return ac_build_varying_gather_values(&ctx->ac, value, num_components, 
component);
+}
+
  static LLVMValueRef fetch_output_tcs(
                struct lp_build_tgsi_context *bld_base,
                const struct tgsi_full_src_register *reg,
                enum tgsi_opcode_type type, unsigned swizzle)
  {
        struct si_shader_context *ctx = si_shader_context(bld_base);
        LLVMValueRef dw_addr, stride;
if (reg->Register.Dimension) {
                stride = get_tcs_out_vertex_dw_stride(ctx);
@@ -5867,20 +5913,21 @@ static bool si_compile_tgsi_main(struct 
si_shader_context *ctx,
                if (shader->key.as_ls)
                        ctx->abi.emit_outputs = si_llvm_emit_ls_epilogue;
                else if (shader->key.as_es)
                        ctx->abi.emit_outputs = si_llvm_emit_es_epilogue;
                else
                        ctx->abi.emit_outputs = si_llvm_emit_vs_epilogue;
                bld_base->emit_epilogue = si_tgsi_emit_epilogue;
                break;
        case PIPE_SHADER_TESS_CTRL:
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_tcs;
+               ctx->abi.load_tess_inputs = si_nir_load_input_tcs;
                bld_base->emit_fetch_funcs[TGSI_FILE_OUTPUT] = fetch_output_tcs;
                bld_base->emit_store = store_output_tcs;
                bld_base->emit_epilogue = si_llvm_emit_tcs_epilogue;
                break;
        case PIPE_SHADER_TESS_EVAL:
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_tes;
                ctx->abi.load_tess_inputs = si_nir_load_input_tes;
                if (shader->key.as_es)
                        ctx->abi.emit_outputs = si_llvm_emit_es_epilogue;
                else



--
Lerne, wie die Welt wirklich ist,
Aber vergiss niemals, wie sie sein sollte.
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to