Park prototype WebGPU canvas (CPU copy present) - #45
Draft
remorses wants to merge 7 commits into
Draft
Conversation
This is not the product path. GPU.create() makes a second wgpu instance, so Linux cannot sample the swap texture in-scene. Every frame copies BGRA into the sprite atlas. The napi surface is a Three.js subset: untextured meshes work, MSAA, cube maps, writeTexture, and copyTextureToBuffer do not. Keep this off main until present uses the window device with no CPU copy. The zed pointer includes gpui-ce SurfaceSource::Texture (8802c83138) for that later work. Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
CustomElement::destroy now receives the window so a <canvas> can drop_image its last snapshot when React removes the node. Buffer create/map/copy/draw reject negative and overflowing ranges instead of truncating them. Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
configure and getCurrentTexture already reject a destroyed canvas. Drop only unregistered the id, so a cached JS context could recreate textures that <canvas source> could no longer find. Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
README now lists what the prototype can and cannot do. The cube test still compares blank vs painted screenshots locally. CI skips that compare because Metal VMs often encode identical black frames. Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
0.170 hashes a circular array in getCacheKey. Bun and JSC overflow. Node does not. forceWebGPU is not a real WebGPURenderer option, so the example no longer passes it. Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
Session: ses_f9d7ce355ffe7zwvdtfk9rOJem
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.
Harness: OpenCode / Kimaki
Agent: build
Model: xai/grok-4.6
This is a parked prototype. Do not merge until present uses the window GPU device with no CPU copy.
What it is
A napi WebGPU subset plus
<canvas source>so Three.jsWebGPURenderercan draw an untextured cube.GPU.create()makes a second wgpu instance. Every frame copies BGRA throughpaint_imageinto the sprite atlas.Linux compositor sampling (
SurfaceSource::Texture) is in the zed pointer (8802c83138) but unused, because the canvas texture is not on the window device.What works
examples/three-webgpu.tsxcube (three >= 0.175)@gpuix/react/webgpu, not the package root (browser build stays clean)What does not
antialias: truethrows)writeTexture,copyTextureToBuffer, render bundles, query setsUser prompts
i want to expose canvas api in gpuix native. so that apps are able to use js canvas api in bun and render it to gpui without leaving gpu or copying from js to rust. read https://github.com/Brooooooklyn/canvas. plan adding it as submodule and exporting it as napi rs in our native package somehow, maybe as a rust dependency first. skip submodule until required. if possible we should also expose webgpu too, so things like three js work as well
research webgpu way, i don’t need canvas 2d api, goal is to run three.js with webgpu and not much else. plan that.
why does b require a copy? seems like easisest to me
google about gpu buffers in napi. can’t we just expose a buffer that writes to you and use that simply
is this how browser works too or not
why cant we do same thing as browser?
search prs in https://github.com/gpui-ce/gpui-ce. does it have anything to help us
should we replace zed submodule with the gpui ce instead? find out how much they differ. try forking this and apply all changes we added in our own fork. and see if it is feasible or not.
ok then lets try to just apply their compositor fix commit to ours. add in commit references. proceed implementing this with tests. then explain next phase: wiring up webgpu.
proceed adding webgpu api to native as well. adding an example as well that tries to create a three.js scene using webgpu to render a 3d object into the screen. make sure everything works end to end
ask oracle to review
fix issues. ask mythos review again
fix issues. ask oracle review again
how complete is our webgpu api? did we only add a subset and if so why
should we add these changes as a PR and separate branch then? given this is just slop work basically.
ok create a branch now then. is there other unrelated changes that should go to main instead?
create a pr for this now. commit in groups. push