summaryrefslogtreecommitdiffstats
path: root/source/slang/slang-stdlib.cpp
diff options
context:
space:
mode:
authorTim Foley <tfoley@nvidia.com>2017-07-13 09:33:07 -0700
committerTim Foley <tfoley@nvidia.com>2017-07-13 09:35:20 -0700
commitc51fd4ee8f478aa3d3b7e6208a3a4e9c00e2413a (patch)
tree88f7f0b51d679cc308437461b8c210e828efeda0 /source/slang/slang-stdlib.cpp
parent6da80f58ba8f51fc768f177f28a7d818b03c434e (diff)
Add several missing GLSL qualifiers
Fixes #81 - This is based on a san over the GLSL spec (but is probably not exhaustive) - There are some qualifiers that are currently being handled by general-case code for all languages, and some of these happen to cover GLSL qualifiers too - Some of the qualifiers being handled by the general-case mechanism are *accidentally* working for GLSL (e.g., the HLSL `shared` qualifier doesn't mean the same thing as GLSL `shared`, but as long as we spit it back out nobody seems to care). - This should be fixed sooner or later.
Diffstat (limited to 'source/slang/slang-stdlib.cpp')
-rw-r--r--source/slang/slang-stdlib.cpp41
1 files changed, 37 insertions, 4 deletions
diff --git a/source/slang/slang-stdlib.cpp b/source/slang/slang-stdlib.cpp
index 563f5a015..3450e72d7 100644
--- a/source/slang/slang-stdlib.cpp
+++ b/source/slang/slang-stdlib.cpp
@@ -2073,13 +2073,46 @@ namespace Slang
sb << "__magic_type(GLSLInputAttachmentType) struct subpassInput {};";
// Define additional keywords
+
sb << "__modifier(GLSLBufferModifier) buffer;\n";
- sb << "__modifier(GLSLWriteOnlyModifier) writeonly;\n";
- sb << "__modifier(GLSLReadOnlyModifier) readonly;\n";
+
+ // [GLSL 4.3] Storage Qualifiers
+
+ // TODO: need to support `shared` here with its GLSL meaning
+
sb << "__modifier(GLSLPatchModifier) patch;\n";
+ // `centroid` and `sample` handled centrally
+
+ // [GLSL 4.5] Interpolation Qualifiers
+ sb << "__modifier(SimpleModifier) smooth;\n";
+ sb << "__modifier(SimpleModifier) flat;\n";
+ sb << "__modifier(SimpleModifier) noperspective;\n";
+
+
+ // [GLSL 4.3.2] Constant Qualifier
+
+ // We need to handle GLSL `const` separately from HLSL `const`,
+ // since they mean such different things.
+
+ // [GLSL 4.7.2] Precision Qualifiers
+ sb << "__modifier(SimpleModifier) highp;\n";
+ sb << "__modifier(SimpleModifier) mediump;\n";
+ sb << "__modifier(SimpleModifier) lowp;\n";
+
+ // [GLSL 4.8.1] The Invariant Qualifier
+
+ sb << "__modifier(GLSLWriteOnlyModifier) invariant;\n";
+
+ // [GLSL 4.10] Memory Qualifiers
+
+ sb << "__modifier(SimpleModifier) coherent;\n";
+ sb << "__modifier(SimpleModifier) volatile;\n";
+ sb << "__modifier(SimpleModifier) restrict;\n";
+ sb << "__modifier(GLSLReadOnlyModifier) readonly;\n";
+ sb << "__modifier(GLSLWriteOnlyModifier) writeonly;\n";
- sb << "__modifier(SimpleModifier) flat;\n";
- sb << "__modifier(SimpleModifier) highp;\n";
+ // We will treat `subroutine` as a qualifier
+ sb << "__modifier(SimpleModifier) subroutine;\n";
glslLibraryCode = sb.ProduceString();
return glslLibraryCode;