From 754837f3b5f1548a1d0f5689c3d340092d64704d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timur=20Krist=C3=B3f?= Date: Mon, 17 Feb 2020 16:56:39 +0100 Subject: [PATCH] aco: Implement load_tess_coord. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Timur Kristóf Reviewed-by: Rhys Perry Part-of: --- .../compiler/aco_instruction_selection.cpp | 24 +++++++++++++++++++ .../aco_instruction_selection_setup.cpp | 1 + 2 files changed, 25 insertions(+) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index a60e57189e3..6a5fb839e1e 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -3527,6 +3527,27 @@ void visit_load_per_vertex_input(isel_context *ctx, nir_intrinsic_instr *instr) } } +void visit_load_tess_coord(isel_context *ctx, nir_intrinsic_instr *instr) +{ + assert(ctx->shader->info.stage == MESA_SHADER_TESS_EVAL); + + Builder bld(ctx->program, ctx->block); + Temp dst = get_ssa_temp(ctx, &instr->dest.ssa); + + Operand tes_u(get_arg(ctx, ctx->args->tes_u)); + Operand tes_v(get_arg(ctx, ctx->args->tes_v)); + Operand tes_w(0u); + + if (ctx->shader->info.tess.primitive_mode == GL_TRIANGLES) { + Temp tmp = bld.vop2(aco_opcode::v_add_f32, bld.def(v1), tes_u, tes_v); + tmp = bld.vop2(aco_opcode::v_sub_f32, bld.def(v1), Operand(0x3f800000u /* 1.0f */), tmp); + tes_w = Operand(tmp); + } + + Temp tess_coord = bld.pseudo(aco_opcode::p_create_vector, Definition(dst), tes_u, tes_v, tes_w); + emit_split_vector(ctx, tess_coord, 3); +} + Temp load_desc_ptr(isel_context *ctx, unsigned desc_set) { if (ctx->program->info->need_indirect_descriptor_sets) { @@ -6175,6 +6196,9 @@ void visit_intrinsic(isel_context *ctx, nir_intrinsic_instr *instr) posy.id() ? bld.vop1(aco_opcode::v_fract_f32, bld.def(v1), posy) : Operand(0u)); break; } + case nir_intrinsic_load_tess_coord: + visit_load_tess_coord(ctx, instr); + break; case nir_intrinsic_load_interpolated_input: visit_load_interpolated_input(ctx, instr); break; diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index 5c4151b23c8..9005c707586 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -328,6 +328,7 @@ void init_context(isel_context *ctx, nir_shader *shader) case nir_intrinsic_load_local_invocation_id: case nir_intrinsic_load_local_invocation_index: case nir_intrinsic_load_subgroup_invocation: + case nir_intrinsic_load_tess_coord: case nir_intrinsic_write_invocation_amd: case nir_intrinsic_mbcnt_amd: case nir_intrinsic_load_instance_id: -- 2.30.2