24#include "dawn/dawn_proc.h"
29 wgpu::TextureFormat swapChainFormat)
31 , fSwapChainFormat(swapChainFormat) {
32 WGPUInstanceDescriptor
desc{};
34 desc.features.timedWaitAnyEnable =
true;
56 fDisplayParams.fGraphiteContextOptions.fPriv.fStoreContextRefInRecorder =
true;
59 if (!fGraphiteContext) {
64 fGraphiteRecorder = fGraphiteContext->makeRecorder(ToolUtils::CreateTestingRecorderOptions());
77 fGraphiteRecorder =
nullptr;
78 fGraphiteContext =
nullptr;
90 wgpu::TextureAspect::All);
103 this->snapRecordingAndSubmit();
114 DawnProcTable backendProcs = dawn::native::GetProcs();
115 dawnProcSetProcs(&backendProcs);
117 static constexpr const char* kAdapterToggles[] = {
119 "use_user_defined_labels_in_backend",
121 wgpu::DawnTogglesDescriptor adapterTogglesDesc;
122 adapterTogglesDesc.enabledToggleCount =
std::size(kAdapterToggles);
123 adapterTogglesDesc.enabledToggles = kAdapterToggles;
125 wgpu::RequestAdapterOptions adapterOptions;
126 adapterOptions.backendType =
type;
127 adapterOptions.nextInChain = &adapterTogglesDesc;
129 std::vector<dawn::native::Adapter> adapters =
fInstance->EnumerateAdapters(&adapterOptions);
130 if (adapters.empty()) {
134 wgpu::Adapter adapter = adapters[0].Get();
136 std::vector<wgpu::FeatureName> features;
137 features.push_back(wgpu::FeatureName::SurfaceCapabilities);
138 if (adapter.HasFeature(wgpu::FeatureName::MSAARenderToSingleSampled)) {
139 features.push_back(wgpu::FeatureName::MSAARenderToSingleSampled);
141 if (adapter.HasFeature(wgpu::FeatureName::TransientAttachments)) {
142 features.push_back(wgpu::FeatureName::TransientAttachments);
144 if (adapter.HasFeature(wgpu::FeatureName::Unorm16TextureFormats)) {
145 features.push_back(wgpu::FeatureName::Unorm16TextureFormats);
147 if (adapter.HasFeature(wgpu::FeatureName::DualSourceBlending)) {
148 features.push_back(wgpu::FeatureName::DualSourceBlending);
150 if (adapter.HasFeature(wgpu::FeatureName::FramebufferFetch)) {
151 features.push_back(wgpu::FeatureName::FramebufferFetch);
153 if (adapter.HasFeature(wgpu::FeatureName::BufferMapExtendedUsages)) {
154 features.push_back(wgpu::FeatureName::BufferMapExtendedUsages);
156 if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionETC2)) {
157 features.push_back(wgpu::FeatureName::TextureCompressionETC2);
159 if (adapter.HasFeature(wgpu::FeatureName::TextureCompressionBC)) {
160 features.push_back(wgpu::FeatureName::TextureCompressionBC);
162 if (adapter.HasFeature(wgpu::FeatureName::R8UnormStorage)) {
163 features.push_back(wgpu::FeatureName::R8UnormStorage);
165 if (adapter.HasFeature(wgpu::FeatureName::DawnLoadResolveTexture)) {
166 features.push_back(wgpu::FeatureName::DawnLoadResolveTexture);
169 wgpu::DeviceDescriptor deviceDescriptor;
170 deviceDescriptor.requiredFeatures = features.data();
171 deviceDescriptor.requiredFeatureCount = features.size();
172 deviceDescriptor.deviceLostCallbackInfo.callback =
173 [](WGPUDeviceImpl *
const *, WGPUDeviceLostReason reason,
const char*
message,
void*) {
174 if (reason != WGPUDeviceLostReason_Destroyed &&
175 reason != WGPUDeviceLostReason_InstanceDropped) {
180 wgpu::DawnTogglesDescriptor deviceTogglesDesc;
183 static constexpr const char* kOptionalDeviceToggles[] = {
184 "disable_symbol_renaming",
186 deviceTogglesDesc.enabledToggleCount =
std::size(kOptionalDeviceToggles);
187 deviceTogglesDesc.enabledToggles = kOptionalDeviceToggles;
191 deviceTogglesDesc.nextInChain = deviceDescriptor.nextInChain;
192 deviceDescriptor.nextInChain = &deviceTogglesDesc;
195 auto device = adapter.CreateDevice(&deviceDescriptor);
200 device.SetUncapturedErrorCallback(
201 [](WGPUErrorType
type,
const char*
message,
void*) {
210 wgpu::SwapChainDescriptor swapChainDesc;
211 swapChainDesc.usage = wgpu::TextureUsage::RenderAttachment |
212 wgpu::TextureUsage::TextureBinding |
213 wgpu::TextureUsage::CopySrc |
214 wgpu::TextureUsage::CopyDst;
216 swapChainDesc.width =
fWidth;
217 swapChainDesc.height =
fHeight;
218 swapChainDesc.presentMode =
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
#define SK_ABORT(message,...)
@ kBGRA_8888_SkColorType
pixel with 8 bits for blue, green, red, alpha; in 32-bit word
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
sk_sp< GrDirectContext > fContext
DisplayParams fDisplayParams
sk_sp< SkSurface > getBackbufferSurface() override
virtual void onDestroyContext()=0
virtual bool onInitializeContext()=0
GraphiteDawnWindowContext(const DisplayParams &, wgpu::TextureFormat swapChainFormat)
void setDisplayParams(const DisplayParams ¶ms) override
wgpu::TextureFormat fSwapChainFormat
std::unique_ptr< dawn::native::Instance > fInstance
wgpu::Device createDevice(wgpu::BackendType type)
void onSwapBuffers() override
~GraphiteDawnWindowContext() override
wgpu::SwapChain createSwapChain()
void initializeContext(int width, int height)
wgpu::SwapChain fSwapChain
const EmbeddedViewParams * params
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
DlSurfaceProvider::BackendType BackendType
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
SK_API std::unique_ptr< Context > MakeDawn(const DawnBackendContext &, const ContextOptions &)
SkSurfaceProps fSurfaceProps
sk_sp< SkColorSpace > fColorSpace