summaryrefslogtreecommitdiff
path: root/source/slang
diff options
context:
space:
mode:
authorPankaj Mistry <63069047+pmistryNV@users.noreply.github.com>2024-04-05 14:52:50 -0700
committerGitHub <noreply@github.com>2024-04-05 14:52:50 -0700
commitd61f81374272c2abc34eecab19e916b979b08a55 (patch)
tree268b99642f3674a9d35a54bc8a9ff05bfa8a0c4b /source/slang
parentcb87a8f1665198660636188e0861cd41bdaef16c (diff)
Add decoration PerPrimitiveEXT when a mesh output variable is decorated with PrimitiveID (#3895)
Fixes bug 3872
Diffstat (limited to 'source/slang')
-rw-r--r--source/slang/slang-emit-spirv.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 942e089db..9f116a1e2 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -3827,6 +3827,7 @@ struct SPIRVEmitContext
// non-tessellation shader stages, and if so include a declaration of
// Geometry capability.
bool needGeometryCapability = true;
+ bool needPerPrimitiveEXTDecoration = false;
if (entryPoints)
{
for (auto entryPoint : *entryPoints)
@@ -3835,9 +3836,13 @@ struct SPIRVEmitContext
{
switch (entryPointDecor->getProfile().getStage())
{
+ case Stage::Mesh:
+ // For outputs decorated with PrimitiveID it must be decorated
+ // with PerPrimitiveEXT to comply with Vulkan validation rules
+ if (m_capabilities.contains(SpvCapabilityMeshShadingEXT))
+ needPerPrimitiveEXTDecoration = true;
case Stage::Geometry:
case Stage::Intersection:
- case Stage::Mesh:
case Stage::Amplification:
case Stage::AnyHit:
case Stage::ClosestHit:
@@ -3851,7 +3856,14 @@ struct SPIRVEmitContext
}
if (needGeometryCapability)
requireSPIRVCapability(SpvCapabilityGeometry);
- return getBuiltinGlobalVar(inst->getFullType(), SpvBuiltInPrimitiveId);
+ auto varInst = getBuiltinGlobalVar(inst->getFullType(), SpvBuiltInPrimitiveId);
+ if (needPerPrimitiveEXTDecoration)
+ emitOpDecorate(
+ getSection(SpvLogicalSectionID::Annotations),
+ nullptr,
+ varInst,
+ SpvDecorationPerPrimitiveEXT);
+ return varInst;
}
else if (semanticName == "sv_rendertargetarrayindex")
{