[webgpu] Use WebGPU context API for ThorVG targets#47
Closed
wenjieshen wants to merge 1 commit into
Closed
Conversation
Motivation:
ThorVG now exposes WgCanvas::Context so callers can provide
the WebGPU adapter together with the instance and device.
The previous target overload left the adapter unset,
which prevents the renderer from receiving the full WebGPU context it now tracks.
Description:
Pass {instance, adapter, device} through the new WgCanvas::target(context, ...)
overload for both the main WebGPU window and the MultiCanvas offscreen render target.
f9d3632 to
069be41
Compare
There was a problem hiding this comment.
Pull request overview
Updates the WebGPU example integration to use ThorVG’s new tvg::WgCanvas::Context API so callers pass the full WebGPU context (instance/adapter/device) into WgCanvas::target(...), including the offscreen MultiCanvas path.
Changes:
- Switch WebGPU canvas target calls to the new
WgCanvas::target(context, ...)overload. - Populate
WgCanvas::Contextwith{instance, adapter, device}for both the main window and MultiCanvas offscreen rendering.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/MultiCanvas.cpp | Uses WgCanvas::Context when targeting an offscreen WebGPU texture in the MultiCanvas loop. |
| src/Example.h | Uses WgCanvas::Context when targeting the main WebGPU window surface on resize. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
357
to
360
| //Set the canvas target and draw on it. | ||
| tvgexam::verify(canvas->target(device, instance, renderTarget, SIZE, SIZE, tvg::ColorSpace::ABGR8888S, 1)); | ||
| tvg::WgCanvas::Context context = {instance, adapter, device}; | ||
| tvgexam::verify(canvas->target(context, renderTarget, SIZE, SIZE, tvg::ColorSpace::ABGR8888, 1)); | ||
|
|
Comment on lines
+520
to
+521
| tvg::WgCanvas::Context context = {instance, adapter, device}; | ||
| verify(static_cast<tvg::WgCanvas*>(canvas)->target(context, surface, width, height, tvg::ColorSpace::ABGR8888)); |
Comment on lines
+358
to
+359
| tvg::WgCanvas::Context context = {instance, adapter, device}; | ||
| tvgexam::verify(canvas->target(context, renderTarget, SIZE, SIZE, tvg::ColorSpace::ABGR8888, 1)); |
Comment on lines
+520
to
+521
| tvg::WgCanvas::Context context = {instance, adapter, device}; | ||
| verify(static_cast<tvg::WgCanvas*>(canvas)->target(context, surface, width, height, tvg::ColorSpace::ABGR8888)); |
Member
|
@wenjieshen not duplicated with this? #45 |
Collaborator
Author
Thank you. It's duplicated. I closed this one. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation:
ThorVG now exposes WgCanvas::Context so callers can provide the WebGPU adapter together with the instance and device. The previous target overload left the adapter unset, which prevents the renderer from receiving the full WebGPU context it now tracks.
Description:
Pass {instance, adapter, device} through the new WgCanvas::target(context, ...) overload for both the main WebGPU window and the MultiCanvas offscreen render target.