20namespace ContextFactory {
29 std::make_unique<DawnQueueManager>(backendContext.
fQueue, sharedContext.
get());
35 std::move(queueManager),
44 case wgpu::TextureFormat::Stencil8: [[fallthrough]];
45 case wgpu::TextureFormat::Depth16Unorm:
46 case wgpu::TextureFormat::Depth32Float:
47 case wgpu::TextureFormat::Depth24PlusStencil8:
48 case wgpu::TextureFormat::Depth32FloatStencil8:
57 case wgpu::TextureFormat::Depth16Unorm: [[fallthrough]];
58 case wgpu::TextureFormat::Depth32Float:
59 case wgpu::TextureFormat::Depth24PlusStencil8:
60 case wgpu::TextureFormat::Depth32FloatStencil8:
69 case wgpu::TextureFormat::Stencil8: [[fallthrough]];
70 case wgpu::TextureFormat::Depth24PlusStencil8:
71 case wgpu::TextureFormat::Depth32FloatStencil8:
84 return wgpu::TextureFormat::Depth16Unorm;
86 return wgpu::TextureFormat::Stencil8;
88 return wgpu::TextureFormat::Depth24PlusStencil8;
91 return wgpu::TextureFormat::Undefined;
95 wgpu::ShaderModule* module,
96 const char* shaderText,
99#if defined(__EMSCRIPTEN__) && \
100 ((__EMSCRIPTEN_major__ < 3 || \
101 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ < 1) || \
102 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ < 51)))
106 static void Fn(WGPUCompilationInfoRequestStatus status,
107 const WGPUCompilationInfo*
info,
109 Handler*
self =
reinterpret_cast<Handler*
>(userdata);
110 SkASSERT(status == WGPUCompilationInfoRequestStatus_Success);
113 self->fSuccess =
true;
114 for (
size_t index = 0; index <
info->messageCount; ++index) {
115 const WGPUCompilationMessage& entry =
info->messages[index];
116 if (entry.type == WGPUCompilationMessageType_Error) {
117 self->fSuccess =
false;
123 if (!
self->fSuccess) {
125 for (
size_t index = 0; index <
info->messageCount; ++index) {
126 const WGPUCompilationMessage& entry =
info->messages[index];
130 entry.message +
'\n';
132 self->fErrorHandler->compileError(
137 const char* fShaderText;
139 bool fSuccess =
false;
143 handler.fShaderText = shaderText;
144 handler.fErrorHandler = errorHandler;
145#if defined(__EMSCRIPTEN__)
147 module->GetCompilationInfo(&Handler::Fn, &handler);
150 wgpu::FutureWaitInfo waitInfo{};
151 waitInfo.future = module->GetCompilationInfo(
152 wgpu::CallbackMode::WaitAnyOnly,
153 [handlerPtr = &handler](wgpu::CompilationInfoRequestStatus status,
154 const wgpu::CompilationInfo*
info) {
155 Handler::Fn(
static_cast<WGPUCompilationInfoRequestStatus
>(status),
156 reinterpret_cast<const WGPUCompilationInfo*
>(
info),
164 [[maybe_unused]]
auto status =
166 SkASSERT(status == wgpu::WaitStatus::Success);
169 return handler.fSuccess;
175 const std::string& wgsl,
176 wgpu::ShaderModule* module,
178 wgpu::ShaderModuleWGSLDescriptor wgslDesc;
179 wgslDesc.code = wgsl.c_str();
181 wgpu::ShaderModuleDescriptor
desc;
182 desc.nextInChain = &wgslDesc;
187 *module = sharedContext->
device().CreateShaderModule(&
desc);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
bool setBackendLabels() const
static std::unique_ptr< Context > MakeContext(sk_sp< SharedContext >, std::unique_ptr< QueueManager >, const ContextOptions &)
const wgpu::Device & device() const
static sk_sp< SharedContext > Make(const DawnBackendContext &, const ContextOptions &)
const Caps * caps() const
uint32_t uint32_t * format
static float max(float r, float g, float b)
SK_API std::unique_ptr< Context > MakeDawn(const DawnBackendContext &, const ContextOptions &)
wgpu::TextureFormat DawnDepthStencilFlagsToFormat(SkEnumBitMask< DepthStencilFlags > mask)
bool DawnFormatIsDepthOrStencil(wgpu::TextureFormat format)
bool DawnFormatIsDepth(wgpu::TextureFormat format)
static bool check_shader_module(const DawnSharedContext *sharedContext, wgpu::ShaderModule *module, const char *shaderText, ShaderErrorHandler *errorHandler)
bool DawnCompileWGSLShaderModule(const DawnSharedContext *sharedContext, const char *label, const std::string &wgsl, wgpu::ShaderModule *module, ShaderErrorHandler *errorHandler)
bool DawnFormatIsStencil(wgpu::TextureFormat format)
static SkString to_string(int n)