92 const char* shaderText,
95#if defined(__EMSCRIPTEN__) && \
96 ((__EMSCRIPTEN_major__ < 3 || \
97 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ < 1) || \
98 (__EMSCRIPTEN_major__ == 3 && __EMSCRIPTEN_minor__ == 1 && __EMSCRIPTEN_tiny__ < 51)))
102 static void Fn(WGPUCompilationInfoRequestStatus status,
103 const WGPUCompilationInfo*
info,
105 Handler*
self =
reinterpret_cast<Handler*
>(userdata);
106 SkASSERT(status == WGPUCompilationInfoRequestStatus_Success);
109 self->fSuccess =
true;
110 for (
size_t index = 0; index <
info->messageCount; ++index) {
111 const WGPUCompilationMessage& entry =
info->messages[index];
112 if (entry.type == WGPUCompilationMessageType_Error) {
113 self->fSuccess =
false;
119 if (!
self->fSuccess) {
121 for (
size_t index = 0; index <
info->messageCount; ++index) {
122 const WGPUCompilationMessage& entry =
info->messages[index];
124 std::to_string(entry.lineNum) +
':' +
125 std::to_string(entry.linePos) +
' ' +
126 entry.message +
'\n';
128 self->fErrorHandler->compileError(
129 self->fShaderText, errors.c_str(),
false);
133 const char* fShaderText;
135 bool fSuccess =
false;
139 handler.fShaderText = shaderText;
140 handler.fErrorHandler = errorHandler;
141 module->GetCompilationInfo(&Handler::Fn, &handler);
143 return handler.fSuccess;
148 const std::string& wgsl,
149 wgpu::ShaderModule* module,
151 wgpu::ShaderModuleWGSLDescriptor wgslDesc;
152 wgslDesc.code = wgsl.c_str();
154 wgpu::ShaderModuleDescriptor desc;
155 desc.nextInChain = &wgslDesc;
158 *
module = sharedContext->device().CreateShaderModule(&desc);
static std::unique_ptr< Context > MakeContext(sk_sp< SharedContext >, std::unique_ptr< QueueManager >, const ContextOptions &)
static sk_sp< SharedContext > Make(const DawnBackendContext &, const ContextOptions &)
uint32_t uint32_t * format
SK_API std::unique_ptr< Context > MakeDawn(const DawnBackendContext &, const ContextOptions &)