Files
reims-vgpu/conformance/suite/main.swift
T
Anees IqbalandClaude Opus 5 596e37c7e3 conformance: an overlapping self-copy is not undefined, and this device drops it
Component: conformance/, test-only. Native oracle: Apple M4, macOS 15.6.1.
Guest: macos-13 rail, x86 macOS / Linux Vulkan pathway.

A driven Maps interaction on this rail issues `copyFromTexture:toTexture:`
naming one texture twice at different origins, several times a boot -- a
horizontal shift inside one row and a one-texel column shifted a dozen rows
down. This device refuses those as `t2t_overlap` and returns an error to a blit
encoder that, on real hardware, does not fail. The copy is dropped and the guest
treats it as complete.

The refusal's own comment called the shape "undefined in Metal", which is the
term this case exists to settle. It is not undefined on the oracle. Measured
there in three identical runs, over both live shapes and on both a buffer-backed
and an ordinary image, `copyFromTexture:toTexture:` with intersecting rectangles
produces source-snapshot semantics: the whole source region is read before any
destination byte is written. Row-at-a-time execution gives a different answer for
both shapes, and a disjoint copy -- where the two readings agree -- separates a
device that mishandles the overlap from one that refuses every self-copy.

Three cases, all `PASS` on the oracle and recorded in the tracked native
baseline:

- `self_copy_overlap_row_shift_14` -- 20 texels of one row copied 14 texels
  right, so the destination overwrites source texels the same row still reads.
- `self_copy_overlap_column_shift_12` -- a one-texel column, 17 rows tall,
  shifted 12 rows down, so a top-down loop overwrites rows 12 through 16 before
  reading them.
- `self_copy_disjoint_control` -- the same call shape, rectangles disjoint.

Raw guest result on the identified control (HEAD, no product change), reproduced
identically in two complete batteries: the control case **passes**, and both
overlap cases **fail** with `still_pre_copy` equal to the full copy extent --
20/20 texels and 17/17 texels still holding exactly what they held before the
copy. That is the signature of a dropped copy rather than a mis-ordered one, and
it is the refusal doing it.

Owner: `exec_copy_texture_to_texture` in `runtime/blit_exec`, which decides the
overlap. Not shader translation and not the guest driver, so neither rail
inventory takes these; they are this device's own defect and the next commit
repairs them.

Counts: 185 PASS / 79 FAIL / 29 SKIP on the guest, against the parent's
184/77/29 -- the disjoint control is a new pass and the two overlap cases are the
two new failures. Every other case is identical to the parent's envelope in both
runs. Native: 293 cases, 0 failures, 0 skipped.

An earlier draft of these cases declared the image over an `MTLBuffer`, and all
three failed on the guest with the readback dispatch refused
(`compute_buffer_texture_unsupported`) rather than on the copy. That would have
made the case a witness for a different gap, so the image is an ordinary one and
the control's pass is what proves the distinction holds. The buffer-backed
readback gap is real, unrelated, and not covered here.

Not verified: one rail and one pathway. The oracle result is Apple silicon only;
no Intel Mac was measured, and nothing here claims the semantics are architecture
independent. No product behavior changes in this commit.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-30 04:08:13 +03:00

