summaryrefslogtreecommitdiff
path: root/source/slang/slang-check-decl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-11-14 17:46:05 -0800
committerGitHub <noreply@github.com>2023-11-14 17:46:05 -0800
commit12f7237e4060388494c549623f4a640327b7ca08 (patch)
tree407c0f8d20b4ccd49ae5df57f84c8f9a310f7055 /source/slang/slang-check-decl.cpp
parentc71b12775c8b13ea2b181e42c04b8db55b10fb2f (diff)
Add GLSL Compatibility. (#3321)
* Parse glsl buffer blocks to GLSLInterfaceBlockDecl * Parse glsl local size layout declarations * Parse (and ignore) glsl version directives * spelling * Better l-value interpretation for glsl interface blocks * Better l-value interpretation for glsl interface blocks * Add compile flag for enabling glsl * Parse and ignore precision modifiers. * Automatically import `glsl` module for compatiblity. * Complete vector and matrix types for glsl * Remove generated file from repo * Bump .gitignore * do not mark out globals as params * Synthesize entrypoint layout from global inout vars. * update test result. * Allow HLSL semantic on global variables. * Fix. * Fix test. * Fix win32 compile error. * Add more builtin input/output and texture intrinsics. * Add struct/array constructor syntax. * Skip `#extension` lines. * overide operator * for matrix/vector multiplication. * Add `matrixCompMult`. * Parse modifiers in for loop init var declr. * Add more glsl intrinsics, add stage into to var layout. * Allow `int[3] x` syntax. * Fix array type syntax. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com> Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'source/slang/slang-check-decl.cpp')
-rw-r--r--source/slang/slang-check-decl.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/source/slang/slang-check-decl.cpp b/source/slang/slang-check-decl.cpp
index 8d7337318..c31c94a85 100644
--- a/source/slang/slang-check-decl.cpp
+++ b/source/slang/slang-check-decl.cpp
@@ -389,6 +389,11 @@ namespace Slang
//
if(decl->hasModifier<HLSLStaticModifier>()) return false;
+ // While not normally allowed, out variables are not constant
+ // parameters, this can happen for example in GLSL mode
+ if(decl->hasModifier<OutModifier>()) return false;
+ if(decl->hasModifier<InModifier>()) return false;
+
// The `groupshared` modifier indicates that a variable cannot
// be a shader parameters, but is instead transient storage
// allocated for the duration of a thread-group's execution.
@@ -1219,6 +1224,22 @@ namespace Slang
varDecl->type.type = m_astBuilder->getConstantBufferType(varDecl->type);
}
}
+
+ if (getLinkage()->getAllowGLSLInput())
+ {
+ // If we are in GLSL compatiblity mode, we want to treat all global variables
+ // without any `uniform` modifiers as true global variables by default.
+ if (!varDecl->findModifier<HLSLUniformModifier>() &&
+ !varDecl->findModifier<InModifier>() &&
+ !varDecl->findModifier<OutModifier>())
+ {
+ if (!as<ResourceType>(varDecl->type) && !as<PointerLikeType>(varDecl->type))
+ {
+ auto staticModifier = m_astBuilder->create<HLSLStaticModifier>();
+ addModifier(varDecl, staticModifier);
+ }
+ }
+ }
}
}