Component: conformance; x86 macOS guest on the Linux Vulkan PCI pathway, rail macos-15.
Add a 290-case Metal battery, native Apple M4 oracle, split driver and translation ownership inventories, focused modes, boot manifests, artifact hashing, typed failure scoring, and catastrophic-run gates. This is test-only and changes no device behavior.
The API invariant is monotonic, oracle-backed compatibility: native results establish each Metal relation, while guest failures remain explicit debt owned by either translation or the device. Missing, duplicate, unexplained, and uncovered results fail the scorer.
Verification:
- Apple M4, macOS 15.6.1 build 24G90: full native oracle 290/290 PASS, zero skips.
- verdict unit tests: 5/5 PASS.
- run-native.sh and run-guest.sh: bash syntax clean.
- baseline file matches the final full native result byte-for-byte.
- current focused VM runs: integer clear and topology repeated clean; RGBA32Float clean with guest import on and off; indexed draw repeated with three classified driver failures and zero unexplained results.
- focused candidate boots loaded QEMU SHA-256 0b4ed961deaac18886b4e1ca8eb1db2a34c7e7f06e46b53652167e6dba61951d and static library SHA-256 512fa87458223053e3ca1a58e49501d28705f26b95984c211581d74ee91d195c from source fa29b2e527.
Not verified: there is no single complete 290-case guest run. The earlier 276-case full candidate emitted four stamp-wait timeouts and is not a passing validation. The consolidated macos-15 ledger is 184 pass, 77 classified driver failure, and 29 capability skip. Other guest rails and Apple-host backends were not run.
48 lines
1.9 KiB
Swift
48 lines
1.9 KiB
Swift
import Metal
|
|
import Foundation
|
|
|
|
// `synchronizeResource:` is a no-op on unified memory and the explicit
|
|
// GPU-to-CPU visibility operation for managed memory. The storage mode follows
|
|
// the device topology, but the contract asserted by the case is identical: CPU
|
|
// reads after command-buffer completion observe the preceding GPU writes.
|
|
func synchronizeResourceCase() {
|
|
let label = "synchronize_resource_gpu_to_cpu"
|
|
let count = 4096
|
|
let bytes = count * MemoryLayout<UInt32>.size
|
|
let options: MTLResourceOptions = dev.hasUnifiedMemory
|
|
? .storageModeShared
|
|
: .storageModeManaged
|
|
guard let words = dev.makeBuffer(length: bytes, options: options) else {
|
|
report(label, false, "buffer creation failed")
|
|
return
|
|
}
|
|
|
|
memset(words.contents(), 0, bytes)
|
|
if !dev.hasUnifiedMemory {
|
|
words.didModifyRange(0..<bytes)
|
|
}
|
|
var token: UInt32 = 0x6A09E667
|
|
let cb = queue.makeCommandBuffer()!
|
|
let compute = cb.makeComputeCommandEncoder()!
|
|
compute.setComputePipelineState(pipeline("sync_resource_write"))
|
|
compute.setBuffer(words, offset: 0, index: 0)
|
|
compute.setBytes(&token, length: MemoryLayout<UInt32>.size, index: 1)
|
|
compute.dispatchThreads(MTLSize(width: count, height: 1, depth: 1),
|
|
threadsPerThreadgroup: MTLSize(width: 64, height: 1, depth: 1))
|
|
compute.endEncoding()
|
|
|
|
let blit = cb.makeBlitCommandEncoder()!
|
|
blit.synchronize(resource: words)
|
|
blit.endEncoding()
|
|
cb.commit()
|
|
cb.waitUntilCompleted()
|
|
|
|
let got = words.contents().bindMemory(to: UInt32.self, capacity: count)
|
|
if let bad = (0..<count).first(where: { got[$0] != token ^ UInt32($0) }) {
|
|
report(label, false,
|
|
"word=\(bad) got=\(hex(got[bad])) want=\(hex(token ^ UInt32(bad)))")
|
|
return
|
|
}
|
|
report(label, true, "managed/shared GPU writes visible to CPU after synchronize")
|
|
}
|