From: George Ouzounoudis Date: Mon, 24 Oct 2022 17:02:02 +0000 (+0300) Subject: nouveau/codegen: Add capability to pre-specify tessellation domain X-Git-Tag: upstream/23.3.3~4865 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cdece16cf4e004a7b7c8d4b39988fa0eabe0dd34;p=platform%2Fupstream%2Fmesa.git 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: --- 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); }