wg_engine: sync up to update the engine work to webgpu_native v22

Only minor changes required
Keeped compatibility with emsdk

issue: https://github.com/thorvg/thorvg/issues/2909
This commit is contained in:
Sergii Liebodkin 2025-04-21 14:24:34 +03:00 committed by Hermet Park
parent bcfbc55af2
commit c77b6ec8db
2 changed files with 20 additions and 16 deletions

View file

@ -156,16 +156,15 @@ void WgCompositor::beginRenderPass(WGPUCommandEncoder commandEncoder, WgRenderSt
.depthLoadOp = WGPULoadOp_Clear, .depthStoreOp = WGPUStoreOp_Discard, .depthClearValue = 1.0f,
.stencilLoadOp = WGPULoadOp_Clear, .stencilStoreOp = WGPUStoreOp_Discard, .stencilClearValue = 0
};
//WGPURenderPassDepthStencilAttachment depthStencilAttachment{ .view = texViewStencil, .depthClearValue = 1.0f, .stencilLoadOp = WGPULoadOp_Clear, .stencilStoreOp = WGPUStoreOp_Discard };
WGPURenderPassColorAttachment colorAttachment{};
colorAttachment.view = target->texViewMS,
colorAttachment.loadOp = clear ? WGPULoadOp_Clear : WGPULoadOp_Load,
colorAttachment.storeOp = WGPUStoreOp_Store;
colorAttachment.resolveTarget = target->texView;
colorAttachment.clearValue = clearColor;
#ifdef __EMSCRIPTEN__
colorAttachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
#endif
const WGPURenderPassColorAttachment colorAttachment{
.view = target->texViewMS,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.resolveTarget = target->texView,
.loadOp = clear ? WGPULoadOp_Clear : WGPULoadOp_Load,
.storeOp = WGPUStoreOp_Store,
.clearValue = clearColor
};
WGPURenderPassDescriptor renderPassDesc{ .colorAttachmentCount = 1, .colorAttachments = &colorAttachment, .depthStencilAttachment = &depthStencilAttachment };
renderPassEncoder = wgpuCommandEncoderBeginRenderPass(commandEncoder, &renderPassDesc);
assert(renderPassEncoder);
@ -273,10 +272,12 @@ void WgCompositor::blit(WgContext& context, WGPUCommandEncoder encoder, WgRender
.depthLoadOp = WGPULoadOp_Load, .depthStoreOp = WGPUStoreOp_Discard,
.stencilLoadOp = WGPULoadOp_Load, .stencilStoreOp = WGPUStoreOp_Discard
};
WGPURenderPassColorAttachment colorAttachment { .view = dstView, .loadOp = WGPULoadOp_Load, .storeOp = WGPUStoreOp_Store };
#ifdef __EMSCRIPTEN__
colorAttachment.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED;
#endif
const WGPURenderPassColorAttachment colorAttachment {
.view = dstView,
.depthSlice = WGPU_DEPTH_SLICE_UNDEFINED,
.loadOp = WGPULoadOp_Load,
.storeOp = WGPUStoreOp_Store,
};
const WGPURenderPassDescriptor renderPassDesc{ .colorAttachmentCount = 1, .colorAttachments = &colorAttachment, .depthStencilAttachment = &depthStencilAttachment };
WGPURenderPassEncoder renderPass = wgpuCommandEncoderBeginRenderPass(encoder, &renderPassDesc);
wgpuRenderPassEncoderSetBindGroup(renderPass, 0, src->bindGroupTexure, 0, nullptr);

View file

@ -116,8 +116,11 @@ bool WgRenderer::surfaceConfigure(WGPUSurface surface, WgContext& context, uint3
#endif
.width = width,
.height = height,
#ifndef __EMSCRIPTEN__
.presentMode = WGPUPresentMode_Fifo,
#ifdef __EMSCRIPTEN__
.presentMode = WGPUPresentMode_Fifo
#elif __linux__
#else
.presentMode = WGPUPresentMode_Immediate
#endif
};
wgpuSurfaceConfigure(surface, &surfaceConfiguration);