33 {
34 static std::unique_ptr<dawn::native::Instance> sInstance;
36
37 static constexpr const char* kToggles[] = {
38 "allow_unsafe_apis",
39 "use_user_defined_labels_in_backend",
40 };
41 wgpu::DawnTogglesDescriptor togglesDesc;
42 togglesDesc.enabledToggleCount =
std::size(kToggles);
43 togglesDesc.enabledToggles = kToggles;
44
45
46
47
48 sOnce([&]{
49 DawnProcTable backendProcs = dawn::native::GetProcs();
50 dawnProcSetProcs(&backendProcs);
51 WGPUInstanceDescriptor
desc{};
52
53 desc.features.timedWaitAnyEnable =
true;
54 sInstance = std::make_unique<dawn::native::Instance>(&
desc);
55 });
56
57 dawn::native::Adapter matchedAdaptor;
58
59 wgpu::RequestAdapterOptions
options;
60 options.nextInChain = &togglesDesc;
61 std::vector<dawn::native::Adapter> adapters = sInstance->EnumerateAdapters(&
options);
63
64
66 adapters.begin(), adapters.end(), [](dawn::native::Adapter
a, dawn::native::Adapter
b) {
67 wgpu::AdapterInfo infoA;
68 wgpu::AdapterInfo infoB;
69 a.GetInfo(&infoA);
70 b.GetInfo(&infoB);
71 return std::tuple(infoA.adapterType, infoA.backendType) <
72 std::tuple(infoB.adapterType, infoB.backendType);
73 });
74
75 for (const auto& adapter : adapters) {
76 wgpu::AdapterInfo props;
77 adapter.GetInfo(&props);
78 if (
backend == props.backendType) {
79 matchedAdaptor = adapter;
80 break;
81 }
82 }
83
84 if (!matchedAdaptor) {
85 return nullptr;
86 }
87
88#if LOG_ADAPTER
89 wgpu::AdapterInfo
info;
90 sAdapter.GetInfo(&
info);
92#endif
93
94 std::vector<wgpu::FeatureName> features;
95 wgpu::Adapter adapter = matchedAdaptor.Get();
96 if (adapter.HasFeature(wgpu::FeatureName::MSAARenderToSingleSampled)) {
97 features.push_back(wgpu::FeatureName::MSAARenderToSingleSampled);
98 }
99 if (adapter.HasFeature(wgpu::FeatureName::TransientAttachments)) {
100 features.push_back(wgpu::FeatureName::TransientAttachments);
101 }
102 if (adapter.HasFeature(wgpu::FeatureName::Unorm16TextureFormats)) {
103 features.push_back(wgpu::FeatureName::Unorm16TextureFormats);
104 }
105 if (adapter.HasFeature(wgpu::FeatureName::DualSourceBlending)) {
106 features.push_back(wgpu::FeatureName::DualSourceBlending);
107 }
108 if (adapter.HasFeature(wgpu::FeatureName::FramebufferFetch)) {
109 features.push_back(wgpu::FeatureName::FramebufferFetch);
110 }
111 if (adapter.HasFeature(wgpu::FeatureName::BufferMapExtendedUsages)) {
112 features.push_back(wgpu::FeatureName::BufferMapExtendedUsages);
113 }
114 if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionETC2)) {
115 features.push_back(wgpu::FeatureName::TextureCompressionETC2);
116 }
117 if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
118 features.push_back(wgpu::FeatureName::TextureCompressionBC);
119 }
120 if (adapter.HasFeature(wgpu::FeatureName::R8UnormStorage)) {
121 features.push_back(wgpu::FeatureName::R8UnormStorage);
122 }
123 if (adapter.HasFeature(wgpu::FeatureName::DawnLoadResolveTexture)) {
124 features.push_back(wgpu::FeatureName::DawnLoadResolveTexture);
125 }
126
127 wgpu::DeviceDescriptor
desc;
128 desc.requiredFeatureCount = features.size();
129 desc.requiredFeatures = features.data();
130 desc.nextInChain = &togglesDesc;
131 desc.deviceLostCallbackInfo.callback =
132 [](WGPUDeviceImpl *
const *, WGPUDeviceLostReason reason,
const char*
message,
void*) {
133 if (reason != WGPUDeviceLostReason_Destroyed) {
135 }
136 };
137
138 wgpu::Device
device = wgpu::Device::Acquire(matchedAdaptor.CreateDevice(&
desc));
140 device.SetUncapturedErrorCallback(
141 [](WGPUErrorType
type,
const char*
message,
void*) {
143 },
144 nullptr);
145
147 backendContext.
fInstance = wgpu::Instance(sInstance->Get());
150 return std::unique_ptr<GraphiteTestContext>(
new DawnTestContext(backendContext));
151}
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
static std::vector< SkPDFIndirectReference > sort(const THashSet< SkPDFIndirectReference > &src)
skgpu::BackendApi backend() override
DawnTestContext(const skgpu::graphite::DawnBackendContext &backendContext)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size