diff options
| author | Tim Foley <tfoley@nvidia.com> | 2017-07-06 20:47:20 -0700 |
|---|---|---|
| committer | Tim Foley <tfoley@nvidia.com> | 2017-07-07 10:00:25 -0700 |
| commit | 6da1782f34e8022774dce8d253bc5c3ab9b496cc (patch) | |
| tree | 8dcebe6003902fb93c1e0b4ca830ba67a9013fa3 /source | |
| parent | 4921bdbe0d75f1ad29fae18920678287919a2e29 (diff) | |
Don't emit the `static` keyword when generating GLSL
GLSL doesn't support `static` at all, while HLSL uses it for multiple things:
- To mark global variables that are "thread local" rather than shader parameters
- In the C/C++ style to mark `static` allocation for variables inside a function or type
The latter case needs to be handled during lowering (but isn't handled right now).
The former case can be solved just by dropping the `static` keyword.
Diffstat (limited to 'source')
| -rw-r--r-- | source/slang/emit.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source/slang/emit.cpp b/source/slang/emit.cpp index 08d2218dc..48644cc6f 100644 --- a/source/slang/emit.cpp +++ b/source/slang/emit.cpp @@ -2021,7 +2021,6 @@ static void EmitModifiers(EmitContext* context, RefPtr<Decl> decl) CASE(HLSLPreciseModifier, precise); CASE(HLSLEffectSharedModifier, shared); CASE(HLSLGroupSharedModifier, groupshared); - CASE(HLSLStaticModifier, static); CASE(HLSLUniformModifier, uniform); CASE(HLSLVolatileModifier, volatile); @@ -2043,6 +2042,27 @@ static void EmitModifiers(EmitContext* context, RefPtr<Decl> decl) #undef CASE + else if (auto staticModifier = mod.As<HLSLStaticModifier>()) + { + // GLSL does not support the `static` keyword. + // HLSL uses it both to mark global variables as being "thread-local" + // (rather than shader inputs), and also seems to support function-`static` + // variables. + // The latter case needs to be dealt with in lowering anyway, so that + // we only need to deal with globals here, and GLSL variables + // don't need a `static` modifier anyway. + + switch(context->shared->target) + { + default: + Emit(context, "static"); + break; + + case CodeGenTarget::GLSL: + break; + } + } + // TODO: eventually we should be checked these modifiers, but for // now we can emit them unchecked, I guess else if (auto uncheckedAttr = mod.As<HLSLAttribute>()) |
