Commit 0973dd68 by Shahbaz Youssefi Committed by Commit Bot

Add a gl-d3d-only target for the translator

Chrome's validating command decoder links statically with the ANGLE translator. This change adds a target that builds the translator with only gl and d3d support for this purpose. This will prevent chrome from linking against glslang because of the Vulkan backend. As a bonus, it will reduce the binary size of Chrome by stipping the Vulkan and Metal translation and transformation codes. Bug: angleproject:5810 Change-Id: I5673bad53817ff2aa8486622ff2c64b44c77240f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2797511Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent fd3b8faf
...@@ -494,91 +494,99 @@ angle_source_set("angle_translator_headers") { ...@@ -494,91 +494,99 @@ angle_source_set("angle_translator_headers") {
public_deps = [ ":includes" ] public_deps = [ ":includes" ]
} }
angle_static_library("translator") { template("translator_lib") {
sources = angle_translator_sources angle_static_library(target_name) {
defines = [] sources = angle_translator_sources
defines = []
_needs_glsl_base = false
_needs_glsl_and_vulkan_base = false _needs_glsl_base = false
_uses_spirv = false _needs_glsl_and_vulkan_base = false
_uses_spirv = false
if (angle_enable_essl || use_fuzzing_engine) {
_needs_glsl_base = true if (angle_enable_essl || use_fuzzing_engine) {
sources += angle_translator_essl_sources _needs_glsl_base = true
defines += [ "ANGLE_ENABLE_ESSL" ] sources += angle_translator_essl_sources
} defines += [ "ANGLE_ENABLE_ESSL" ]
}
if (angle_enable_glsl || use_fuzzing_engine) { if (angle_enable_glsl || use_fuzzing_engine) {
_needs_glsl_base = true _needs_glsl_base = true
_needs_glsl_and_vulkan_base = true _needs_glsl_and_vulkan_base = true
sources += angle_translator_glsl_sources sources += angle_translator_glsl_sources
if (is_apple) { if (is_apple) {
sources += angle_translator_glsl_mac_sources sources += angle_translator_glsl_mac_sources
}
defines += [ "ANGLE_ENABLE_GLSL" ]
} }
defines += [ "ANGLE_ENABLE_GLSL" ]
}
if (angle_enable_hlsl || use_fuzzing_engine) { if (angle_enable_hlsl || use_fuzzing_engine) {
sources += angle_translator_hlsl_sources sources += angle_translator_hlsl_sources
defines += [ "ANGLE_ENABLE_HLSL" ] defines += [ "ANGLE_ENABLE_HLSL" ]
} }
if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) { if (!invoker.gl_d3d_only) {
_needs_glsl_base = true if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) {
_needs_glsl_and_vulkan_base = true _needs_glsl_base = true
_uses_spirv = true _needs_glsl_and_vulkan_base = true
_uses_spirv = true
# This translator is needed by metal backend also. # This translator is needed by metal backend also.
sources += angle_translator_lib_vulkan_sources sources += angle_translator_lib_vulkan_sources
} }
if (_needs_glsl_base) { if (angle_enable_vulkan || use_fuzzing_engine) {
sources += angle_translator_glsl_base_sources defines += [ "ANGLE_ENABLE_VULKAN" ]
} }
if (_needs_glsl_and_vulkan_base) {
sources += angle_translator_glsl_and_vulkan_base_sources
}
if (angle_enable_vulkan || use_fuzzing_engine) { if (angle_enable_metal) {
defines += [ "ANGLE_ENABLE_VULKAN" ] sources += angle_translator_lib_metal_sources
} defines += [ "ANGLE_ENABLE_METAL" ]
}
}
if (angle_enable_metal) { if (_needs_glsl_base) {
sources += angle_translator_lib_metal_sources sources += angle_translator_glsl_base_sources
defines += [ "ANGLE_ENABLE_METAL" ] }
} if (_needs_glsl_and_vulkan_base) {
sources += angle_translator_glsl_and_vulkan_base_sources
}
if (angle_enable_swiftshader) { public_configs += [ ":external_config" ]
defines += [ "ANGLE_ENABLE_SWIFTSHADER" ]
}
public_configs += [ ":external_config" ] deps = [
":includes",
":preprocessor",
]
deps = [ if (_uses_spirv) {
":includes", deps += [
":preprocessor", "$angle_root/src/common/spirv:angle_spirv_base",
] "${angle_glslang_dir}:glslang_default_resource_limits_sources",
"${angle_glslang_dir}:glslang_lib_sources",
"${angle_spirv_tools_dir}:spvtools_headers",
"${angle_spirv_tools_dir}:spvtools_val",
]
}
if (_uses_spirv) { public_deps = [
deps += [ ":angle_common",
"$angle_root/src/common/spirv:angle_spirv_base", ":angle_translator_headers",
"${angle_glslang_dir}:glslang_default_resource_limits_sources",
"${angle_glslang_dir}:glslang_lib_sources",
"${angle_spirv_tools_dir}:spvtools_headers",
"${angle_spirv_tools_dir}:spvtools_val",
] ]
if (is_win) {
# Necessary to suppress some system header xtree warnings in Release.
# For some reason this warning doesn't get triggered in Chromium
cflags = [ "/wd4718" ]
}
} }
}
public_deps = [ translator_lib("translator") {
":angle_common", gl_d3d_only = false
":angle_translator_headers", }
]
if (is_win) { translator_lib("translator_gl_d3d_only") {
# Necessary to suppress some system header xtree warnigns in Release. gl_d3d_only = true
# For some reason this warning doesn't get triggered in Chromium
cflags = [ "/wd4718" ]
}
} }
angle_source_set("translator_fuzzer") { angle_source_set("translator_fuzzer") {
......
...@@ -88,6 +88,11 @@ angle_translator_sources = [ ...@@ -88,6 +88,11 @@ angle_translator_sources = [
"src/compiler/translator/SymbolTable_autogen.h", "src/compiler/translator/SymbolTable_autogen.h",
"src/compiler/translator/SymbolUniqueId.cpp", "src/compiler/translator/SymbolUniqueId.cpp",
"src/compiler/translator/SymbolUniqueId.h", "src/compiler/translator/SymbolUniqueId.h",
"src/compiler/translator/TranslatorESSL.h",
"src/compiler/translator/TranslatorGLSL.h",
"src/compiler/translator/TranslatorHLSL.h",
"src/compiler/translator/TranslatorMetal.h",
"src/compiler/translator/TranslatorVulkan.h",
"src/compiler/translator/Types.cpp", "src/compiler/translator/Types.cpp",
"src/compiler/translator/Types.h", "src/compiler/translator/Types.h",
"src/compiler/translator/ValidateAST.cpp", "src/compiler/translator/ValidateAST.cpp",
...@@ -115,6 +120,7 @@ angle_translator_sources = [ ...@@ -115,6 +120,7 @@ angle_translator_sources = [
"src/compiler/translator/glslang_lex_autogen.cpp", "src/compiler/translator/glslang_lex_autogen.cpp",
"src/compiler/translator/glslang_tab_autogen.cpp", "src/compiler/translator/glslang_tab_autogen.cpp",
"src/compiler/translator/glslang_tab_autogen.h", "src/compiler/translator/glslang_tab_autogen.h",
"src/compiler/translator/glslang_wrapper.h",
"src/compiler/translator/length_limits.h", "src/compiler/translator/length_limits.h",
"src/compiler/translator/tree_ops/ClampPointSize.cpp", "src/compiler/translator/tree_ops/ClampPointSize.cpp",
"src/compiler/translator/tree_ops/ClampPointSize.h", "src/compiler/translator/tree_ops/ClampPointSize.h",
...@@ -221,7 +227,6 @@ angle_translator_essl_sources = [ ...@@ -221,7 +227,6 @@ angle_translator_essl_sources = [
"src/compiler/translator/OutputESSL.cpp", "src/compiler/translator/OutputESSL.cpp",
"src/compiler/translator/OutputESSL.h", "src/compiler/translator/OutputESSL.h",
"src/compiler/translator/TranslatorESSL.cpp", "src/compiler/translator/TranslatorESSL.cpp",
"src/compiler/translator/TranslatorESSL.h",
"src/compiler/translator/tree_ops/gl/RecordConstantPrecision.cpp", "src/compiler/translator/tree_ops/gl/RecordConstantPrecision.cpp",
"src/compiler/translator/tree_ops/gl/RecordConstantPrecision.h", "src/compiler/translator/tree_ops/gl/RecordConstantPrecision.h",
] ]
...@@ -231,7 +236,6 @@ angle_translator_glsl_sources = [ ...@@ -231,7 +236,6 @@ angle_translator_glsl_sources = [
"src/compiler/translator/ExtensionGLSL.cpp", "src/compiler/translator/ExtensionGLSL.cpp",
"src/compiler/translator/ExtensionGLSL.h", "src/compiler/translator/ExtensionGLSL.h",
"src/compiler/translator/TranslatorGLSL.cpp", "src/compiler/translator/TranslatorGLSL.cpp",
"src/compiler/translator/TranslatorGLSL.h",
"src/compiler/translator/VersionGLSL.cpp", "src/compiler/translator/VersionGLSL.cpp",
"src/compiler/translator/VersionGLSL.h", "src/compiler/translator/VersionGLSL.h",
"src/compiler/translator/tree_ops/gl/ClampFragDepth.cpp", "src/compiler/translator/tree_ops/gl/ClampFragDepth.cpp",
...@@ -271,7 +275,6 @@ angle_translator_hlsl_sources = [ ...@@ -271,7 +275,6 @@ angle_translator_hlsl_sources = [
"src/compiler/translator/TextureFunctionHLSL.cpp", "src/compiler/translator/TextureFunctionHLSL.cpp",
"src/compiler/translator/TextureFunctionHLSL.h", "src/compiler/translator/TextureFunctionHLSL.h",
"src/compiler/translator/TranslatorHLSL.cpp", "src/compiler/translator/TranslatorHLSL.cpp",
"src/compiler/translator/TranslatorHLSL.h",
"src/compiler/translator/UtilsHLSL.cpp", "src/compiler/translator/UtilsHLSL.cpp",
"src/compiler/translator/UtilsHLSL.h", "src/compiler/translator/UtilsHLSL.h",
"src/compiler/translator/blocklayoutHLSL.cpp", "src/compiler/translator/blocklayoutHLSL.cpp",
...@@ -311,9 +314,7 @@ angle_translator_lib_vulkan_sources = [ ...@@ -311,9 +314,7 @@ angle_translator_lib_vulkan_sources = [
"src/compiler/translator/OutputVulkanGLSL.cpp", "src/compiler/translator/OutputVulkanGLSL.cpp",
"src/compiler/translator/OutputVulkanGLSL.h", "src/compiler/translator/OutputVulkanGLSL.h",
"src/compiler/translator/TranslatorVulkan.cpp", "src/compiler/translator/TranslatorVulkan.cpp",
"src/compiler/translator/TranslatorVulkan.h",
"src/compiler/translator/glslang_wrapper.cpp", "src/compiler/translator/glslang_wrapper.cpp",
"src/compiler/translator/glslang_wrapper.h",
"src/compiler/translator/tree_ops/vulkan/EarlyFragmentTestsOptimization.cpp", "src/compiler/translator/tree_ops/vulkan/EarlyFragmentTestsOptimization.cpp",
"src/compiler/translator/tree_ops/vulkan/FlagSamplersWithTexelFetch.cpp", "src/compiler/translator/tree_ops/vulkan/FlagSamplersWithTexelFetch.cpp",
"src/compiler/translator/tree_ops/vulkan/FlagSamplersWithTexelFetch.h", "src/compiler/translator/tree_ops/vulkan/FlagSamplersWithTexelFetch.h",
...@@ -358,7 +359,6 @@ angle_translator_lib_metal_sources = [ ...@@ -358,7 +359,6 @@ angle_translator_lib_metal_sources = [
"src/compiler/translator/OutputVulkanGLSLForMetal.h", "src/compiler/translator/OutputVulkanGLSLForMetal.h",
"src/compiler/translator/OutputVulkanGLSLForMetal.mm", "src/compiler/translator/OutputVulkanGLSLForMetal.mm",
"src/compiler/translator/TranslatorMetal.cpp", "src/compiler/translator/TranslatorMetal.cpp",
"src/compiler/translator/TranslatorMetal.h",
] ]
angle_preprocessor_sources = [ angle_preprocessor_sources = [
......
...@@ -1372,7 +1372,7 @@ bool TranslatorVulkan::shouldFlattenPragmaStdglInvariantAll() ...@@ -1372,7 +1372,7 @@ bool TranslatorVulkan::shouldFlattenPragmaStdglInvariantAll()
bool TranslatorVulkan::compileToSpirv(const TInfoSinkBase &glsl) bool TranslatorVulkan::compileToSpirv(const TInfoSinkBase &glsl)
{ {
angle::spirv::Blob spirvBlob; std::vector<uint32_t> spirvBlob;
if (!GlslangCompileToSpirv(getResources(), getShaderType(), glsl.str(), &spirvBlob)) if (!GlslangCompileToSpirv(getResources(), getShaderType(), glsl.str(), &spirvBlob))
{ {
return false; return false;
......
...@@ -108,7 +108,7 @@ void GlslangFinalize() ...@@ -108,7 +108,7 @@ void GlslangFinalize()
ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources, ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources,
sh::GLenum shaderType, sh::GLenum shaderType,
const std::string &shaderSource, const std::string &shaderSource,
angle::spirv::Blob *spirvBlobOut) std::vector<uint32_t> *spirvBlobOut)
{ {
TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource); TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource);
GetBuiltInResources(resources, &builtInResources); GetBuiltInResources(resources, &builtInResources);
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "GLSLANG/ShaderLang.h" #include "GLSLANG/ShaderLang.h"
#include "common/PackedEnums.h" #include "common/PackedEnums.h"
#include "common/spirv/spirv_types.h"
#include <string> #include <string>
#include <vector> #include <vector>
...@@ -28,7 +27,7 @@ void GlslangFinalize(); ...@@ -28,7 +27,7 @@ void GlslangFinalize();
ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources, ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources,
sh::GLenum shaderType, sh::GLenum shaderType,
const std::string &shaderSource, const std::string &shaderSource,
angle::spirv::Blob *spirvBlobOut); std::vector<uint32_t> *spirvBlobOut);
#else #else
ANGLE_INLINE void GlslangInitialize() ANGLE_INLINE void GlslangInitialize()
{ {
......
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