Skip to content

[webgpu] Use WebGPU context API for ThorVG targets#47

Closed
wenjieshen wants to merge 1 commit into
mainfrom
jay/wg/receive-webgpu-adapter
Closed

[webgpu] Use WebGPU context API for ThorVG targets#47
wenjieshen wants to merge 1 commit into
mainfrom
jay/wg/receive-webgpu-adapter

Conversation

@wenjieshen

Copy link
Copy Markdown
Collaborator

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.

@wenjieshen wenjieshen self-assigned this Jul 3, 2026
Copilot AI review requested due to automatic review settings July 3, 2026 11:07
@wenjieshen wenjieshen requested a review from hermet as a code owner July 3, 2026 11:07
@wenjieshen wenjieshen changed the title Use WebGPU context API for ThorVG targets [webgpu] Use WebGPU context API for ThorVG targets Jul 3, 2026
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.
@wenjieshen wenjieshen force-pushed the jay/wg/receive-webgpu-adapter branch from f9d3632 to 069be41 Compare July 3, 2026 11:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::Context with {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 thread src/MultiCanvas.cpp
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 thread src/Example.h
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));
Copilot AI review requested due to automatic review settings July 3, 2026 11:10

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread src/MultiCanvas.cpp
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 thread src/Example.h
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));
@hermet

hermet commented Jul 6, 2026

Copy link
Copy Markdown
Member

@wenjieshen not duplicated with this? #45

@wenjieshen

Copy link
Copy Markdown
Collaborator Author

@wenjieshen not duplicated with this? #45

Thank you. It's duplicated. I closed this one.

@wenjieshen wenjieshen closed this Jul 6, 2026
@wenjieshen wenjieshen deleted the jay/wg/receive-webgpu-adapter branch July 6, 2026 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants