Use GLSLANG_ANGLE to strip features to what ANGLE requires

This change strips a few features similar to GLSLANG_WEB but doesn't remove every detail like the latter. It also hardcodes profile/version to core/450. In particular, TBuiltIns::initialize is specialized to remove most of what is not supported or won't be supported by ANGLE. The result of this function is parsed with TParseContext::parseShaderStrings which is a performance bottleneck. This change shaves about 300KB off of ANGLE's binary size and reduces the cost of SetupBuiltinSymbolTable to nearly a sixth. Signed-off-by: 's avatarShahbaz Youssefi <ShabbyX@gmail.com>
parent f5ed7a69
...@@ -83,7 +83,6 @@ template("glslang_sources_common") { ...@@ -83,7 +83,6 @@ template("glslang_sources_common") {
"SPIRV/SpvBuilder.cpp", "SPIRV/SpvBuilder.cpp",
"SPIRV/SpvBuilder.h", "SPIRV/SpvBuilder.h",
"SPIRV/SpvPostProcess.cpp", "SPIRV/SpvPostProcess.cpp",
"SPIRV/SpvTools.cpp",
"SPIRV/SpvTools.h", "SPIRV/SpvTools.h",
"SPIRV/bitutils.h", "SPIRV/bitutils.h",
"SPIRV/disassemble.cpp", "SPIRV/disassemble.cpp",
...@@ -183,8 +182,12 @@ template("glslang_sources_common") { ...@@ -183,8 +182,12 @@ template("glslang_sources_common") {
defines = [] defines = []
if (invoker.enable_opt) { if (invoker.enable_opt) {
sources += [ "SPIRV/SpvTools.cpp" ]
defines += [ "ENABLE_OPT=1" ] defines += [ "ENABLE_OPT=1" ]
} }
if (invoker.is_angle) {
defines += [ "GLSLANG_ANGLE" ]
}
if (is_win) { if (is_win) {
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ] sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
...@@ -228,11 +231,13 @@ template("glslang_sources_common") { ...@@ -228,11 +231,13 @@ template("glslang_sources_common") {
glslang_sources_common("glslang_lib_sources") { glslang_sources_common("glslang_lib_sources") {
enable_opt = !glslang_angle enable_opt = !glslang_angle
enable_hlsl = !glslang_angle enable_hlsl = !glslang_angle
is_angle = glslang_angle
} }
glslang_sources_common("glslang_sources") { glslang_sources_common("glslang_sources") {
enable_opt = true enable_opt = true
enable_hlsl = true enable_hlsl = true
is_angle = false
} }
source_set("glslang_default_resource_limits_sources") { source_set("glslang_default_resource_limits_sources") {
......
...@@ -281,6 +281,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile ...@@ -281,6 +281,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
{ {
#ifdef GLSLANG_WEB #ifdef GLSLANG_WEB
return spv::SourceLanguageESSL; return spv::SourceLanguageESSL;
#elif defined(GLSLANG_ANGLE)
return spv::SourceLanguageGLSL;
#endif #endif
switch (source) { switch (source) {
...@@ -8684,7 +8686,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName) ...@@ -8684,7 +8686,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
// Write SPIR-V out to a text file with 32-bit hexadecimal words // Write SPIR-V out to a text file with 32-bit hexadecimal words
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName) void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
{ {
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
std::ofstream out; std::ofstream out;
out.open(baseName, std::ios::binary | std::ios::out); out.open(baseName, std::ios::binary | std::ios::out);
if (out.fail()) if (out.fail())
......
...@@ -291,6 +291,9 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi ...@@ -291,6 +291,9 @@ void InitializeStageSymbolTable(TBuiltInParseables& builtInParseables, int versi
#ifdef GLSLANG_WEB #ifdef GLSLANG_WEB
profile = EEsProfile; profile = EEsProfile;
version = 310; version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif #endif
(*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]); (*symbolTables[language]).adoptLevels(*commonTable[CommonIndex(profile, language)]);
...@@ -312,6 +315,9 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS ...@@ -312,6 +315,9 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
#ifdef GLSLANG_WEB #ifdef GLSLANG_WEB
profile = EEsProfile; profile = EEsProfile;
version = 310; version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif #endif
std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source)); std::unique_ptr<TBuiltInParseables> builtInParseables(CreateBuiltInParseables(infoSink, source));
...@@ -351,7 +357,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS ...@@ -351,7 +357,6 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
(profile == EEsProfile && version >= 310)) (profile == EEsProfile && version >= 310))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangGeometry, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
#endif
// check for compute // check for compute
if ((profile != EEsProfile && version >= 420) || if ((profile != EEsProfile && version >= 420) ||
...@@ -359,6 +364,7 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS ...@@ -359,6 +364,7 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangCompute, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
#ifndef GLSLANG_ANGLE
// check for ray tracing stages // check for ray tracing stages
if (profile != EEsProfile && version >= 450) { if (profile != EEsProfile && version >= 450) {
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangRayGen, source,
...@@ -386,6 +392,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS ...@@ -386,6 +392,8 @@ bool InitializeSymbolTables(TInfoSink& infoSink, TSymbolTable** commonTable, TS
(profile == EEsProfile && version >= 320)) (profile == EEsProfile && version >= 320))
InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source, InitializeStageSymbolTable(*builtInParseables, version, profile, spvVersion, EShLangTaskNV, source,
infoSink, commonTable, symbolTables); infoSink, commonTable, symbolTables);
#endif // !GLSLANG_ANGLE
#endif // !GLSLANG_WEB
return true; return true;
} }
...@@ -487,7 +495,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp ...@@ -487,7 +495,7 @@ void SetupBuiltinSymbolTable(int version, EProfile profile, const SpvVersion& sp
// Function to Print all builtins // Function to Print all builtins
void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable) void DumpBuiltinSymbolTable(TInfoSink& infoSink, const TSymbolTable& symbolTable)
{ {
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
infoSink.debug << "BuiltinSymbolTable {\n"; infoSink.debug << "BuiltinSymbolTable {\n";
symbolTable.dump(infoSink, true); symbolTable.dump(infoSink, true);
...@@ -591,7 +599,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo ...@@ -591,7 +599,7 @@ bool DeduceVersionProfile(TInfoSink& infoSink, EShLanguage stage, bool versionNo
break; break;
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Correct for stage type... // Correct for stage type...
switch (stage) { switch (stage) {
case EShLangGeometry: case EShLangGeometry:
...@@ -867,7 +875,7 @@ bool ProcessDeferred( ...@@ -867,7 +875,7 @@ bool ProcessDeferred(
: userInput.scanVersion(version, profile, versionNotFirstToken); : userInput.scanVersion(version, profile, versionNotFirstToken);
bool versionNotFound = version == 0; bool versionNotFound = version == 0;
if (forceDefaultVersionAndProfile && source == EShSourceGlsl) { if (forceDefaultVersionAndProfile && source == EShSourceGlsl) {
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound && if (! (messages & EShMsgSuppressWarnings) && ! versionNotFound &&
(version != defaultVersion || profile != defaultProfile)) { (version != defaultVersion || profile != defaultProfile)) {
compiler->infoSink.info << "Warning, (version, profile) forced to be (" compiler->infoSink.info << "Warning, (version, profile) forced to be ("
...@@ -890,10 +898,13 @@ bool ProcessDeferred( ...@@ -890,10 +898,13 @@ bool ProcessDeferred(
#ifdef GLSLANG_WEB #ifdef GLSLANG_WEB
profile = EEsProfile; profile = EEsProfile;
version = 310; version = 310;
#elif defined(GLSLANG_ANGLE)
profile = ECoreProfile;
version = 450;
#endif #endif
bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst)); bool versionWillBeError = (versionNotFound || (profile == EEsProfile && version >= 300 && versionNotFirst));
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool warnVersionNotFirst = false; bool warnVersionNotFirst = false;
if (! versionWillBeError && versionNotFirstToken) { if (! versionWillBeError && versionNotFirstToken) {
if (messages & EShMsgRelaxedErrors) if (messages & EShMsgRelaxedErrors)
...@@ -963,7 +974,7 @@ bool ProcessDeferred( ...@@ -963,7 +974,7 @@ bool ProcessDeferred(
parseContext->setLimits(*resources); parseContext->setLimits(*resources);
if (! goodVersion) if (! goodVersion)
parseContext->addError(); parseContext->addError();
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (warnVersionNotFirst) { if (warnVersionNotFirst) {
TSourceLoc loc; TSourceLoc loc;
loc.init(); loc.init();
...@@ -1000,7 +1011,7 @@ bool ProcessDeferred( ...@@ -1000,7 +1011,7 @@ bool ProcessDeferred(
return success; return success;
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Responsible for keeping track of the most recent source string and line in // Responsible for keeping track of the most recent source string and line in
// the preprocessor and outputting newlines appropriately if the source string // the preprocessor and outputting newlines appropriately if the source string
...@@ -1223,14 +1234,16 @@ struct DoFullParse{ ...@@ -1223,14 +1234,16 @@ struct DoFullParse{
parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n"; parseContext.infoSink.info << parseContext.getNumErrors() << " compilation errors. No code generated.\n\n";
} }
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST) if (messages & EShMsgAST)
intermediate.output(parseContext.infoSink, true); intermediate.output(parseContext.infoSink, true);
#endif
return success; return success;
} }
}; };
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Take a single compilation unit, and run the preprocessor on it. // Take a single compilation unit, and run the preprocessor on it.
// Return: True if there were no issues found in preprocessing, // Return: True if there were no issues found in preprocessing,
// False if during preprocessing any unknown version, pragmas or // False if during preprocessing any unknown version, pragmas or
...@@ -1860,7 +1873,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion ...@@ -1860,7 +1873,7 @@ bool TShader::parse(const TBuiltInResource* builtInResources, int defaultVersion
&environment); &environment);
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Fill in a string with the result of preprocessing ShaderStrings // Fill in a string with the result of preprocessing ShaderStrings
// Returns true if all extensions, pragmas and version strings were valid. // Returns true if all extensions, pragmas and version strings were valid.
// //
...@@ -1898,7 +1911,7 @@ const char* TShader::getInfoDebugLog() ...@@ -1898,7 +1911,7 @@ const char* TShader::getInfoDebugLog()
} }
TProgram::TProgram() : TProgram::TProgram() :
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
reflection(0), reflection(0),
#endif #endif
linked(false) linked(false)
...@@ -1914,7 +1927,7 @@ TProgram::TProgram() : ...@@ -1914,7 +1927,7 @@ TProgram::TProgram() :
TProgram::~TProgram() TProgram::~TProgram()
{ {
delete infoSink; delete infoSink;
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
delete reflection; delete reflection;
#endif #endif
...@@ -1961,7 +1974,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages) ...@@ -1961,7 +1974,7 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
if (stages[stage].size() == 0) if (stages[stage].size() == 0)
return true; return true;
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
int numEsShaders = 0, numNonEsShaders = 0; int numEsShaders = 0, numNonEsShaders = 0;
for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) { for (auto it = stages[stage].begin(); it != stages[stage].end(); ++it) {
if ((*it)->intermediate->getProfile() == EEsProfile) { if ((*it)->intermediate->getProfile() == EEsProfile) {
...@@ -2015,8 +2028,10 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages) ...@@ -2015,8 +2028,10 @@ bool TProgram::linkStage(EShLanguage stage, EShMessages messages)
#endif #endif
intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0); intermediate[stage]->finalCheck(*infoSink, (messages & EShMsgKeepUncalled) != 0);
#ifndef GLSLANG_ANGLE
if (messages & EShMsgAST) if (messages & EShMsgAST)
intermediate[stage]->output(*infoSink, true); intermediate[stage]->output(*infoSink, true);
#endif
return intermediate[stage]->getNumErrors() == 0; return intermediate[stage]->getNumErrors() == 0;
} }
...@@ -2031,7 +2046,7 @@ const char* TProgram::getInfoDebugLog() ...@@ -2031,7 +2046,7 @@ const char* TProgram::getInfoDebugLog()
return infoSink->debug.c_str(); return infoSink->debug.c_str();
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// //
// Reflection implementation. // Reflection implementation.
...@@ -2113,6 +2128,6 @@ bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper) ...@@ -2113,6 +2128,6 @@ bool TProgram::mapIO(TIoMapResolver* pResolver, TIoMapper* pIoMapper)
return ioMapper->doMap(pResolver, *infoSink); return ioMapper->doMap(pResolver, *infoSink);
} }
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
} // end namespace glslang } // end namespace glslang
...@@ -178,7 +178,7 @@ void TType::buildMangledName(TString& mangledName) const ...@@ -178,7 +178,7 @@ void TType::buildMangledName(TString& mangledName) const
} }
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// //
// Dump functions. // Dump functions.
......
...@@ -117,7 +117,7 @@ public: ...@@ -117,7 +117,7 @@ public:
virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); } virtual int getNumExtensions() const { return extensions == nullptr ? 0 : (int)extensions->size(); }
virtual const char** getExtensions() const { return extensions->data(); } virtual const char** getExtensions() const { return extensions->data(); }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0; virtual void dump(TInfoSink& infoSink, bool complete = false) const = 0;
void dumpExtensions(TInfoSink& infoSink) const; void dumpExtensions(TInfoSink& infoSink) const;
#endif #endif
...@@ -196,7 +196,7 @@ public: ...@@ -196,7 +196,7 @@ public:
} }
virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); } virtual const char** getMemberExtensions(int member) const { return (*memberExtensions)[member].data(); }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const; virtual void dump(TInfoSink& infoSink, bool complete = false) const;
#endif #endif
...@@ -319,7 +319,7 @@ public: ...@@ -319,7 +319,7 @@ public:
virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; } virtual TParameter& operator[](int i) { assert(writable); return parameters[i]; }
virtual const TParameter& operator[](int i) const { return parameters[i]; } virtual const TParameter& operator[](int i) const { return parameters[i]; }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override; virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif #endif
...@@ -381,7 +381,7 @@ public: ...@@ -381,7 +381,7 @@ public:
virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); } virtual const char** getExtensions() const override { return anonContainer.getMemberExtensions(memberNumber); }
virtual int getAnonId() const { return anonId; } virtual int getAnonId() const { return anonId; }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
virtual void dump(TInfoSink& infoSink, bool complete = false) const override; virtual void dump(TInfoSink& infoSink, bool complete = false) const override;
#endif #endif
...@@ -551,7 +551,7 @@ public: ...@@ -551,7 +551,7 @@ public:
void relateToOperator(const char* name, TOperator op); void relateToOperator(const char* name, TOperator op);
void setFunctionExtensions(const char* name, int num, const char* const extensions[]); void setFunctionExtensions(const char* name, int num, const char* const extensions[]);
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const; void dump(TInfoSink& infoSink, bool complete = false) const;
#endif #endif
TSymbolTableLevel* clone() const; TSymbolTableLevel* clone() const;
...@@ -854,7 +854,7 @@ public: ...@@ -854,7 +854,7 @@ public:
} }
int getMaxSymbolId() { return uniqueId; } int getMaxSymbolId() { return uniqueId; }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
void dump(TInfoSink& infoSink, bool complete = false) const; void dump(TInfoSink& infoSink, bool complete = false) const;
#endif #endif
void copyTable(const TSymbolTable& copyOf); void copyTable(const TSymbolTable& copyOf);
......
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
// //
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "localintermediate.h" #include "localintermediate.h"
#include "../Include/InfoSink.h" #include "../Include/InfoSink.h"
...@@ -1562,4 +1562,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree) ...@@ -1562,4 +1562,4 @@ void TIntermediate::output(TInfoSink& infoSink, bool tree)
} // end namespace glslang } // end namespace glslang
#endif // not GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
// //
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h" #include "../Include/Common.h"
#include "../Include/InfoSink.h" #include "../Include/InfoSink.h"
...@@ -1281,4 +1281,4 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) { ...@@ -1281,4 +1281,4 @@ bool TGlslIoMapper::doMap(TIoMapResolver* resolver, TInfoSink& infoSink) {
} // end namespace glslang } // end namespace glslang
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
// //
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _IOMAPPER_INCLUDED #ifndef _IOMAPPER_INCLUDED
#define _IOMAPPER_INCLUDED #define _IOMAPPER_INCLUDED
...@@ -186,7 +186,7 @@ protected: ...@@ -186,7 +186,7 @@ protected:
} }
}; };
// Defaulf I/O resolver for OpenGL // Default I/O resolver for OpenGL
struct TDefaultGlslIoResolver : public TDefaultIoResolverBase { struct TDefaultGlslIoResolver : public TDefaultIoResolverBase {
public: public:
typedef std::map<TString, int> TVarSlotMap; // <resourceName, location/binding> typedef std::map<TString, int> TVarSlotMap; // <resourceName, location/binding>
...@@ -299,4 +299,4 @@ public: ...@@ -299,4 +299,4 @@ public:
#endif // _IOMAPPER_INCLUDED #endif // _IOMAPPER_INCLUDED
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
...@@ -82,7 +82,7 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message) ...@@ -82,7 +82,7 @@ void TIntermediate::warn(TInfoSink& infoSink, const char* message)
// //
void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit) void TIntermediate::merge(TInfoSink& infoSink, TIntermediate& unit)
{ {
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
mergeCallGraphs(infoSink, unit); mergeCallGraphs(infoSink, unit);
mergeModes(infoSink, unit); mergeModes(infoSink, unit);
mergeTrees(infoSink, unit); mergeTrees(infoSink, unit);
...@@ -104,7 +104,7 @@ void TIntermediate::mergeCallGraphs(TInfoSink& infoSink, TIntermediate& unit) ...@@ -104,7 +104,7 @@ void TIntermediate::mergeCallGraphs(TInfoSink& infoSink, TIntermediate& unit)
callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end()); callGraph.insert(callGraph.end(), unit.callGraph.begin(), unit.callGraph.end());
} }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#define MERGE_MAX(member) member = std::max(member, unit.member) #define MERGE_MAX(member) member = std::max(member, unit.member)
#define MERGE_TRUE(member) if (unit.member) member = unit.member; #define MERGE_TRUE(member) if (unit.member) member = unit.member;
...@@ -533,7 +533,7 @@ void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType) ...@@ -533,7 +533,7 @@ void TIntermediate::mergeImplicitArraySizes(TType& type, const TType& unitType)
// //
void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage) void TIntermediate::mergeErrorCheck(TInfoSink& infoSink, const TIntermSymbol& symbol, const TIntermSymbol& unitSymbol, bool crossStage)
{ {
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
bool writeTypeComparison = false; bool writeTypeComparison = false;
// Types have to match // Types have to match
......
...@@ -241,7 +241,10 @@ class TIntermediate { ...@@ -241,7 +241,10 @@ class TIntermediate {
public: public:
explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) : explicit TIntermediate(EShLanguage l, int v = 0, EProfile p = ENoProfile) :
language(l), language(l),
profile(p), version(v), treeRoot(0), #ifndef GLSLANG_ANGLE
profile(p), version(v),
#endif
treeRoot(0),
numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false), numEntryPoints(0), numErrors(0), numPushConstants(0), recursive(false),
invertY(false), invertY(false),
useStorageBuffer(false), useStorageBuffer(false),
...@@ -295,9 +298,20 @@ public: ...@@ -295,9 +298,20 @@ public:
#endif #endif
} }
void setVersion(int v) { version = v; } void setVersion(int v)
{
#ifndef GLSLANG_ANGLE
version = v;
#endif
}
void setProfile(EProfile p)
{
#ifndef GLSLANG_ANGLE
profile = p;
#endif
}
int getVersion() const { return version; } int getVersion() const { return version; }
void setProfile(EProfile p) { profile = p; }
EProfile getProfile() const { return profile; } EProfile getProfile() const { return profile; }
void setSpv(const SpvVersion& s) void setSpv(const SpvVersion& s)
{ {
...@@ -929,8 +943,13 @@ protected: ...@@ -929,8 +943,13 @@ protected:
typedef std::list<TCall> TGraph; typedef std::list<TCall> TGraph;
TGraph callGraph; TGraph callGraph;
#ifdef GLSLANG_ANGLE
const EProfile profile = ECoreProfile;
const int version = 450;
#else
EProfile profile; // source profile EProfile profile; // source profile
int version; // source version int version; // source version
#endif
SpvVersion spvVersion; SpvVersion spvVersion;
TIntermNode* treeRoot; TIntermNode* treeRoot;
std::map<std::string, TExtensionBehavior> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them std::map<std::string, TExtensionBehavior> requestedExtensions; // cumulation of all enabled or required extensions; not connected to what subset of the shader used them
......
...@@ -58,7 +58,7 @@ public: ...@@ -58,7 +58,7 @@ public:
const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink, const SpvVersion& spvVersion, EShLanguage language, TInfoSink& infoSink,
bool forwardCompatible, EShMessages messages) bool forwardCompatible, EShMessages messages)
: :
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
forwardCompatible(forwardCompatible), forwardCompatible(forwardCompatible),
profile(profile), profile(profile),
#endif #endif
...@@ -117,8 +117,13 @@ public: ...@@ -117,8 +117,13 @@ public:
bool suppressWarnings() const { return true; } bool suppressWarnings() const { return true; }
bool isForwardCompatible() const { return false; } bool isForwardCompatible() const { return false; }
#else #else
#ifdef GLSLANG_ANGLE
const bool forwardCompatible = true;
const EProfile profile = ECoreProfile;
#else
bool forwardCompatible; // true if errors are to be given for use of deprecated features bool forwardCompatible; // true if errors are to be given for use of deprecated features
EProfile profile; // the declared profile in the shader (core by default) EProfile profile; // the declared profile in the shader (core by default)
#endif
bool isEsProfile() const { return profile == EEsProfile; } bool isEsProfile() const { return profile == EEsProfile; }
void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc); void requireProfile(const TSourceLoc& loc, int profileMask, const char* featureDesc);
void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions, void profileRequires(const TSourceLoc& loc, int profileMask, int minVersion, int numExtensions,
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
// //
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#include "../Include/Common.h" #include "../Include/Common.h"
#include "reflection.h" #include "reflection.h"
...@@ -1266,4 +1266,4 @@ void TReflection::dump() ...@@ -1266,4 +1266,4 @@ void TReflection::dump()
} // end namespace glslang } // end namespace glslang
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
// POSSIBILITY OF SUCH DAMAGE. // POSSIBILITY OF SUCH DAMAGE.
// //
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
#ifndef _REFLECTION_INCLUDED #ifndef _REFLECTION_INCLUDED
#define _REFLECTION_INCLUDED #define _REFLECTION_INCLUDED
...@@ -220,4 +220,4 @@ protected: ...@@ -220,4 +220,4 @@ protected:
#endif // _REFLECTION_INCLUDED #endif // _REFLECTION_INCLUDED
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
...@@ -687,7 +687,7 @@ private: ...@@ -687,7 +687,7 @@ private:
TShader& operator=(TShader&); TShader& operator=(TShader&);
}; };
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// //
// A reflection database and its interface, consistent with the OpenGL API reflection queries. // A reflection database and its interface, consistent with the OpenGL API reflection queries.
...@@ -805,7 +805,7 @@ public: ...@@ -805,7 +805,7 @@ public:
virtual void addStage(EShLanguage stage) = 0; virtual void addStage(EShLanguage stage) = 0;
}; };
#endif // GLSLANG_WEB #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
// Make one TProgram per set of shaders that will get linked together. Add all // Make one TProgram per set of shaders that will get linked together. Add all
// the shaders that are to be linked together. After calling shader.parse() // the shaders that are to be linked together. After calling shader.parse()
...@@ -826,7 +826,7 @@ public: ...@@ -826,7 +826,7 @@ public:
TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; } TIntermediate* getIntermediate(EShLanguage stage) const { return intermediate[stage]; }
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
// Reflection Interface // Reflection Interface
...@@ -920,7 +920,7 @@ public: ...@@ -920,7 +920,7 @@ public:
// If resolver is not provided it uses the previous approach // If resolver is not provided it uses the previous approach
// and respects auto assignment and offsets. // and respects auto assignment and offsets.
GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr); GLSLANG_EXPORT bool mapIO(TIoMapResolver* pResolver = nullptr, TIoMapper* pIoMapper = nullptr);
#endif #endif // !GLSLANG_WEB && !GLSLANG_ANGLE
protected: protected:
GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages); GLSLANG_EXPORT bool linkStage(EShLanguage, EShMessages);
...@@ -930,7 +930,7 @@ protected: ...@@ -930,7 +930,7 @@ protected:
TIntermediate* intermediate[EShLangCount]; TIntermediate* intermediate[EShLangCount];
bool newedIntermediate[EShLangCount]; // track which intermediate were "new" versus reusing a singleton unit in a stage bool newedIntermediate[EShLangCount]; // track which intermediate were "new" versus reusing a singleton unit in a stage
TInfoSink* infoSink; TInfoSink* infoSink;
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
TReflection* reflection; TReflection* reflection;
#endif #endif
bool linked; bool linked;
......
...@@ -75,7 +75,7 @@ TEST_P(LinkTestVulkan, FromFile) ...@@ -75,7 +75,7 @@ TEST_P(LinkTestVulkan, FromFile)
result.linkingOutput = program.getInfoLog(); result.linkingOutput = program.getInfoLog();
result.linkingError = program.getInfoDebugLog(); result.linkingError = program.getInfoDebugLog();
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success) if (success)
program.mapIO(); program.mapIO();
#endif #endif
......
...@@ -253,7 +253,7 @@ public: ...@@ -253,7 +253,7 @@ public:
glslang::TProgram program; glslang::TProgram program;
program.addShader(&shader); program.addShader(&shader);
success &= program.link(controls); success &= program.link(controls);
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success) if (success)
program.mapIO(); program.mapIO();
#endif #endif
...@@ -315,7 +315,7 @@ public: ...@@ -315,7 +315,7 @@ public:
program.addShader(&shader); program.addShader(&shader);
success &= program.link(controls); success &= program.link(controls);
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success) if (success)
program.mapIO(); program.mapIO();
#endif #endif
...@@ -360,7 +360,7 @@ public: ...@@ -360,7 +360,7 @@ public:
glslang::TProgram program; glslang::TProgram program;
program.addShader(&shader); program.addShader(&shader);
success &= program.link(controls); success &= program.link(controls);
#ifndef GLSLANG_WEB #if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
if (success) if (success)
program.mapIO(); program.mapIO();
#endif #endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment