diff options
author | Timothy Arceri <[email protected]> | 2017-12-06 17:34:32 +1100 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2018-01-05 11:58:55 +1100 |
commit | 14adf7853a569b966bca80cd3429a9eb24ddebd4 (patch) | |
tree | 5b56aa2ba4a464677540dfec693887cbc3397547 /src/gallium | |
parent | eb1e555cfdac76696c71ffa93a686f7c5d54f9fa (diff) |
ac/radeonsi: add load_tess_coord() to the abi
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium')
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 42 |
1 files changed, 25 insertions, 17 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index 45c4720d35a..f6e3083e4cb 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -1893,11 +1893,33 @@ static LLVMValueRef load_sample_position(struct si_shader_context *ctx, LLVMValu return lp_build_gather_values(&ctx->gallivm, pos, 4); } +static LLVMValueRef si_load_tess_coord(struct ac_shader_abi *abi, + LLVMTypeRef type, + unsigned num_components) +{ + struct si_shader_context *ctx = si_shader_context_from_abi(abi); + struct lp_build_context *bld = &ctx->bld_base.base; + + LLVMValueRef coord[4] = { + LLVMGetParam(ctx->main_fn, ctx->param_tes_u), + LLVMGetParam(ctx->main_fn, ctx->param_tes_v), + ctx->ac.f32_0, + ctx->ac.f32_0 + }; + + /* For triangles, the vector should be (u, v, 1-u-v). */ + if (ctx->shader->selector->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == + PIPE_PRIM_TRIANGLES) + coord[2] = lp_build_sub(bld, ctx->ac.f32_1, + lp_build_add(bld, coord[0], coord[1])); + + return lp_build_gather_values(&ctx->gallivm, coord, 4); +} + void si_load_system_value(struct si_shader_context *ctx, unsigned index, const struct tgsi_full_declaration *decl) { - struct lp_build_context *bld = &ctx->bld_base.base; LLVMValueRef value = 0; assert(index < RADEON_LLVM_MAX_SYSTEM_VALUES); @@ -1998,23 +2020,8 @@ void si_load_system_value(struct si_shader_context *ctx, break; case TGSI_SEMANTIC_TESSCOORD: - { - LLVMValueRef coord[4] = { - LLVMGetParam(ctx->main_fn, ctx->param_tes_u), - LLVMGetParam(ctx->main_fn, ctx->param_tes_v), - ctx->ac.f32_0, - ctx->ac.f32_0 - }; - - /* For triangles, the vector should be (u, v, 1-u-v). */ - if (ctx->shader->selector->info.properties[TGSI_PROPERTY_TES_PRIM_MODE] == - PIPE_PRIM_TRIANGLES) - coord[2] = lp_build_sub(bld, ctx->ac.f32_1, - lp_build_add(bld, coord[0], coord[1])); - - value = lp_build_gather_values(&ctx->gallivm, coord, 4); + value = si_load_tess_coord(&ctx->abi, NULL, 4); break; - } case TGSI_SEMANTIC_VERTICESIN: if (ctx->type == PIPE_SHADER_TESS_CTRL) @@ -5958,6 +5965,7 @@ static bool si_compile_tgsi_main(struct si_shader_context *ctx, 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; + ctx->abi.load_tess_coord = si_load_tess_coord; if (shader->key.as_es) ctx->abi.emit_outputs = si_llvm_emit_es_epilogue; else |