summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2024-11-25 15:40:47 +0200
committerGitHub <noreply@github.com>2024-11-25 21:40:47 +0800
commit044b52c3195edf3282a0b530a21ad54b87135cd9 (patch)
treec1bd9d9a916faf64629442baf2b4e05ea053c230 /source
parentaaca2d2b615ce113ae9eff11a6fc01f579471b12 (diff)
Fix issue where inter-stage parameters without semantics don't get location attributes (#5670)
* wgsl: Make sure each shader input field has a semantic This closes #5633. * Add test for inter-stage variables without semantics This verifies the fix of the second issue identified in https://github.com/shader-slang/slang/issues/5633 * format code --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com>
Diffstat (limited to 'source')
-rw-r--r--source/slang/slang-ir-wgsl-legalize.cpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/slang/slang-ir-wgsl-legalize.cpp b/source/slang/slang-ir-wgsl-legalize.cpp
index 8eb820b4d..4d5f6e4ba 100644
--- a/source/slang/slang-ir-wgsl-legalize.cpp
+++ b/source/slang/slang-ir-wgsl-legalize.cpp
@@ -147,6 +147,9 @@ struct LegalizeWGSLEntryPointContext
semanticInfoToRemove);
// Validate/rearange all semantics which overlap in our flat struct.
fixFieldSemanticsOfFlatStruct(flattenedStruct);
+ ensureStructHasUserSemantic<LayoutResourceKind::VaryingInput>(
+ flattenedStruct,
+ layout);
if (flattenedStruct != structType)
{
// Replace the 'old IRParam type' with a 'new IRParam type'
@@ -381,7 +384,8 @@ struct LegalizeWGSLEntryPointContext
semanticName);
}
- void ensureResultStructHasUserSemantic(IRStructType* structType, IRVarLayout* varLayout)
+ template<LayoutResourceKind K>
+ void ensureStructHasUserSemantic(IRStructType* structType, IRVarLayout* varLayout)
{
// Ensure each field in an output struct type has either a system semantic or a user
// semantic, so that signature matching can happen correctly.
@@ -415,11 +419,10 @@ struct LegalizeWGSLEntryPointContext
}
typeLayout->getFieldLayout(index);
auto fieldLayout = typeLayout->getFieldLayout(index);
- if (auto offsetAttr = fieldLayout->findOffsetAttr(LayoutResourceKind::VaryingOutput))
+ if (auto offsetAttr = fieldLayout->findOffsetAttr(K))
{
UInt varOffset = 0;
- if (auto varOffsetAttr =
- varLayout->findOffsetAttr(LayoutResourceKind::VaryingOutput))
+ if (auto varOffsetAttr = varLayout->findOffsetAttr(K))
varOffset = varOffsetAttr->getOffset();
varOffset += offsetAttr->getOffset();
builder.addSemanticDecoration(key, toSlice("_slang_attr"), (int)varOffset);
@@ -1101,7 +1104,9 @@ struct LegalizeWGSLEntryPointContext
}
// Ensure non-overlapping semantics
fixFieldSemanticsOfFlatStruct(flattenedStruct);
- ensureResultStructHasUserSemantic(flattenedStruct, resultLayout);
+ ensureStructHasUserSemantic<LayoutResourceKind::VaryingOutput>(
+ flattenedStruct,
+ resultLayout);
return;
}
@@ -1121,7 +1126,7 @@ struct LegalizeWGSLEntryPointContext
auto typeLayout = structTypeLayoutBuilder.build();
IRVarLayout::Builder varLayoutBuilder(&builder, typeLayout);
auto varLayout = varLayoutBuilder.build();
- ensureResultStructHasUserSemantic(structType, varLayout);
+ ensureStructHasUserSemantic<LayoutResourceKind::VaryingOutput>(structType, varLayout);
_replaceAllReturnInst(
builder,