forked from axmolengine/axslcc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglslang.patch
More file actions
124 lines (114 loc) · 4.88 KB
/
glslang.patch
File metadata and controls
124 lines (114 loc) · 4.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
diff --git a/SPIRV/GlslangToSpv.cpp b/SPIRV/GlslangToSpv.cpp
index ff9c8b04..8a4700fb 100644
--- a/SPIRV/GlslangToSpv.cpp
+++ b/SPIRV/GlslangToSpv.cpp
@@ -11148,6 +11148,14 @@ spv::Id TGlslangToSpvTraverser::getSymbolId(const glslang::TIntermSymbol* symbol
// default to 0
builder.addDecoration(id, spv::Decoration::Binding, 0);
}
+ if (options.allowNonStandardDecorations) { // axslcc spec
+ if (symbol->getQualifier().hasSamplerSlot())
+ builder.addDecoration(id, spv::Decoration::SamplerSlot, symbol->getQualifier().layoutSamplerSlot);
+ else if (IsDescriptorResource(symbol->getType())) {
+ // default to 0
+ builder.addDecoration(id, spv::Decoration::SamplerSlot, 0);
+ }
+ }
if (symbol->getQualifier().hasAttachment())
builder.addDecoration(id, spv::Decoration::InputAttachmentIndex, symbol->getQualifier().layoutAttachment);
if (glslangIntermediate->getXfbMode()) {
diff --git a/SPIRV/GlslangToSpv.h b/SPIRV/GlslangToSpv.h
index 9fb4f3ff..e12dcc26 100644
--- a/SPIRV/GlslangToSpv.h
+++ b/SPIRV/GlslangToSpv.h
@@ -55,6 +55,7 @@ struct SpvOptions {
bool emitNonSemanticShaderDebugSource{ false };
bool compileOnly{false};
bool optimizerAllowExpandedIDBound{false};
+ bool allowNonStandardDecorations{false}; // axslcc spec
};
GLSLANG_EXPORT void GetSpirvVersion(std::string&);
diff --git a/SPIRV/doc.cpp b/SPIRV/doc.cpp
index f81faefa..cb81b170 100644
--- a/SPIRV/doc.cpp
+++ b/SPIRV/doc.cpp
@@ -356,6 +356,7 @@ const char* DecorationString(int decoration)
case (int)Decoration::ArrayStrideIdEXT: return "DecorationArrayStrideIdEXT";
case (int)Decoration::OffsetIdEXT: return "DecorationOffsetIdEXT";
+ case (int)Decoration::SamplerSlot: return "SamplerSlot"; // axslcc spec
}
}
diff --git a/SPIRV/spirv.hpp11 b/SPIRV/spirv.hpp11
index 36a82e7a..95a64e12 100644
--- a/SPIRV/spirv.hpp11
+++ b/SPIRV/spirv.hpp11
@@ -657,6 +657,7 @@ enum class Decoration : unsigned {
ImplementInRegisterMapINTEL = 6191,
CacheControlLoadINTEL = 6442,
CacheControlStoreINTEL = 6443,
+ SamplerSlot = 7000, // axslcc spec
Max = 0x7fffffff,
};
diff --git a/glslang/Include/Types.h b/glslang/Include/Types.h
index 3fb0c55b..6b6ef437 100644
--- a/glslang/Include/Types.h
+++ b/glslang/Include/Types.h
@@ -940,6 +940,9 @@ public:
unsigned int layoutBinding : 16;
static const unsigned int layoutBindingEnd = 0xFFFF;
+ unsigned int layoutSamplerSlot : 16;
+ static const unsigned int layoutSamplerSlotEnd = 0xFFFF;
+
unsigned int layoutIndex : 8;
static const unsigned int layoutIndexEnd = 0xFF;
@@ -1015,6 +1018,7 @@ public:
layoutSet = layoutSetEnd;
layoutBinding = layoutBindingEnd;
+ layoutSamplerSlot = layoutSamplerSlotEnd;
layoutAttachment = layoutAttachmentEnd;
}
@@ -1048,6 +1052,10 @@ public:
{
return layoutBinding != layoutBindingEnd;
}
+ bool hasSamplerSlot() const
+ {
+ return layoutSamplerSlot != layoutSamplerSlotEnd;
+ }
bool hasOffset() const
{
return layoutOffset != layoutNotSet;
diff --git a/glslang/Include/glslang_c_interface.h b/glslang/Include/glslang_c_interface.h
index 4eec55b5..caa880fd 100644
--- a/glslang/Include/glslang_c_interface.h
+++ b/glslang/Include/glslang_c_interface.h
@@ -239,6 +239,7 @@ typedef struct glslang_spv_options_s {
bool emit_nonsemantic_shader_debug_source;
bool compile_only;
bool optimize_allow_expanded_id_bound;
+ bool allow_non_standard_decorations; // axslcc spec
} glslang_spv_options_t;
#ifdef __cplusplus
diff --git a/glslang/MachineIndependent/ParseHelper.cpp b/glslang/MachineIndependent/ParseHelper.cpp
index 658ca42d..9090ad73 100644
--- a/glslang/MachineIndependent/ParseHelper.cpp
+++ b/glslang/MachineIndependent/ParseHelper.cpp
@@ -7121,6 +7121,10 @@ void TParseContext::setLayoutQualifier(const TSourceLoc& loc, TPublicType& publi
error(loc, "needs a literal integer", "binding", "");
return;
}
+ else if (id == "sampler_slot") { // axslcc spec
+ publicType.qualifier.layoutSamplerSlot = value;
+ return;
+ }
if (id == "constant_id") {
requireSpv(loc, "constant_id");
if (value >= (int)TQualifier::layoutSpecConstantIdEnd) {
@@ -7498,6 +7502,8 @@ void TParseContext::mergeObjectLayoutQualifiers(TQualifier& dst, const TQualifie
dst.layoutSet = src.layoutSet;
if (src.layoutBinding != TQualifier::layoutBindingEnd)
dst.layoutBinding = src.layoutBinding;
+ if (src.layoutSamplerSlot != TQualifier::layoutSamplerSlotEnd)
+ dst.layoutSamplerSlot = src.layoutSamplerSlot;
if (src.hasSpecConstantId())
dst.layoutSpecConstantId = src.layoutSpecConstantId;