From bb2d06b0a3bf872a3905dce5e65383a95c64d11c Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Tue, 21 Nov 2023 20:12:47 +0100 Subject: [PATCH] Added semantic and semantic_idx layout qualifiers. --- glslang/Include/Types.h | 22 +++++++++++++++++++ glslang/MachineIndependent/ParseHelper.cpp | 25 ++++++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h index 26aba9bb..657158e2 100644 --- a/glslang/Include/Types.h +++ b/glslang/Include/Types.h @@ -856,6 +856,10 @@ public: layoutBindlessSampler = false; layoutBindlessImage = false; layoutBufferReferenceAlign = layoutBufferReferenceAlignEnd; + // BEGIN @MEWIN - 2023-11-21 - Added semantic and semantic_idx layout qualifiers. + layoutSemantic = layoutSemanticEnd; + layoutSemanticIndex = layoutSemanticIndexEnd; + // END @MEWIN layoutFormat = ElfNone; clearInterstageLayout(); @@ -940,6 +944,14 @@ public: unsigned int layoutBufferReferenceAlign : 6; static const unsigned int layoutBufferReferenceAlignEnd = 0x3F; + // BEGIN @MEWIN - 2023-11-21 - Added semantic and semantic_idx layout qualifiers. + unsigned int layoutSemantic : 5; + static const unsigned int layoutSemanticEnd = 0x1F; + + unsigned int layoutSemanticIndex : 3; + static const unsigned int layoutSemanticIndexEnd = 7; + // END @MEWIN + TLayoutFormat layoutFormat : 8; bool layoutPushConstant; @@ -1057,6 +1069,16 @@ public: bool isShaderRecord() const { return layoutShaderRecord; } bool hasHitObjectShaderRecordNV() const { return layoutHitObjectShaderRecordNV; } bool hasBufferReference() const { return layoutBufferReference; } + // BEGIN @MEWIN - 2023-11-21 - Added semantic and semantic_idx layout qualifiers. + bool hasSemantic() const + { + return layoutSemantic != layoutSemanticEnd; + } + bool hasSemanticIndex() const + { + return layoutSemanticIndex != layoutSemanticIndexEnd; + } + // END @MEWIN bool hasBufferReferenceAlign() const { return layoutBufferReferenceAlign != layoutBufferReferenceAlignEnd; diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp index f3d982ac..2cb7e0a1 100644 --- a/glslang/MachineIndependent/ParseHelper.cpp +++ b/glslang/MachineIndependent/ParseHelper.cpp @@ -5928,6 +5928,24 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi if (nonLiteral) error(loc, "needs a literal integer", "location", ""); return; + // BEGIN @MEWIN - 2023-11-21 - Added semantic and semantic_idx layout qualifiers. + } else if (id == "semantic") { + if ((unsigned int) value >= TQualifier::layoutSemanticEnd) + error(loc, "semantic is too large", id.c_str(), ""); + else + publicType.qualifier.layoutSemantic = value; + if (nonLiteral) + error(loc, "needs a literal integer", "location", ""); + return; + } else if (id == "semantic_idx") { + if ((unsigned int) value >= TQualifier::layoutSemanticIndexEnd) + error(loc, "semantic index is too large", id.c_str(), ""); + else + publicType.qualifier.layoutSemanticIndex = value; + if (nonLiteral) + error(loc, "needs a literal integer", "location", ""); + return; + // END @MEWIN } else if (id == "set") { if ((unsigned int)value >= TQualifier::layoutSetEnd) error(loc, "set is too large", id.c_str(), ""); @@ -6257,6 +6275,13 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie if (src.hasSpecConstantId()) dst.layoutSpecConstantId = src.layoutSpecConstantId; + // BEGIN @MEWIN - 2023-11-21 - Added semantic and semantic_idx layout qualifiers. + if (src.hasSemantic()) + dst.layoutSemantic = src.layoutSemantic; + if (src.hasSemanticIndex()) + dst.layoutSemanticIndex = src.layoutSemanticIndex; + // END @MEWIN + if (src.hasComponent()) dst.layoutComponent = src.layoutComponent; if (src.hasIndex())