gn: Optionally disable optimizations and HLSL
To reduce the binary size of ANGLE, a gn override is added (glslang_angle) which: - Controls whether ENABLE_OPT=1 is set - Customizes the build for the Vulkan backend of ANGLE. As a first step, this removes HLSL functionality which together with no optimization shave ~2.5MB off of ANGLE's binary size. Upcoming changes will add a macro for GLSLANG_ANGLE similar to GLSLANG_WEB that will strip features from glslang to support only what ANGLE needs. Signed-off-by: Shahbaz Youssefi <ShabbyX@gmail.com>
This commit is contained in:
parent
4728509962
commit
8f8f1bc518
65
BUILD.gn
65
BUILD.gn
@ -51,10 +51,13 @@ spirv_tools_dir = glslang_spirv_tools_dir
|
|||||||
config("glslang_public") {
|
config("glslang_public") {
|
||||||
include_dirs = [ "." ]
|
include_dirs = [ "." ]
|
||||||
|
|
||||||
|
if (!glslang_angle) {
|
||||||
defines = [ "ENABLE_HLSL=1" ]
|
defines = [ "ENABLE_HLSL=1" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
source_set("glslang_sources") {
|
template("glslang_sources_common") {
|
||||||
|
source_set(target_name) {
|
||||||
public_configs = [ ":glslang_public" ]
|
public_configs = [ ":glslang_public" ]
|
||||||
|
|
||||||
sources = [
|
sources = [
|
||||||
@ -88,21 +91,6 @@ source_set("glslang_sources") {
|
|||||||
"SPIRV/spvIR.h",
|
"SPIRV/spvIR.h",
|
||||||
"glslang/GenericCodeGen/CodeGen.cpp",
|
"glslang/GenericCodeGen/CodeGen.cpp",
|
||||||
"glslang/GenericCodeGen/Link.cpp",
|
"glslang/GenericCodeGen/Link.cpp",
|
||||||
"glslang/HLSL/hlslAttributes.cpp",
|
|
||||||
"glslang/HLSL/hlslAttributes.h",
|
|
||||||
"glslang/HLSL/hlslGrammar.cpp",
|
|
||||||
"glslang/HLSL/hlslGrammar.h",
|
|
||||||
"glslang/HLSL/hlslOpMap.cpp",
|
|
||||||
"glslang/HLSL/hlslOpMap.h",
|
|
||||||
"glslang/HLSL/hlslParseables.cpp",
|
|
||||||
"glslang/HLSL/hlslParseables.h",
|
|
||||||
"glslang/HLSL/hlslParseHelper.cpp",
|
|
||||||
"glslang/HLSL/hlslParseHelper.h",
|
|
||||||
"glslang/HLSL/hlslScanContext.cpp",
|
|
||||||
"glslang/HLSL/hlslScanContext.h",
|
|
||||||
"glslang/HLSL/hlslTokens.h",
|
|
||||||
"glslang/HLSL/hlslTokenStream.cpp",
|
|
||||||
"glslang/HLSL/hlslTokenStream.h",
|
|
||||||
"glslang/Include/BaseTypes.h",
|
"glslang/Include/BaseTypes.h",
|
||||||
"glslang/Include/Common.h",
|
"glslang/Include/Common.h",
|
||||||
"glslang/Include/ConstantUnion.h",
|
"glslang/Include/ConstantUnion.h",
|
||||||
@ -164,7 +152,30 @@ source_set("glslang_sources") {
|
|||||||
"glslang/Public/ShaderLang.h",
|
"glslang/Public/ShaderLang.h",
|
||||||
]
|
]
|
||||||
|
|
||||||
defines = [ "ENABLE_OPT=1" ]
|
if (!glslang_angle) {
|
||||||
|
sources += [
|
||||||
|
"glslang/HLSL/hlslAttributes.cpp",
|
||||||
|
"glslang/HLSL/hlslAttributes.h",
|
||||||
|
"glslang/HLSL/hlslGrammar.cpp",
|
||||||
|
"glslang/HLSL/hlslGrammar.h",
|
||||||
|
"glslang/HLSL/hlslOpMap.cpp",
|
||||||
|
"glslang/HLSL/hlslOpMap.h",
|
||||||
|
"glslang/HLSL/hlslParseables.cpp",
|
||||||
|
"glslang/HLSL/hlslParseables.h",
|
||||||
|
"glslang/HLSL/hlslParseHelper.cpp",
|
||||||
|
"glslang/HLSL/hlslParseHelper.h",
|
||||||
|
"glslang/HLSL/hlslScanContext.cpp",
|
||||||
|
"glslang/HLSL/hlslScanContext.h",
|
||||||
|
"glslang/HLSL/hlslTokens.h",
|
||||||
|
"glslang/HLSL/hlslTokenStream.cpp",
|
||||||
|
"glslang/HLSL/hlslTokenStream.h",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
defines = []
|
||||||
|
if (invoker.enable_opt) {
|
||||||
|
defines += [ "ENABLE_OPT=1" ]
|
||||||
|
}
|
||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
|
sources += [ "glslang/OSDependent/Windows/ossource.cpp" ]
|
||||||
@ -193,13 +204,24 @@ source_set("glslang_sources") {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (invoker.enable_opt) {
|
||||||
deps = [
|
deps = [
|
||||||
"${spirv_tools_dir}:spvtools_opt",
|
"${spirv_tools_dir}:spvtools_opt",
|
||||||
"${spirv_tools_dir}:spvtools_val",
|
"${spirv_tools_dir}:spvtools_val"
|
||||||
]
|
]
|
||||||
|
}
|
||||||
|
|
||||||
configs -= _configs_to_remove
|
configs -= _configs_to_remove
|
||||||
configs += _configs_to_add
|
configs += _configs_to_add
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glslang_sources_common("glslang_sources") {
|
||||||
|
enable_opt = !glslang_angle
|
||||||
|
}
|
||||||
|
|
||||||
|
glslang_sources_common("glslang_standalone_sources") {
|
||||||
|
enable_opt = true
|
||||||
}
|
}
|
||||||
|
|
||||||
source_set("glslang_default_resource_limits_sources") {
|
source_set("glslang_default_resource_limits_sources") {
|
||||||
@ -207,9 +229,6 @@ source_set("glslang_default_resource_limits_sources") {
|
|||||||
"StandAlone/ResourceLimits.cpp",
|
"StandAlone/ResourceLimits.cpp",
|
||||||
"StandAlone/ResourceLimits.h",
|
"StandAlone/ResourceLimits.h",
|
||||||
]
|
]
|
||||||
deps = [
|
|
||||||
":glslang_sources",
|
|
||||||
]
|
|
||||||
public_configs = [ ":glslang_public" ]
|
public_configs = [ ":glslang_public" ]
|
||||||
|
|
||||||
configs -= _configs_to_remove
|
configs -= _configs_to_remove
|
||||||
@ -227,7 +246,7 @@ executable("glslang_validator") {
|
|||||||
defines = [ "ENABLE_OPT=1" ]
|
defines = [ "ENABLE_OPT=1" ]
|
||||||
deps = [
|
deps = [
|
||||||
":glslang_default_resource_limits_sources",
|
":glslang_default_resource_limits_sources",
|
||||||
":glslang_sources",
|
":glslang_standalone_sources",
|
||||||
]
|
]
|
||||||
|
|
||||||
configs -= _configs_to_remove
|
configs -= _configs_to_remove
|
||||||
@ -240,7 +259,7 @@ executable("spirv-remap") {
|
|||||||
]
|
]
|
||||||
defines = [ "ENABLE_OPT=1" ]
|
defines = [ "ENABLE_OPT=1" ]
|
||||||
deps = [
|
deps = [
|
||||||
":glslang_sources",
|
":glslang_standalone_sources",
|
||||||
]
|
]
|
||||||
|
|
||||||
configs -= _configs_to_remove
|
configs -= _configs_to_remove
|
||||||
|
Loading…
x
Reference in New Issue
Block a user