From 706aa030ad08ebefd5669f2b866763d10af561ce Mon Sep 17 00:00:00 2001 From: Senaxx Date: Fri, 23 Oct 2026 13:28:23 +0200 Subject: [PATCH] shader: extract 9-bit NGG primitive vertex indices, leaving the edge flags out --- .../shader/recompiler/backend/spirv/spirvEmitterMesh.cpp | 2 +- tests/shaderCfgTests.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cpp b/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cpp index 2c8f210b2..c4c9d094d 100644 --- a/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cpp +++ b/src/graphics/shader/recompiler/backend/spirv/spirvEmitterMesh.cpp @@ -187,7 +187,7 @@ void EmitMeshEntryPoint(EmitterState& state) { vertex[component] = state.builder.AllocateId(); state.builder.AddFunction( spv::OpBitFieldUExtract, TypeU32(state), vertex[component], packed, - ConstantU32(state, component * 10u), ConstantU32(state, 10)); + ConstantU32(state, component * 10u), ConstantU32(state, 9)); } const auto triangle = state.builder.AllocateId(); state.builder.AddFunction(spv::OpCompositeConstruct, TypeU32Vector(state, 3), triangle, diff --git a/tests/shaderCfgTests.cpp b/tests/shaderCfgTests.cpp index 8519eaec0..3d155c8c1 100644 --- a/tests/shaderCfgTests.cpp +++ b/tests/shaderCfgTests.cpp @@ -11160,6 +11160,8 @@ void TestMeshExportStorage() { !SpirvSourceHasInstructionUsing(source, "OpAccessChain", "vsharp %uint_0 %uint_4294967295"), "mesh draw prefix was lost or spilled shader data wrapped into push constants"); + Check(SpirvSourceHasInstructionUsing(source, "OpBitFieldUExtract", "%uint_10 %uint_9"), + "NGG primitive vertex indices must be 9 bits; bit 9 of each field is the edge flag"); const auto &binary = result.spirv; for (const auto builtin : {3u, 4u}) { auto expected = builtin == 3u ? std::vector{0, 3}