-
Notifications
You must be signed in to change notification settings - Fork 837
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Untangle build target cyclic dependencies #2267
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,6 +106,7 @@ source_set("glslang_sources") { | |
"glslang/MachineIndependent/Initialize.h", | ||
"glslang/MachineIndependent/IntermTraverse.cpp", | ||
"glslang/MachineIndependent/Intermediate.cpp", | ||
"glslang/MachineIndependent/Language.cpp", | ||
"glslang/MachineIndependent/LiveTraverser.h", | ||
"glslang/MachineIndependent/ParseContextBase.cpp", | ||
"glslang/MachineIndependent/ParseHelper.cpp", | ||
|
@@ -151,6 +152,7 @@ source_set("glslang_sources") { | |
"hlsl/hlslAttributes.h", | ||
"hlsl/hlslGrammar.cpp", | ||
"hlsl/hlslGrammar.h", | ||
"hlsl/hlslLanguage.cpp", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tabs versus spaces. |
||
"hlsl/hlslOpMap.cpp", | ||
"hlsl/hlslOpMap.h", | ||
"hlsl/hlslParseHelper.cpp", | ||
|
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,110 @@ | ||
/** | ||
This code is based on the glslang_c_interface implementation by Viktor Latypov | ||
**/ | ||
|
||
/** | ||
BSD 2-Clause License | ||
|
||
Copyright (c) 2019, Viktor Latypov | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. 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. | ||
|
||
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 HOLDER 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 "glslang/Include/glslang_c_interface.h" | ||
|
||
#include "SPIRV/GlslangToSpv.h" | ||
#include "SPIRV/Logger.h" | ||
#include "SPIRV/SpvTools.h" | ||
|
||
typedef struct glslang_program_s { | ||
glslang::TProgram* program; | ||
std::vector<unsigned int> spirv; | ||
std::string loggerMessages; | ||
} glslang_program_t; | ||
|
||
static EShLanguage c_shader_stage(glslang_stage_t stage) | ||
{ | ||
switch (stage) { | ||
case GLSLANG_STAGE_VERTEX: | ||
return EShLangVertex; | ||
case GLSLANG_STAGE_TESSCONTROL: | ||
return EShLangTessControl; | ||
case GLSLANG_STAGE_TESSEVALUATION: | ||
return EShLangTessEvaluation; | ||
case GLSLANG_STAGE_GEOMETRY: | ||
return EShLangGeometry; | ||
case GLSLANG_STAGE_FRAGMENT: | ||
return EShLangFragment; | ||
case GLSLANG_STAGE_COMPUTE: | ||
return EShLangCompute; | ||
case GLSLANG_STAGE_RAYGEN_NV: | ||
return EShLangRayGen; | ||
case GLSLANG_STAGE_INTERSECT_NV: | ||
return EShLangIntersect; | ||
case GLSLANG_STAGE_ANYHIT_NV: | ||
return EShLangAnyHit; | ||
case GLSLANG_STAGE_CLOSESTHIT_NV: | ||
return EShLangClosestHit; | ||
case GLSLANG_STAGE_MISS_NV: | ||
return EShLangMiss; | ||
case GLSLANG_STAGE_CALLABLE_NV: | ||
return EShLangCallable; | ||
case GLSLANG_STAGE_TASK_NV: | ||
return EShLangTaskNV; | ||
case GLSLANG_STAGE_MESH_NV: | ||
return EShLangMeshNV; | ||
default: | ||
break; | ||
} | ||
return EShLangCount; | ||
} | ||
|
||
void glslang_program_SPIRV_generate(glslang_program_t* program, glslang_stage_t stage) | ||
{ | ||
spv::SpvBuildLogger logger; | ||
glslang::SpvOptions spvOptions; | ||
spvOptions.validate = true; | ||
|
||
const glslang::TIntermediate* intermediate = program->program->getIntermediate(c_shader_stage(stage)); | ||
|
||
glslang::GlslangToSpv(*intermediate, program->spirv, &logger, &spvOptions); | ||
|
||
program->loggerMessages = logger.getAllMessages(); | ||
} | ||
|
||
size_t glslang_program_SPIRV_get_size(glslang_program_t* program) { return program->spirv.size(); } | ||
|
||
void glslang_program_SPIRV_get(glslang_program_t* program, unsigned int* out) | ||
{ | ||
memcpy(out, program->spirv.data(), program->spirv.size() * sizeof(unsigned int)); | ||
} | ||
|
||
unsigned int* glslang_program_SPIRV_get_ptr(glslang_program_t* program) | ||
{ | ||
return program->spirv.data(); | ||
} | ||
|
||
const char* glslang_program_SPIRV_get_messages(glslang_program_t* program) | ||
{ | ||
return program->loggerMessages.empty() ? nullptr : program->loggerMessages.c_str(); | ||
} |
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 |
---|---|---|
|
@@ -1250,6 +1250,10 @@ void CompileAndLinkShaderFiles(glslang::TWorklist& Worklist) | |
|
||
int singleMain() | ||
{ | ||
#ifdef ENABLE_HLSL | ||
glslang::RegisterHlslLanguage(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We won't need this if we can get HLSL to auto register (review comments below). |
||
#endif | ||
|
||
glslang::TWorklist workList; | ||
std::for_each(WorkItems.begin(), WorkItems.end(), [&workList](std::unique_ptr<glslang::TWorkItem>& item) { | ||
assert(item); | ||
|
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 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like mixing tabs and spaces.