Repository navigation
feat(napi): texImage2D and texSubImage2D take a WebGPU canvas - #191
Merged
Merged
Conversation
A WebGPU canvas used as a WebGL texture source threw (texImage2D) or, before #188, panicked (texSubImage2D). Both now read the canvas's frame (the current texture if one is out, else the last presented frame) as unpremultiplied RGBA8 and upload it, like a 2D canvas source. canvas-c: toDataURL's copy-and-map step is now with_mapped_texture, shared with the new read_rgba8; canvas_native_webgl_tex_{,sub_}image2d_webgpu return false when there is no 8-bit frame, which the binding throws for. Specs: toDataURL pixel check for a WebGPU canvas (all platforms), and texImage2D/texSubImage2D from a WebGPU canvas (Windows for now).
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Finishes #188: a WebGPU canvas is now a WebGL texture source on the Node-API hosts (Windows, and Linux once #189 lands), instead of
texImage2Dthrowing andtexSubImage2Dthrowing (previously panicking).What it does
texImage2D/texSubImage2Dwith a WebGPU canvas read its frame and upload it, the same way a 2D canvas source does. The frame is the current texture ifgetCurrentTexture()handed one out, otherwise the last presented frame, matchingtoDataURL.alphaMode: 'premultiplied'are unpremultiplied.rgba16floatcanvases, and canvases that were never configured, still throw, with a message saying there is no 8-bit frame to read.canvas-c
toDataURL's copy-texture-to-buffer-and-map step is pulled out intowith_mapped_texture, which bothtoDataURLand the newread_rgba8use.toDataURL's encoding is unchanged.canvas_native_webgl_tex_image2d_webgpu/canvas_native_webgl_tex_sub_image2d_webgpu. They returnfalsewhen there is no 8-bit frame; the binding throws on that. Header regenerated.texImage2Dstill has no WebGPU-canvas case.Testing
webgpu.canvas"toDataURL reads back the current frame": clears a WebGPU canvas to blue, decodes the PNG and checks the pixel. It covers the refactored readback on every platform.canvassource.webgl"texImage2D / texSubImage2D accepts a webgpu canvas", which render the uploaded texture and check for blue. They're gated to Windows for now.toDataURLtest), canvassource 9/9, offscreen 64/64. The newtoDataURLtest also passes on the previous binary.canvas-napion master doesn't build on macOS (the Windows-only callbacks that feat: Linux support #189 fixes), so it was type-checked here despite those two pre-existing errors, with a deliberate type error inbase.rsconfirming that file is checked. Please run--suite canvassource.webglon Windows.