Skip to content

Commit 5743eed

Browse files
authored
Merge pull request KhronosGroup#2362 from ShabbyX/optimize_for_angle
Use GLSLANG_ANGLE to strip features to what ANGLE requires
2 parents 928b7b2 + 1ef2e25 commit 5743eed

17 files changed

+214
-102
lines changed

BUILD.gn

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ template("glslang_sources_common") {
109109
"SPIRV/SpvBuilder.cpp",
110110
"SPIRV/SpvBuilder.h",
111111
"SPIRV/SpvPostProcess.cpp",
112-
"SPIRV/SpvTools.cpp",
113112
"SPIRV/SpvTools.h",
114113
"SPIRV/bitutils.h",
115114
"SPIRV/disassemble.cpp",
@@ -208,8 +207,12 @@ template("glslang_sources_common") {
208207

209208
defines = []
210209
if (invoker.enable_opt) {
210+
sources += [ "SPIRV/SpvTools.cpp" ]
211211
defines += [ "ENABLE_OPT=1" ]
212212
}
213+
if (invoker.is_angle) {
214+
defines += [ "GLSLANG_ANGLE" ]
215+
}
213216

214217
if (is_win) {
215218
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
@@ -257,11 +260,13 @@ template("glslang_sources_common") {
257260
glslang_sources_common("glslang_lib_sources") {
258261
enable_opt = !glslang_angle
259262
enable_hlsl = !glslang_angle
263+
is_angle = glslang_angle
260264
}
261265

262266
glslang_sources_common("glslang_sources") {
263267
enable_opt = true
264268
enable_hlsl = true
269+
is_angle = false
265270
}
266271

267272
source_set("glslang_default_resource_limits_sources") {

SPIRV/GlslangToSpv.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,8 @@ spv::SourceLanguage TranslateSourceLanguage(glslang::EShSource source, EProfile
283283
{
284284
#ifdef GLSLANG_WEB
285285
return spv::SourceLanguageESSL;
286+
#elif defined(GLSLANG_ANGLE)
287+
return spv::SourceLanguageGLSL;
286288
#endif
287289

288290
switch (source) {
@@ -8694,7 +8696,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
86948696
// Write SPIR-V out to a text file with 32-bit hexadecimal words
86958697
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
86968698
{
8697-
#ifndef GLSLANG_WEB
8699+
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
86988700
std::ofstream out;
86998701
out.open(baseName, std::ios::binary | std::ios::out);
87008702
if (out.fail())

0 commit comments

Comments
 (0)