1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
  154
  155
  156
  157
  158
  159
  160
  161
  162
  163
  164
  165
  166
  167
  168
  169
  170
  171
  172
  173
  174
  175
  176
  177
  178
  179
  180
  181
  182
  183
  184
  185
  186
  187
  188
  189
  190
  191
  192
  193
  194
  195
  196
  197
  198
  199
  200
  201
  202
  203
  204
  205
  206
  207
  208
  209
  210
  211
  212
  213
  214
  215
  216
  217
  218
  219
  220
  221
  222
  223
  224
  225
  226
  227
  228
  229
  230
  231
  232
  233
  234
  235
  236
  237
  238
  239
  240
  241
  242
  243
  244
  245
  246
  247
  248
  249
  250
  251
  252
  253
  254
  255
  256
  257
  258
  259
  260
  261
  262
  263
  264
  265
  266
  267
  268
  269
  270
  271
  272
  273
  274
  275
  276
  277
  278
  279
  280
  281

gpu / config / BUILD.gn [blame]

# Copyright 2014 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//build/config/cast.gni")
import("//build/config/chrome_build.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/ui.gni")
import("//gpu/vulkan/features.gni")
import("//skia/features.gni")
import("//ui/gl/features.gni")

if (is_android) {
  import("//build/config/android/rules.gni")
}

group("config") {
  if (is_component_build) {
    public_deps = [ "//gpu" ]
  } else {
    public_deps = [ ":config_sources" ]
  }
}

process_json_outputs = [
  "$target_gen_dir/gpu_driver_bug_list_arrays_and_structs_autogen.h",
  "$target_gen_dir/gpu_driver_bug_list_autogen.cc",
  "$target_gen_dir/gpu_driver_bug_list_autogen.h",
  "$target_gen_dir/gpu_driver_bug_list_exceptions_autogen.h",
  "$target_gen_dir/software_rendering_list_arrays_and_structs_autogen.h",
  "$target_gen_dir/software_rendering_list_autogen.cc",
  "$target_gen_dir/software_rendering_list_autogen.h",
  "$target_gen_dir/software_rendering_list_exceptions_autogen.h",
]

action("process_json") {
  script = "process_json.py"

  inputs = [
    "gpu_driver_bug_list.json",
    "gpu_driver_bug_workaround_type.h",
    "gpu_feature_type.h",
    "software_rendering_list.json",
  ]

  outputs = process_json_outputs

  args = [
    "--output-dir",
    rebase_path("$target_gen_dir", root_build_dir),
    "--skip-testing-data",
    "--os-filter",
  ]
  if (is_win) {
    args += [ "win" ]
  } else if (is_mac) {
    args += [ "macosx" ]
  } else if (is_android) {
    args += [ "android" ]
  } else if (is_chromeos) {
    args += [ "chromeos" ]
  } else if (is_fuchsia) {
    args += [ "fuchsia" ]
  } else {
    args += [ "linux" ]
  }

  public_deps = [ ":workaround_list" ]
}

action("workaround_list") {
  script = "build_workaround_header.py"

  skia_workaround_list = "//third_party/skia/src/gpu/gpu_workaround_list.txt"
  inputs = [
    "gpu_workaround_list.txt",
    skia_workaround_list,
  ]

  outputs = [ "$target_gen_dir/gpu_driver_bug_workaround_autogen.h" ]

  args = [
    "--output-file",
    rebase_path(outputs[0], root_build_dir),
  ]
  foreach(file, inputs) {
    args += [ rebase_path(file, root_build_dir) ]
  }
}

if (enable_vulkan) {
  component("vulkan_info") {
    sources = [
      "vulkan_info.cc",
      "vulkan_info.h",
    ]

    configs += [ "//gpu:gpu_implementation" ]

    deps = [ "//gpu/ipc/common:vulkan_interface" ]
    public_deps = [
      "//third_party/vulkan-headers/src:vulkan_headers",
      "//ui/gfx",
    ]

    # surpass linke error 4217. It is because vulkan_info depends on
    # //gpu/ipc/common:vulkan_interface and //gpu/ipc/common:vulkan_interface"
    # depends on this target.
    # TODO(penghuang): Fix this link error
    if (is_win && is_component_build) {
      ldflags = [ "/IGNORE:4217" ]
    }
  }
}

source_set("webgpu_blocklist_impl") {
  sources = [
    "webgpu_blocklist_impl.cc",
    "webgpu_blocklist_impl.h",
  ]

  deps = [ "//base" ]

  public_deps = [ "//third_party/dawn/include/dawn:cpp_headers" ]
}

