From cdece16cf4e004a7b7c8d4b39988fa0eabe0dd34 Mon Sep 17 00:00:00 2001 From: George Ouzounoudis Date: Mon, 24 Oct 2022 20:02:02 +0300 Subject: [PATCH] nouveau/codegen: Add capability to pre-specify tessellation domain In the case of SPIRV tessellation shaders, the execution mode can be specified in the tessellation control shader. So we need a way to know the domain when compiling the tessellation evaluation shader. Acked-by: M Henning Reviewed-by: Karol Herbst Part-of: --- src/nouveau/codegen/nv50_ir_driver.h | 3 +++ src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/nouveau/codegen/nv50_ir_driver.h b/src/nouveau/codegen/nv50_ir_driver.h index 8a3f637..fdd8b21 100644 --- a/src/nouveau/codegen/nv50_ir_driver.h +++ b/src/nouveau/codegen/nv50_ir_driver.h @@ -103,6 +103,9 @@ struct nv50_ir_prog_info uint32_t gridInfoBase; /* base address for NTID,NCTAID */ uint16_t numThreads[3]; /* max number of threads */ } cp; + struct { + uint8_t prespecified_domain; /* MESA_PRIM_{QUADS,TRIANGLES,LINES}, POINTS if unspecified */ + } tese; } prop; struct { diff --git a/src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp b/src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp index 78fab61..da1f04e 100644 --- a/src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp +++ b/src/nouveau/codegen/nv50_ir_lowering_nvc0.cpp @@ -2916,6 +2916,18 @@ NVC0LoweringPass::handleLDST(Instruction *i) void NVC0LoweringPass::readTessCoord(LValue *dst, int c) { + // GLSL requires domain qualifier to be defined in TES while SPIRV allows + // domain to be defined in TES and/or TCS + uint8_t domain = prog->driver_out->prop.tp.domain; + const bool tese_defined_domain = + domain == MESA_PRIM_LINES || + domain == MESA_PRIM_TRIANGLES || + domain == MESA_PRIM_QUADS; + + if (!tese_defined_domain) { + domain = prog->driver->prop.tese.prespecified_domain; + } + Value *laneid = bld.getSSA(); Value *x, *y; @@ -2930,7 +2942,8 @@ NVC0LoweringPass::readTessCoord(LValue *dst, int c) y = dst; } else { assert(c == 2); - if (prog->driver_out->prop.tp.domain != MESA_PRIM_TRIANGLES) { + if (domain != MESA_PRIM_TRIANGLES) { + // optimize out tesscoord.z bld.mkMov(dst, bld.loadImm(NULL, 0)); return; } @@ -2943,6 +2956,7 @@ NVC0LoweringPass::readTessCoord(LValue *dst, int c) bld.mkFetch(y, TYPE_F32, FILE_SHADER_OUTPUT, 0x2f4, NULL, laneid); if (c == 2) { + // compute tesscoord.z from x, y bld.mkOp2(OP_ADD, TYPE_F32, dst, x, y); bld.mkOp2(OP_SUB, TYPE_F32, dst, bld.loadImm(NULL, 1.0f), dst); } -- 2.7.4