Skip to content

test(wgslmsl): mutation-harden render.go/translator.go/expr.go for engine#415 M7 - #447

Open
tannevaled wants to merge 11 commits into
mainfrom
webgpu-render-wgslmsl
Open

tannevaled wants to merge 11 commits into
mainfrom
webgpu-render-wgslmsl

Conversation

@tannevaled

@tannevaled tannevaled commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part of the WebGPU roadmap M7 standing brief (engine#415, left open). This PR
now covers two steps of that brief on one branch: the wgslmsl translator
hardening (below, unchanged from the previous revision) and the JS-facing
js/webgpu.go bindings for textures and render pipelines (new, this
revision). A FIDELITY.md entry remains a follow-up, tracked separately.

Hardens wgslmsl's entry-point-to-MSL translation (5e4b786) against the
coverage gaps mutsweep's push gate originally flagged, closing every one of
them without a skip flag:

  • 8b02358: tidied go.sum, left stale by the go-macos/metal v0.8.0 bump
    (e0751dd) — unrelated to this branch's own changes, fixed because it was
    blocking a clean push gate.
  • 6658ab3: deleted 6 guards proven unreachable (resource validation already
    done by resolveResources/emitHelperFuncs before each site is reached),
    each with a doc-comment proof, not a waiver.
  • 804bf42: added/strengthened 3 tests that killed real coverage gaps
    (render.go:260, render.go:415, render.go:434) — an f16 struct output
    field, a switch statement inside a helper function, and a strengthened
    assertion on the existing f16-bare-fragment-output test that had been
    accepting a different error message than the one the mutated line actually
    produces. Also added a documented, deliberately-not-fixed test
    (TestRejectsF16StorageArrayViaResourceParamDecl) for an asymmetry between
    resolveResources' resource-level f16 check and mslType's own, confirmed
    not a live correctness gap — resourceParamDecl independently and always
    rejects it.
  • 67785a6: deleted the 7th and last flagged line, expr.go:448's
    textureLoad arity check — proven unreachable by hand on both branches:
    go-gfx/wgsl's own overload table ties exactly one arity to each texture
    Kind, and resolveResources' ASHandle case accepts only the one
    Kind/Dim/Arrayed combination whose own arity is 3, so a checker-valid call
    of any other arity is already rejected before this line — either by
    resolveResources itself or by the checker, before Translate ever
    reaches the translator.

mutsweep disposition (wgslmsl)

All 10 originally-SURVIVED lines from the base commit's -only sweep
(expr.go:448,452,456,460; render.go:227,256,334,406,425,429) are now
resolved: 7 deleted as proven-dead code, 3 covered by new/strengthened tests.
gitpush's own mutsweep hook re-swept this tree and raised no refusal —
pushed clean, no MUTSWEEP_SKIP.

A separate, broader mutsweep -dir wgslmsl -files expr.go,render.go sweep
(no -only, covering every line in both files, not just the ones this PR
touched) still reports 33 SURVIVED + 5 caught-by-PANIC lines. These are
pre-existing, from 5e4b786/f95ecbe, outside this PR's own diff, and not
flagged by the push gate itself — out of scope here, left for a dedicated
mutation-hardening pass if the team wants one.

JS bindings: textures and render pipelines (a947cb7, 8448e65)

Adds the remaining JS-facing WebGPU surface for M7, in js/webgpu.go,
following the file's own established binding conventions exactly (no new
patterns):

  • GPUTexture/GPUTextureView: createTexture (format/usage/dimension/
    mip/sample-count validation, go-macos/metal's only supported
    PixelFormatR8Uint), createView.
  • GPURenderPipeline: createRenderPipeline — vertex/fragment state
    resolved via wgslmsl.TranslateRender, vertex attributes matched to the
    shader's own @location inputs by component count and scalar kind,
    layout: 'auto' only, no depthStencil, triangle-list only, any
    resource binding (@group/@binding) named as an unsupported rejection.
  • GPURenderPassEncoder: beginRenderPass (exactly one color attachment,
    no depth/stencil, loadOp/storeOp mapped to Metal load/store actions),
    setPipeline, setVertexBuffer, setIndexBuffer (uint32 only),
    draw, drawIndexed, end.
  • GPUQueue.writeTexture and GPUCommandEncoder.copyTextureToBuffer.