source_set("config_sources") {
  # External code should depend on this via //gpu/config above rather than
  # depending on this directly or the component build will break.
  visibility = [ "//gpu/*" ]

  sources = [
    "device_perf_info.cc",
    "device_perf_info.h",
    "gpu_blocklist.cc",
    "gpu_blocklist.h",
    "gpu_control_list.cc",
    "gpu_control_list.h",
    "gpu_crash_keys.cc",
    "gpu_crash_keys.h",
    "gpu_domain_guilt.h",
    "gpu_driver_bug_list.cc",
    "gpu_driver_bug_list.h",
    "gpu_driver_bug_workaround_type.h",
    "gpu_driver_bug_workarounds.cc",
    "gpu_driver_bug_workarounds.h",
    "gpu_feature_info.cc",
    "gpu_feature_info.h",
    "gpu_feature_type.h",
    "gpu_finch_features.cc",
    "gpu_finch_features.h",
    "gpu_info.cc",
    "gpu_info.h",
    "gpu_info_collector.cc",
    "gpu_info_collector.h",
    "gpu_mode.h",
    "gpu_preferences.cc",
    "gpu_preferences.h",
    "gpu_switches.cc",
    "gpu_switches.h",
    "gpu_switching.cc",
    "gpu_switching.h",
    "gpu_test_config.cc",
    "gpu_test_config.h",
    "gpu_test_expectations_parser.cc",
    "gpu_test_expectations_parser.h",
    "gpu_util.cc",
    "gpu_util.h",
    "skia_limits.cc",
    "skia_limits.h",
    "webgpu_blocklist.cc",
    "webgpu_blocklist.h",
  ]

  if (is_fuchsia) {
    sources += [ "gpu_info_collector_fuchsia.cc" ]
  }

  sources += process_json_outputs

  configs += [ "//gpu:gpu_implementation" ]

  public_deps = [ "//components/crash/core/common:crash_key" ]

  if (enable_vulkan) {
    public_deps += [ ":vulkan_info" ]
  }

  deps = [
    ":process_json",
    "//base",
    "//build:branding_buildflags",
    "//build:chromecast_buildflags",
    "//build:chromeos_buildflags",
    "//components/miracle_parameter/common",
    "//gpu/command_buffer/common:common_sources",
    "//gpu/ipc/common:gpu_preferences_interface",
    "//gpu/vulkan:buildflags",
    "//media:media_buildflags",
    "//services/webnn/public/mojom",
    "//skia:buildflags",
    "//third_party/re2",
    "//third_party/vulkan-headers/src:vulkan_headers",
    "//ui/gfx",
    "//ui/gl",
    "//ui/gl:buildflags",
    "//ui/gl/init",
  ]

  if (use_dawn || skia_use_dawn) {
    public_deps += [ "//third_party/dawn/include/dawn:headers" ]

    deps += [
      "//third_party/dawn/include/dawn:cpp_headers",
      "//third_party/dawn/src/dawn:proc",
      "//third_party/dawn/src/dawn/native",
    ]
  }

  if (use_dawn) {
    deps += [ ":webgpu_blocklist_impl" ]
  }

  # GpuPreferences is using its own mojo bindings which creates a
  # cycle between this target and gpu_preferences_interface.
  allow_circular_includes_from =
      [ "//gpu/ipc/common:gpu_preferences_interface" ]

  # Prefer mesa GL headers to system headers, which cause problems on Win.
  include_dirs = [ "//third_party/mesa_headers" ]

  if (is_android) {
    sources += [ "gpu_info_collector_android.cc" ]
  }
  if (is_win) {
    sources += [ "gpu_info_collector_win.cc" ]
    deps += [ "//third_party/microsoft_dxheaders:dxguids" ]
    libs = [ "dxgi.lib" ]
  }
  if (is_mac) {
    sources += [ "gpu_info_collector_mac.mm" ]
    frameworks = [ "OpenGL.framework" ]
  }
  if (is_ios) {
    sources += [ "gpu_info_collector_ios.mm" ]
  }
  if (is_linux || is_chromeos) {
    sources += [ "gpu_info_collector_linux.cc" ]
  }
  if (is_linux || is_chromeos || is_apple || is_fuchsia || is_android) {
    deps += [ "//third_party/angle:angle_gpu_info_util" ]
  }
  if (use_ozone) {
    deps += [ "//ui/ozone" ]
  }
}

if (is_android) {
  java_cpp_strings("java_switches_srcjar") {
    # External code should depend on ":config_java" instead.
    visibility = [ ":*" ]
    sources = [ "gpu_switches.cc" ]
    template = "android/java/src/org/chromium/gpu/config/GpuSwitches.java.tmpl"
  }

  java_cpp_features("java_features_srcjar") {
    # External code should depend on ":config_java" instead.
    visibility = [ ":*" ]
    sources = [ "gpu_finch_features.cc" ]
    template = "android/java/src/org/chromium/gpu/config/GpuFeatures.java.tmpl"
  }

  android_library("config_java") {
    # Right now, this only includes the Java switches/features. But if we need
    # more Java files, they should be added here as necessary.
    srcjar_deps = [
      ":java_features_srcjar",
      ":java_switches_srcjar",
    ]
  }
}