ac: add load_tess_level() to the abi
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 11 Dec 2017 05:16:30 +0000 (16:16 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Mon, 8 Jan 2018 23:21:32 +0000 (10:21 +1100)
Fixes the following piglit tests in radeonsi:

vs-tcs-tes-tessinner-tessouter-inputs-quads.shader_test
vs-tcs-tes-tessinner-tessouter-inputs-tris.shader_test
vs-tes-tessinner-tessouter-inputs-quads.shader_test
vs-tes-tessinner-tessouter-inputs-tris.shader_test

v2: make use of si_shader_io_get_unique_index_patch()
    via the helper in the previous patch rather than
    shader_io_get_unique_index()

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_nir_to_llvm.c
src/amd/common/ac_shader_abi.h
src/gallium/drivers/radeonsi/si_shader.c

index 42ddebbeef0028691ebcd8e03a94f84d41a71e5e..cad4adfa03b615025e7170d95108e1779f9b904b 100644 (file)
@@ -4369,6 +4369,12 @@ static void visit_intrinsic(struct ac_nir_context *ctx,
                result = ctx->abi->load_tess_coord(ctx->abi, type, instr->num_components);
                break;
        }
+       case nir_intrinsic_load_tess_level_outer:
+               result = ctx->abi->load_tess_level(ctx->abi, VARYING_SLOT_TESS_LEVEL_OUTER);
+               break;
+       case nir_intrinsic_load_tess_level_inner:
+               result = ctx->abi->load_tess_level(ctx->abi, VARYING_SLOT_TESS_LEVEL_INNER);
+               break;
        case nir_intrinsic_load_patch_vertices_in:
                result = LLVMConstInt(ctx->ac.i32, ctx->nctx->options->key.tcs.input_vertices, false);
                break;
index 277e4efe47ed1d6d5eccbfbd06489cdc17b19dea..e3a47089a526506fcd5e6686cb7bad9f806c86f3 100644 (file)
@@ -103,6 +103,10 @@ struct ac_shader_abi {
                                        LLVMTypeRef type,
                                        unsigned num_components);
 
+       LLVMValueRef (*load_tess_level)(struct ac_shader_abi *abi,
+                                       unsigned varying_id);
+
+
        LLVMValueRef (*load_ubo)(struct ac_shader_abi *abi, LLVMValueRef index);
 
        /**
index e579916359ef9dcb1ccbee1cfdd4a4ded94f0c6e..86f3f7a8ba2208861b50cdc282e2034ef0fcb90e 100644 (file)
@@ -1934,6 +1934,27 @@ static LLVMValueRef load_tess_level(struct si_shader_context *ctx,
 
 }
 
+static LLVMValueRef si_load_tess_level(struct ac_shader_abi *abi,
+                                      unsigned varying_id)
+{
+       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+       unsigned semantic_name;
+
+       switch (varying_id) {
+       case VARYING_SLOT_TESS_LEVEL_INNER:
+               semantic_name = TGSI_SEMANTIC_TESSINNER;
+               break;
+       case VARYING_SLOT_TESS_LEVEL_OUTER:
+               semantic_name = TGSI_SEMANTIC_TESSOUTER;
+               break;
+       default:
+               unreachable("unknown tess level");
+       }
+
+       return load_tess_level(ctx, semantic_name);
+
+}
+
 void si_load_system_value(struct si_shader_context *ctx,
                          unsigned index,
                          const struct tgsi_full_declaration *decl)
@@ -5971,6 +5992,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx,
                bld_base->emit_fetch_funcs[TGSI_FILE_INPUT] = fetch_input_tes;
                ctx->abi.load_tess_inputs = si_nir_load_input_tes;
                ctx->abi.load_tess_coord = si_load_tess_coord;
+               ctx->abi.load_tess_level = si_load_tess_level;
                if (shader->key.as_es)
                        ctx->abi.emit_outputs = si_llvm_emit_es_epilogue;
                else