Debian Codegraph @

tools/graphite/dawn/GraphiteDawnToggles.cpp

raw
1 /*
2 * Copyright 2025 Google LLC
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "tools/graphite/dawn/GraphiteDawnToggles.h"
9
10 namespace skiatest::graphite {
11
12 wgpu::DawnTogglesDescriptor GetInstanceToggles() {
13 static constexpr const char* kToggles[] = {
14 // Needed for newer Dawn APIs that aren't launched in WebGPU.
15 "allow_unsafe_apis",
16 };
17 wgpu::DawnTogglesDescriptor togglesDesc;
18 togglesDesc.enabledToggleCount = std::size(kToggles);
19 togglesDesc.enabledToggles = kToggles;
20 return togglesDesc;
21 }
22
23 wgpu::DawnTogglesDescriptor GetAdapterToggles() {
24 static constexpr const char* kToggles[] = {
25 #if defined(SK_DEBUG)
26 // Setting labels on backend objects has performance overhead.
27 "use_user_defined_labels_in_backend",
28 #else
29 "skip_validation",
30 #endif
31 // Lazy clear has performance overhead.
32 "disable_lazy_clear_for_mapped_at_creation_buffer",
33 // Robustness impacts performance and is always disabled when running Graphite in
34 // Chrome, so this keeps Skia's tests operating closer to real-use behavior.
35 "disable_robustness",
36 // Validating the SPIR-V shaders generated by Tint may have some overhead, and is
37 // not required for Graphite since the input is trusted.
38 "enable_spirv_validation",
39 };
40 wgpu::DawnTogglesDescriptor togglesDesc;
41 togglesDesc.enabledToggleCount = std::size(kToggles);
42 togglesDesc.enabledToggles = kToggles;
43 return togglesDesc;
44 }
45
46 void AddPreferredFeatures(const wgpu::Adapter& adapter, std::vector<wgpu::FeatureName>& features) {
47 auto addFeature = [&](wgpu::FeatureName feature) {
48 if (adapter.HasFeature(feature)) {
49 for (auto existing : features) {
50 if (existing == feature) {
51 return; // Don't re-add it if it was already in `features`
52 }
53 }
54 features.push_back(feature);
55 }
56 };
57
58 addFeature(wgpu::FeatureName::BufferMapExtendedUsages);
59 addFeature(wgpu::FeatureName::DawnLoadResolveTexture);
60 addFeature(wgpu::FeatureName::DawnPartialLoadResolveTexture);
61 addFeature(wgpu::FeatureName::DawnTexelCopyBufferRowAlignment);
62 addFeature(wgpu::FeatureName::DualSourceBlending);
63 addFeature(wgpu::FeatureName::FramebufferFetch);
64 addFeature(wgpu::FeatureName::ImplicitDeviceSynchronization);
65 addFeature(wgpu::FeatureName::MSAARenderToSingleSampled);
66 addFeature(wgpu::FeatureName::TextureCompressionBC);
67 addFeature(wgpu::FeatureName::TextureCompressionETC2);
68 addFeature(wgpu::FeatureName::TextureFormatsTier1);
69 addFeature(wgpu::FeatureName::TimestampQuery);
70 addFeature(wgpu::FeatureName::TransientAttachments);
71 addFeature(wgpu::FeatureName::Unorm16TextureFormats);
72 }
73
74
75 } // namespace skiatest::graphite