diff options
author | Dave Airlie <[email protected]> | 2017-03-30 08:25:18 +0100 |
---|---|---|
committer | Dave Airlie <[email protected]> | 2017-04-01 07:16:32 +1000 |
commit | 326b9bc6dc43b1fe58ee95ad0022c1005cb756ea (patch) | |
tree | 4f8c29ed995a7a9e89550a35feb5d3410efb8364 | |
parent | d8ab71b207138439f23d377b07e7c4678426b62b (diff) |
radv/ac: hook up tessellation intrinsics.
This just adds support for the nir intrinsics that tessellation uses.
Reviewed-by: Bas Nieuwenhuizen <[email protected]>
Signed-off-by: Dave Airlie <[email protected]>
-rw-r--r-- | src/amd/common/ac_nir_to_llvm.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/amd/common/ac_nir_to_llvm.c b/src/amd/common/ac_nir_to_llvm.c index bd42bbff399..1666de4081b 100644 --- a/src/amd/common/ac_nir_to_llvm.c +++ b/src/amd/common/ac_nir_to_llvm.c @@ -3253,6 +3253,26 @@ visit_end_primitive(struct nir_to_llvm_context *ctx, ac_build_sendmsg(&ctx->ac, AC_SENDMSG_GS_OP_CUT | AC_SENDMSG_GS | (0 << 8), ctx->gs_wave_id); } +static LLVMValueRef +visit_load_tess_coord(struct nir_to_llvm_context *ctx, + nir_intrinsic_instr *instr) +{ + LLVMValueRef coord[4] = { + ctx->tes_u, + ctx->tes_v, + ctx->f32zero, + ctx->f32zero, + }; + + if (ctx->tes_primitive_mode == GL_TRIANGLES) + coord[2] = LLVMBuildFSub(ctx->builder, ctx->f32one, + LLVMBuildFAdd(ctx->builder, coord[0], coord[1], ""), ""); + + LLVMValueRef result = ac_build_gather_values(&ctx->ac, coord, instr->num_components); + return LLVMBuildBitCast(ctx->builder, result, + get_def_type(ctx, &instr->dest.ssa), ""); +} + static void visit_intrinsic(struct nir_to_llvm_context *ctx, nir_intrinsic_instr *instr) { @@ -3282,11 +3302,18 @@ static void visit_intrinsic(struct nir_to_llvm_context *ctx, result = ctx->draw_index; break; case nir_intrinsic_load_invocation_id: - result = ctx->gs_invocation_id; + if (ctx->stage == MESA_SHADER_TESS_CTRL) + result = unpack_param(ctx, ctx->tcs_rel_ids, 8, 5); + else + result = ctx->gs_invocation_id; break; case nir_intrinsic_load_primitive_id: if (ctx->stage == MESA_SHADER_GEOMETRY) result = ctx->gs_prim_id; + else if (ctx->stage == MESA_SHADER_TESS_CTRL) + result = ctx->tcs_patch_id; + else if (ctx->stage == MESA_SHADER_TESS_EVAL) + result = ctx->tes_patch_id; else fprintf(stderr, "Unknown primitive id intrinsic: %d", ctx->stage); break; @@ -3408,6 +3435,12 @@ static void visit_intrinsic(struct nir_to_llvm_context *ctx, case nir_intrinsic_end_primitive: visit_end_primitive(ctx, instr); break; + case nir_intrinsic_load_tess_coord: + result = visit_load_tess_coord(ctx, instr); + break; + case nir_intrinsic_load_patch_vertices_in: + result = LLVMConstInt(ctx->i32, ctx->options->key.tcs.input_vertices, false); + break; default: fprintf(stderr, "Unknown intrinsic: "); nir_print_instr(&instr->instr, stderr); |