Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions FIDELITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ The committed PNGs under `testdata/renders/` back every claim here. Reproduce
them with the commands at the bottom. The measured-vs-Chrome numbers live in
[`bench/REPORT.md`](bench/REPORT.md).

## 2026-11-23 (M7) — `GPUTexture`/`GPUTextureView`, `GPURenderPipeline`, `GPURenderPassEncoder`, `queue.writeTexture`, `copyTextureToBuffer`: a real render pipeline, dispatched end to end (feature, engine#415, PR #447, commit `cd234ea`)

Closes out M7 (WebGPU textures and render pipelines) in the go-wasmcontainers WebGPU-readiness roadmap, the render-pipeline counterpart to M5's compute-only path (above). Read directly from the W3C WebGPU specification before writing any code: texture creation and validation (§6.1 GPUTexture, §6.1.1 GPUTextureDescriptor, §6.1.2 Texture Usages, §6.1.3 Texture Creation, §6.3 Texture Formats), texture views (§6.2 GPUTextureView, §6.2.1 Texture View Creation), render pipeline creation (§10.3 GPURenderPipeline, §10.3.1 Render Pipeline Creation, vertex state §10.3.7, fragment state §10.3.4), render pass encoding (§13.3 Pass Encoding for `beginRenderPass`, §17.1 GPURenderPassEncoder / §17.1.2 Finalization for `end()`, §17.2 GPURenderCommandsMixin / §17.2.1 Drawing for `setVertexBuffer`/`setIndexBuffer`/`draw`/`drawIndexed`), `queue.writeTexture` (§19.2 GPUQueue), and `copyTextureToBuffer` (§13.5 Texel Copy Commands, §11.2 Texel Copies).

