summaryrefslogtreecommitdiff
path: root/source/slang/slang-emit-spirv.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-06-12 09:39:20 -0700
committerGitHub <noreply@github.com>2024-06-12 09:39:20 -0700
commit180d6b13c6794a0bbb209df023301701cda15158 (patch)
tree3a7ff1697c9b7fc71c6d44850659ea13013dcc69 /source/slang/slang-emit-spirv.cpp
parentfa8c11ebe8f9b1bf2174a5a4dbe92a34c16811c8 (diff)
Fix duplicate SPIRV decorations. (#4346)
* Fix duplicate `DescriptorSet` decorations. * Fix duplicate `Block` decoration.
Diffstat (limited to 'source/slang/slang-emit-spirv.cpp')
-rw-r--r--source/slang/slang-emit-spirv.cpp39
1 files changed, 24 insertions, 15 deletions
diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp
index 10c263793..df60feecf 100644
--- a/source/slang/slang-emit-spirv.cpp
+++ b/source/slang/slang-emit-spirv.cpp
@@ -2139,6 +2139,7 @@ struct SPIRVEmitContext
{
bool needDefaultSetBindingDecoration = false;
bool hasExplicitSetBinding = false;
+ bool isDescirptorSetDecorated = false;
for (auto rr : layout->getOffsetAttrs())
{
UInt index = rr->getOffset();
@@ -2200,32 +2201,40 @@ struct SPIRVEmitContext
nullptr,
varInst,
SpvLiteralInteger::from32(int32_t(index)));
- if (space)
+ if (!isDescirptorSetDecorated)
+ {
+ if (space)
+ {
+ emitOpDecorateDescriptorSet(
+ getSection(SpvLogicalSectionID::Annotations),
+ nullptr,
+ varInst,
+ SpvLiteralInteger::from32(int32_t(space)));
+ isDescirptorSetDecorated = true;
+ }
+ else
+ {
+ needDefaultSetBindingDecoration = true;
+ }
+ }
+ break;
+ case LayoutResourceKind::RegisterSpace:
+ if (!isDescirptorSetDecorated)
{
emitOpDecorateDescriptorSet(
getSection(SpvLogicalSectionID::Annotations),
nullptr,
varInst,
- SpvLiteralInteger::from32(int32_t(space)));
+ SpvLiteralInteger::from32(int32_t(index)));
+ hasExplicitSetBinding = true;
+ isDescirptorSetDecorated = true;
}
- else
- {
- needDefaultSetBindingDecoration = true;
- }
- break;
- case LayoutResourceKind::RegisterSpace:
- emitOpDecorateDescriptorSet(
- getSection(SpvLogicalSectionID::Annotations),
- nullptr,
- varInst,
- SpvLiteralInteger::from32(int32_t(index)));
- hasExplicitSetBinding = true;
break;
default:
break;
}
}
- if (needDefaultSetBindingDecoration && !hasExplicitSetBinding)
+ if (needDefaultSetBindingDecoration && !hasExplicitSetBinding && !isDescirptorSetDecorated)
{
emitOpDecorateDescriptorSet(
getSection(SpvLogicalSectionID::Annotations),