-
Notifications
You must be signed in to change notification settings - Fork 816
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add glslang::Language to break cyclic dependency
between `HLSL` and `glslang` build targets. Applications now require a call to `glslang::RegisterHlslLanguage()` to enable support for the HLSL language. This is implemented in the HLSL library. Fixes building of shared libraries.
- Loading branch information
1 parent
45de441
commit 0b6ece0
Showing
11 changed files
with
330 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// | ||
// Copyright (C) 2020 Google, Inc. | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// | ||
// Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following | ||
// disclaimer in the documentation and/or other materials provided | ||
// with the distribution. | ||
// | ||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its | ||
// contributors may be used to endorse or promote products derived | ||
// from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
// POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
|
||
#include "Language.h" | ||
#include "ParseHelper.h" | ||
#include "ScanContext.h" | ||
|
||
#include <array> | ||
|
||
namespace glslang { | ||
|
||
namespace { | ||
|
||
class GlslLanguage : public Language { | ||
public: | ||
static GlslLanguage instance; | ||
|
||
void Initialize() override { | ||
TScanContext::fillInKeywordMap(); | ||
} | ||
|
||
void Terminate() override { | ||
TScanContext::deleteKeywordMap(); | ||
} | ||
|
||
EShSource Source() const override { | ||
return EShSourceGlsl; | ||
} | ||
|
||
TBuiltInParseables* CreateBuiltInParseables(TInfoSink&) override { | ||
return new TBuiltIns(); | ||
} | ||
|
||
TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& intermediate, | ||
int version, EProfile profile, | ||
EShLanguage language, TInfoSink& infoSink, | ||
SpvVersion spvVersion, bool forwardCompatible, EShMessages messages, | ||
bool parsingBuiltIns, std::string sourceEntryPointName) override { | ||
if (sourceEntryPointName.size() == 0) | ||
intermediate.setEntryPointName("main"); | ||
TString entryPoint = sourceEntryPointName.c_str(); | ||
return new TParseContext(symbolTable, intermediate, parsingBuiltIns, version, profile, spvVersion, | ||
language, infoSink, forwardCompatible, messages, &entryPoint); | ||
} | ||
}; | ||
|
||
GlslLanguage GlslLanguage::instance; | ||
|
||
std::array<Language*, EShSourceCount> languages = {}; | ||
|
||
// Automatically register the GLSL language when the static initializers are run | ||
// for this compilation unit. | ||
struct AutoRegisterGlslLanguage { | ||
AutoRegisterGlslLanguage() { Language::Register(&GlslLanguage::instance); } | ||
} autoRegisterGlslLanguage; | ||
|
||
} // end anonymous namespace | ||
|
||
void Language::InitializeAll() { | ||
for (Language* language : languages) { | ||
if (language) { | ||
language->Initialize(); | ||
} | ||
} | ||
} | ||
|
||
void Language::TerminateAll() { | ||
for (Language* language : languages) { | ||
if (language) { | ||
language->Terminate(); | ||
} | ||
} | ||
} | ||
|
||
void Language::Register(Language* language) { | ||
EShSource source = language->Source(); | ||
languages[source] = language; | ||
} | ||
|
||
Language* Language::Get(EShSource source) { | ||
return languages[source]; | ||
} | ||
|
||
} // end namespace glslang | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
// | ||
// Copyright (C) 2020 Google, Inc. | ||
// | ||
// All rights reserved. | ||
// | ||
// Redistribution and use in source and binary forms, with or without | ||
// modification, are permitted provided that the following conditions | ||
// are met: | ||
// | ||
// Redistributions of source code must retain the above copyright | ||
// notice, this list of conditions and the following disclaimer. | ||
// | ||
// Redistributions in binary form must reproduce the above | ||
// copyright notice, this list of conditions and the following | ||
// disclaimer in the documentation and/or other materials provided | ||
// with the distribution. | ||
// | ||
// Neither the name of 3Dlabs Inc. Ltd. nor the names of its | ||
// contributors may be used to endorse or promote products derived | ||
// from this software without specific prior written permission. | ||
// | ||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
// COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, | ||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | ||
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN | ||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
// POSSIBILITY OF SUCH DAMAGE. | ||
// | ||
#ifndef _GLSLANG_LANGUAGE_INCLUDED_ | ||
#define _GLSLANG_LANGUAGE_INCLUDED_ | ||
|
||
#include "Initialize.h" | ||
|
||
namespace glslang { | ||
|
||
class TParseContextBase; | ||
|
||
// Language is an interface implemented by a source language. | ||
// Languages are registered by source (EShSource). | ||
class Language { | ||
public: | ||
virtual ~Language() {} | ||
|
||
// Register() registers the language. | ||
static void Register(Language*); | ||
|
||
// Get() returns the registered language for the given source type. | ||
static Language* Get(EShSource source); | ||
|
||
// InitializeAll() initializes all the registered languages. | ||
static void InitializeAll(); | ||
|
||
// TerminateAll() terminates all the registered languages. | ||
static void TerminateAll(); | ||
|
||
// Initialize() initializes the language. | ||
// Must be called, once, before any other method (with exception to Source()). | ||
virtual void Initialize() = 0; | ||
|
||
// Terminate() terminates the language. | ||
// Must be called, once, before process termination. | ||
// No method may be called after calling. | ||
virtual void Terminate() = 0; | ||
|
||
// Source() returns the EShSource that this language implements. | ||
virtual EShSource Source() const = 0; | ||
|
||
// CreateBuiltInParseables() constructs and returns the parseable strings | ||
// for the given language. | ||
virtual TBuiltInParseables* CreateBuiltInParseables(TInfoSink& infoSink) = 0; | ||
|
||
// CreateParseContext() constructs and returns the parse context for the | ||
// given language. | ||
virtual TParseContextBase* CreateParseContext(TSymbolTable& symbolTable, TIntermediate& intermediate, | ||
int version, EProfile profile, | ||
EShLanguage language, TInfoSink& infoSink, | ||
SpvVersion spvVersion, bool forwardCompatible, EShMessages messages, | ||
bool parsingBuiltIns, std::string sourceEntryPointName) = 0; | ||
}; | ||
|
||
} // end namespace glslang | ||
|
||
#endif // _GLSLANG_LANGUAGE_INCLUDED_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.