Error-model split matches the existing buffer bindings exactly: a WebIDL-level
argument problem (bad shape, out-of-range bytes known at call time, an
unsupported format/dimension/layout) is a synchronous TypeError
(unsupportedJS or a plain vm.NewTypeError, both pass through gpuGuard
unchanged); GPU content validation (a shader that fails to translate, a draw
with no pipeline bound, a bounds mismatch only known against the real data)
is panicValidation/panicOutOfMemory, captured by an open error scope,
never a synchronous throw.

Test coverage

20 new tests in js/webgpu_test.go, every one exercising real Metal hardware
(confirmed non-skipped on this machine) — a happy path plus at least one
validation/error path for every new binding:

  • Texture lifecycle: creation + shape readback, unsupported-format rejection,
    createView + unsupported-dimension rejection.
  • Render pipeline: resource-binding rejection (two distinct shapes — a
    runtime-sized storage array that TranslateRender itself can't translate,
    captured by error scope like a genuinely bad shader; and a translatable
    fixed-size uniform binding that reaches this binding's own rejection check,
    a synchronous throw).
  • Render pass: indexed and non-indexed draw end-to-end (real GPU readback,
    bit-exact), draw-without-pipeline captured by error scope,
    unsupported-index-format rejection.
  • writeTexture: round-trip readback, out-of-range data captured by error
    scope.
  • copyTextureToBuffer: out-of-bounds destination rejection.
  • 6 tests added after a mutsweep sweep of the new helpers
    (gpuReadExtent, gpuIsZeroOrigin, gpuReadColor) flagged 6 refusals as
    never distinguished by any existing test: a missing size key, a
    non-object origin/clearValue (plain number, not a dict or sequence), a
    partial origin object with one field present and the rest genuinely
    absent from the object (not merely undefined — real missing keys reached
    only once the && chain's own short-circuit is avoided), and the
    clearValue dict-vs-sequence branch made observable by a render pass with
    no draw call at all (the clear colour is otherwise always painted over).
    All 6 re-swept clean (caught, 0 survivors).

mutsweep remediation for the 8 reviewer-found bugs (e5c5b64, e91a4bd)

e5c5b64 fixed all 8 bugs the reviewer found on the previous revision of
this PR (each with its own regression test). Closing the diff's push-gate
gaps took one more commit, e91a4bd, because several of the new guards were
only reachable through a process-ending panic rather than a plain assertion
("caught by PANIC" — luck, not proof — rather than "caught"):

  • js/webgpu.go: gpuValidateIndexedVertexBuffers's indexCount <= 0 guard
    deleted as proven dead code (doc comment in place) — its only caller,
    gpuDrawIndexed, already guarantees a non-nil index buffer and
    indexCount >= 0 before calling it, and the loop below already runs zero
    iterations for indexCount == 0 on its own. gpuGetFloat/gpuReadColor's
    missing-vs-explicit-undefined handling: added
    TestGPUReadColorExplicitUndefinedGDefaultsToZero (built via
    vm.RunString, the only way to get a real explicit-undefined property —
    vm.NewObject+Set cannot produce one) and added defer recover() to the
    two existing missing-property tests so a reintroduced nil-panic fails as a
    plain assertion instead of crashing the whole test binary.
  • wgslmsl/render.go: registerStageInputAccessor's in.Member == "" guard
    deleted as proven dead code (doc comment in place) — go-gfx/wgsl's
    IOVar.Param is always a valid parameter index for every input regardless
    of Member, so without the guard a bare top-level builtin input only ever
    writes a harmless orphan inputFlatten[po][""] entry that memberExpr can
    never look up (WGSL's own grammar has no member-access syntax with an empty
    name). Added defer recover() to six existing tests
    (RejectsParseError, RejectsMissingVertexEntryPoint,
    RejectsMissingFragmentEntryPoint, RejectsFragmentOutputBuiltin,
    RejectsF16UniformResource, RejectsSamplerResource) whose crash paths
    previously masked whether translateStageEntry's resolveResources error
    check, outputIOAttr's builtin check, and resolveResources's own
    texture-type assertion (translator.go) would also have failed as plain
    assertions.

Verified clean: mutsweep -dir js -only webgpu.go:1693 (1 caught, 0
caught-by-panic, 0 survived) and mutsweep -dir wgslmsl -only <30 lines spanning render.go and translator.go covering this diff> (30 caught, 0
caught-by-panic, 0 survived). gofmt -l . is clean on every file this PR
touches (5 unrelated pre-existing findings elsewhere in the repo, confirmed
present on the base commit too, untouched). buildscan --vet --dir .
recorded a clean pass for tree c4a1d305e927 — go vet passed under all 13
CI configurations; the one pre-existing, unrelated finding (client_none.go
has no configuration that compiles it under webengine_nonet && webengine_nojs together) predates this branch and is out of scope. CI is
green on the exact pushed commit: go-webengine/engine#447 @e91a4bd PASS SUCCESS:15. No skip flags of any kind (MUTSWEEP_SKIP, MODTIDY_WAIVE,
BUILDSCAN_SKIP) were used on any push, including this one.

