Skip to content

Commit 8c49d15

Browse files
committed
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: Shahbaz Youssefi <[email protected]>
1 parent f5ed7a6 commit 8c49d15

17 files changed

+215
-103
lines changed

BUILD.gn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ template("glslang_sources_common") {
8383
"SPIRV/SpvBuilder.cpp",
8484
"SPIRV/SpvBuilder.h",
8585
"SPIRV/SpvPostProcess.cpp",
86-
"SPIRV/SpvTools.cpp",
8786
"SPIRV/SpvTools.h",
8887
"SPIRV/bitutils.h",
8988
"SPIRV/disassemble.cpp",
@@ -183,8 +182,12 @@ template("glslang_sources_common") {
183182

184183
defines = []
185184
if (invoker.enable_opt) {
185+
sources += [ "SPIRV/SpvTools.cpp" ]
186186
defines += [ "ENABLE_OPT=1" ]
187187
}
188+
if (invoker.is_angle) {
189+
defines += [ "GLSLANG_ANGLE" ]
190+
}
188191

189192
if (is_win) {
190193
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
@@ -228,11 +231,13 @@ template("glslang_sources_common") {
228231
glslang_sources_common("glslang_lib_sources") {
229232
enable_opt = !glslang_angle
230233
enable_hlsl = !glslang_angle
234+
is_angle = glslang_angle
231235
}
232236

233237
glslang_sources_common("glslang_sources") {
234238
enable_opt = true
235239
enable_hlsl = true
240+
is_angle = false
236241
}
237242

238243
source_set("glslang_default_resource_limits_sources") {

SPIRV/GlslangToSpv.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
281281
{
282282
#ifdef GLSLANG_WEB
283283
return spv::SourceLanguageESSL;
284+
#elif defined(GLSLANG_ANGLE)
285+
return spv::SourceLanguageGLSL;
284286
#endif
285287

286288
switch (source) {
@@ -8684,7 +8686,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
86848686
// Write SPIR-V out to a text file with 32-bit hexadecimal words
86858687
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
86868688
{
8687-
#ifndef GLSLANG_WEB
8689+
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
86888690
std::ofstream out;
86898691
out.open(baseName, std::ios::binary | std::ios::out);
86908692
if (out.fail())

0 commit comments

Comments
 (0)