Scott Violet | e9edfaa | 2023-11-16 02:08:58 | [diff] [blame] | 1 | // 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 Paz | f3b236d | 2024-05-24 11:51:45 | [diff] [blame] | 8 | #include <cstdint> |
Scott Violet | e9edfaa | 2023-11-16 02:08:58 | [diff] [blame] | 9 | #include <string> |
| 10 | |
Austin Eng | f572294 | 2024-05-03 22:18:31 | [diff] [blame] | 11 | namespace wgpu { |
| 12 | class Adapter; |
François Beaufort | ba2849d | 2024-06-20 13:41:37 | [diff] [blame] | 13 | struct AdapterInfo; |
Austin Eng | f572294 | 2024-05-03 22:18:31 | [diff] [blame] | 14 | } |
| 15 | |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 16 | // Bitmask of blocklist reasons. |
| 17 | enum class WebGPUBlocklistReason : uint64_t { |
| 18 | None = 0, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 19 | StringPattern = 1, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 20 | DynamicArrayIndexInStruct = 1 << 1, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 21 | IndirectComputeRootConstants = 1 << 2, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 22 | WindowsARM = 1 << 3, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 23 | AndroidGLES = 1 << 4, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 24 | AndroidLimitedSupport = 1 << 5, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 25 | AMDMissingDrmFormatModifier = 1 << 6, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 26 | CPUAdapter = 1 << 7, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 27 | D3D11 = 1 << 8, |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 28 | Consteval22ndBit = 1 << 9, |
François Beaufort | 7f1b87b | 2024-06-20 13:41:54 | [diff] [blame] | 29 | // When adding an enum, update kKnownReasons with a description. |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | inline constexpr WebGPUBlocklistReason operator|(WebGPUBlocklistReason l, |
| 33 | WebGPUBlocklistReason r) { |
| 34 | return static_cast<WebGPUBlocklistReason>(uint64_t(l) | uint64_t(r)); |
| 35 | } |
| 36 | |
| 37 | inline constexpr WebGPUBlocklistReason operator&(WebGPUBlocklistReason l, |
| 38 | WebGPUBlocklistReason r) { |
| 39 | return static_cast<WebGPUBlocklistReason>(uint64_t(l) & uint64_t(r)); |
| 40 | } |
| 41 | |
| 42 | inline constexpr WebGPUBlocklistReason operator~(WebGPUBlocklistReason v) { |
| 43 | return static_cast<WebGPUBlocklistReason>(~uint64_t(v)); |
| 44 | } |
| 45 | |
François Beaufort | 7f1b87b | 2024-06-20 13:41:54 | [diff] [blame] | 46 | inline 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 Violet | e9edfaa | 2023-11-16 02:08:58 | [diff] [blame] | 52 | namespace gpu { |
| 53 | |
François Beaufort | 7f1b87b | 2024-06-20 13:41:54 | [diff] [blame] | 54 | struct WebGPUBlocklistResultImpl { |
| 55 | bool blocked; |
| 56 | std::string reason; |
| 57 | }; |
| 58 | |
Austin Eng | 8fa5bec | 2024-05-07 23:43:52 | [diff] [blame] | 59 | struct WebGPUBlocklistOptions { |
| 60 | std::string_view blocklist_string = ""; |
| 61 | WebGPUBlocklistReason ignores = WebGPUBlocklistReason::None; |
| 62 | }; |
| 63 | |
Austin Eng | a5f4eec | 2024-05-04 03:54:33 | [diff] [blame] | 64 | namespace detail { |
François Beaufort | 7f1b87b | 2024-06-20 13:41:54 | [diff] [blame] | 65 | WebGPUBlocklistReason GetWebGPUAdapterBlocklistReason( |
| 66 | const wgpu::AdapterInfo& info, |
| 67 | const WebGPUBlocklistOptions& options); |
Austin Eng | a5f4eec | 2024-05-04 03:54:33 | [diff] [blame] | 68 | } // namespace detail |
Scott Violet | e9edfaa | 2023-11-16 02:08:58 | [diff] [blame] | 69 | |
François Beaufort | 7f1b87b | 2024-06-20 13:41:54 | [diff] [blame] | 70 | WebGPUBlocklistResultImpl IsWebGPUAdapterBlocklisted( |
| 71 | const wgpu::Adapter& adapter, |
| 72 | WebGPUBlocklistOptions options = {}); |
Austin Eng | f572294 | 2024-05-03 22:18:31 | [diff] [blame] | 73 | |
Clark DuVall | ca0315e | 2025-02-15 01:22:14 | [diff] [blame] | 74 | WebGPUBlocklistResultImpl IsWebGPUAdapterBlocklisted( |
| 75 | const wgpu::AdapterInfo& info, |
| 76 | WebGPUBlocklistOptions options); |
| 77 | |
Scott Violet | e9edfaa | 2023-11-16 02:08:58 | [diff] [blame] | 78 | } // namespace gpu |
| 79 | |
| 80 | #endif // GPU_CONFIG_WEBGPU_BLOCKLIST_IMPL_H_ |