wg_engine: hotfix

- initialize stage buffers before drawing
- confirm the surface size in sync stage

Co-authored-by: Jinny You <jinny@lottiefiles.com>
This commit is contained in:
Sergii Liebodkin 2025-06-14 05:25:40 +03:00 committed by GitHub
parent fd1ef5f7ec
commit 85c1ec4281
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 18 additions and 14 deletions

View file

@ -39,6 +39,8 @@ void WgCompositor::initialize(WgContext& context, uint32_t width, uint32_t heigh
resize(context, width, height);
// composition and blend geometries
meshDataBlit.blitBox();
// force stage buffers initialization
flush(context);
}

View file

@ -111,11 +111,11 @@ public:
void beginRenderPass(WGPUCommandEncoder encoder, WgRenderTarget* target, bool clear, WGPUColor clearColor = { 0.0, 0.0, 0.0, 0.0 });
void endRenderPass();
// request shapes for drawing (staging)
// stage data
// stage buffers operations
void reset(WgContext& context);
void flush(WgContext& context);
// request shapes for drawing (staging)
void requestShape(WgRenderDataShape* renderData);
void requestImage(WgRenderDataPicture* renderData);

View file

@ -341,22 +341,24 @@ bool WgRenderer::sync()
// there is no external dest buffer
if (!dstTexture) return false;
// get external dest buffer
WGPUTextureView dstTextureView = mContext.createTextureView(dstTexture);
// insure that surface and offscreen target have the same size
if ((wgpuTextureGetWidth(dstTexture) == mRenderTargetRoot.width) &&
(wgpuTextureGetHeight(dstTexture) == mRenderTargetRoot.height)) {
// get external dest buffer
WGPUTextureView dstTextureView = mContext.createTextureView(dstTexture);
// create command encoder
WGPUCommandEncoder commandEncoder = mContext.createCommandEncoder();
// show root offscreen buffer
mCompositor.blit(mContext, commandEncoder, &mRenderTargetRoot, dstTextureView);
mContext.submitCommandEncoder(commandEncoder);
mContext.releaseCommandEncoder(commandEncoder);
// release dest buffer view
mContext.releaseTextureView(dstTextureView);
}
// create command encoder
WGPUCommandEncoder commandEncoder = mContext.createCommandEncoder();
// show root offscreen buffer
mCompositor.blit(mContext, commandEncoder, &mRenderTargetRoot, dstTextureView);
mContext.submitCommandEncoder(commandEncoder);
mContext.releaseCommandEncoder(commandEncoder);
// release dest buffer view
mContext.releaseTextureView(dstTextureView);
return true;
}
// render target handle
bool WgRenderer::target(WGPUDevice device, WGPUInstance instance, void* target, uint32_t width, uint32_t height, int type)
{