Known gap — NOT verified from this environment

The cross-repo go-wasmcontainers/gpu TestBatchRender end-to-end test is
out of reach here and has not been run. Everything above was verified with
this repository's own go test ./... and the real Metal GPU on this
machine; the cross-repo e2e path remains to be exercised separately.

🤖 Generated with Claude Code

tannevaled and others added 11 commits November 22, 2026 11:38
go-macos/metal#23 (v0.8.0) adds the render pass and texture
primitives engine#415 (WebGPU M7) needs: Device.NewTexture,
Library.RenderPipeline, Device.RunRender, RenderEncoder. Pulling
the new version in now so wgslmsl's own end-to-end tests can compile
and run vertex/fragment pipelines against real Metal.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…e#415 M7)

Adds TranslateRender (render.go), the render-pipeline counterpart to
Translate's own @compute path, plus BindingTexture/textureLoad support
shared by both paths. Confirmed against a real Metal compiler and an
actual render + pixel-readback test (not just a compile check), which
caught two 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 a viable bare output.
  - A vertex @location input must be a field of a struct parameter marked
    [[stage_in]]; an individual bare [[attribute(N)]] parameter is
    rejected outright.
  - A fragment @location varying declared as an individual 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).

js/webgpu.go bindings and the FIDELITY.md entry follow in a later PR.
The cross-repo go-wasmcontainers/gpu TestBatchRender e2e test is not run
from this environment and remains an unverified gap.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…gine#415 M7

Adds coverage mutsweep's push gate flagged as missing against 5e4b786
(translate @vertex/@Fragment entry points to MSL): resource-handle
rejections (non-2D and non-u32 sampled textures), the f16
WGSL-Check-accepts/this-package-rejects asymmetry (uniform resource,
vertex input, bare fragment output), a matrix helper-function
parameter, a runtime-sized storage array in a render stage, and a
local alias of a texture resource.

Two judgment calls made without coordinator review, disclosed here:

- Replaced the existing "arrayed texture handle resource" case (a
  4-arg textureLoad on texture_2d_array<u32>) with a texture_3d<u32>
  one, because the 4-arg call is rejected earlier by this package's
  arity check and never reaches translator.go's own Dim/Arrayed/Kind
  guard. Isolation of the texture_3d<u32> replacement was
  hand-mutation-verified (mutate the guard to `if false && (...)`,
  confirm the real-code error disappears).

