From 89758544c45a15e546a1eb08891e2787bb88de4a Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 29 Jul 2019 14:55:04 -0700 Subject: Fix issue with outputting "static" in GLSL (#1006) This appears to be a regression introduced in #1001, and missed because none of our existing tests covered `static const` arrays on the GLSL/SPIR-V targets. The basic problem is that we cannot output a `static const` definition in GLSL because `static` is a reserved word and not a keyword. Instead for GLSL we just want a `const` array. This change makes the emission of `static` for global-scope constants key on the target language for code generation, and only emit it for HLSL, C, and C++. This change also adds a test case specifically for running Slang input that has a `static const` array on the Vulkan target. --- source/slang/slang-emit-c-like.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index d7930130e..c7b5b602b 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -982,7 +982,20 @@ void CLikeSourceEmitter::emitInstResultDecl(IRInst* inst) if(as(inst->getParent())) { // "Ordinary" instructions at module scope are constants - m_writer->emit("static const "); + + switch (getSourceStyle()) + { + case SourceStyle::HLSL: + case SourceStyle::C: + case SourceStyle::CPP: + m_writer->emit("static "); + break; + + default: + break; + } + + m_writer->emit("const "); } emitType(type, getName(inst)); -- cgit v1.2.3