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") {
public_deps = [ ":includes" ]
}
angle_static_library("translator") {
sources = angle_translator_sources
defines = []
_needs_glsl_base = false
_needs_glsl_and_vulkan_base = false
_uses_spirv = false
if (angle_enable_essl || use_fuzzing_engine) {
_needs_glsl_base = true
sources += angle_translator_essl_sources
defines += [ "ANGLE_ENABLE_ESSL" ]
}
template("translator_lib") {
angle_static_library(target_name) {
sources = angle_translator_sources
defines = []
_needs_glsl_base = false
_needs_glsl_and_vulkan_base = false
_uses_spirv = false
if (angle_enable_essl || use_fuzzing_engine) {
_needs_glsl_base = true
sources += angle_translator_essl_sources
defines += [ "ANGLE_ENABLE_ESSL" ]
}
if (angle_enable_glsl || use_fuzzing_engine) {
_needs_glsl_base = true
_needs_glsl_and_vulkan_base = true
sources += angle_translator_glsl_sources
if (is_apple) {
sources += angle_translator_glsl_mac_sources
if (angle_enable_glsl || use_fuzzing_engine) {
_needs_glsl_base = true
_needs_glsl_and_vulkan_base = true
sources += angle_translator_glsl_sources
if (is_apple) {
sources += angle_translator_glsl_mac_sources
}
defines += [ "ANGLE_ENABLE_GLSL" ]
}
defines += [ "ANGLE_ENABLE_GLSL" ]
}
if (angle_enable_hlsl || use_fuzzing_engine) {
sources += angle_translator_hlsl_sources
defines += [ "ANGLE_ENABLE_HLSL" ]
}
if (angle_enable_hlsl || use_fuzzing_engine) {
sources += angle_translator_hlsl_sources
defines += [ "ANGLE_ENABLE_HLSL" ]
}
if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) {
_needs_glsl_base = true
_needs_glsl_and_vulkan_base = true
_uses_spirv = true
if (!invoker.gl_d3d_only) {
if (angle_enable_vulkan || use_fuzzing_engine || angle_enable_metal) {
_needs_glsl_base = true
_needs_glsl_and_vulkan_base = true
_uses_spirv = true
# This translator is needed by metal backend also.
sources += angle_translator_lib_vulkan_sources
}
# This translator is needed by metal backend also.
sources += angle_translator_lib_vulkan_sources
}
if (_needs_glsl_base) {
sources += angle_translator_glsl_base_sources
}
if (_needs_glsl_and_vulkan_base) {
sources += angle_translator_glsl_and_vulkan_base_sources
}
if (angle_enable_vulkan || use_fuzzing_engine) {
defines += [ "ANGLE_ENABLE_VULKAN" ]
}
if (angle_enable_vulkan || use_fuzzing_engine) {
defines += [ "ANGLE_ENABLE_VULKAN" ]
}
if (angle_enable_metal) {
sources += angle_translator_lib_metal_sources
defines += [ "ANGLE_ENABLE_METAL" ]
}
}
if (angle_enable_metal) {
sources += angle_translator_lib_metal_sources
defines += [ "ANGLE_ENABLE_METAL" ]
}
if (_needs_glsl_base) {
sources += angle_translator_glsl_base_sources
}
if (_needs_glsl_and_vulkan_base) {
sources += angle_translator_glsl_and_vulkan_base_sources
}
if (angle_enable_swiftshader) {
defines += [ "ANGLE_ENABLE_SWIFTSHADER" ]
}
public_configs += [ ":external_config" ]
public_configs += [ ":external_config" ]
deps = [
":includes",
":preprocessor",
]
deps = [
":includes",
":preprocessor",
]
if (_uses_spirv) {
deps += [
"$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) {
deps += [
"$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",
public_deps = [
":angle_common",
":angle_translator_headers",
]
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 = [
":angle_common",
":angle_translator_headers",
]
translator_lib("translator") {
gl_d3d_only = false
}
if (is_win) {
# Necessary to suppress some system header xtree warnigns in Release.
# For some reason this warning doesn't get triggered in Chromium
cflags = [ "/wd4718" ]
}
translator_lib("translator_gl_d3d_only") {
gl_d3d_only = true
}
angle_source_set("translator_fuzzer") {
......
......@@ -88,6 +88,11 @@ angle_translator_sources = [
"src/compiler/translator/SymbolTable_autogen.h",
"src/compiler/translator/SymbolUniqueId.cpp",
"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.h",
"src/compiler/translator/ValidateAST.cpp",
......@@ -115,6 +120,7 @@ angle_translator_sources = [
"src/compiler/translator/glslang_lex_autogen.cpp",
"src/compiler/translator/glslang_tab_autogen.cpp",
"src/compiler/translator/glslang_tab_autogen.h",
"src/compiler/translator/glslang_wrapper.h",
"src/compiler/translator/length_limits.h",
"src/compiler/translator/tree_ops/ClampPointSize.cpp",
"src/compiler/translator/tree_ops/ClampPointSize.h",
......@@ -221,7 +227,6 @@ angle_translator_essl_sources = [
"src/compiler/translator/OutputESSL.cpp",
"src/compiler/translator/OutputESSL.h",
"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.h",
]
......@@ -231,7 +236,6 @@ angle_translator_glsl_sources = [
"src/compiler/translator/ExtensionGLSL.cpp",
"src/compiler/translator/ExtensionGLSL.h",
"src/compiler/translator/TranslatorGLSL.cpp",
"src/compiler/translator/TranslatorGLSL.h",
"src/compiler/translator/VersionGLSL.cpp",
"src/compiler/translator/VersionGLSL.h",
"src/compiler/translator/tree_ops/gl/ClampFragDepth.cpp",
......@@ -271,7 +275,6 @@ angle_translator_hlsl_sources = [
"src/compiler/translator/TextureFunctionHLSL.cpp",
"src/compiler/translator/TextureFunctionHLSL.h",
"src/compiler/translator/TranslatorHLSL.cpp",
"src/compiler/translator/TranslatorHLSL.h",
"src/compiler/translator/UtilsHLSL.cpp",
"src/compiler/translator/UtilsHLSL.h",
"src/compiler/translator/blocklayoutHLSL.cpp",
......@@ -311,9 +314,7 @@ angle_translator_lib_vulkan_sources = [
"src/compiler/translator/OutputVulkanGLSL.cpp",
"src/compiler/translator/OutputVulkanGLSL.h",
"src/compiler/translator/TranslatorVulkan.cpp",
"src/compiler/translator/TranslatorVulkan.h",
"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/FlagSamplersWithTexelFetch.cpp",
"src/compiler/translator/tree_ops/vulkan/FlagSamplersWithTexelFetch.h",
......@@ -358,7 +359,6 @@ angle_translator_lib_metal_sources = [
"src/compiler/translator/OutputVulkanGLSLForMetal.h",
"src/compiler/translator/OutputVulkanGLSLForMetal.mm",
"src/compiler/translator/TranslatorMetal.cpp",
"src/compiler/translator/TranslatorMetal.h",
]
angle_preprocessor_sources = [
......
......@@ -1372,7 +1372,7 @@ bool TranslatorVulkan::shouldFlattenPragmaStdglInvariantAll()
bool TranslatorVulkan::compileToSpirv(const TInfoSinkBase &glsl)
{
angle::spirv::Blob spirvBlob;
std::vector<uint32_t> spirvBlob;
if (!GlslangCompileToSpirv(getResources(), getShaderType(), glsl.str(), &spirvBlob))
{
return false;
......
......@@ -108,7 +108,7 @@ void GlslangFinalize()
ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources,
sh::GLenum shaderType,
const std::string &shaderSource,
angle::spirv::Blob *spirvBlobOut)
std::vector<uint32_t> *spirvBlobOut)
{
TBuiltInResource builtInResources(glslang::DefaultTBuiltInResource);
GetBuiltInResources(resources, &builtInResources);
......
......@@ -13,7 +13,6 @@
#include "GLSLANG/ShaderLang.h"
#include "common/PackedEnums.h"
#include "common/spirv/spirv_types.h"
#include <string>
#include <vector>
......@@ -28,7 +27,7 @@ void GlslangFinalize();
ANGLE_NO_DISCARD bool GlslangCompileToSpirv(const ShBuiltInResources &resources,
sh::GLenum shaderType,
const std::string &shaderSource,
angle::spirv::Blob *spirvBlobOut);
std::vector<uint32_t> *spirvBlobOut);
#else
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