Skip to content

fix(metal): preserve texture array copy shape#261

Open
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:codex/upstream-metal-texture-arrays
Open

fix(metal): preserve texture array copy shape#261
besmpl wants to merge 1 commit into
gogpu:mainfrom
besmpl:codex/upstream-metal-texture-arrays

Conversation

@besmpl

@besmpl besmpl commented Jul 14, 2026

Copy link
Copy Markdown

Summary

  • represent WebGPU 1D/2D array textures with Metal arrayLength and physical depth 1
  • copy array layers as Metal slices while preserving true 3D Z/depth semantics
  • validate complete Queue.WriteTexture source ranges before any Metal effect, including compressed block geometry
  • use dimension-correct Metal row/image strides and checked copy arithmetic

Why

The previous Metal descriptor stored DepthOrArrayLayers in depth for every texture dimension, and copy paths used origin Z as both a texture slice and a region Z coordinate. That is correct for true 3D textures but not for 1D/2D arrays. It can create the wrong physical texture shape and copy only or address the wrong array layer. This also blocked a portable standard texture-array page in downstream renderers.

Scope

This is an independent Metal correctness fix. It contains no multi-draw, prepared-command, ICB, material-page, or Hearth API surface.

Verification

  • go test -count=1 ./hal/metal
  • focused physical copy/upload matrix repeated 20 times
  • CGO_ENABLED=0 go test ./...
  • git diff --check HEAD^..HEAD

Physical tests cover 1D arrays, 2D arrays, true 3D, both mixed 3D↔2D-array copy directions, private and shared uploads, non-zero origins/offsets, padded rows/images, and truncated final layers. Full race/vet remain blocked by pre-existing Objective-C/goffi unsafe/checkptr diagnostics outside this diff.

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