blob: 870bf84ac0746e2ed7b8a5e2605caa43e93b9f10 [file] [log] [blame]
Scott Violete9edfaa2023-11-16 02:08:581// Copyright 2023 The Chromium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef GPU_CONFIG_WEBGPU_BLOCKLIST_IMPL_H_
6#define GPU_CONFIG_WEBGPU_BLOCKLIST_IMPL_H_
7
Jose Dapena Pazf3b236d2024-05-24 11:51:458#include <cstdint>
Scott Violete9edfaa2023-11-16 02:08:589#include <string>
10
Austin Engf5722942024-05-03 22:18:3111namespace wgpu {
12class Adapter;
François Beaufortba2849d2024-06-20 13:41:3713struct AdapterInfo;
Austin Engf5722942024-05-03 22:18:3114}
15
Austin Eng8fa5bec2024-05-07 23:43:5216// Bitmask of blocklist reasons.
17enum class WebGPUBlocklistReason : uint64_t {
18 None = 0,
Austin Eng8fa5bec2024-05-07 23:43:5219 StringPattern = 1,
Austin Eng8fa5bec2024-05-07 23:43:5220 DynamicArrayIndexInStruct = 1 << 1,
Austin Eng8fa5bec2024-05-07 23:43:5221 IndirectComputeRootConstants = 1 << 2,
Austin Eng8fa5bec2024-05-07 23:43:5222 WindowsARM = 1 << 3,
Austin Eng8fa5bec2024-05-07 23:43:5223 AndroidGLES = 1 << 4,
Austin Eng8fa5bec2024-05-07 23:43:5224 AndroidLimitedSupport = 1 << 5,
Austin Eng8fa5bec2024-05-07 23:43:5225 AMDMissingDrmFormatModifier = 1 << 6,
Austin Eng8fa5bec2024-05-07 23:43:5226 CPUAdapter = 1 << 7,
Austin Eng8fa5bec2024-05-07 23:43:5227 D3D11 = 1 << 8,
Austin Eng8fa5bec2024-05-07 23:43:5228 Consteval22ndBit = 1 << 9,
François Beaufort7f1b87b2024-06-20 13:41:5429 // When adding an enum, update kKnownReasons with a description.
Austin Eng8fa5bec2024-05-07 23:43:5230};
31
32inline constexpr WebGPUBlocklistReason operator|(WebGPUBlocklistReason l,
33 WebGPUBlocklistReason r) {
34 return static_cast<WebGPUBlocklistReason>(uint64_t(l) | uint64_t(r));
35}
36
37inline constexpr WebGPUBlocklistReason operator&(WebGPUBlocklistReason l,
38 WebGPUBlocklistReason r) {
39 return static_cast<WebGPUBlocklistReason>(uint64_t(l) & uint64_t(r));
40}
41
42inline constexpr WebGPUBlocklistReason operator~(WebGPUBlocklistReason v) {
43 return static_cast<WebGPUBlocklistReason>(~uint64_t(v));
44}
45
François Beaufort7f1b87b2024-06-20 13:41:5446inline constexpr WebGPUBlocklistReason operator&=(WebGPUBlocklistReason& l,
47 WebGPUBlocklistReason r) {
48 l = static_cast<WebGPUBlocklistReason>(uint64_t(l) & uint64_t(r));
49 return static_cast<WebGPUBlocklistReason>(uint64_t(l));
50}
51
Scott Violete9edfaa2023-11-16 02:08:5852namespace gpu {
53
François Beaufort7f1b87b2024-06-20 13:41:5454struct WebGPUBlocklistResultImpl {
55 bool blocked;
56 std::string reason;
57};
58
Austin Eng8fa5bec2024-05-07 23:43:5259struct WebGPUBlocklistOptions {
60 std::string_view blocklist_string = "";
61 WebGPUBlocklistReason ignores = WebGPUBlocklistReason::None;
62};
63
Austin Enga5f4eec2024-05-04 03:54:3364namespace detail {
François Beaufort7f1b87b2024-06-20 13:41:5465WebGPUBlocklistReason GetWebGPUAdapterBlocklistReason(
66 const wgpu::AdapterInfo& info,
67 const WebGPUBlocklistOptions& options);
Austin Enga5f4eec2024-05-04 03:54:3368} // namespace detail
Scott Violete9edfaa2023-11-16 02:08:5869
François Beaufort7f1b87b2024-06-20 13:41:5470WebGPUBlocklistResultImpl IsWebGPUAdapterBlocklisted(
71 const wgpu::Adapter& adapter,
72 WebGPUBlocklistOptions options = {});
Austin Engf5722942024-05-03 22:18:3173
Clark DuVallca0315e2025-02-15 01:22:1474WebGPUBlocklistResultImpl IsWebGPUAdapterBlocklisted(
75 const wgpu::AdapterInfo& info,
76 WebGPUBlocklistOptions options);
77
Scott Violete9edfaa2023-11-16 02:08:5878} // namespace gpu
79
80#endif // GPU_CONFIG_WEBGPU_BLOCKLIST_IMPL_H_