267 lines
8.1 KiB
Swift
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// The battery’s running order. Every case invocation lives here and nowhere
// else: Swift permits top-level statements in `main.swift` alone, so a case that
// is not called from this file cannot run at all. The "a case nobody called
// reports nothing, and the totals do not notice" trap is closed by construction
// rather than by remembering.
import Metal
import Foundation
import IOSurface
if CommandLine.arguments.contains("--depth-task-child") {
exit(depthTaskIsolationChild())
}
if CommandLine.arguments.contains("--integer-clear-only") {
integerClearCases()
finish()
}
if CommandLine.arguments.contains("--topology-only") {
_ = library
report("shader_compile", true, "runtime library built")
topologyCases()
finish()
}
if CommandLine.arguments.contains("--float-sampling-only") {
_ = library
report("shader_compile", true, "runtime library built")
floatSamplingCases()
finish()
}
if CommandLine.arguments.contains("--indexed-draw-only") {
_ = library
report("shader_compile", true, "runtime library built")
indexedDrawCases()
finish()
}
// Shaderless by construction. A mismatch in either case is driver-owned, and
// still runs if a later shader-library build exposes a translator failure.
integerClearCases()
// `library` is lazily initialised now that it lives in a declaration
// file, so force the build before the line that reports it.
_ = library
report("shader_compile", true, "runtime library built")
topologyCases()
floatSamplingCases()
indexedDrawCases()
depthTaskIsolationCase()
for f in formats {
linearAliasCase(f, 64, 16, pitch: .tight, sampler: false)
linearAliasCase(f, 64, 16, pitch: .tight, sampler: true)
}
// The label-layer geometries, from a driven boot's own census. Their pitches
// are the guest's, so a device whose `minimumLinearTextureAlignment` forbids
// one skips it -- Metal itself would reject the descriptor there, and the
// alignment differs by device (16 on an M-series host, 256 on Apple's
// paravirtual one), so a literal pitch is not portable and must not be a
// failure where it is simply not expressible.
linearAliasCase(formats[1], 54, 16, pitch: .exact(64), sampler: false)
linearAliasCase(formats[1], 54, 16, pitch: .exact(64), sampler: true)
linearAliasCase(formats[1], 218, 16, pitch: .exact(256), sampler: false)
linearAliasCase(formats[1], 85, 85, pitch: .exact(128), sampler: false)
linearAliasCase(formats[0], 128, 16, pitch: .exact(128), sampler: false)
linearAliasCase(formats[4], 60, 8, pitch: .exact(256), sampler: false)
// The same shapes with the padding expressed against whatever this device's
// alignment actually is, so every host runs a padded-pitch case whatever its
// limit. One alignment unit of padding beyond tight, and then two.
for f in formats {
for rows in 1...2 {
linearAliasCase(f, 54, 16, pitch: .padded(rows: rows), sampler: false)
}
}
for f in formats {
incrementalCase(f, viaFragment: false)
}
renderTargetCases()
multisampleStoreCase()
depthStencilIndependenceCases()
stencilIndependenceCases()
combinedDepthStencilDefaultBufferCopyCase()
mipCase()
mipBlitCase()
vertexBufferCase()
fragmentBufferCase()
renderBarrierCase()
computeBarrierCase(resourceBarrier: true)
computeBarrierCase(resourceBarrier: false)
indirectComputeDispatchCase()
synchronizeResourceCase()
heapTextureAliasCase()
heapTexturePlacementOverlapCase()
heapTexturePlacementOverlapWidthCase()
bufferBackedAliasWidthCase()
bufferBackedAliasPartialCase()
encoderBindingLifetimeCase()
sameQueueCommandBufferOrderCase()
sameQueueCompletionPublicationCase()
emptyCommandBufferCompletionCase()
independentQueueCompletionPublicationCase()
scheduledBeforeCompletedPublicationCase()
defaultCommandBufferRetainsResourceCase()
indirectCommandMutationCase()
pipelineInformationCase()
// A bound texture view names its base's storage. Identity first, so a failure
// there is the view mechanism and nothing else; then a slice of an array, which
// says the view reached the right storage and not merely some storage; then a
// view over a surface plane, where the resource that owns the image is not the
// one at the end of the view chain.
textureViewIdentityCase(64, 32)
textureViewIdentityCase(256, 64)
textureViewArraySliceCase(64, 32, slices: 3)
textureViewOverSurfaceCase(64, 32)
selfCopyOverlapRowShiftCase()
selfCopyOverlapColumnShiftCase()
selfCopyDisjointCase()
textureViewOverSurfaceCase(256, 64)
if texPipeline == nil {
report("fragsample_pipeline", false, "tex_fs pipeline would not build")
} else {
fragmentAliasCase(formats[1], 54, 16, pitch: .exact(64)) // the label geometry
fragmentAliasCase(formats[1], 218, 16, pitch: .exact(256))
fragmentAliasCase(formats[1], 85, 85, pitch: .exact(128))
fragmentAliasCase(formats[3], 64, 16, pitch: .tight) // rgba8, tight
fragmentAliasCase(formats[4], 60, 8, pitch: .exact(256)) // bgra8, padded
// And once more with the padding derived from this device's own limit, so
// a host whose alignment skipped the literal pitches above still runs a
// padded fragment-sampled alias.
for f in [formats[1], formats[4]] {
fragmentAliasCase(f, 54, 16, pitch: .padded(rows: 1))
}
}
// The glyph-atlas lifecycle from section B, now through the stage the type
// layer actually uses. This is the arm that can see a defect on the draw path,
// and for `a8Unorm` it is the only arm that produces a reading at all.
for f in formats {
incrementalCase(f, viaFragment: true)
}
// The same lifecycle again, filled by `replaceRegion:` rather than through a
// buffer alias — section H says why the two are different rails. Declared
// there, invoked here, because the fragment arm needs `texPipeline`.
for f in formats {
replaceRegionCase(f, viaFragment: true)
}
// Tight and padded, read both ways, so the pitch is the only thing that varies
// between a passing case and a failing one.
// 256 and 250 rather than the device's alignment and six under it: at one byte
// per texel both round up to a tight pitch of 256 on a device that aligns to 16
// and on one that aligns to 256, so the pair means "no padding" and "six bytes
// of padding" on either host and the two runs pair up by name.
for viaFragment in [false, true] {
offsetOracleCase(256, 16, pitch: .tight, viaFragment: viaFragment)
offsetOracleCase(250, 16, pitch: .tight, viaFragment: viaFragment)
offsetOracleCase(218, 16, pitch: .tight, viaFragment: viaFragment)
offsetOracleCase(54, 16, pitch: .padded(rows: 1), viaFragment: viaFragment)
}
for w in [256, 250, 218, 64, 60, 54, 63, 57] { targetWidthCase(w, 16) }
// A width that divides the threadgroup and one that does not, in both axes.
gridBoundsCase(64, 16, 8)
gridBoundsCase(218, 16, 8)
gridBoundsCase(54, 15, 8)
gridBoundsCase(57, 9, 8)
gridBoundsCase(31, 31, 16)
cpuWriteAfterRenderCase(64, 32, secondPass: false)
cpuWriteAfterRenderCase(64, 32, secondPass: true)
cpuWriteAfterRenderCase(256, 64, secondPass: false)
cpuWriteAfterRenderCase(256, 64, secondPass: true)
offsetAliasCase(formats[1], 54, 16, tiles: 4)
offsetAliasCase(formats[3], 32, 32, tiles: 3)
for f in formats {
replaceRegionCase(f, viaFragment: false)
}
sharedTargetCases(60, 32)
sharedTargetCases(256, 64)
sharedTargetCases(1000, 40)
sharedTargetCpuSeedCase(60, 32)
sharedTargetCpuSeedCase(256, 64)
sharedTargetCpuSeedCase(1000, 40)
sharedTargetGlyphCase(60, 32)
sharedTargetGlyphCase(256, 64)
sharedTargetGlyphCase(1000, 40)
biplanarSurfaceCase(64, 32)
biplanarSurfaceCase(256, 64)
iosurfaceCases(60, 32)
iosurfaceCases(256, 64)
iosurfaceCases(1000, 40)
for (cw, ch) in [(60, 32), (256, 64), (1000, 40)] {
cpuWriteThenSampleCase(cw, ch, iosurface: false)
cpuWriteThenSampleCase(cw, ch, iosurface: true)
}
blitAfterRenderCase(1024, 768)
blitAfterRenderCase(1920, 1080)
blitPipelinedCase(1024, 768, frames: 8)
blitIOSurfaceSourceCase(1024, 768, frames: 8)
blitIOSurfaceSourceCase(1920, 1080, frames: 4)
blitBufferBackedCase(512, 512)
// A device-wide waiter-first scheduling defect can stop all later work, so
// this bounded probe deliberately closes the battery.
crossQueueSharedEventVisibilityCase()
finish()