- **`wgslmsl.TranslateRender`** (`wgslmsl/render.go`), the render-pipeline counterpart to the existing compute-only `Translate`, translates `@vertex`/`@fragment` WGSL entry points to MSL, plus `BindingTexture`/`textureLoad` support shared by both the compute and render paths. Confirmed against a real Metal compiler and an actual render + pixel-readback test, not just a compile check — which caught two real MSL syntax errors and one silently-wrong translation before they could ship: a non-struct vertex/fragment return has no MSL attribute syntax at all (only Metal's own implicit per-stage default, `@builtin(position)` for vertex / `@location(0)` for fragment, is viable bare output); a vertex `@location` input must be a field of a struct parameter marked `[[stage_in]]`, never a bare `[[attribute(N)]]` parameter; and a fragment `@location` varying declared as a bare `[[user(locnN)]]` parameter compiles but silently never receives the rasterizer-interpolated value — fixed by grouping every `@location` input, vertex or fragment, into its own synthesized `[[stage_in]]` struct, never shared by type identity between the two stages.
- **`GPUTexture`/`GPUTextureView`** (`js/webgpu.go`): creation, format/usage validation, `createView` — following the existing `gpuGuard`-wrapped validation convention, matching `gpuCopyBufferToBuffer`/`gpuQueueWriteBuffer`'s own split between guarded validation and plain synchronous `TypeError`.
- **`GPURenderPipeline`**: vertex/fragment state built via `wgslmsl.TranslateRender`.
- **`GPURenderPassEncoder`**: `beginRenderPass`, `setVertexBuffer`, `setIndexBuffer`, `draw`, `drawIndexed`, `end`.
- **`GPUQueue.writeTexture`** and **`GPUCommandEncoder.copyTextureToBuffer`**.
- **Dependency bump: `go-macos/metal` to v0.8.0** (go-macos/metal#23) — adds the render pass and texture primitives this milestone needs: `Device.NewTexture`, `Library.RenderPipeline`, `Device.RunRender`, `RenderEncoder`.
- **8 reviewer-found bugs, all fixed with a real regression test each, no skips**: an unguarded panic in `beginRenderPass`/`copyTextureToBuffer` (now `gpuGuard`-wrapped, captured by an open error scope instead of crashing the script); nil-pointer panics on optional render-pass/texture properties (every optional property now guarded before dereference); undeclared `in` in generated MSL (the `[[stage_in]]`-struct fix above); a helper function emitted twice when shared by a vertex/fragment pair (`translator.sharedHelpers` now skips re-emitting a helper the other stage already wrote; `TestTranslateRenderSharedHelperEmittedOnce`); the compute path wrongly accepting a texture binding (`gpuBuildComputePipeline` now rejects any `wgslmsl.BindingTexture` binding with a `TypeError`, fixed at the `js/webgpu.go` binding layer so the raw `wgslmsl.Translate` API's own texture-in-compute path is untouched; `TestComputePipelineRejectsTextureResource`); no draw validation (`gpuValidateVertexBuffers`/`gpuValidateIndexedVertexBuffers` wired into `gpuDraw`/`gpuDrawIndexed`, with negative-value and out-of-range checks; `TestGPUDrawRejectsMissingVertexBuffer`, `TestGPUDrawRejectsVertexBufferTooSmall`, `TestGPUDrawRejectsNegativeVertexCount`, `TestGPUDrawIndexedRejectsOutOfRangeIndex`); render pass lifecycle not enforced (`finish()` now rejects a still-open pass, and `dispatchWorkgroups`/`draw`/`drawIndexed`/`end` each reject once their own pass has ended, on both the compute and render encoders via shared `passOpen`/`passEnded` state; `TestGPURenderPassEndCalledTwiceRejected`, `TestGPUDrawAfterRenderPassEndRejected`, `TestGPUCommandEncoderFinishWithOpenRenderPassRejected`, `TestGPUComputePassDispatchAfterEndRejected`, `TestGPUComputePassEndCalledTwiceRejected`); and unsupported render options silently ignored (`primitive.cullMode`/`frontFace`/`unclippedDepth`, `multisample.count`/`alphaToCoverageEnabled`, `vertex.constants`, `fragment.constants`, `fragment.targets[0].blend`/`writeMask`, `vertex.buffers[].stepMode` are each now a named rejection for any non-default value instead of being silently dropped; `TestGPUCreateRenderPipelineUnsupportedRenderOptionsRejected`, a 10-case table).
- **Mutation-hardened, not waived**: `mutsweep` flagged SURVIVED guards in the new `wgslmsl` and `js/webgpu.go` code across several rounds of this PR; each was hand-verified rather than reached past with `MUTSWEEP_SKIP` — 6 genuinely unreachable guards in `expr.go`/`render.go` were deleted with a doc-comment reachability proof each (e.g. `resolveResources` already validates every transitively-reachable resource before any expr is translated, so a later `err != nil` check on an already-resolved identifier can never fire), while the remaining guards that looked redundant but are real defense-in-depth against a WGSL construct `go-gfx/wgsl`'s checker accepts but this backend's `mslType` does not support (f16 fields/params/returns) got specific new tests instead (`TestTranslateRenderRejectsF16StructOutputField`, `TestTranslateRenderRejectsSwitchInHelperFunction`, `TestRejectsF16StorageArrayViaResourceParamDecl`, among others).
- Tests: 14 new end-to-end tests exercising real Metal hardware (`js/webgpu_test.go`), each covering a happy path plus at least one validation/error path, plus the targeted tests above from the 8 bug fixes and the mutsweep-hardening rounds. `go build`/`go vet`/`gofmt -l`/`go test ./...`/`govulncheck` clean (real Metal GPU, no skips), `buildscan --dir . --vet` clean under all 13 CI configurations, `go mod tidy` clean in both the root and `bench/` modules.
- **M7 is now complete**: `GPUTexture`/`GPUTextureView`/`GPURenderPipeline`/`GPURenderPassEncoder` alongside M5's `GPUBuffer`/`GPUComputePipeline`/`GPUBindGroup`/`GPUCommandEncoder`, still off by default (`Engine.EnableWebGPU`), backed by the same pure-Go WGSL→MSL translator and pure-Go, no-cgo Metal binding — a full, if deliberately scoped, WebGPU compute-and-render path with no Rust toolchain or vendored binary blob anywhere in it.

## 2026-11-21 (round 49) — engine#418 CLOSED for real: the goja compiler bug round 48 characterized was already fixed upstream a month before this repo's pinned commit; bumping the dependency fixes the real page end to end (fix, engine#418)

Round 48 (just below) stopped at "no safe engine-level mitigation exists" without checking whether goja itself had already addressed the bug it had just characterized — a `priorart --repo dop251/goja` search against the exact mechanism, run before concluding anything further, should have been (and now was) the very next step per this fleet's own bibliography-first rule, not an afterthought.
Expand Down
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1125,6 +1125,25 @@ PNGs, measured vs headless Chrome) is in [`FIDELITY.md`](FIDELITY.md) and
exact `@workgroup_size`-matching dispatch (needed by their LLM kernels)
— `go-macos/metal` v0.6.0 still has no way to pin an explicit
threadgroup shape for `Dispatch`.
- **`GPUTexture`/`GPUTextureView`/`GPURenderPipeline`/`GPURenderPassEncoder`,
`queue.writeTexture`, `copyTextureToBuffer`** (2026-11-23, engine#415, PR
#447): WebGPU textures and render pipelines (M7), the render-pipeline
counterpart to M5's compute-only path. `wgslmsl.TranslateRender`
(`wgslmsl/render.go`) translates `@vertex`/`@fragment` WGSL entry points to
MSL, with every `@location` input or varying grouped into its own
synthesized `[[stage_in]]` struct per stage — a bare `[[attribute(N)]]`/
`[[user(locnN)]]` parameter compiles under Metal but is either rejected
outright or silently never populated, confirmed against a real render +
pixel-readback test, not just a compile check. `go-macos/metal` bumped to
v0.8.0 for the render-pass/texture primitives this needs (`Device.NewTexture`,
`Library.RenderPipeline`, `Device.RunRender`, `RenderEncoder`). 14 new
end-to-end tests against real Metal hardware, plus a follow-up round fixing
8 reviewer-found bugs (an unguarded panic on bad input, render-pass
lifecycle not enforced, unsupported render options silently ignored, among
others), each with its own regression test, no skips. **M7 is now
complete**: still off by default (`Engine.EnableWebGPU`), no Rust toolchain
or vendored binary blob anywhere in the path. See
[`FIDELITY.md`](FIDELITY.md) for the full account.

**Honest limits (not overclaimed)**

Expand Down
Loading