- render.go:406 (emitHelperFuncs' own error propagation) and
  render.go:425 (mslType(ep.Func.Ret) for a bare return type) are left
  untested: hand-mutation shows both survive, under every input tried,
  because any value of the disallowed type still trips this package's
  shared mslType gate elsewhere in the same translation (the entry
  body's own matrix/f16 expression, not the line being mutated). Each
  is documented in its test's doc comment as a structural invariant,
  not a coverage gap.

mutsweep -dir wgslmsl -only <36 lines> -- go test ./...: 21 caught, 5
caught by panic, 10 survived — all 10 hand-verified equivalent (4
carried over from the prior commit's own baseline, the 2 above, plus
render.go:227/256/334/429, expr.go:448/452/456/460 from the existing
baseline). gofmt -l and go test ./wgslmsl/... both clean.

NOT verified from this environment: the cross-repo
go-wasmcontainers/gpu TestBatchRender end-to-end test. This commit is
compiler/test-only (wgslmsl package); no change to js/webgpu.go
bindings or FIDELITY.md, which remain for a follow-up PR per the
standing M7 roadmap (engine#415, left open).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
e0751dd bumped github.com/go-macos/metal to v0.8.0 but did not re-run
go mod tidy, leaving the superseded v0.7.0 checksum lines in go.sum for
both the root module and the nested bench module. Unrelated to this
branch's wgslmsl test-coverage work; fixed here because the push gate
requires go.sum to be tidy and a waiver is not an acceptable substitute.

Verified with GOTOOLCHAIN=go1.27.4 GOWORK=off go mod tidy in both
modules (the installed go is 1.27.3; the go.mod directive on this
branch names 1.27.4). go.mod is unchanged in both modules; only the
stale go.sum lines were removed.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mutsweep flagged 10 SURVIVED guards in this PR's new expr.go/render.go
code. Per explicit instruction, each of the 10 was analyzed line-by-line
to tell genuinely dead code from defense-in-depth, instead of reaching
for MUTSWEEP_SKIP.

6 of the 10 are unreachable and are deleted here, each with a doc
comment giving the specific reachability proof:

- expr.go textureLoadExpr: the `!tracked` check, the
  `b.Kind != BindingTexture` check, and the `err != nil` check on
  tr.expr(c.Args[0]) for the texture argument. resolveResources
  validates every transitively-reachable resource (tracked + textures
  only) before any expr is translated, and tr.expr on an already-
  resolved Ident/resource cannot itself fail.

- render.go outputIOAttr: `io.Location == nil`. go-gfx/wgsl's entryIO
  rejects any IO with neither a builtin nor a location before
  wgsl.Check returns, and Translate/TranslateRender bail on any
  checker error before translation starts.

- render.go stageEntryParams: the `err != nil` check on
  vecShape(in.Type) for a located (non-builtin) input. scalarOf's
  exact type-shape correspondence with vecShape, combined with
  entryIO's own location-type validation, means vecShape cannot fail
  on a type that reached this branch.

- render.go translateStageEntry: `len(ep.Outputs) != 1` for a
  non-struct bare return. go-gfx/wgsl's entryIO/addIO appends to
  ep.Outputs exactly once for any non-struct, non-void return value,
  so this branch (reached only when ep.Func.Ret is not a StructType)
  always has len(ep.Outputs) == 1.

Re-swept wgslmsl/{expr,render}.go with mutsweep after the deletions:
none of the 6 deleted conditions appear anywhere in the 75-refusal
report (confirmed by content, not just line number, since deletions
shift line numbers) — there is nothing left at those sites to mutate.

Full test suite and gofmt remain green.

The remaining 4 of the 10 (expr.go textureLoad's len(c.Args) != 3;
render.go emitIOStruct's mslType(io.Type) err; render.go's
emitHelperFuncs call err; render.go's bare-return mslType err) are
confirmed genuine defense-in-depth — each guards against a WGSL
construct (extra/fewer textureLoad args, f16 fields/params/returns,
unsupported aggregate types) that go-gfx/wgsl's checker accepts but
this backend's mslType deliberately does not support. These are
reported separately for a decision on how to account for them, not
silently waived here.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
engine#447's mutsweep push-hook flagged 4 SURVIVED lines after the
expr.go/render.go dead-code cleanup: expr.go:448, render.go:260,
render.go:415, render.go:434. All 4 turned out to be reachable by a
real, checker-valid input except expr.go:448 (reported separately).

- render.go:260 (emitIOStruct's mslType(io.Type) check): a struct-typed
  fragment output with an f16 field fails here, before the body is ever
  translated (TestTranslateRenderRejectsF16StructOutputField).
- render.go:415 (translateStageEntry's emitHelperFuncs propagation): a
  switch statement inside a helper function's own body fails here,
  independently of the already-redundant matrix-parameter shape
  (TestTranslateRenderRejectsSwitchInHelperFunction).
- render.go:434 (translateStageEntry's mslType(ep.Func.Ret) check): an
  f16 bare fragment return IS caught here first (it runs before the body
  is translated at all) — the existing test just never asserted a
  specific enough message to tell this check apart from the body's own,
  later, independent literal-translation rejection. Strengthened
  TestTranslateRenderRejectsF16FragmentBareOutput's assertion to require
  mslScalar's own "only bool/i32/u32/f32" text.

Also: corrected a stale comment on "non-2D texture handle resource"
(wgslmsl_test.go) that had the masking direction backwards — measured
directly this round, resolveResources rejects an arrayed texture
resource itself, before any call's own arity is ever inspected.

And: added TestRejectsF16StorageArrayViaResourceParamDecl, confirming
with a specific message that the scalarOrVecElemBytes/mslType f16
asymmetry noted earlier is not a live correctness gap — resourceParamDecl's
own mslType check on the same element type always runs, and always
rejects f16, before any success path can return a Result.

expr.go:448 remains SURVIVED; reported back separately as an apparent
equivalent mutant (every texture kind/dim combination this backend's
checker could accept at a different arity is rejected earlier, either
by the checker itself or by resolveResources, before this arity check
is ever reached).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
expr.go:448's "if len(c.Args) != 3" was the last of the 10 lines
mutsweep flagged SURVIVED on this branch. Verified by hand, both
directions, not just reasoned about: go-gfx/wgsl's own overload table
(builtins_custom.go) ties exactly one arity to each texture Kind, and
resolveResources' own ASHandle case accepts exactly one Kind/Dim/Arrayed
combination — the one whose own arity is 3. A checker-valid 4-argument
call on an arrayed texture_2d_array<u32> resource is rejected by
resolveResources itself, before the body is translated; a wrong-arity
call on the one resource type resolveResources accepts has no matching
overload at all, rejected by the checker before Translate ever reaches
the translator. Neither path reaches this line. Doc-comment proof added
alongside the other 6 already-deleted checks in this function
(6658ab3), same "hand-verified by mutation" standard.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Implement the remaining JS-facing WebGPU surface for M7: GPUTexture and
GPUTextureView (creation, format/usage validation, createView),
GPURenderPipeline (vertex/fragment state via wgslmsl.TranslateRender),
GPURenderPassEncoder (beginRenderPass, setVertexBuffer, setIndexBuffer,
draw, drawIndexed, end), GPUQueue.writeTexture, and
GPUCommandEncoder.copyTextureToBuffer. Follows the existing binding
conventions (gpuGuard-wrapped validation vs. plain synchronous TypeError)
exactly, matching gpuCopyBufferToBuffer/gpuQueueWriteBuffer's own split.

Adds 14 end-to-end tests exercising real Metal hardware, each covering a
happy path plus at least one validation/error path.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
mutsweep flagged 6 refusals in webgpu.go's new gpuReadExtent/
gpuIsZeroOrigin/gpuReadColor helpers (missing-size, non-object and
partial-object origin/clearValue inputs) as never distinguished by any
test. Adds 6 targeted end-to-end tests — including one that avoids the
`&&` chain's own short-circuit so a missing key's default path is
actually reached — closing all 6.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Addresses every bug the review of engine#447 (textures and render
pipelines, engine#415 M7) raised against this branch, with a real
regression test proving each one (no MUTSWEEP_SKIP/MODTIDY_WAIVE/
BUILDSCAN_SKIP used on either side):

1. Unguarded panic in beginRenderPass/copyTextureToBuffer — wrapped in
   gpuGuard so a validation failure is captured by an open error scope
   instead of crashing the whole script synchronously.
2. Nil-pointer panics on optional render-pass/texture properties — guarded
   every optional property read against a missing key before dereferencing.
3. Undeclared `in` in generated MSL — fixed TranslateRender's fragment-
   input emission so every @location varying is grouped into its own
   synthesized [[stage_in]] struct, matching Metal's own requirement.
4. Helper function emitted twice when shared by a vertex/fragment pair —
   translator.sharedHelpers (one map instance shared by both translators)
   now skips re-emitting a helper the other stage already wrote.
   Test: TestTranslateRenderSharedHelperEmittedOnce (wgslmsl/render_test.go).
5. Compute path wrongly accepted a texture binding — gpuBuildComputePipeline
   now rejects any wgslmsl.BindingTexture binding with a TypeError (fixed at
   the js/webgpu.go binding layer, not in wgslmsl, so the raw
   wgslmsl.Translate API's own supported texture-in-compute-via-Metal-direct
   path is untouched).
   Test: TestComputePipelineRejectsTextureResource (js/webgpu_test.go).
6. No draw validation — added gpuVertexSlot/gpuBoundVertexBuffer.size and
   gpuValidateVertexBuffers/gpuValidateIndexedVertexBuffers, wired into
   gpuDraw/gpuDrawIndexed with negative-value and out-of-range checks.
   Tests: TestGPUDrawRejectsMissingVertexBuffer,
   TestGPUDrawRejectsVertexBufferTooSmall,
   TestGPUDrawRejectsNegativeVertexCount,
   TestGPUDrawIndexedRejectsOutOfRangeIndex (js/webgpu_test.go).
7. Render pass lifecycle not enforced — finish() now rejects a still-open
   pass, and dispatchWorkgroups/draw/drawIndexed/end each reject once their
   own pass has already ended, on both the compute and render encoders
   (they share gpuCommandEncoderState's passOpen/passEnded fields).
   Tests: TestGPURenderPassEndCalledTwiceRejected,
   TestGPUDrawAfterRenderPassEndRejected,
   TestGPUCommandEncoderFinishWithOpenRenderPassRejected,
   TestGPUComputePassDispatchAfterEndRejected,
   TestGPUComputePassEndCalledTwiceRejected (js/webgpu_test.go).
8. Unsupported render options silently ignored — primitive.cullMode/
   frontFace/unclippedDepth, multisample.count/alphaToCoverageEnabled,
   vertex.constants, fragment.constants, fragment.targets[0].blend/
   writeMask and vertex.buffers[].stepMode were read nowhere in
   gpuCreateRenderPipeline; each is now a named rejection for any
   non-default value instead of being silently dropped.
   Test: TestGPUCreateRenderPipelineUnsupportedRenderOptionsRejected,
   a 10-case table covering every option above (js/webgpu_test.go).

gofmt -l (on every touched file) is clean, go mod tidy reports no change,
go test ./... is green across every package (real Metal GPU, no skips),
and buildscan --dir . --vet passes go vet under all 13 CI configurations
(the one pre-existing finding, client_none.go under
webengine_nonet+webengine_nojs together, predates this branch).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Each guard the previous commit's fixes rely on now has a test that
fails on an ordinary assertion if the guard is removed, instead of
relying on a process-ending panic to turn the suite red ("caught by
PANIC", luck rather than proof), or is deleted with a doc comment
proving it dead code no test can ever distinguish.

js/webgpu.go, js/webgpu_test.go:
- gpuValidateIndexedVertexBuffers's "indexCount <= 0" guard: deleted.
  Its only caller, gpuDrawIndexed, already guarantees a non-nil index
  buffer and indexCount >= 0 before calling it, and the loop below
  already runs zero iterations for indexCount == 0 on its own.
- gpuGetFloat's missing-vs-undefined handling (used by gpuReadColor):
  added TestGPUReadColorExplicitUndefinedGDefaultsToZero, which builds
  a real explicit-undefined property via vm.RunString (vm.NewObject +
  Set can never produce one), and added defer-recover guards to the
  two existing missing-property tests so a reintroduced nil-panic
  fails as an assertion instead of crashing the whole test binary.

wgslmsl/render.go, wgslmsl/render_test.go:
- registerStageInputAccessor's "in.Member == \"\"" guard: deleted.
  go-gfx/wgsl's IOVar.Param is always a valid parameter index for
  every input regardless of Member, so without the guard a bare
  top-level builtin input only ever writes a harmless orphan
  inputFlatten[po][""] entry that memberExpr can never look up (WGSL's
  grammar has no member-access syntax with an empty name).
- Added defer-recover guards to six existing tests
  (RejectsParseError, RejectsMissingVertexEntryPoint,
  RejectsMissingFragmentEntryPoint, RejectsFragmentOutputBuiltin,
  RejectsF16UniformResource, RejectsSamplerResource) whose crash paths
  previously masked whether translateStageEntry's resolveResources
  error check, outputIOAttr's builtin check, and resolveResources's
  own texture-type assertion (translator.go) would also have failed as
  plain assertions.

Verified: mutsweep -dir js -only webgpu.go:1693 and mutsweep -dir
wgslmsl -only <30 render.go/translator.go lines covering the diff that
fixed engine#447's review bugs> both report every line caught, zero
caught-by-panic, zero survived.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant