Skip to content

Commit 1ee5d1c

Browse files
authored
Merge pull request KhronosGroup#2330 from ShabbyX/optimize_for_angle
Optimize for angle
2 parents 906d48a + 59fb2d6 commit 1ee5d1c

27 files changed

+13706
-3146
lines changed

BUILD.gn

Lines changed: 19 additions & 2 deletions
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",
@@ -156,7 +155,7 @@ template("glslang_sources_common") {
156155
"glslang/MachineIndependent/attribute.cpp",
157156
"glslang/MachineIndependent/attribute.h",
158157
"glslang/MachineIndependent/gl_types.h",
159-
"glslang/MachineIndependent/glslang_tab.cpp",
158+
"glslang/MachineIndependent/glslang_angle_tab.cpp.h",
160159
"glslang/MachineIndependent/glslang_tab.cpp.h",
161160
"glslang/MachineIndependent/intermOut.cpp",
162161
"glslang/MachineIndependent/iomapper.cpp",
@@ -207,9 +206,25 @@ template("glslang_sources_common") {
207206
}
208207

209208
defines = []
209+
if (invoker.is_angle) {
210+
sources += [
211+
"glslang/MachineIndependent/glslang_angle_tab.cpp",
212+
]
213+
defines += [ "GLSLANG_ANGLE" ]
214+
}
215+
else {
216+
sources += [
217+
"glslang/MachineIndependent/glslang_tab.cpp",
218+
]
219+
}
220+
210221
if (invoker.enable_opt) {
222+
sources += [ "SPIRV/SpvTools.cpp" ]
211223
defines += [ "ENABLE_OPT=1" ]
212224
}
225+
if (invoker.is_angle) {
226+
defines += [ "GLSLANG_ANGLE" ]
227+
}
213228

214229
if (is_win) {
215230
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
@@ -257,11 +272,13 @@ template("glslang_sources_common") {
257272
glslang_sources_common("glslang_lib_sources") {
258273
enable_opt = !glslang_angle
259274
enable_hlsl = !glslang_angle
275+
is_angle = glslang_angle
260276
}
261277

262278
glslang_sources_common("glslang_sources") {
263279
enable_opt = true
264280
enable_hlsl = true
281+
is_angle = false
265282
}
266283

267284
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) {
@@ -8686,7 +8688,7 @@ void OutputSpvBin(const std::vector<unsigned int>& spirv, const char* baseName)
86868688
// Write SPIR-V out to a text file with 32-bit hexadecimal words
86878689
void OutputSpvHex(const std::vector<unsigned int>& spirv, const char* baseName, const char* varName)
86888690
{
8689-
#ifndef GLSLANG_WEB
8691+
#if !defined(GLSLANG_WEB) && !defined(GLSLANG_ANGLE)
86908692
std::ofstream out;
86918693
out.open(baseName, std::ios::binary | std::ios::out);
86928694
if (out.fail())

0 commit comments

Comments
 (0)