set_visibility_result_mode refused Boolean and Counting in a pass whose
visibilityResultType is Accumulate (Gap::Draw{AccumulatedVisibilityResults}, counted in
Metrics::accumulated_visibility_refused). MTLRenderPass.h documents Accumulate in one
sentence, "Accumulate visibility results data across multiple render passes." Measured
(the conformance recordings, values.rs VisibilityResultType): Metal on an Apple M3 Max
(macOS 27.0.1) adds a Counting result into the word's low 32 bits and ORs a Boolean one,
while Metal on a Radeon Pro 5300M and a UHD Graphics 630 (macOS 26.7.1) writes it in
place of the word, as Reset does. The documented sum needs an add of a query's count into
a buffer word: a scratch copy of the query results and a kernel of the runtime's own after
the rendering, which is not built. The planner ruled that the runtime answers Accumulate
as Reset on every device until that sum is built, which then replaces it everywhere.
So the setter takes every mode in an Accumulate pass as in a Reset pass, and the
encoder no longer keeps the pass's visibilityResultType, which nothing reads now.
Removed public items: DrawKind::AccumulatedVisibilityResults and
Metrics::accumulated_visibility_refused (the consumer's checkout names neither in code;
two doc comments and one test of its rt platform describe the refusal:
rt_platform/render.rs:76 and its test at :2299, rt_platform/descriptor.rs:21).
DrawKind::VisibilityResultInterrupt stays refused, its doc now saying why: its answer
needs the same add. docs/API.md's accepted differences records the measured answers; the
rt README, VisibilityResultType's doc, the validation replay's docs and
docs/REPLAY-STREAM.md follow. The validation replay test of an Accumulate stream now
holds that its modes write as a Reset pass's, nothing skipped. REFUSALS.md regenerated
(Gap::Draw loses one site); api_signatures blessed (the two removed records).
1382 lines
117 KiB
Markdown
1382 lines
117 KiB
Markdown
# Replay streams (format version 2)
|
|
|
|
A replay stream records, in order, what Metal programs asked of their devices: every call with its
|
|
objects and arguments, the bytes the CPU left in GPU-visible memory before each commit, and the GPU
|
|
addresses the programs saw. `command-replay play` runs a stream on a Vulkan device through the
|
|
runtime, with no guest, and reports deterministic metrics and checksums, so two runs, two devices
|
|
or two commits compare.
|
|
|
|
Records use Metal's own selectors and raw enum values. Structs and descriptors are maps keyed by
|
|
the recorder's field names (section 2). This page is all a reader needs. The reader, the writer and
|
|
the player live in `crates/metal2vulkan-validation` (`src/replay/`).
|
|
|
|
A stream recorded from a consumer's guest is the consumer's data: it stays on the hosts that may
|
|
hold guest data and is never committed. Tests write their own streams.
|
|
|
|
## 1. Container
|
|
|
|
- **File:** a 16-byte header, then records. The header is ASCII `M2VRSTRM`, a u32 version (`2`)
|
|
and a u32 of flags. Fixed-width values are little-endian.
|
|
- **Flags.** Bytes 12-15 are the flags, a little-endian u32, the same in every segment's header.
|
|
Bit 0, `ANNOUNCED_BYTES_RECORDED` (`FLAG_ANNOUNCED_BYTES_RECORDED`), says the stream keeps the
|
|
announce invariant of section 6; streams recorded before it carry flags 0. Bit 1,
|
|
`COMPLETION_BYTES_RECORDED` (`FLAG_COMPLETION_BYTES_RECORDED`, value 2), says it keeps the
|
|
completion invariant of section 6; a stream recorded after the recorder's completion fix reads
|
|
flags 3. Other bits are 0. The version stays 2: a reader that checks only the magic and the
|
|
version reads a stream with either bit as before. This crate's reader refuses a segment whose
|
|
flags hold another bit or differ from the first segment's.
|
|
- **Record:** a kind (u8), the payload's length (varint), the payload. Varints are unsigned LEB128
|
|
of at most 10 bytes; signed values are zigzag-encoded.
|
|
- **Append-only.** A recorder only appends whole records and flushes at least at every commit. A
|
|
record cut short at the end of the last segment is a truncated tail: the reader reports it, and
|
|
everything before it plays. A recording process that exits can lose its last records this way,
|
|
about the last 50 ms of calls.
|
|
- **Segments.** A stream may be split at any record boundary into files `NAME.0000.m2vr`,
|
|
`NAME.0001.m2vr`, ..., each starting with the header; the stream is the segments in order, and
|
|
names and blobs carry across them. A record cut short in any segment but the last is an error.
|
|
- **An unknown record kind** is an error naming the kind and its offset.
|
|
- The recorder's statistics file is written apart from the stream and can trail it by up to 5 s;
|
|
the stream is the record.
|
|
- **The recording range sidecar.** `NAME.range` beside the first segment (`NAME.0000.m2vr`, or
|
|
`NAME.range` beside a stream of one file `NAME.m2vr`) states how far the recording is sound: one
|
|
line, `last-frame F` (through frame `F`'s present, frames counted from 0) or `whole`. A player
|
|
ends its play there by default (section 10).
|
|
- **The display library sidecar.** `NAME.display.metallib` beside the first segment, as
|
|
`NAME.range`, is the metallib of the host's own display shaders, which the host makes as a
|
|
library from source: the stream's `newLibraryWithSource:options:error:` of the device with no
|
|
arguments. It holds the host's display shaders alone, never a program's: a program's own
|
|
libraries reach the stream as data (`newLibraryWithData:error:`, section 9), never as source. A
|
|
player makes that one library of the sidecar, as of data, and nothing else of it; a stream
|
|
without one leaves it skipped and counted, with the host's draws that use it.
|
|
|
|
| kind | record | payload |
|
|
|---|---|---|
|
|
| 1 | name | UTF-8 text. The n-th name record of the stream defines name id n, from 1 |
|
|
| 2 | blob | the data's SHA-256 (32 bytes), then the data. Each hash at most once per stream, before its first use |
|
|
| 3 | call | section 3 |
|
|
|
|
## 2. Values
|
|
|
|
Each value starts with a one-byte tag.
|
|
|
|
| tag | type | encoding | used for |
|
|
|---|---|---|---|
|
|
| 0 | nil | none | nil; an optional field left unset; host memory |
|
|
| 1, 2 | false, true | none | `BOOL` |
|
|
| 3 | uint | varint | unsigned integers, raw enums and option sets |
|
|
| 4 | sint | zigzag varint | signed integers |
|
|
| 5 | f32 | 4 bytes | read as a number; the recorder writes `float` as f64 |
|
|
| 6 | f64 | 8 bytes | `float`, `double`, `CGFloat` |
|
|
| 7 | object | varint id | Metal objects; object 0, which no object is, a property set to nil (section 9) |
|
|
| 8 | address | varint | a GPU address: moved with its object (section 5) |
|
|
| 9 | string | varint length, UTF-8 | `NSString`, names |
|
|
| 10 | bytes | varint length, data | data, inline |
|
|
| 11 | blob | 32-byte SHA-256 | data, by content |
|
|
| 12 | list | varint count, values | arrays, tuples and ranges |
|
|
| 13 | map | varint count, (name id, value) pairs | structs and descriptors; a key at most once |
|
|
|
|
- **Structs and descriptors are maps** keyed by the recorder's field names in camelCase, which are
|
|
Metal's property names except where the table in section 9 says. `MTLOrigin` is `{x, y, z}`,
|
|
`MTLSize` `{width, height, depth}`, `MTLRegion` `{origin, size}`, `NSRange` `{location, length}`,
|
|
`MTLScissorRect` `{x, y, width, height}`, `MTLViewport` `{originX, originY, width, height,
|
|
znear, zfar}`, `MTLClearColor` and `MTLTextureSwizzleChannels` `{red, green, blue, alpha}`.
|
|
- **An optional field** is nil where it is unset, and a player leaves the property as it was. One
|
|
set to nil reads the same, but for the object properties of the pass descriptor's setters
|
|
(section 9): one of those set to nil is object 0, which a player clears.
|
|
- **Other shapes:** a range of host addresses is the list `[start, end]`; a tuple is a list; an
|
|
enum value without data is its name as a string (`"Itu709"`); one with data is a map of one
|
|
pair, `{Name: value}` (a resource `{Buffer: object}` or `{Texture: object}`, an option setter
|
|
`{ResourceOptions: raw}`). A C array and its count are one list.
|
|
- **Host memory** (a pointer into the host's or the guest's memory) is nil: its bytes arrive as
|
|
writes (section 6) or as a copy's data (section 7).
|
|
|
|
## 3. Calls
|
|
|
|
The payload is: the selector (name id), the receiver (object id, 0 for none), the result (the id
|
|
of the object the call makes, 0 for none), the argument count and the arguments, the answer count
|
|
and the (name id, value) answer pairs.
|
|
|
|
- **Selector:** Metal's Objective-C selector as Metal's headers spell it
|
|
(`dispatchThreadgroups:threadsPerThreadgroup:`), a C function's name
|
|
(`MTLCreateSystemDefaultDevice`), `Class.selector` for a class method
|
|
(`MTLRenderPassDescriptor.new`), or an `m2v.` name for what Metal has no call for. Where two
|
|
classes share a selector, the receiver's kind tells them apart.
|
|
- **Receiver 0** is the host's platform: the device, descriptor and drawable records it makes.
|
|
A call of receiver 0 that makes nothing and whose selector names no class (no `.`) is a message
|
|
the program sent to nil: it does nothing, and a player plays nothing for it.
|
|
- **Arguments:** one value per argument of the selector, in order; an encoder command's are its
|
|
fields. Error out-parameters, blocks and handlers are left out: their effects reach the stream as
|
|
later calls and writes.
|
|
- **Answers:** what the call returned that the program could see (section 5). A player ignores
|
|
answer keys it does not use.
|
|
- Getters are not recorded, but for `gpuResourceID` (section 5).
|
|
|
|
## 4. Objects
|
|
|
|
- **Ids** are nonzero u64s, unique across the whole stream and never reused, so an object that
|
|
several processes use (a surface's buffer, a shared event) has one id.
|
|
- An object is made by the call whose result names it and dies at `release` (receiver: the id;
|
|
its last reference). Releasing a device releases everything it made; a later `release` of one
|
|
of those objects releases nothing more (Metal's objects keep their device, so a program may
|
|
release its device before them).
|
|
- **Devices:** `MTLCreateSystemDefaultDevice`, one per device the recording's host made; every
|
|
guest process may share one. The player serves every recorded device from one runtime device.
|
|
- **Device identity:** `m2v.deviceIdentity` (receiver: the device; no arguments) follows each
|
|
`MTLCreateSystemDefaultDevice` record, and opens every later segment, one record per live device
|
|
in id order. Its answers are `name` (the recording runtime's device name) and
|
|
`hasUnifiedMemory` (what the guest's `hasUnifiedMemory` answered), and later keys may join them.
|
|
It plays as nothing; the player takes from it how the recording kept Managed buffers
|
|
(section 10), from the record of the device the guest makes its objects on: the one that most
|
|
calls making an object have as their receiver (the lowest id of a tie). Another device's record
|
|
(the host's own, such as the display's) says nothing of the guest's buffers, and the report names
|
|
such devices. A stream without it says nothing of that.
|
|
- **Exported surfaces** (`m2v.newExportedSurface` and the records on it) are the host's memory
|
|
shared with another API, which has no Metal call (section 7).
|
|
- Everything else is made by its Metal selector: queues, command buffers, encoders of every kind,
|
|
buffers, heaps, textures and views, samplers, depth and stencil states, events, shared events,
|
|
fences, indirect command buffers, libraries, functions, pipeline states, argument encoders and
|
|
visible function tables, and the descriptors Metal makes as objects (section 9).
|
|
- **The host's own plumbing** is recorded as `m2v.` records that stand for a plain Metal call; a
|
|
player plays each as that call:
|
|
|
|
| record | arguments | what the host did | plays as |
|
|
|---|---|---|---|
|
|
| `m2v.newBufferOfLengthPaddingUnobserved` | `[length, options, alignedByte]` | `newBufferWithLength:options:`, whose texture rows may keep or change the bytes between them; `alignedByte` (or nil) is the buffer's byte the host put on a 256-byte boundary | `newBufferWithLength:options:` `[length, options]` |
|
|
| `m2v.newExportableBufferOfLength` | `[length, options, alignedByte]` | the same buffer in an allocation of its own, which another API imports; result 0 where the host made none | the same, and nothing at result 0 |
|
|
| `m2v.newDmaBufBufferOfLengthPaddingUnobserved` | `[length, options, alignedByte]` | the same, also exported as a dma-buf for video decoding; the video's writes arrive as a later commit's writes (section 6); result 0 where the host made none | the same, and nothing at result 0; the backend makes its textures through the surface call (section 10) |
|
|
| `m2v.newCommandQueueUnshared` | `[]` | a queue the host kept apart | `newCommandQueue` |
|
|
| `m2v.externalWriteDone` | `[]`, on an exported buffer | another API's write into the buffer landed (a decoded picture) | nothing where the textures over the buffer read it in place; the backend fills the textures over it at their next use, or on a video surface's pages acquires its surface (section 10) |
|
|
|
|
## 5. Memory and addresses
|
|
|
|
- **Blocks.** `m2v.newBlockWithLength:storageMode:` (receiver: the device; arguments: the length
|
|
and the `MTLStorageMode`) makes a range the guest sub-allocates in, and answers `gpuAddress` and
|
|
`gpuLength`. A buffer in a block is the block's `m2v.newBufferInBlock:offset:length:options:`
|
|
(arguments: the block, the offset, the length, the `MTLResourceOptions`), which answers
|
|
`gpuAddress` and `gpuLength`.
|
|
- **Other buffers and heaps** answer `gpuAddress` and `gpuLength` where the host pinned them at an
|
|
address: `newBufferWithDescriptor:`, `newHeapWithDescriptor:`, and a heap's
|
|
`newBufferWithLength:options:offset:` (`[length, options, offset]`). An object the host made
|
|
without a pinned address answers none. `newBufferWithBytesNoCopy:length:options:deallocator:`
|
|
is `[nil, length, options, nil]`, and a no-copy descriptor's `contents` nil; their bytes arrive
|
|
as writes.
|
|
- **A no-copy Managed buffer's bytes at its making.** Where the device's `hasUnifiedMemory` is
|
|
false, the GPU copy of a Managed buffer is made from its bytes at its making, then changed only by
|
|
`didModifyRange:`. A no-copy one (storage mode Managed) then carries those bytes:
|
|
`newBufferWithBytesNoCopy:length:options:deallocator:`'s first argument holds all its bytes as
|
|
the making read them (a blob where they are 64 bytes or longer, bytes otherwise), and a no-copy
|
|
descriptor's `contents` holds its bytes up to `zeroFrom` (all of them where `zeroFrom` is nil;
|
|
nil where it is 0), its GPU copy zero from there. Its bytes still arrive as writes before its
|
|
first use, as any buffer's do.
|
|
- **Copied buffers.** A buffer `newBufferWithDescriptor:` made as a copy of host memory (`contents`
|
|
set, `noCopy` not) carries the bytes it starts with as its descriptor's `contents`: a blob where
|
|
they are 64 bytes or longer, bytes otherwise. The player makes the buffer, then puts them at its
|
|
first byte as a write's bytes (section 6).
|
|
- **Textures over memory:** a buffer's `newTextureWithDescriptor:offset:bytesPerRow:`,
|
|
`newTiledTextureWithDescriptor:offset:bytesPerRow:` and
|
|
`newLinearTextureWithDescriptor:offset:bytesPerRow:bytesPerImage:`, a heap's
|
|
`newTextureWithDescriptor:offset:`, each taking a texture descriptor object (section 9). The
|
|
linear form (Apple's SPI) makes what the first makes of a 2D descriptor, and also a 2D array,
|
|
whose slices Metal lays out itself; the player plays a 2D one as the first and refuses another.
|
|
- **The address map** is the ranges `[gpuAddress, gpuAddress + gpuLength)` of the live objects that
|
|
answered them; `release` removes an object's range. A range that meets a live one in part (the
|
|
program put a newer object in memory an older one still held, as a guest's own allocator in a
|
|
block may) ends the older range, whose inner ranges stay: a word there is the newer object's.
|
|
The player's report counts the ranges it ended (`parted`).
|
|
- **Address arguments move.** The player makes each object where the runtime has room. Every address value (tag 8) whose value lies in a live range becomes the player's
|
|
address of that range's object plus its offset into the range; the innermost range wins, so an
|
|
address in a buffer in a block moves with the buffer. One outside every live range stays. The
|
|
report counts the address values (`address_arguments`) and those that moved
|
|
(`relocated_words`).
|
|
- **Written words play as recorded, but noted ones.** A word's value alone is no reason to move
|
|
it: the bytes the player puts into an object (`m2v.write`, a copied buffer's `contents`, the
|
|
copies from the guest's RAM) and the data of every
|
|
`set*Bytes:length:atIndex:` play as the stream holds them, except the words that lie in the
|
|
range of a buffer the stream noted escaped (below). A word there that is an address of a buffer
|
|
with no note, which a stream recorded before the escape note cannot tell from data, keeps its
|
|
recorded value. The player counts, as a census that writes nothing, the words that look like
|
|
addresses: in the bytes put into an object that answered a `gpuAddress` and in `set*Bytes`
|
|
data, each 8-byte word at an offset that is a multiple of 8 from the target's start whose value
|
|
lies in a live range (`address_looking_words`), and apart from them the 8-byte values at 4 past
|
|
a multiple of 8 that do (`misaligned_address_words`). Both are the stream's, the same on every
|
|
play.
|
|
- **The escape note.** `m2v.bufferEscaped` (receiver: a buffer; arguments: `[kind]`) says the
|
|
program may hold the buffer's address in memory from then on; the whole buffer escapes. Its
|
|
kind is 0 for a `gpuAddress` read of the buffer or of a texture over it, 1 for an argument
|
|
encoder's write of its address or of a texture-over-it's resource ID, 2 for a `gpuResourceID`
|
|
read of a texture or view over it, and 3 for a residency set's add. The recorder writes it once
|
|
in the buffer's life, at the first escape, in stream order: after the `m2v.write` records of
|
|
the commits before it and before those of every commit after it. The buffer is a no-copy one,
|
|
never Managed. Once a buffer's note is read, and until its release, a written word that
|
|
looks like an address (above) whose value lies in that buffer's recorded range may be its
|
|
address: the player moves it before the bytes reach the runtime, as it moves an address
|
|
argument, to the address the play put the object of the innermost live range the value lies in,
|
|
plus its offset into that range (the buffer's, or a buffer's inside it), and counts it
|
|
(`noted_words`). A word that points into memory no live range holds (a buffer the stream never
|
|
made, one released, a range a newer object parted) cannot be told from data, and plays as
|
|
recorded. Where the play put the object elsewhere, a buffer whose bytes hold a moved word reads
|
|
back other bytes than the recording's, and its `m2v.check` differs by those words. A note of a
|
|
kind past 3, or of an object no call made, is an invalid stream. A stream recorded before the
|
|
recorder wrote the note holds none, and the report's `addresses` line says it predates the note
|
|
(section 10).
|
|
- **Resource IDs.** A descriptor's resource index places its object at that ID, as Metal places it
|
|
whether or not the index is forced: a texture descriptor's and a render pipeline's
|
|
`resourceIndex` (`[index, forced]`), a sampler's (an index), and a view's `resourceIndex:`
|
|
argument. Every other texture and sampler state takes, as the runtime's consumer gives every
|
|
texture and sampler index, the index of the ID the program saw of the object (its first
|
|
`gpuResourceID` record, read ahead), else the lowest index of its class that
|
|
no live object holds and the program did not reserve (`reserveResourceIndicesForResourceType:
|
|
indices:indexCount:`), as Metal's pool hands out a sampler state's ID. A reserved index is taken
|
|
only where the stream names it. A named index a live object of the play holds is taken from
|
|
it, as Metal's later texture at an ID takes the ID: the earlier object's release leaves the
|
|
index. The runtime leaves it to its consumer never to write an element that work in flight may
|
|
use, and a consumer keeps a released ID back until every command buffer committed before the
|
|
release has retired; the player keeps that duty. An index is owed to every commit before the
|
|
release of the object that held it (work may reach the object through an ID in memory, which
|
|
no call names), and to the commits of the command buffers that named an object while it held
|
|
the index, live or released since. A placement at an index first waits until the commits it is
|
|
owed to have retired (their completed handlers have run, which the runtime runs once it has let
|
|
go of what they held). An object named after a later one took its index holds it no more: the
|
|
index is the later one's, and that naming owes it nothing. Where one of the commits is held on
|
|
records not yet played (its command buffer waits for an event only a later record signals, or
|
|
is behind one that does on its queue), no wait can end before the placement: the player keeps
|
|
the index back, and the object takes the highest free index of its class that no commit in
|
|
flight is owed, outside the sequence the program's objects take. Its ID then differs from the
|
|
one the program saw (section 10), and an ID of it the program wrote into memory reads another
|
|
element. A sampler state whose recorded descriptor is that of the sampler state placed at the
|
|
index last takes the index without waiting: the runtime writes no element for it. Where the
|
|
runtime refuses a named index (it lies outside the object's class), the object takes the lowest
|
|
free one, and the report counts it. A constexpr sampler, which the stream names no index for,
|
|
takes the highest free sampler index that no commit in flight is owed, outside the sequence the
|
|
program's sampler states take, so none of theirs takes its index. Every other object takes the
|
|
ID the runtime gives it.
|
|
- **Textures outside the program's IDs.** A texture the recorder makes for itself, not the
|
|
program's (the host's cursor), comes from a texture descriptor record whose map holds
|
|
`outside: true` and a device's `newTextureWithDescriptor:` of that descriptor. Live, it took no
|
|
ID in Metal's space, so the program's textures took theirs as if it were not there. The player
|
|
makes it where it moves no ID of the program's: at the highest free index of its class that no
|
|
commit in flight is owed, outside the sequence the program's textures take. A marked descriptor with a `resourceIndex`, a marked
|
|
descriptor any other call makes a texture of, and a drawable's map with the mark are refused; a
|
|
`gpuResourceID` record of a marked texture stops the play (`invalid stream`): the program never
|
|
saw its ID, so the mark or the record is wrong.
|
|
- **The IDs the program saw.** Each `gpuResourceID` the platform answered of a texture, sampler,
|
|
depth-stencil state, compute or render pipeline, indirect command buffer or visible function
|
|
table is a `gpuResourceID` record: the object its receiver, no arguments, result 0, and the ID
|
|
under the answer `gpuResourceID`. A getter that raised answers nothing. The player compares the
|
|
first answer of each object with the ID its runtime gives the object, and reports each object
|
|
where they differ (section 10): the bytes in which the program wrote that ID name no object of
|
|
the play.
|
|
|
|
## 6. CPU writes
|
|
|
|
- `m2v.write` (receiver: a block or a buffer, a surface's pages included; arguments: one or more
|
|
pairs of an offset and its data, bytes or blob): the bytes the CPU left at those offsets.
|
|
- **Before each `commit`**, the stream holds a write for every byte that changed since it was last
|
|
recorded, in the memory the command buffer can reach: its bound buffers, textures over buffers
|
|
and argument buffers; its `useResource:` and `useHeap:` resources; its attachments, blit operands
|
|
and executed indirect command buffers. Memory reached only through pointers the command buffer
|
|
did not declare is undefined in Metal and outside this format.
|
|
- **The comparison point** is the bytes as last recorded. When a command buffer completes, the
|
|
4 KiB chunks wholly inside ranges only the GPU writes (attachments, blit destinations) take the
|
|
GPU's bytes as the stream's without a write: the player's own run writes them again.
|
|
- **The completion invariant.** In a stream whose header has bit 1 set, at each command buffer's
|
|
completion the stream holds every chunk that the command buffer's work could store to as the GPU
|
|
left it, before any later CPU write, on each of the four late routes by which a recorder learns
|
|
of a completion: a signalled event, a final status read, a refused hook and a released command
|
|
buffer. Each such chunk that differs from the comparison point is an `m2v.write` after the
|
|
command buffer's `commit` record, holding the bytes the run left. The chunks are those a blit
|
|
wrote only part of, and everything the command buffer's compute and render encoders reach: each
|
|
buffer, texture and heap they bind or use, and what an indirect command buffer they execute
|
|
binds, except a resource `useResources:usage:` names for reading alone. A `Managed` buffer
|
|
counts only on a device that keeps one copy of it; where there are two, the GPU never writes the
|
|
CPU's copy. A player waits before each write (section 10), so it puts back what its own run
|
|
wrote and changes nothing. The write moves the comparison point: when the CPU later restores the
|
|
earlier bytes (a program resetting counters a kernel adds to), the restore differs from it and is
|
|
recorded before the next commit that reaches those bytes.
|
|
- **A stream without bit 1** was recorded before the recorder's completion fix and keeps no such
|
|
invariant: where a completion's bytes are missing, a CPU write that restores the bytes last
|
|
recorded is missing too, and the play runs the next command buffer from its own run's bytes
|
|
where the recording device ran it from the restored ones. Such a stream may differ from what the
|
|
program did, and every report the player writes of it says so on the line after its mode line
|
|
(section 10).
|
|
- **No half-written bytes.** Before capturing, a recorder waits for every earlier command buffer
|
|
that can run: one not held on an event wait that a later record satisfies. The bytes may then
|
|
include final bytes the GPU wrote; the player puts them back at the same point, after its own
|
|
wait, so they change nothing.
|
|
- Private memory never appears in a write. A Managed buffer's changed range is a write on the
|
|
buffer, immediately before its `didModifyRange:`.
|
|
- **The announce invariant.** In a stream whose header has bit 0 set, at each `didModifyRange:`
|
|
record on a buffer, for every 4 KiB chunk the range touches (of the target its `m2v.write`
|
|
records name: the buffer, or the block it lies in), the last `m2v.write` record before it that
|
|
carries the chunk holds the bytes the program's CPU copy of the buffer held at the call, bytes the
|
|
GPU wrote there (a blit's, a pass's, `synchronizeResource:`'s read-back) that the recorder took as
|
|
the stream's without a write included, however late it took them. A player may push its recorded
|
|
bytes of the range at the announce. A stream without the bit gives no such promise where the GPU
|
|
wrote the chunk, and a player pushes its own read-back there.
|
|
- Granularity is the recorder's: whole pages or changed runs. Data of 64 bytes or more is best a
|
|
blob, so a repeated page is stored once.
|
|
|
|
## 7. Surfaces and the guest's RAM
|
|
|
|
- **A surface's pages** are a no-copy buffer, whose CPU changes arrive as writes at each commit
|
|
that reaches it (section 6). There are no surface records of their own.
|
|
- **A texture over a surface's plane** is `newTextureWithDescriptor:iosurface:plane:` with that
|
|
buffer as its receiver and the arguments `[descriptor, {plane, offset, bytesPerRow, planar,
|
|
facts}]`: the plane's index, its first byte and row pitch in the buffer, whether the surface is
|
|
planar, and `facts`, what the texture reads of the surface besides: `{pixelFormat, planeCount,
|
|
width, height, chromaOffset, chromaBytesPerRow, ycbcrMatrix}`, the pixel format as its four
|
|
characters big-endian, the matrix one of `"Itu601"`, `"Itu709"`, `"Itu2020"`,
|
|
`"Smpte240M1995"`, `"DciP3"`, `"P3D65"`, `"Other"`, or nil. Where `facts` is nil, the buffer
|
|
stands for no surface and the texture is the buffer's `newTextureWithDescriptor:offset:bytesPerRow:`.
|
|
A texture of a two-plane YCbCr or XR10 format over a surface of two planes reads the facts.
|
|
- **Copies between the guest's RAM and a buffer** are blit-encoder commands, ordered against the
|
|
encoder's others as a buffer-to-buffer copy is. Each is recorded only where the host's platform
|
|
made it, after the earlier command buffers that can run were waited for.
|
|
- `m2v.copyFromGuestRam` and `m2v.copyFromGuestRamAt` (`[buffer, [[byte, data], ...]]`): each
|
|
piece's data, as the copy read it (bytes, or a blob where long), lands in the buffer from its
|
|
byte. The two differ in the host's call, one offset for all its runs or one per run, not in
|
|
the record.
|
|
- `m2v.copyToGuestRam` (`[buffer, [[byte, [start, end]], ...]]`): the buffer's bytes from each
|
|
byte, as long as its run of host addresses, go back to the guest's RAM. It carries no data:
|
|
later reads of that RAM carry their own bytes, so it needs nothing beyond its order. The
|
|
player copies the bytes into memory of its own that nothing reads.
|
|
- Streams recorded before the host left out the copies its platform refused may hold one in the
|
|
call's own arguments; a player stops there.
|
|
- **Exported surfaces** are a picture's planes in memory the host shares with another API (a video
|
|
decoder), made through the runtime's surface call. They have no Metal counterpart: an IOSurface
|
|
needs no hand-over between APIs. The records:
|
|
- `m2v.newExportedSurface` (receiver: the device; `[handle, pitchMultiple, startMultiple,
|
|
planes]`) makes one (`Device::new_exported_surface`). `handle` is `"DmaBuf"`, `"OpaqueFd"` or
|
|
`"OpaqueWin32"`, the multiples are those the host asked of each plane's row pitch and first
|
|
byte, and each plane is a map `{pixelFormat, width, height, usage, rowsBelow}`: its texture's
|
|
format, size and usage, and the rows of room the host asked below it. Its result is the
|
|
surface.
|
|
- `m2v.surfacePlane` (receiver: the surface; `[plane]`) is the plane's texture (its result),
|
|
outside the program's IDs (section 5). Views, blits and passes of it are ordinary calls.
|
|
- `m2v.exportSurface` (receiver: the surface; `[]`) is the host's export of its handle, once the
|
|
surface is ready for the other API's writes (`Surface::wait_until_ready`).
|
|
- `m2v.surfaceWritesDone` (receiver: the surface; `[planes]`) is a picture the other API wrote,
|
|
landed (`Surface::external_writes_done`). `planes` holds each plane's bytes, rows packed
|
|
(width times bytes a texel a row, luma first), or is nil where the stream holds none.
|
|
- `release` of the surface ends it, its export and its planes' textures.
|
|
|
|
What a player does at each record, the runtime's hand-overs among it, and what it cannot
|
|
reproduce, are in section 10.
|
|
|
|
## 8. Commands, commits and frames
|
|
|
|
- **Encoder commands** are Metal's selectors on the encoder: every render, tile, compute, blit and
|
|
resource-state call. An indirect command buffer's contents are `indirectRenderCommandAtIndex:`
|
|
records on it, `[index, commands]`.
|
|
- **Uploads and downloads:** `replaceRegion:...` carries its bytes; `didModifyRange:`,
|
|
`synchronizeResource:` and `synchronizeTexture:slice:level:` sit where they were made;
|
|
`getBytes:...` has a nil destination and may answer `sha256`.
|
|
- **Commits:** the order of `commit` records is the global commit order. A command buffer's queue is
|
|
the receiver of the call that made it; each queue keeps its own order, and an event wait may hold
|
|
one queue while the others go on. Record order is the order of the program's calls, not of its
|
|
GPU work: a command buffer committed before a call may wait for an event that only a later
|
|
record signals, so a commit record does not promise that the work ran, or could run, before the
|
|
records after it.
|
|
- **Synchronization:** `encodeSignalEvent:value:` and `encodeWaitForEvent:value:` on a command
|
|
buffer; fences as encoder calls; `setSignaledValue:`; and `waitUntilCompleted` and
|
|
`waitUntilSignaledValue:timeoutMS:` where the program's CPU waited.
|
|
- **The host's own commit splits** (no Metal counterpart): `m2v.split` commits its command buffer
|
|
as a part and makes the command buffer of the same queue that goes on from it (its result);
|
|
`m2v.part` makes a command buffer of the same queue for a later range (its result), and
|
|
`m2v.commitPart` commits its receiver as a part where its answer `cut` is `"Cut"`. Where it is
|
|
`"Fails"` or `{Whole: reason}`, the host committed nothing; a record without the answer commits.
|
|
A split or part of result 0 is one the host did not cut: it commits nothing and makes nothing.
|
|
- **The host's scheduling records** change nothing a program sees, and a player plays none of
|
|
them: `m2v.setCompletionJoinsNext` (`[joins]`: the host groups the command buffer's completion
|
|
with the next ones of its queue), `m2v.holdsNoPredication` (`[]`), `m2v.fold` (`[later]`: the
|
|
command buffer takes in how the GPU fails the later one's encoders) and `m2v.rebindNoCopy`
|
|
(`[bytes, deallocator]`, recorded `[nil, nil]`: a no-copy buffer moved to new host memory, whose
|
|
bytes arrive as writes).
|
|
- `m2v.privateBytes` (receiver: a buffer, which a `release` may already have ended; arguments
|
|
`[dispatch, {location, length}, before, after]`) holds the bytes of a Private buffer's range
|
|
before and after one dispatch of a compute pipeline made with linked functions: `dispatch` is
|
|
the dispatch's position in the stream (how many call records come before it, from 0), and
|
|
`before` and `after` are blobs that lie in the blob directory alone. It is recorded at the
|
|
command buffer's completion, so later in the stream than the dispatch. The player reads these
|
|
records ahead and counts the dispatches they name; it takes no snapshot and compares no range
|
|
(section 10).
|
|
- `m2v.present` (arguments: the texture over the guest surface shown) is recorded where the
|
|
device's display shows a guest present, with or without a window. It ends a frame: the player
|
|
waits for what can complete and closes the frame's counters; it reads nothing.
|
|
- `m2v.check` (arguments: objects) asks the player to read those objects there and report their
|
|
checksums. Its optional answer `sha256` is a list of the recording's own, one per object. A
|
|
Private buffer or texture, which the CPU does not reach, is read through a copy into a Shared
|
|
buffer of the player's own.
|
|
|
|
## 9. Descriptors and libraries
|
|
|
|
- **Descriptor objects.** The platform (receiver 0) makes the descriptors Metal makes as objects,
|
|
and setter records on them change them; a creation call names the object, as it is then.
|
|
- `m2v.textureDescriptor` (`[map]`): `MTLTextureDescriptor.new` with the map's properties set,
|
|
in the order `textureType`, `pixelFormat`, `width`, `height`, `depth`, `mipmapLevelCount`,
|
|
`sampleCount`, `arrayLength`, `usage`, `resourceOptions`, `swizzle`, `resourceIndex`
|
|
(`[index, forced]`), `protectionOptions`, `framebufferOnly`, `isDrawable`,
|
|
`writeSwizzleEnabled`, `allowGpuOptimizedContents`, `rotation`, and `outside` (a bool; only
|
|
`true` is written), the mark of a texture outside the program's IDs (section 5).
|
|
`MTLTextureDescriptor.texture2DDescriptorWithPixelFormat:width:height:mipmapped:` makes one
|
|
too; `setUsage:` and `setResourceOptions:` on it change it.
|
|
- `MTLRenderPassDescriptor.new` (`[]`) makes a render pass descriptor. `m2v.setPass` (`[map]`)
|
|
sets its own properties: `visibilityResultBuffer`, `visibilityResultType`,
|
|
`renderTargetArrayLength`, `renderTargetWidth`, `renderTargetHeight`,
|
|
`defaultRasterSampleCount`, `defaultColorSampleCount`, `rasterizationRateMap`,
|
|
`imageblockSampleLength`, `threadgroupMemoryLength`, `tileWidth`, `tileHeight`.
|
|
`m2v.setColorAttachment` (`[index, map]`), `m2v.setDepthAttachment` (`[map]`) and
|
|
`m2v.setStencilAttachment` (`[map]`) set that attachment's: `texture`, `resolveTexture`,
|
|
`level`, `slice`, `depthPlane`, `resolveLevel`, `resolveSlice`, `resolveDepthPlane`,
|
|
`loadAction`, `storeAction`, `storeActionOptions`, then `clearColor`, `clearDepth` and
|
|
`depthResolveFilter`, or `clearStencil` and `stencilResolveFilter`. A nil property takes
|
|
nothing: the descriptor keeps what it had. An object property (`visibilityResultBuffer`,
|
|
`rasterizationRateMap`, `texture`, `resolveTexture`) set to nil is object 0, which clears it.
|
|
`setSamplePositions:count:` (`[list]`) sets its sample positions, the list of
|
|
`MTLSamplePosition`s `{x, y}`; an empty list (a count of 0) sets none, Metal's defaults.
|
|
- `m2v.rateMapDescriptor` (`[{screenSize, mutability, minFactor}]`) makes an
|
|
`MTLRasterizationRateMapDescriptor`; its layers are set on it afterwards.
|
|
- **Drawables.** A `newTextureWithDescriptor:` of receiver 0 whose argument is a map
|
|
(`{textureType, pixelFormat, width, height, usage, storageMode}`) and whose answer
|
|
`m2v.drawable` is true is a window's swapchain image the stream never saw made. The player makes
|
|
a texture of that descriptor to stand in for it.
|
|
- **Creation descriptors** are a map argument of their creation call. Option setters are a list of
|
|
`{Setter: raw}` applied in order to the options of Metal's new descriptor: `ResourceOptions`,
|
|
`ResourceOptionsOr` (bits or'ed in), `StorageMode`, `HazardTrackingMode`.
|
|
- `newBufferWithDescriptor:`: `{length, options, pinnedGpuAddress, contents, noCopy,
|
|
deallocator, zeroFrom}`.
|
|
- `newHeapWithDescriptor:`: `{size, heapType, options, pinnedGpuAddress}`.
|
|
- `newSamplerStateWithDescriptor:`: `{minFilter, magFilter, lodAverage, compareFunction,
|
|
sAddressMode, tAddressMode, rAddressMode, mipFilter, maxAnisotropy, normalizedCoordinates,
|
|
supportArgumentBuffers, reductionMode, lodMinClamp, lodMaxClamp, lodBias, borderColor,
|
|
resourceIndex}`.
|
|
- `newDepthStencilStateWithDescriptor:`: `{depthCompareFunction, depthWriteEnabled, front,
|
|
back}`, each face `{stencilCompareFunction, stencilFailureOperation, depthFailureOperation,
|
|
depthStencilPassOperation, readMask, writeMask}`.
|
|
- `newRenderPipelineStateWithDescriptor:error:`: `{label, vertex, fragment, vertexDescriptor,
|
|
colors, depthPixelFormat, stencilPixelFormat, rasterSampleCount, alphaToCoverage, alphaToOne,
|
|
rasterizationEnabled, inputPrimitiveTopology, maxVertexAmplificationCount,
|
|
supportIndirectCommandBuffers, vertexLinked, fragmentLinked, privateState, tessellation,
|
|
maxVertexCallStackDepth, maxFragmentCallStackDepth}`. The last three are always written where
|
|
a recorder carries them: `tessellation` is `{partitionMode, maxFactor, factorScaleEnabled,
|
|
factorFormat, controlPointIndexType, factorStepFunction, outputWinding}`, Metal's raw values,
|
|
and the depths are uints. A record without them, as every stream recorded before the recorder
|
|
carried them, does not hold the program's state: a player plays Metal's defaults in its place,
|
|
`{0, 16, false, 0, 0, 0, 0}` and depths 1 and 1, and the backend counts the patch
|
|
draws it plays through such a state (`patch_draws_unrecorded_tessellation`, in each frame and
|
|
the total, and the report's `patch draws through a render pipeline state whose record lacks
|
|
tessellation` line), so a report that quotes their pass says the tessellation state there is
|
|
unknown. A player gives a tessellation state other than the defaults to the pipeline; the
|
|
translator draws a post-tessellation vertex function's patch with it, which it knows from the
|
|
function's AIR, and ignores it for any other, as Metal does. The vertex descriptor is `{layouts: [{bufferIndex, stride, stepFunction, stepRate}], attributes:
|
|
[{attributeIndex, format, offset, bufferIndex}]}` (a stride of 2^64 - 1 is
|
|
`MTLBufferLayoutStrideDynamic`); `colors` is `[[index, {pixelFormat, blendingEnabled,
|
|
sourceRgbBlendFactor, destinationRgbBlendFactor, rgbBlendOperation, sourceAlphaBlendFactor,
|
|
destinationAlphaBlendFactor, alphaBlendOperation, writeMask}], ...]`; linked functions are
|
|
`{functions, binaryFunctions, groups, privateFunctions}`, a group `[name, functions]`; the
|
|
private state (Apple's) is `{openGlModeEnabled, sampleMask, sampleCoverage,
|
|
sampleCoverageInvert, logicOperationEnabled, logicOperation, depthStencilWriteDisabled}`. The
|
|
host's own pipelines take the short form `{label, vertex, fragment, color0PixelFormat,
|
|
resourceIndex}`.
|
|
- `newComputePipelineStateWithDescriptor:options:reflection:error:`: `{label, function,
|
|
threadgroupSizeIsMultipleOfExecutionWidth, maxTotalThreadsPerThreadgroup, maxCallStackDepth,
|
|
supportIndirectCommandBuffers, stageInput, linked, libraries: {preloaded, loaded},
|
|
openClMode}`. `stageInput` is nil where the descriptor has none, or `{layouts, attributes,
|
|
indexType, indexBufferIndex}`: the layouts and attributes in the vertex descriptor's form,
|
|
Metal's raw step functions and attribute formats, and the index type and index buffer as
|
|
Metal's `MTLStageInputOutputDescriptor` holds them. A player gives it to the pipeline; an
|
|
attribute's buffer that no layout names takes Metal's unset layout. A player gives
|
|
`openClMode` to the pipeline too (off where absent), whose kernel then takes the three hidden
|
|
buffers ahead of its own buffers as Metal's OpenCL mode does.
|
|
- **Keys that are not Metal's property names:**
|
|
|
|
| key | Metal's |
|
|
|---|---|
|
|
| `vertex`, `fragment`, `function` | `vertexFunction`, `fragmentFunction`, `computeFunction` |
|
|
| `colors` | `colorAttachments` |
|
|
| `depthPixelFormat`, `stencilPixelFormat` | `depthAttachmentPixelFormat`, `stencilAttachmentPixelFormat` |
|
|
| `vertexLinked`, `fragmentLinked`, `linked` | `vertexLinkedFunctions`, `fragmentLinkedFunctions`, `linkedFunctions` |
|
|
| `libraries` | `preloadedLibraries` and the libraries the functions load |
|
|
| `alphaToCoverage`, `alphaToOne` | `alphaToCoverageEnabled`, `alphaToOneEnabled` |
|
|
| `tessellation` | the tessellation properties: `partitionMode`, `maxFactor`, `factorScaleEnabled`, `factorFormat`, `controlPointIndexType`, `factorStepFunction`, `outputWinding` are `tessellationPartitionMode`, `maxTessellationFactor`, `tessellationFactorScaleEnabled`, `tessellationFactorFormat`, `tessellationControlPointIndexType`, `tessellationFactorStepFunction`, `tessellationOutputWindingOrder` |
|
|
| `front`, `back` | `frontFaceStencil`, `backFaceStencil` |
|
|
| `heapType` | `type` |
|
|
| `options` | the setters of `resourceOptions`, `storageMode` and `hazardTrackingMode` |
|
|
| `pinnedGpuAddress`, `contents`, `noCopy`, `deallocator`, `zeroFrom` | the host's buffer creation: a pin, the bytes a copied buffer starts with or a no-copy Managed one's at its making (section 5), no-copy host memory and its deallocator, and the bytes known zero from an offset |
|
|
| `openGlModeEnabled`, `openClMode` | `openGLModeEnabled`, `openCLModeEnabled` |
|
|
| `znear`, `zfar` | `MTLViewport`'s `znear` and `zfar` |
|
|
| `rotation`, `isDrawable`, `framebufferOnly`, `protectionOptions`, `writeSwizzleEnabled` | Apple's texture descriptor properties of those names |
|
|
|
|
- **Functions:** `newFunctionWithName:constantValues:error:` is `[name, constants]`, each
|
|
constant `{index, dataType, value}`, the value 32 bytes holding the constant packed from the
|
|
first (the rest zero); `newFunctionWithDescriptor:error:` is `[name, constants, options,
|
|
specializedName]`.
|
|
- **Libraries:** `newLibraryWithData:error:` takes the metallib as a blob: the SHA-256 of the exact
|
|
bytes passed (for a universal file that is not the runtime's `Library::content_hash`, which
|
|
hashes the AIR slice). The blob record may be left out; the player then reads the data from its
|
|
blob directory (`--blobs DIR`, one file per blob named by its lowercase hex hash) and checks it
|
|
against the hash.
|
|
|
|
## 10. The player
|
|
|
|
`command-replay play --stream FILE --out DIR --device-type cpu|gpu --shader-cache DIR
|
|
[--blobs DIR] [--managed one-copy|two-copy]
|
|
[--until-frame F] [--past-range yes|no] [--states-only yes|no] [--gpu-wait-timeout SECONDS]
|
|
[--video-handle dma-buf|opaque-fd|opaque-win32] [--check-presents F,...] [--read-device-copies yes|no]` plays a stream (its first segment) on one device through the
|
|
runtime, and writes `DIR/report.txt`, whose first line names the play's mode: `mode full: every
|
|
call`, or with `--states-only yes`, `mode states-only: the device, library, function and pipeline
|
|
state records and the presents alone (--states-only yes)`. A states-only play plays the device
|
|
(`MTLCreateSystemDefaultDevice`, `m2v.deviceIdentity`), every library, function and dynamic
|
|
library made, every render and compute pipeline state made, and every `m2v.present`, so its frames
|
|
and its recording range end where a full play's do; it passes over every other call, runs no
|
|
command and writes no memory, so its pipeline states are made as a full play makes them, cold, and
|
|
it writes none of the matrix's judged metrics. `--video-handle`
|
|
names the consumer's decoder route, the handle its video surfaces are made
|
|
with (a dma-buf where it is not given; below), and the handle and multiples its exported surfaces
|
|
are made with in place of the recorded ones (where it is not given, the recorded ones). Each wait on the device's work is bounded by `--gpu-wait-timeout` (10 seconds
|
|
by default; docs/VALIDATION.md, the hang tripwire), which a play on a CPU device raises. It
|
|
writes each frame's `frame` and `end` lines as the frame ends, flushed, so a play that never ends
|
|
leaves every frame it finished. Every line it writes to `report.txt`, the frame lines among them, it writes to
|
|
its standard error too, so a caller that loses the directory keeps the report.
|
|
It takes no `m2v.privateBytes` snapshot: each such dispatch plays as it is, counted on the
|
|
`unsnapshotted` line, so two plays do the same work and their times and memory compare. With `--until-frame F` it stops after frame `F`'s present (frames
|
|
counted from 0), completes the work committed so far that can complete, reports as at the stream's end and says
|
|
`until-frame F`. A command buffer committed by then that waits on an event no call played
|
|
signals stays held, as the calls past the stop may signal it: the report names it on a
|
|
`held #ID ...` line and the play ends as it would without it, where at the stream's end such a
|
|
command buffer is an invalid stream. With `--check-presents F,...` it checks, at the `m2v.present` of each listed frame (counted from
|
|
0), the texture the present shows, as an `m2v.check` of it with no recorded checksum would: a
|
|
`check ID frame F SHA256 unrecorded` line, which `compare-plays` reads as the frame's digest
|
|
(below); it also writes the bytes it read to `presents/frame-F.bytes` in the `--out` directory
|
|
and names them with a `shown ID frame F format P width W height H` line (`P` the
|
|
`MTLPixelFormat`'s raw value; `shape unknown` where the backend gives none), so two plays'
|
|
pictures that differ there can be sized (below). The bytes are the program's picture: they stay
|
|
on the host that played them. A present of nil checks nothing. The readback is the player's own work, in none of the
|
|
counts, and its time is the frame's `read`, so a play timed for a verdict lists no frame and the
|
|
digests come from a play of their own. `command-replay dump --stream FILE` prints the call
|
|
records as text, and
|
|
`command-replay shapes --stream FILE` each selector's argument shapes, with no data.
|
|
`command-replay snippet video-surfaces --out DIR [--handle dma-buf|opaque-fd|opaque-win32]`
|
|
writes `DIR/video-surfaces.0000.m2vr`, a synthetic stream of ours that holds nothing of any
|
|
program's: one exported surface of a two-plane 4:2:0 picture (R8 and RG8 planes, 64 by 36 texels,
|
|
pitch and plane starts multiples of 256) of the handle given (an NT handle on Windows, else a
|
|
dma-buf, where it is not given), exported once, then three pictures of its own bytes landed in it,
|
|
one a frame; each frame reads the two planes back through two parts of one command buffer, one
|
|
through a view of the luma plane, checks them against the picture's SHA-256s, and commits one more
|
|
command buffer that uses none of the surface. Played, each of its frames agrees with the hand-over
|
|
contract (below) where the surface is made, and each check matches where the stand-in wrote.
|
|
|
|
- **The recording range.** A play ends at the stream's recording range by default: through the
|
|
frame its sidecar (section 1) states, else the frame the player's table `RECORDED_RANGES`
|
|
states for it (the streams recorded before sidecars, found by their first segment's file name
|
|
and byte length), else the whole stream. `--past-range yes` plays past it, to the stream's end
|
|
or to `--until-frame F`; without it, `--until-frame F` stops the play at the earlier of `F` and
|
|
the range. The
|
|
report's `range` line says which range the play used, where it came from, and whether the play
|
|
ends there or `--past-range yes` takes it past; a play that ends at the range says
|
|
`until-frame F` as `--until-frame` does. A sidecar that reads as neither `last-frame F` nor
|
|
`whole` is an error.
|
|
- **The display library.** The report's line after `range` is `display library the stream's
|
|
sidecar, N bytes, sha256 HEX, git blob ID` where the stream has `NAME.display.metallib` (section
|
|
1), which names the file the play ran by its SHA-256 and its git blob id in the host's tree, and
|
|
the host's library from source is made of it; else `display library none: the
|
|
host's library from source is skipped`.
|
|
- **Streams recorded before the completion fix.** Where the stream's header lacks bit 1 (section
|
|
6), the report's line after its mode line is, by itself, `recorded before the recorder's
|
|
completion fix: the stream may differ from what the program did`, so no table taken from the
|
|
report loses it.
|
|
- It moves address arguments (section 5) and plays the host's plumbing as the plain calls it
|
|
stands for (section 4).
|
|
- **Managed buffers** play in the form the recording device kept them: its
|
|
`m2v.deviceIdentity` record's `hasUnifiedMemory`, or where the stream has none, `--managed`
|
|
(`one-copy` for unified memory, `two-copy` for a GPU copy). With neither, a Managed buffer stops
|
|
the play with an error that says so. One copy: every Managed buffer plays as a Shared buffer, on
|
|
every device. Two copies: it plays as the runtime's Managed buffer, whose GPU copy starts from
|
|
the bytes it was made with: a copied buffer's bytes, or a no-copy one's bytes at its making
|
|
(section 5), which the backend's making takes from the call (a descriptor's `contents`, the
|
|
pages `newBufferWithBytesNoCopy:length:options:deallocator:` holds) and the player writes again
|
|
once the buffer is made. A stream with no identity record gives a no-copy buffer none, so its GPU copy takes
|
|
the writes recorded before its first use (a commit of a command buffer one of whose encoders
|
|
names it), the nearest record the stream has of its bytes at its making. Where the device keeps
|
|
a GPU copy, the player places it as it places a Private buffer of the buffer's length (below), a
|
|
buffer made in a stream's block or heap included, and frees that range as it frees the buffer's.
|
|
On a device with unified memory the runtime keeps one copy anyway. The report's `managed` line says which form
|
|
played and from what, counts the Managed buffers and the no-copy ones whose contents came from
|
|
first use, not from create, and says where a two-copy recording played as one copy.
|
|
- **Which copy a read takes.** A check or dump of a buffer the play keeps two copies of (a
|
|
two-copy stream's Managed buffer: the runtime's device copy beside the consumer's bytes, or on a
|
|
device with unified memory, the player's own CPU copy beside the device's one copy) reads its
|
|
CPU copy, as Metal's `contents` answers, and says so: its `check` line ends `(CPU copy)` and its
|
|
dump holds a `.copy` file (below). With `--read-device-copies yes` it reads the device copy instead, back through a blit into a Shared buffer of the play's own
|
|
where the runtime keeps one (that blit's commit takes the ranges named and not yet taken, as the
|
|
program's next commit would), and its line ends `(device copy, read back)`. On a device that
|
|
keeps a device copy of each Managed buffer, the line after `device` says which the play reads:
|
|
`managed digests: this device keeps a device copy of each Managed buffer; a check or dump of one
|
|
reads its CPU copy only, as Metal's contents answers (--read-device-copies yes reads the device
|
|
copy back)`, or `... reads the device copy back`. Two plays' CPU copies agreeing says nothing of
|
|
their device copies, which commands read.
|
|
- **No-copy buffers** play as the product makes them, by creator:
|
|
- A `newBufferWithDescriptor:` with `noCopy` is a pool buffer in the product: a guest buffer's
|
|
storage in one of the host's blocks. Where its recorded address and length lie inside a live
|
|
block's recorded range (`m2v.newBlockWithLength:storageMode:`) it plays as a buffer of the
|
|
block at that offset, as `m2v.newBufferInBlock:offset:length:options:` does, its bytes at its
|
|
making (`contents`, where the stream gives them) first put there; elsewhere, in a place of its
|
|
own, as any other buffer. No import. The recordings do not tell the program's own no-copy
|
|
memory, which the product imports, from these, so it plays as a pool buffer too: a known gap.
|
|
The host's recorder makes such a buffer over the program's own memory only with a
|
|
`pinnedGpuAddress` and no `zeroFrom`, so the report's `gap: descriptor-form buffers that may
|
|
be the app's own no-copy memory are played as pool buffers, count unknown: at most N, ...`
|
|
line bounds the gap by those outside every block and their bytes, wherever there are any.
|
|
- A `newBufferWithBytesNoCopy:length:options:deallocator:`, which in the recordings is the host's
|
|
own buffer and never the program's, is made over zeroed host pages of the player's own: its
|
|
length rounded up to the device's `minImportedHostPointerAlignment`, imported as a block of its
|
|
own (`Device::import_host_memory`), as the product imports such pages, and freed once the
|
|
runtime frees the import. Where the buffer plays with two copies, the import holds the copy
|
|
the CPU writes where the runtime keeps a GPU copy, and the copy shaders and textures reach
|
|
where the player keeps the second copy itself. On a device that imports no host memory such a
|
|
buffer stops the play with a refusal that says so.
|
|
|
|
A texture over an imported buffer is the runtime's counted copy. Each frame's `over_copies` and
|
|
`over_copy_bytes` count every copy of a texture over a buffer, and its `over_copies_imported` and
|
|
`over_copy_bytes_imported` those over an imported one alone; the rest are over the runtime's own
|
|
blocks, where the device's linear image does not take the texture. `over_copies_host_memory`,
|
|
`over_copies_pitch` and the ten like them, each beside its `over_copy_bytes_` sum, split them by
|
|
the runtime's cause (`Metrics::over_copies_host_memory` and the rest), and its
|
|
`over_copy_bytes_private` and `over_copy_bytes_shared` split their bytes by the memory class
|
|
the buffer's bytes are in, the rest being over a Managed buffer's device copy. Each frame's
|
|
`rendering_interrupts` counts the renderings a render encoder ended and began again inside
|
|
itself (`Metrics::rendering_interrupts`). The report's `no-copy
|
|
buffers` line counts the descriptor-form ones in a block, those outside every block and their
|
|
bytes, and the bytes-form ones and their bytes imported, apart; its `textures over buffers` line
|
|
counts the textures over buffers it made (not substituted), in place and in an image of their
|
|
own, by whether the runtime's `textures_copied_over` gauge rose across the making (a copied
|
|
texture freed on another thread in that moment hides one), and its `textures over buffers in an
|
|
image of their own, by pixel format and usage` line those in an image of their own by the
|
|
descriptor's pixel format and usage, most first. Its `over copies by frame, N frames as the
|
|
calls played` line gives the over-copy bytes a frame, the frames cut where the play locates
|
|
each frame's first call (the last counts where any call of it played), as their mean and as
|
|
the largest frame's (the first of a tie), each split into `bytes` (every copy's),
|
|
`private` and `shared` (`over_copy_bytes_private` and `over_copy_bytes_shared`), and by
|
|
cause `pitch`, `dma_buf`, `host_memory` and `own_image` (every other cause's), then the
|
|
number of those textures in an image of their own, each counted once and a view as its
|
|
texture, that the largest frame's calls named: an encoder's call's arguments and a render
|
|
pass's attachments. A texture an argument buffer or a heap holds is named by no call.
|
|
- **Announced bytes.** On a stream whose header has bit 0 set (section 6), a
|
|
`synchronizeResource:` of a buffer played with two copies leaves the CPU's copy as the stream's
|
|
writes made it, so the next `didModifyRange:` puts the stream's bytes into the GPU's copy: it
|
|
copies the GPU's copy into an aside buffer of the player's own, which a check of the buffer
|
|
reads from the read-back to its next `didModifyRange:`. A stream without the bit plays its
|
|
read-backs into the CPU's copy, as Metal does. A Managed buffer played as one copy holds the
|
|
GPU's bytes either way. The report's `announced bytes` line says which rule played and counts the read-backs
|
|
it kept out of the CPU's copies.
|
|
- **Unwritten buffers:** the report's `unwritten` line counts, once each, the Shared
|
|
buffers made without bytes that a dispatch read and whose command buffer committed before any
|
|
recorded write, upload or GPU pass reached their bytes, since their making or, in a block,
|
|
before it, and names the first few with the command buffer that read each. Such a buffer plays
|
|
with whatever its memory held, which is where a recording that missed the program's writes
|
|
shows. A dispatch reads the buffer bound at a slot its pipeline state reads (the runtime's
|
|
`ComputePipelineState::buffer_accesses`: `ReadOnly` or `ReadWrite`) and one `useResource:usage:`
|
|
names for reading (each of a `useResources:count:usage:` list as its own); it writes the buffer
|
|
at a slot the state writes and one used for writing,
|
|
and a slot the state does not use touches nothing. A buffer another call of its encoder named
|
|
since its last dispatch, and each bound under a state the play skipped, is taken as read and
|
|
written, and the line says how many of the count were. In a command buffer a dispatch's write
|
|
comes before the later dispatches' reads. What reaches a buffer's bytes: an `m2v.write` into
|
|
it, into its block over them or into another buffer of the block over them; a blit or render
|
|
encoder's call that names it or such another buffer (a residency declaration's resource
|
|
included, `{Buffer: object}`); and the commit of a command buffer whose
|
|
dispatch writes it or such another buffer. A buffer made in a block over bytes that a write or a
|
|
GPU pass reached before is not counted. Every commit the player makes counts: a `commit`, an
|
|
`m2v.split` and an `m2v.commitPart` it cuts. A texture over a buffer is not followed. The line
|
|
counts; it stops nothing.
|
|
- **Writes into Managed textures** (the backend tells a texture's storage mode): the report's `texture_writes` line counts the CPU's writes into Managed textures
|
|
(`replaceRegion:...` and any other call on a texture that carries bytes), their bytes and
|
|
textures, and of them those made while a command buffer that used the texture (an encoder of it
|
|
named the texture or a view of it, or it was made with a descriptor that names one) was committed
|
|
and the stream records no completion of it. The play waits for each command buffer at its commit;
|
|
the stream records a completion only where the program's CPU waited: `waitUntilCompleted` of the
|
|
command buffer or a later one of its queue, or `waitUntilSignaledValue:timeoutMS:` reaching a
|
|
value that it or a later one of its queue signals. So such a write may have met a user still
|
|
running on the recording device. It counts them by the presents between the user's commit and the
|
|
write (0, 1, 2, 3 or more), names the first eight (position, texture, user, presents) and counts
|
|
the writes into textures whose storage the backend does not tell. It stops nothing.
|
|
- **Reads of Managed bytes on two copies:** the report's `managed reads on two copies: made-with
|
|
CLASS, served; stale CLASS, played as recorded` line (`CLASS` `N objects, U uses, first at
|
|
frame F`, or `none`) counts, from the stream's calls alone and so alike on every commit and
|
|
device, the GPU's reads of a Managed object's bytes that no announcement took to its GPU copy,
|
|
as a play that keeps two copies holds them. A Managed object is a buffer of any maker whose
|
|
options say Managed, a Managed block and its buffers, and a texture over such a buffer or a view
|
|
of it. A GPU use is a command that names the object, judged at its command buffer's commit: a
|
|
blit's source range and a copy to the guest's RAM read; a blit's, a fill's and a guest-RAM
|
|
copy's destination bytes are a GPU write; every other naming reads the whole object, as the
|
|
stream carries no buffer access. Made-with reads are of the bytes a buffer was made with (a
|
|
descriptor's `contents`, a no-copy buffer's pages, `newBufferWithBytes:length:options:`'s bytes;
|
|
bytes that are all zero left out) before a `didModifyRange:` or a GPU write covered them. The
|
|
player serves them (section 5: the GPU copy starts from them), so the count
|
|
says how many reads depend on that, not that any is wrong. Stale reads are of bytes an
|
|
`m2v.write` put in that no `didModifyRange:` announced and no GPU write covered: what the GPU
|
|
reads there Metal leaves undefined, and the play takes one rule, the GPU copy's bytes
|
|
as the making and the announcements left them. Where the stream has no identity record, a
|
|
no-copy buffer's writes before its first use reach its GPU copy (section 5) and are not counted;
|
|
the line ends `; writes before first use served (no identity record)`. Where the guest device's
|
|
identity record keeps one copy, the line is `managed reads on two copies: none counted: the
|
|
stream's identity record keeps one copy`. It stops nothing.
|
|
- After each commit, before each write, check and present, and where the program waited, it waits
|
|
for every committed command buffer that can complete: one whose event waits are met by values the
|
|
CPU set or by signals of command buffers that can complete. It never waits on a command buffer
|
|
held behind an event wait. Each wait is bounded under the validation crate's hang protocol.
|
|
- It reads the `m2v.privateBytes` records (section 8) ahead, before it plays the stream. It
|
|
takes no snapshot, so each dispatch they name plays as it is and is counted on the report's
|
|
`unsnapshotted` line.
|
|
- It lays each placement heap out again for the runtime's sizes and alignments, as a program that
|
|
lays out its heap by `heapTextureSizeAndAlignWithDescriptor:` and
|
|
`heapBufferSizeAndAlignWithLength:options:` does: the stream's offsets and heap sizes are the
|
|
recording device's answers. Before it plays, it reads ahead every `newTextureWithDescriptor:offset:`
|
|
and `newBufferWithLength:options:offset:` of each placement heap and asks the runtime the size
|
|
and alignment of each, a texture's of its descriptor as the calls before it made and set it.
|
|
Going up the offsets the stream placed at, each keeps at least its distance from the one below,
|
|
moves up until the resources placed below it end, and rounds up to the largest alignment of the
|
|
resources placed there. The heap keeps at least its distance past its last offset and holds the
|
|
resources placed there. Resources the stream placed at one offset still share it; resources at different offsets no longer share memory, even where the
|
|
stream's did. Where every resource ends before the next offset and every offset
|
|
is aligned, the layout is the stream's. A placement whose size the runtime does not answer keeps
|
|
its offset, and the play meets the runtime's refusal where it lies.
|
|
- It reports, for each group of command buffers it waited for (normally the one just committed),
|
|
for each frame and in total, two sets of counts:
|
|
- **Fixed by the stream** (`stream`), the same on every play of the stream: the
|
|
calls played (`calls`), the command buffers committed (`commits`, a host's split included),
|
|
the encoders made (`encoders`: the objects a command buffer or an encoder makes), the draws,
|
|
dispatches and blit commands their calls issued (`draws`, `dispatches` and `blits`: an
|
|
encoder's calls whose selectors begin `draw`, `dispatch`, and `copy`, `fill`,
|
|
`generateMipmaps`, `synchronize`, `resetCommandsInBuffer` or `optimize`), the buffer slots
|
|
their set-buffer calls set (`setBuffer:offset:atIndex:`, `setBufferOffset:atIndex:` and
|
|
`setBuffers:offsets:withRange:`, and their `Vertex` and `Fragment` forms), on render encoders
|
|
(`render_buffer_binds`) and on compute encoders (`compute_buffer_binds`), and of those the
|
|
buffer changes (`render_buffer_changes`, `compute_buffer_changes`: another buffer than the
|
|
slot held in the encoder, or the slot's first set) and the offset-only changes
|
|
(`render_offset_changes`, `compute_offset_changes`: the buffer the slot held, at another
|
|
offset); a set of the buffer and offset the slot holds is neither. The written words that look like addresses
|
|
(`address_looking_words`) and the 8-byte values at offsets 4 past a multiple of 8 that lie in
|
|
a live range (`misaligned_address_words`), both played as recorded (section 5), but those of
|
|
the first in a noted buffer's range, moved (`noted_words`), the address
|
|
arguments (`address_arguments`) and those it moved (`relocated_words`), and the bytes it
|
|
wrote or copied in, `m2v.write`, the copied
|
|
buffers' `contents` and the copies from the guest's RAM (`written_bytes`). A group's calls are those played before it completed:
|
|
the call that waited for it counts in the next.
|
|
- **As executed** (`executed`): the runtime's metrics (`Device::counters`): its submissions,
|
|
passes, barriers, bytes copied, copies of textures over buffers, pipelines made, allocations
|
|
and the rest. The barriers are counted in their causes too, which sum to `barriers`:
|
|
`pass_start_barriers`, `pass_home_barriers`, `blit_barriers`, `dispatch_hazard_barriers`,
|
|
`segment_end_barriers`, `upload_barriers` and `other_barriers` (`Metrics::pass_start_barriers`
|
|
and the rest), and a dispatch's barriers in their sources too, which sum to
|
|
`dispatch_hazard_barriers`: `dispatch_after_write_barriers`,
|
|
`dispatch_write_after_read_barriers`, `dispatch_encoder_end_barriers`,
|
|
`dispatch_pass_end_barriers`, `dispatch_indirect_barriers`, `dispatch_unbound_barriers`,
|
|
`dispatch_arena_piece_barriers`, `dispatch_heap_barriers` and `dispatch_other_barriers`
|
|
(`Metrics::dispatch_after_write_barriers` and the rest), and the dispatches by the form their
|
|
kernel reaches its buffers in: through storage buffers of set 0 (`bound_dispatches`, with the
|
|
sets written for them, `buffer_sets_written`, and those that kept the set written last,
|
|
`buffer_sets_held`) or at their device addresses (`address_dispatches`). They differ between commits, and
|
|
between plays of one commit where what the runtime records depends on timing. Only the
|
|
stream's counts are compared between plays.
|
|
|
|
Its own readbacks are not counted. The backend reads a Private buffer, which has no CPU
|
|
mapping, through a blit copy of it into a Shared buffer of the play's own, on a queue of the
|
|
play's own, and waits for the copy.
|
|
- A selector, argument or descriptor key the backend does not implement is a typed refusal naming
|
|
it; the run stops there and the report keeps what ran. Indirect command buffers are among them:
|
|
the backend makes none and executes none, so a recording that makes one stops at that call.
|
|
- The backend plays compute, render, blits, `synchronizeResource:`, fences, events and queues.
|
|
Visibility results play as the runtime's: a pass's `visibilityResultBuffer` and
|
|
`visibilityResultType`, and each `setVisibilityResultMode:offset:` (`[mode, offset]`), whose
|
|
counts the runtime writes into the buffer at the pass's end.
|
|
`setSamplePositions:count:` sets the runtime's descriptor's `sample_positions`: the pass
|
|
rasterizes at them on a device that answers `programmableSamplePositionsSupported` yes. A set
|
|
the runtime refuses, as Metal's validation does or on a device that answers no, ends the play
|
|
with that refusal at the render encoder; a pass at custom positions the runtime does not build
|
|
(beside a depth attachment) is a skipped encoder, counted by its gap.
|
|
What the runtime does not build yet it skips and counts, and never fakes:
|
|
- objects: libraries from source, and whatever a call makes of a skipped object
|
|
(`skipped_objects`). A call that makes an object on a skipped receiver or naming a skipped
|
|
object is a creation not attempted (`not_attempted`, counted in `skipped_objects` or
|
|
`skipped_calls` too): a `not attempted SELECTOR N: WHY` line for each selector and reason,
|
|
the reason naming the selector that made the first object of the chain skipped, with the
|
|
first creation's object and that root object. A `render states made M, refused R, not
|
|
attempted N` line, with the compute states' the same, adds up the stream's pipeline states;
|
|
- render pipeline states the runtime answers with a typed gap or the translator refuses
|
|
(`skipped_render_states`), and compute pipeline states the same way
|
|
(`skipped_compute_states`), whose dispatches are skipped (`skipped_dispatches`);
|
|
- parallel render encoders, and render encoders of a pass the runtime does not build
|
|
(`skipped_encoders`): a pass whose setter records leave in it what the runtime's render pass
|
|
descriptor does not hold (store action options, tile or imageblock sizes, or a skipped
|
|
texture, resolve texture or visibility result buffer; a color attachment's depth plane is
|
|
played, and a depth or stencil attachment's, which Metal reads of a 3D texture alone, is not;
|
|
`renderTargetArrayLength` is played, so a layered pass is the runtime's to build or answer),
|
|
or one the runtime answers with a typed gap; and
|
|
every call of a skipped object (`skipped_calls`, with `useResource:usage:` and `useHeap:` of
|
|
one, and each skipped object of a `useResources:count:usage:` or `useHeaps:count:` list);
|
|
- dispatches whose pipeline state or bound buffer or texture is a skipped object
|
|
(`skipped_dispatches`), and draws whose pipeline state, or a buffer or texture bound to
|
|
either stage, or whose index buffer is one (`skipped_draws`);
|
|
- render commands the runtime answers with a typed gap, a draw it does not build among them,
|
|
and visibility result modes the runtime refuses as Metal's validation does (no visibility result
|
|
buffer, an offset off a multiple of 8 or past the buffer, at a byte of the buffer's allocation
|
|
off a multiple of 8, or one the encoder took before), whose mode stays as it was
|
|
(`skipped_render_commands`, and a line for each gap, or `Refused(KIND)` for each kind of
|
|
refusal, with its first frame and call). `setTessellationFactorScale:` at Metal's default of
|
|
1 plays as nothing, and at any other scale is a skipped render command
|
|
(`TessellationFactorScale`): Metal reads the scale only in a patch draw through a
|
|
post-tessellation pipeline state that enables it, and the runtime refuses every such state
|
|
(`RenderPipeline { kind: Tessellation }`), which the report counts as a skipped render
|
|
pipeline state;
|
|
- blit commands that name a skipped object (`skipped_blits`), and by kind:
|
|
`synchronizeTexture:slice:level:` (`skipped_texture_syncs`), and the pieces of a copy from
|
|
the guest's RAM that are not whole 4-byte words at a 4-byte offset, into a buffer with no
|
|
mapping (`skipped_guest_ram_writes`). `optimizeContentsForGPUAccess:`, a layout hint, plays
|
|
as nothing, and `generateMipmapsForTexture:` as the runtime's `generate_mipmaps`.
|
|
|
|
A buffer-to-buffer copy plays as the runtime's (`copy_from_buffer_to_buffer`). The copies
|
|
between the guest's RAM and a buffer play in the host's form, the one-copy form: one buffer copy a call, in a command buffer of the backend's own on the queue of the
|
|
call's command buffer, through a Shared scratch of the backend's own; the report's `guest RAM`
|
|
line says so. A copy from the guest's RAM gathers its pieces on the CPU into the scratch, laid
|
|
out as the target's bytes they span, and copies them into the target in a command buffer
|
|
committed just before the call's: the bytes of those words no piece carries (a piece's edges up
|
|
to whole words, the gaps between pieces) come from the target's mapping where it has one, and
|
|
into a target with none the copy is one for each run of touching words, so no gap is written
|
|
(`guest_ram_fills`, `guest_ram_pieces_in`, `guest_ram_fill_copies`, `guest_ram_fill_bytes`). A
|
|
copy back to the guest's RAM, the recording host's own work, first copies a surface's texels
|
|
into the bytes in the call's blit encoder (below), then copies the whole words its runs span
|
|
within the buffer into the scratch in a command buffer committed just after the call's; a wait
|
|
for the call's command buffer waits for that copy too, as the guest sees its RAM written when
|
|
its command buffer completes, and the CPU then copies each run out of the scratch into memory
|
|
of the backend's own that nothing reads (`guest_ram_downloads`, `guest_ram_download_bytes`,
|
|
`guest_ram_runs_out`, `guest_ram_run_bytes_out`). Those command buffers are the backend's
|
|
stand-in for the host's work, apart from the stream's: their GPU time is
|
|
`guest_ram_gpu_nanos`, counted in the frame whose end first sees each complete, and in no
|
|
frame's `gpu_busy`. A command buffer released uncommitted makes none of its copies.
|
|
|
|
Textures over a buffer play as the runtime's (`Buffer::new_texture`) and texture views as its
|
|
views (`Texture::new_texture_view`). A tiled texture over a buffer of one level plays as the
|
|
first form's texture over the buffer, and one of more than one level, which the runtime takes no
|
|
form of, plays as an ordinary texture of the descriptor that takes, at its first use, a copy of the buffer's bytes from the
|
|
offset, rows `bytesPerRow` apart, into its first level and makes its later levels from the first
|
|
as `generateMipmapsForTexture:` makes them (a format whose mipmaps the runtime refuses or cannot
|
|
filter keeps them). The take is a blit encoder of a command buffer of the backend's own,
|
|
committed on the queue of the command buffer whose encoder (a command, or a render pass's
|
|
attachment) named the texture or a view of it first since its making, just before it and after
|
|
its copies from the guest's RAM, so what an earlier encoder of that command buffer writes into
|
|
the bytes or the texture lands after the take. A `replaceRegion` of such a texture's first level, which writes
|
|
the bytes and asks for another take, is refused. The stand-in is counted apart from the stream's
|
|
work: `tiled_textures`, `tiled_takes`, `tiled_take_bytes` (the first level's bytes),
|
|
`tiled_mipmap_generations`, `tiled_levels_kept`, and its GPU time `tiled_gpu_nanos`, in no
|
|
frame's `gpu_busy`, as the guest RAM's is; the report's `tiled textures over a buffer` line
|
|
gives them. Where the runtime cannot make a texture the program made, the backend makes an
|
|
ordinary texture of the same descriptor in its place, so that the IDs and addresses the program
|
|
wrote name a live texture, and counts it: a texture over a buffer or a view the runtime answers
|
|
with a typed gap (`substituted_gap_textures`), and the report's
|
|
`substituted textures KIND N, the first #ID` line counts each kind (`KIND` the runtime's gap as
|
|
Rust prints it for debugging, such as `TextureView { kind: TextureType }`; `ID` the first one's
|
|
object). A substitute is the recording's artefact, never the
|
|
runtime's, and its texels are not the program's: `substitutes_read` counts the substitutes, and
|
|
the views of one, that a call other than the making of a view named (a binding, an attachment,
|
|
a blit, a descriptor's field, a call on it), and the report's `substitutes read` line gives the
|
|
first few. A play with a substitute read is equal at best where played; one with a substitute
|
|
only made is not touched by it.
|
|
|
|
A texture over a surface's plane (section 7) plays as the product's per-shape form makes it: one
|
|
texture of the runtime's made for views (`Device::new_texture_for_views`) for each plane (the
|
|
receiver buffer, the plane, its offset and row pitch) and shape (width, height and bytes a
|
|
texel, and whether shaders may write it), and each recorded surface texture, and each view of
|
|
one, a view of it at the texture's own index. A plain shape, made for a texture whose usage has
|
|
neither shader write nor shader atomic (a storage image's operation) and is not Metal's unknown,
|
|
takes shader read and render-target usage alone, so it views as its own format and that format's
|
|
sRGB sibling; a texture or view of another format over it is refused
|
|
(`surface_format_refusals`), and textures over it that declare pixel-format-view usage are
|
|
counted (`surface_plain_format_views`). A shape shaders may write takes the usage Metal gives a
|
|
texture whose use it does not know (shader atomic too where the texture declares it), so a
|
|
texture of another format of the same bytes a texel shares its texels; it serves a later texture
|
|
of its extent that does not declare it, and a texture that declares it over a plane whose shape
|
|
of its extent has none is another shape of the plane. Textures over the same pages at
|
|
another offset or pitch are another plane: nothing moves between two planes but through the
|
|
buffer, at the recorded copies. The receiver buffer holds the pages' bytes as the stream writes
|
|
them, and every shape is current over its whole extent, by the product's three rules:
|
|
- A new shape is filled from the buffer, once the buffer's dirty shapes are copied into it, by
|
|
blits in a command buffer of the backend's own committed at the making, after every earlier
|
|
commit. The same shape made again is a view of it, with no copy.
|
|
- A shape is dirty once a committed command buffer may have written it, until it is copied into
|
|
the buffer. A copy back to the guest's RAM first copies every dirty shape of the buffer, and
|
|
every shape its command buffer may have written before, into the buffer, in the copy's own blit
|
|
encoder, where the GPU's order holds it.
|
|
- At the end of an encoder that may have written a shape, the write goes into each other shape of
|
|
its plane that a live texture views or that is dirty: the write's texels that the others
|
|
overlap (every two shapes of a plane overlap from its first texel) are copied into the buffer at
|
|
the plane's offset and pitch, then from there into each other shape, in two blit encoders of the
|
|
same command buffer; the plane's other shapes go. A texel the write's rows reach only in part
|
|
keeps its bytes (`surface_straddled`), and an encoder that may have written two shapes of one
|
|
plane takes the one noted last as the plane's write (`surface_unordered_writes`).
|
|
|
|
An encoder may have written a shape through a render pass's attachment, a blit's destination, a
|
|
texture bound at a slot that the bound pipeline state's interface writes
|
|
(`texture_accesses`), and, where no interface is at hand (a stage the runtime answers none for, a
|
|
skipped state, a `useResource:usage:`), a texture whose usage lets a shader write it
|
|
(`surface_usage_writes`). A write through an argument buffer with no use named is not seen, and
|
|
not counted. A shape no texture views stays while it is one of its buffer's four most recently
|
|
used such shapes, or dirty. A copy from the guest's RAM into the buffer also copies the bytes into
|
|
every shape they reach, in the copy's own blit encoder, the guest's bytes winning over a shape's
|
|
write not yet in the buffer. A recorded CPU write reaches the texels it covers of every shape
|
|
through the runtime's upload (`Texture::replace_region`), until the buffer's first
|
|
`m2v.externalWriteDone`. That record (a picture landed) makes every shape of its buffer owe a
|
|
fill from the buffer, its own write lost, as the product's shapes owe one after a video command
|
|
buffer: the first command buffer whose encoders use a texture of the buffer fills every owing
|
|
shape of the buffers it uses before its commit, by blits in a command buffer of the backend's
|
|
own committed then, and a picture that another one lands over before any use is never copied
|
|
(`surface_pictures_filled`, `surface_pictures_unfilled`). The next commit of the stream after a
|
|
command buffer of the backend's own (a fill at a making or at a use) waits on the CPU for it
|
|
first (`surface_host_waits`): the runtime, as Metal, orders a command buffer of another queue
|
|
only after work already submitted, and the backend's fill may be held behind its queue's
|
|
earlier work. Another call that names a receiver
|
|
buffer as a buffer is refused, and a texture of a format that reads across a surface's two planes
|
|
(a two-plane YCbCr or XR10 format) is skipped (`skipped_surfaces_across_planes`). The counts
|
|
(`surface_textures`, `surface_shapes`, `surface_shapes_found`, `surface_order_shapes`,
|
|
`surface_shapes_dropped`, `surface_written_back`, `surface_written_back_bytes`,
|
|
`surface_overlap_copies`, `surface_overlap_bytes`, `surface_straddled`,
|
|
`surface_unordered_writes`, `surface_usage_writes`, `surface_declared_writes`,
|
|
`surface_cpu_writes`, `surface_external_writes`, `surface_refills`, `surface_refill_bytes`,
|
|
`surface_refill_gpu_nanos`, `surface_host_waits`, `surface_pictures_filled`,
|
|
`surface_pictures_unfilled`, `surface_copies_in`, `surface_copies_out`, `surface_bytes`,
|
|
`surface_format_refusals`, `surface_plain_format_views`) are the player's work, among its
|
|
executed counters; `surface_refill_gpu_nanos` is the GPU time of the refills' command buffers, counted in the frame whose end first sees each
|
|
complete. The report's `surfaces` line gives them with the longest refill command buffer.
|
|
|
|
A buffer made as a video surface's pages (`m2v.newDmaBufBufferOfLengthPaddingUnobserved`, section
|
|
4), which another API decodes pictures into, plays instead as the product makes it: one surface
|
|
of the runtime's (`Device::new_exported_surface`) for the buffer, made at its first texture from
|
|
what that texture reads of the surface (its pixel format, width and height), and every texture
|
|
over a plane a view of that plane's texture at the texture's own index. Once made, the surface
|
|
is waited for at its ready point (`Surface::wait_until_ready`), as the consumer waits before
|
|
the other API's first write into it. A picture landed
|
|
(`m2v.externalWriteDone`) is the surface's acquire (`Surface::external_writes_done`). The stream
|
|
holds no bytes of the pictures (the buffer is Private and another API wrote it), so the play
|
|
writes none, and no shape, fill or refill stands in for such a buffer. `--video-handle` picks
|
|
the surface's handle and layout: `dma-buf` (the default, the stream's own) with the layout the
|
|
product passes for a VA-API import (pitch and plane starts multiples of 256, each plane holding
|
|
the coded picture's rows: the luma's height rounded up to 16, the chroma half that), or
|
|
`opaque-fd` with the layout it passes for NVIDIA's route (pitch a multiple of 4, no rows below),
|
|
or `opaque-win32`, an NT handle, the opaque handle of a Windows host, at the opaque fd's layout:
|
|
the runtime lays both opaque handles alike, at the driver's own pitch for each plane's `LINEAR`
|
|
image.
|
|
The planes ask shader read and write; where the device's image in place lacks storage
|
|
(`Gap::SurfaceUsage`) they take shader read alone, counted. The formats played so are the
|
|
two-plane 4:2:0 ones, 8-bit (`420v`, `420f`: R8 and RG8 planes) and 10-bit in 16 (`x420`,
|
|
`xf20`: R16 and RG16); a buffer whose first texture reads no facts or another format plays as
|
|
any surface's pages do (above), counted. The report's `video surfaces through the surface call
|
|
(HANDLE): ...` line counts the surfaces made in place and in the copy form (with the runtime's
|
|
reasons), those whose planes take shader read alone, the textures over their planes, the
|
|
acquires, the pictures landed in a buffer before its first texture (no surface to acquire) and
|
|
the buffers played as any surface's pages; the executed counters `video_surfaces_in_place`,
|
|
`video_surfaces_copied`, `video_surface_textures`, `video_surface_acquires`,
|
|
`video_pictures_before_surface` and `video_buffers_otherwise` give them by frame, beside the
|
|
runtime's own `surfaces_in_place`, `surfaces_copied` and `surface_waits` (the ready waits of
|
|
surfaces made in place), and the gauges add `surface_imports`.
|
|
|
|
An exported surface (section 7) plays as the host made it, through the runtime's surface call:
|
|
the recorded handle and multiples, or with `--video-handle` that route's handle and multiples
|
|
(above) with the recorded planes. A surface the runtime refuses (its limit, gap or refusal) is
|
|
a skipped object, counted by its reason; a handle this host has none of (an NT handle on Unix,
|
|
an fd on Windows) stops the play, which `--video-handle` avoids. At `m2v.exportSurface` the
|
|
player waits for the surface's ready point (`Surface::wait_until_ready`). The other API that
|
|
wrote the pictures where the stream was recorded is not there on replay, so on Linux and macOS
|
|
a Vulkan device of the player's own, on the runtime's instance and physical device, stands in
|
|
for it: at the surface's first export it imports the handle, an fd, as one buffer over the whole
|
|
memory (an opaque fd at the size and memory type it was exported with, in an allocation
|
|
dedicated to no buffer; a dma-buf into a memory type its fd's query lists, dedicated). Where the
|
|
driver keeps the stand-in's buffer to a dedicated allocation, an opaque fd's import would have to
|
|
name a buffer identical to the exporter's, whose create info the export does not give, and where
|
|
the buffer lists no memory type of the import, it cannot bind it: either is an import the
|
|
stand-in cannot make, counted with its reason. On Windows nothing stands in for it: the stand-in's writes wait
|
|
under the validation crate's bounded fence waits, which only Linux and macOS have, so there
|
|
each landing is counted unwritten with that reason. At `m2v.surfaceWritesDone` the player first waits for every committed command
|
|
buffer that can complete, as the other API writes a picture after the work before it; then the
|
|
stand-in copies each plane's rows into the memory at the play's layout (`SurfaceExport::planes`:
|
|
each plane's first byte and row pitch), or, where the record holds no bytes, fills the whole
|
|
memory with the landing's number on the surface (from 1) as a byte; releases the memory to the
|
|
handle's queue family (`VK_QUEUE_FAMILY_FOREIGN_EXT` for a dma-buf, `VK_QUEUE_FAMILY_EXTERNAL`
|
|
for an opaque handle); and waits for that work on a fence of its own, bounded as every wait is.
|
|
Then the player calls `Surface::external_writes_done`. An import or a write the stand-in cannot
|
|
make is counted with its reason, and the play goes on with that picture unwritten. A player
|
|
cannot reproduce the other API itself (its device, queue, timing and barriers: the stand-in
|
|
writes with copies, releases with one barrier and waits, so no picture's writes overlap the
|
|
runtime's work), a picture whose bytes the stream does not hold, or the layout the recording's
|
|
device gave the planes: the play's planes lie where this device's runtime puts them, and the
|
|
stream's bytes are laid out again there.
|
|
|
|
The hand-over has no record: the runtime makes it, and its documentation of
|
|
`Metrics::external_acquires` and `Metrics::external_releases` is the contract. Each
|
|
`vkQueueSubmit2` whose command buffers or uploads use the surface's memory acquires it at its
|
|
head and releases it at its end, one each; each submission that carries a surface's making
|
|
releases what was made once more; `Surface::external_writes_done` records nothing of its own on
|
|
a surface in place, and in the copy form marks the surface's block changed, so each texture over
|
|
it takes the block's bytes again in the next submission that uses it. The backend counts by
|
|
frame what those follow from, among its executed counters: `handover_parts`, the commits whose
|
|
command buffers name a texture in an exported surface (a plane, a view of one, a pass with one as
|
|
an attachment, the old video path's textures over a surface's planes; the player waits after each
|
|
commit, so each is a submission of its own); `handover_makings`, the surfaces whose making a
|
|
submission carried (at the ready wait, or else the next commit); `handover_landings`, the
|
|
pictures landed; and `handover_unjudged`, the CPU's uploads into and reads of such textures
|
|
(`replaceRegion...`, `getBytes...`), whose submissions it does not see. The report's `hand-over
|
|
against the runtime's contract (acquires = parts, releases = parts + makings): A frames agree, D
|
|
differ, U not judged` line, where any frame has any of those, compares each frame's
|
|
`external_acquires` and `external_releases` with the contract's numbers; a frame with an
|
|
unjudged call is not judged, and where a frame differs the line ends `; the first that differs:
|
|
frame F acquires A want W, releases R want V`. The count is exact for a surface in place. In the
|
|
copy form a submission uses the block only where a texture over it owes the block's bytes (after
|
|
its making or a landing), so a frame that uses one plane in two submissions after one landing
|
|
differs, and the line says so. The report's `exported surfaces (ROUTE): ...` line counts the
|
|
surfaces made in place and in the copy form (with the runtime's reasons), those refused (with
|
|
theirs), the exports, the stand-in's imports, and the landings with the stream's bytes (and
|
|
those bytes), with the stand-in's pattern and unwritten (with the reasons), and says what stood
|
|
in for the other API; the executed counters `exported_surfaces_in_place`,
|
|
`exported_surfaces_copied`, `exported_surfaces_refused`, `exported_exports`,
|
|
`exported_stand_in_imports`, `exported_landings`, `exported_landings_with_bytes`,
|
|
`exported_landing_bytes`, `exported_landings_patterned` and `exported_landings_unwritten` give
|
|
them by frame.
|
|
|
|
The counts are among its executed counters; a `skipped_` one above zero makes the play no gate
|
|
result, and `report.txt` says so on a `skipped` line. It places buffers of their own, and the GPU
|
|
copies of two-copy Managed buffers, in the runtime's blocks of 16 MiB of either class (a longer
|
|
one in a block of its own), each place its length rounded up to the buffer's recorded granule:
|
|
the largest power of two that divides its recorded `gpuAddress`, from 256 bytes to 64 KiB (256
|
|
bytes where it has none). A program that writes past a buffer's end then writes into the slack
|
|
the buffer had in the recording, not into the next buffer; the backend's `places by recorded
|
|
granule` line counts the places by granule and gives the most bytes of slack held at once. A
|
|
place is free for reuse once every command buffer committed before its buffer's release
|
|
completed. The backend zeroes a block or heap of the stream once at its making (as the live
|
|
system zeroes a heap's memory once: a buffer placed there reads zero where nothing wrote it,
|
|
though the runtime may take a released block's bytes again), gives the runtime back a block or
|
|
heap of the stream at its release (`release_block`), and gives textures and sampler states
|
|
indices from the whole of each index class (section 5): its
|
|
`indices named N: ...` line counts the objects placed at the index the stream named, those
|
|
whose named index the runtime refused, the indices the program reserved, the placements
|
|
that waited for the commits an index is owed to, with the time waited, and the sampler states
|
|
placed without waiting at an index whose last sampler state had the same recorded descriptor
|
|
while its commits were in flight (Metal hands an equal descriptor the same sampler state and
|
|
ID, so work in flight reads nothing new there). A placement at an index owed to a command
|
|
buffer no record played so far lets complete (its event waits only later records signal, or it
|
|
is behind such a one on its queue) is kept back: the object takes the highest free index of its
|
|
class that no commit in flight is owed, and the `indices kept back N: ...` line counts it. The
|
|
index stays owed to that command buffer. Its readback serves
|
|
Shared and Managed buffers only; a check of anything else is a refusal. The runtime gives a
|
|
compute or render pipeline state no `gpuResourceID`, so each one the program saw is reported on
|
|
an `id` line as `none` and counted (`gap_pipeline_ids`); each skipped object's the program saw
|
|
is reported so too and counted (`skipped_resource_ids`). Nothing in the play reads either, so
|
|
neither counts among the differing IDs. A render pipeline state takes no label and no
|
|
`resourceIndex`, and `defaultColorSampleCount` and `defaultRasterSampleCount` are not played:
|
|
the runtime refuses a pass with no attachment, the one kind they would change. Render encoders
|
|
play `setRenderPipelineState:`, `setDepthStencilState:`, the vertex and fragment stages'
|
|
buffers, offsets, bytes, textures and sampler states, the viewport, scissor, cull mode, winding,
|
|
blend color and stencil references, the draws (indexed or not, with instance counts, base
|
|
vertex and base instance), fences and memory barriers (their stages are the runtime's to
|
|
order). A bind of a range (`withRange:`) of buffers, textures or sampler states plays as the
|
|
single-slot bind of each, from the range's location, on render and compute encoders alike.
|
|
Compute encoders play `setStageInRegion:` (the runtime takes it and it changes nothing a
|
|
dispatch of a kernel without a stage-in argument does, the only kernel it builds) and
|
|
`setImageblockWidth:height:`, whose size the player's pre-pass passes with each dispatch it
|
|
prepares, 1 by 1 until the encoder sets one. Render and compute encoders play their residency
|
|
declarations through the runtime's encoder: `useResource:usage:` and, for each resource of its
|
|
list, `useResources:count:usage:` through `use_resource` with the usage (`MTLResourceUsage`'s
|
|
read, write and sample bits); `useHeap:` and, for each heap of its list, `useHeaps:count:`
|
|
through `use_heap`. A render encoder's forms with `stages:` play as those without: the
|
|
runtime's render encoder takes no stages.
|
|
|
|
`report.txt` holds one line per item: the mode line (`mode full: every call` or `mode
|
|
states-only: ...`) first, then the line `recorded before the recorder's completion fix: the
|
|
stream may differ from what the program did` where the stream's header lacks bit 1 (section
|
|
6), then `range last-frame F (SOURCE); the play ends there`, `range last-frame F (SOURCE);
|
|
--past-range yes plays past it` or `range whole (SOURCE)`, where `SOURCE` is `the stream's
|
|
sidecar`, `the player's table, stream LABEL` or `no sidecar and no table row`, then
|
|
`device NAME runtime rt buffer alignment N` (the alignment Vulkan's memory requirements give the
|
|
runtime's buffers, `Device::buffer_alignment`), then on a device that keeps a
|
|
device copy of each Managed buffer, `managed digests: ...` (above), then
|
|
`addresses address_looking_words=N misaligned_address_words=N noted_words=N address_arguments=N
|
|
relocated_words=N differing_ids=N: written words play as recorded, the noted ones moved; NOTES`
|
|
(the census of the written words that look like addresses, at a multiple of 8 and 4 past one,
|
|
which play as the stream holds them, and of the first those a noted buffer's range holds, which
|
|
move; the address arguments and those moved; `NOTES` `the stream predates the escape
|
|
note` where it holds no `m2v.bufferEscaped` record, else `escape notes N`; and the objects
|
|
whose ID differs from the recording's, those of the compute pipeline states' typed gap and of
|
|
the skipped objects aside: any such object makes the play an error, as a word that names it
|
|
names something else in the play),
|
|
`completed IDS COUNTS`, `frame N COUNTS`,
|
|
`end N wall_nanos=NANOS unix_nanos=NANOS resident_bytes=BYTES times KEY=NANOS ... live KEY=VALUE ...`
|
|
for each frame (the nanoseconds from the frame before's end, or the first call played, to this
|
|
frame's, the wait for its work included; the system's clock at the frame's end, in nanoseconds
|
|
since the Unix epoch, which sets the present beside samples another tool takes of the device;
|
|
the process's resident memory then where the system tells it,
|
|
`VmRSS` on Linux; where the frame's wall time went on the player's thread, in nanoseconds:
|
|
`stream` reading and decoding the stream and its blobs, `write` putting bytes in the runtime's
|
|
memory, `read` reading bytes back, `wait` waiting for command buffers, `resource` the calls that
|
|
make or release a buffer, texture, heap or block and `resource_max` the longest of them,
|
|
`pipeline` the calls that make a library, a function or a pipeline state and `pipeline_max` the
|
|
longest of them, `other` every other call the runtime ran, `upload` the host's copies from the
|
|
guest's RAM, which a backend stages and copies (the recording's plumbing, the player's share),
|
|
`count` reading the runtime's
|
|
counters, and `player` what of the wall time is left, the player's own work; then
|
|
`untimed_waits` and `untimed_wait`, the command buffers the frame waited for that completed with
|
|
no GPU interval or one of no length (the runtime's start 0, or its end not past its start), which
|
|
`gpu_busy` cannot hold, and the nanoseconds of `wait` spent on them; then `gpu_busy`, the
|
|
union of the GPU intervals of the command buffers the frame waited for, where the runtime gives
|
|
them, which runs beside the rest, then `gpu_longest` and `gpu_longest_cb`, the longest of those
|
|
intervals, one command buffer's, and that command buffer's stream id (the first of equal ones; 0
|
|
and 0 where the runtime gives none); and the backend's gauges then, as they stand, never as growth:
|
|
the runtime's live blocks, imports, exports, surface imports, surface buffers, buffers, textures and
|
|
those copied over, samplers, LOD clamp variants, level elements, pipelines, kernels, kernel
|
|
variants and entries, render contents, attachment views, command buffers, descriptor slots,
|
|
events, device samplers, shadows, resolve images, plane stand-ins, timestamp, occlusion and buffer
|
|
set pools, indirect command buffers, releases waiting, handles out, the pipeline cache's bytes,
|
|
spilled bytes, Managed buffers'
|
|
spilled bytes (`managed_spilled_bytes`: the bytes of those whose GPU copy the player placed in a
|
|
spilled Private block), the pool's Shared and Private bytes allocated, idle (and the idle ones'
|
|
ages), reserved and reused long, its Private units and their bytes used, the texture blocks'
|
|
bytes and those held, the Private takes' bytes and those held, the textures' own allocations'
|
|
bytes, the staging bytes, the translator's entries and their bytes, and the bytes
|
|
of the blocks the backend holds for the stream by class, `shared_block_bytes` and
|
|
`private_block_bytes`; at the ends of frames 100 and 200, the gauges once they hold still: read
|
|
every 10 ms until no release waits and two reads in a row agree on every kind the gauge records
|
|
below carry, for at most 2 seconds, a wait of the player's own that no frame's time holds, and
|
|
with them the play's own objects of each of those kinds, `buffers_held`, `textures_held`,
|
|
`samplers_held` and `events_held`: the stream's live ones the backend made, and the backend's own
|
|
that stand for them, the CPU copies of Managed buffers played with two (and both copies of a
|
|
released one whose named ranges the next commit still copies), the asides, the guest RAM copies'
|
|
scratches, the planes' shapes (one texture a plane and shape, which the plane's surface textures
|
|
and their views are views of, kept while one views it, while dirty or while one of its buffer's
|
|
four most recently used that none views, until its buffer's release) and the video and exported
|
|
surfaces' planes),
|
|
`devices apart from the guest's: #ID ...` where the stream recorded devices besides the one the
|
|
guest makes its objects on (section 4), `check ID frame F SHA256 match|differs|unrecorded|covered|receiver` (`F` the frame it was read in, the presents played before it), ending `(CPU copy)` or `(device copy, read back)` for a buffer with two copies (above), `id ID RECORDED PLAYED` for each object whose runtime
|
|
gives another `gpuResourceID` than the program saw (both in hex, `PLAYED` `none` where the
|
|
runtime's getter raises), `id ID RECORDED PLAYED word WORD`, as the runtime lays its IDs
|
|
out as [RESOURCE-ID.md](RESOURCE-ID.md) does: there the ID's low word, its index, is compared with
|
|
the recording's, and its high word with `WORD`, the document's own function of the descriptor the
|
|
object was made of (a texture's `TextureWord`, a sampler state's `SamplerWord`), never with the
|
|
recording's high word, which is the recording runtime's own; `covered N: texture writes over other objects of a placement
|
|
heap; C checks they covered not compared; B covers taken off by a binding,
|
|
which may be a read` where a texture write covered
|
|
bytes of another object the stream placed in its placement heap (`N` the times one did): Metal
|
|
leaves an aliased resource's contents undefined once another resource is written over its
|
|
memory, so from that write until the object is written again its check (`covered`) is not
|
|
compared. The ranges are the stream's
|
|
offsets in the heap with a buffer's length and a texture's size as the runtime answers it, and
|
|
the writes are found by structure: a draw's or a dispatch's to the texture slots the pipeline
|
|
state's interface marks written, a render pass's to the textures its descriptor names, a blit's
|
|
to its destination, `generateMipmapsForTexture:`, a `useResource:usage:` with write usage (and
|
|
each resource of a `useResources:count:usage:` with write usage) and the CPU's `replaceRegion:…`; a write of a texture over a buffer is the buffer's. An object is written
|
|
again by the player's writes into it, a blit into it, and, as the stream carries no buffer
|
|
access, any binding of it to an encoder, a `useResource:usage:` with write usage or a `useHeap:`
|
|
of its heap (each of a `useResources:…` or `useHeaps:…` list as its own); a binding may be a read,
|
|
so `B` counts the covers a binding or a `useHeap:` took off,
|
|
and a difference in that object's later compares may be the covering texture's bytes. `receivers:
|
|
C checks of surfaces' receiver buffers not compared; the textures over the
|
|
surfaces hold the texels` where the stream checks a buffer a texture over a surface's plane was made
|
|
on (section 7), while that buffer lives: a runtime may keep the texels apart from the buffer, as the
|
|
product does, so such a check (`receiver`) is
|
|
not compared, and the textures' own checks carry the bytes. `unsnapshotted N` where
|
|
`m2v.privateBytes` records name dispatches (`N` of them, each played as it is),
|
|
`parted N` where a recorded range met a live one in part (`N` the older ranges ended),
|
|
`relaid HEAPS moved OFFSETS grown BYTES` where it laid placement heaps out again (the heaps, the
|
|
offsets it moved in them and the bytes it added to their sizes), `untimed waits N: ...` (the
|
|
frames' `untimed_waits` and `untimed_wait` summed, beside their `wait`), `texture_writes ...` (the
|
|
CPU's writes into Managed textures, above), `managed reads on two copies: ...` (the reads of
|
|
Managed bytes no announcement took to the GPU copy, above), `total COUNTS` (its `calls` the
|
|
calls played: where
|
|
the play stopped, the stopping call is the next), the backend's
|
|
`pipeline I wall_nanos=N kernel=new|again` for each compute pipeline state it made, in order (the
|
|
making's wall time, and whether no state of another specialization of the kernel, a library's
|
|
function by name, was made before), its `commit lock wait longest N ns` (the runtime's
|
|
`commit_lock_wait_max_nanos`: the longest wait of a commit for the runtime's work lock in the play;
|
|
the executed counter `commit_lock_wait_nanos` gives the waits by frame, summed), its
|
|
`loss CALL RESULT` where the device was lost (`Device::loss`: the first loss's call and result,
|
|
then, where the runtime read the driver's fault report, `; fault "DESCRIPTION"` and an
|
|
`; access KIND ADDRESS precision P PLACES`, `; instruction KIND ADDRESS precision P` or
|
|
`; vendor "DESCRIPTION" code C data D` for each of its records, as the driver gave them; an
|
|
access's `PLACES` are where the play placed it among the stream's buffers and heaps, its range
|
|
being the address rounded down to `P`, `P` bytes long: ` in #OBJECT buffer +OFFSET live` or
|
|
`heap` for each live one its range meets, by address, then `... released at frame F call C` for
|
|
each of the last 65,536 released ones it meets, newest first, at most 8 of each with `N more`
|
|
after, or ` outside every buffer and heap of the stream`; an offset is `-` where the address lies
|
|
below the start, and a texture is placed only through the heap or block it lies in), its
|
|
`stages F commit_to_scheduled=C0,...,C22 scheduled_to_gpu_start=... gpu_run=...
|
|
gpu_end_to_handler=...` for each frame `F` a later call followed and `stages end ...` at the play's
|
|
end (the runtime's four histograms of its command buffers' stages, `Metrics::commit_to_scheduled`
|
|
and the three after it, bucket by bucket, as they stood then, since the device was made: a span's
|
|
histogram is the difference of two lines; the executed counters `commit_to_scheduled_nanos` and
|
|
the three like it sum each stage's spans, `scheduled_to_gpu_start_behind_nanos` the part from
|
|
scheduling to GPU start under other command buffers' GPU spans, the runtime's own included,
|
|
`gpu_end_to_handler_seen_nanos`, `_told_nanos`, `_stamp_read_nanos`, `_calibration_nanos`,
|
|
`_earlier_nanos` and `_own_nanos` the completion thread's six steps of the span from GPU end to
|
|
handlers (`Metrics::gpu_end_to_handler_steps_nanos`), `gpu_end_to_handler_tail` the command
|
|
buffers whose span is 1,024 us or more and `gpu_end_to_handler_tail_seen_nanos` and the five
|
|
like it their steps, `calibrations` and `calibration_nanos` the clock calibrations and their
|
|
calls' time, `held_starts` and `held_start_gap_nanos` count the
|
|
groups a queue held without room for them and the GPU's time behind them, and
|
|
`runtime_command_buffers` and `runtime_command_buffer_gpu_nanos` the runtime's own uploads and
|
|
copy-ins and their GPU time, outside every Metal command buffer's GPU interval), its
|
|
`pipeline makes N states: C new (MADE), SPLIT; H held, SPLIT; B beside a pre-pass call, whose work
|
|
their figures count` and, for each of the ten slowest makings, slowest first, `pipeline make
|
|
slowest K #ID KINDS new|held (MADE): SPLIT` (where each render and compute pipeline state's making
|
|
went, read from the runtime's counters on the player's thread before and after it: `MADE` is `L
|
|
lowered, D loaded, P VkPipelines`, the functions the translator lowered, `translations`, the
|
|
lowerings read from the cache directory, `translations_loaded`, and the `VkPipeline`s made,
|
|
`pipelines_created`; `SPLIT` is `wall W ms = translation T ms + driver D ms + other O ms`, the
|
|
making's wall time on the runtime's clock, `host_time`, and of it the translator's calls,
|
|
`translation_nanos`, the driver's `vkCreate*Pipelines` calls, `pipeline_creation_nanos`, and the
|
|
rest; a making that made any of the three is of a content new to the device, and one that made
|
|
none is of a content the device held; the counters sum every thread's calls, so the `B` makings
|
|
during which a pre-pass thread ran a call, each marked `, beside a pre-pass call`, count that
|
|
call's work too; `ID` the state's object and `KINDS` `kernel`, or `vertex` or `post-tessellation
|
|
vertex`, where the library states a `patchType`, then `+fragment` where the state has a fragment
|
|
function; states the runtime refused are not among them), its
|
|
`skipped render states GAP N, the first #ID: WHY` for each
|
|
typed gap a render pipeline state met (`GAP` the runtime's gap as Rust prints it for debugging, such
|
|
as `RenderPipeline { kind: DepthAttachment }`, or `Translation(KIND)` where the translator refused
|
|
it: `Unsupported(FEATURE)` with the refused feature as Rust prints it for debugging, such as
|
|
`Unsupported(Lowering(Tessellation))`, `LimitExceeded(LIMIT)` and `Internal(KIND)` the same, or
|
|
the error's variant alone, such as `InvalidDescriptor`, never a symbol or a location; `N`
|
|
the states skipped, `ID` the first one's object and `WHY` the runtime's answer), its
|
|
`skipped compute states GAP N, the first #ID: WHY` the same for compute pipeline states, its
|
|
`skipped render commands GAP N, the first at frame F, call C` for each typed gap a render command
|
|
met, a draw the runtime does not build among them (`GAP` the runtime's gap as Rust prints it for
|
|
debugging, such as `Draw { kind: Points }`, `N` the commands skipped, `F`
|
|
and `C` the first one's frame and stream position), its `skipped render encoders KIND N, the first
|
|
at frame F, call C` for each kind of render encoder it does not build (`KIND`
|
|
`ParallelRenderCommandEncoder`, `Unheld(KEYS)` for a pass whose descriptor sets properties `KEYS`
|
|
the runtime's does not hold, or the runtime's gap for the pass as Rust prints it for debugging),
|
|
`cut SEGMENT OFFSET` where the last segment ends
|
|
in a record cut short, `skipped KEY=VALUE ...: no gate result` where the backend skipped
|
|
anything, `gaps KEY=VALUE ...` where it met a typed gap (`gap_pipeline_ids`: the compute and
|
|
render pipeline states whose `gpuResourceID` the player asked, which the runtime does not
|
|
give; bookkeeping: no draw or dispatch is skipped for it, and only an argument buffer's
|
|
pipeline-state member would read such an ID, which the runtime refuses at the making of a state
|
|
whose function reads it), where the play
|
|
finished its range (it ended without an error, through frame `F`'s present where it plays to
|
|
`F`) and the backend skipped nothing, the matrix's judged metrics, one line each, `M2V-MATRIX
|
|
metric replay-rt/STEM/RANGE/NAME N` (`STEM` the first segment's stem, whitespace made `_`;
|
|
`RANGE` `through-F` or `whole`; `N` the play's executed total of `submissions`, `passes`,
|
|
`barriers` less `texture_clear_barriers`, `bytes_copied` and `pipelines_created`, and of
|
|
`new_textures_zeroed`, the new textures zeroed by a clear (`texture_clears`), and
|
|
`new_texture_zeroed_bytes`, their bytes), each one two plays of one stream at one commit
|
|
on one card gave alike, which the matrix's rule (`scripts/matrix/results.py`) holds equal to the
|
|
base's, failing a play whose base has a record it lacks; a play that did not finish its range
|
|
prints none; where the play ended frame 200 and the backend skipped nothing by then, the matrix's
|
|
gauge records, one line each, `M2V-MATRIX gauge replay-rt/STEM/KIND_excess@F N` for `F` 100 and
|
|
200 and each kind the program makes one object at a time, `buffers`, `textures`, `samplers` and
|
|
`events`: `N` the runtime's live objects of the kind on the frame's `end` line less the play's own
|
|
(`KIND_held`), what the runtime holds of its own, which the matrix's rule holds equal between the
|
|
two frames, as it holds the harness's gauges between its 100th and 200th runs (an `N` below zero,
|
|
the play holding more than the runtime, is written as it is, which the rule takes for no count);
|
|
the runtime's other kinds follow the program's objects and the work it does with them, not one
|
|
object each, and are not records here (the harness's loops hold those its workloads reach, and the
|
|
matrix holds every kind at zero at the device's drop), nor are the handles out, the releases
|
|
waiting, the Private units or any byte or age gauge,
|
|
then `ok`, `ids: played to the end; N objects' gpuResourceID differ from the recording's` where
|
|
the play ended but objects whose ID the program saw have other IDs in the runtime, or
|
|
`error WHAT`. Where the backend skipped anything, the `skipped` line and the last
|
|
one end `; not a verdict past frame F, call C`: `F` and `C` the frame and stream position of the
|
|
call at which it first skipped, past which nothing the play shows is a verdict. A dispatch is
|
|
skipped only where it names a skipped object. `COUNTS` is `stream KEY=VALUE ... executed
|
|
KEY=VALUE ...`. The player then ends its device and prints, for each of the
|
|
runtime's gauges read once the device dropped, `M2V-MATRIX gauge replay-rt/device/GAUGE@drop N`:
|
|
the matrix's own record, so the matrix's rule (`scripts/matrix/results.py`) fails a play whose
|
|
gauge is not 0 at device drop. Such a gauge, or a device that did not quiesce within 30 seconds,
|
|
also writes `error teardown: WHAT`. The exit status is 0 for `ok`, 1 for a run that stopped or an `ok` followed
|
|
by `error teardown`, 2 for a harness failure (a bad command line or an unreadable stream) and 3
|
|
for `ids`, a run that played to the end.
|
|
|
|
With `--dump-command-buffers LIST --dump-dir DIR`, the player also writes, once each command
|
|
buffer whose stream id `LIST` holds completed (a split command buffer's parts by their own ids),
|
|
every buffer its encoders named, read after the wait that saw the command buffer
|
|
complete and before the next call plays: `cbC-objO.bin` its bytes, `cbC-objO.cover` the ranges of
|
|
it covered then (as above, `start..end` byte offsets joined by commas, or `-`), and
|
|
`cbC-objO.unread` in place of the bytes where the backend could not read it, and for a buffer with
|
|
two copies `cbC-objO.copy`, which copy the bytes are: `CPU copy` or `device copy, read back`
|
|
(above). `LIST` is `FIRST..LAST` ranges (both ends held) and single ids, joined by commas, such as
|
|
`20..29,31`; anything else stops the play before it starts. It writes too each colour attachment
|
|
the command buffer's render passes stored: a texture its attachment names under
|
|
`MTLStoreActionStore` or `MTLStoreActionStoreAndMultisampleResolve`, and a resolve texture under
|
|
`MTLStoreActionMultisampleResolve` or that one, an `MTLStoreActionUnknown` decided by the
|
|
encoder's `setColorStoreAction:atIndex:`. `cbC-objT.bin` holds the texture's parts the passes
|
|
stored, each a level, a slice and a depth plane (`level`, `slice` and `depthPlane`, or the
|
|
resolve's; a pass of `renderTargetArrayLength` 2 or more stores that many slices from the slice),
|
|
one after another by level, then slice, then plane, each laid out as a check reads a texture's
|
|
first level and slice; and `cbC-objT.unread` replaces the bytes where the backend could not read
|
|
a part (a multisample texture stored without its resolve, for one). It writes too each texture the command buffer's compute encoders bound
|
|
(`setTexture:atIndex:` and `setTextures:withRange:`, a nil one left out): its first level and
|
|
slice as a part, read once the command buffer completed as an attachment's parts are, so what the
|
|
command buffer's last write left there; a texture both stored and bound holds each of its parts
|
|
once, in that order. A depth or stencil attachment is not written: a texture of a combined depth and
|
|
stencil format reads back one aspect at a time, through a copy with that aspect's blit option,
|
|
which this read does not make. A texture's `cbC-objT.cover` is `0..N`, the whole of its `N`
|
|
bytes, where the cover rule (above) held any byte of the texture covered then, and `-` otherwise:
|
|
the rule's ranges are the texture's bytes in its heap, which its parts are not laid out as.
|
|
`command-replay compare-dumps --a DIR --b DIR` compares two plays' dumps word by word (4 bytes), leaving out a word
|
|
wholly inside a range either play held covered, and prints `differs cb #C obj #O: N words outside every cover, the first word
|
|
W (a X, b Y); M covered; lengths A and B` for each buffer that differs outside every cover, `X` and `Y` that word in each
|
|
play's dump as `0x` and 8 hex digits (a short end's bytes with zeros above them, `none` past a dump's end), `only in a|b:
|
|
cbC-objO` for a dump one play lacks, `unread in a|b: cbC-objO: WHY`, `copies differ: cbC-objO: a
|
|
read its COPY, b its COPY` for a buffer the two plays read different copies of (`one copy` where a
|
|
dump holds no `.copy` file), which it does not compare, then `compared N buffers (C as both plays'
|
|
CPU copies, V as their device copies, read back): D differ, U words outside every cover, M
|
|
covered; O dumps in one play only, R unread, X of different copies: agree|DIFFER`.
|
|
Its exit status is 0 for `agree`, 1 for `DIFFER` and 2 for a bad command line or an unreadable
|
|
dump. This compare says whether two plays of a range of command buffers agree; a whole-object
|
|
checksum does not, as a buffer partly under a cover would differ under it and a difference outside
|
|
the cover would show only as the same mismatch.
|
|
|
|
**Two plays compared for a timing verdict.** `command-replay compare-plays --a REPORT --b REPORT
|
|
[--frame F]` reads two plays' reports (each a `report.txt` or the directory holding it), of one
|
|
stream on two devices or two commits, and prints `served a|b: yes`, or `no: ...` for a report
|
|
without the `managed reads` line; `frames a N b M; both B; counts equal in E, unequal in U` and
|
|
`unequal frame F: KEY a=X b=Y` for the first eight frames whose player-side counts differ (the
|
|
frame line's `stream` `calls`, `draws` and `dispatches`, and every `executed` count of a skip,
|
|
`skipped_…`, or a refusal, `…_refusals`; a count a report lacks is 0); `digests: D frames with
|
|
checks in both; equal in E, differ in X` and `digests differ at frame F` for the first eight
|
|
frames whose `check` lines differ, ending `; stale reads from frame S, the first suspect` where a
|
|
play kept two copies and its stale reads start at or before `F`. With `--frame F` it ends with
|
|
`verdict at frame F: b is P% faster|slower than a by GPU-busy time (a A ns, b B ns); wall a W ns,
|
|
b V ns` (or `level`), or `no verdict at frame F: WHY`. Without `--frame`, for each frame whose
|
|
digests differ and whose shown texture both plays kept (`shown` lines, and `presents` beside each
|
|
report), it ends with `pixels at frame F: N of M texels of format P WxH differ (S%); largest
|
|
difference per channel C D, ... (UNITS); box x X0..X1, y Y0..Y1`: the texels that differ and
|
|
their share, the largest difference of each channel in the format's units and in its channels'
|
|
order, and the box the differing texels lie in (the bytes compared as bytes for a format it
|
|
does not read). A timing verdict between two plays needs all three of:
|
|
|
|
1. both plays by a player that serves every read class the stream has, which a report shows by
|
|
its `managed reads` line: a player that prints none may not serve the made-with reads or, for
|
|
a stream with no identity record, the writes before first use;
|
|
2. the frame's player-side counts equal in both;
|
|
3. equal digests at the judged frame: its `check` lines alike in both. A frame with no check in
|
|
both plays gets no verdict until a play adds one: a stream's own `m2v.check`, or the shown
|
|
texture that `--check-presents` checks at the frame's present, in a play of each arm apart
|
|
from the timed ones. A picture difference at the judged frame is accepted only when its size
|
|
is printed and its first parting draw on that card is traced either to a function that
|
|
carries a static precision note, with no state difference, or to a counted player
|
|
substitute. Such a row reads "pictures differ within <note>: N pixels, largest difference
|
|
D", or for a substitute "pictures differ in a WxH region where the replay substitutes
|
|
<what>", and its time verdict stands. No trace means no verdict.
|
|
|
|
An NVIDIA time row is GPU ms a present over presents whose covering clock sample is the same
|
|
state on both arms, the state named, at least 30 presents an arm; otherwise 'not comparable by
|
|
time' with the counts.
|
|
|
|
A recording is a timing source only on a card of its own memory class. A guest on a device with
|
|
unified memory builds its work on Shared storage; played on a discrete card, its kernels read and
|
|
write that storage across the bus, which no guest on a discrete card asks for. One run of a GPU
|
|
compute benchmark, recorded on an Intel integrated card, took 257.2 s of compute in a whole play
|
|
on a Radeon RX 7900 XTX (m3-max-71531), and the same benchmark recorded on that XTX took 10.7 s
|
|
there (m3-max-71625), both plays exit 0 through their last frame.
|
|
|
|
Stale reads bar no verdict: Metal leaves those bytes undefined and every play takes them by one
|
|
rule. Where the digests differ, they are the first suspect. The exit status is 0 where the
|
|
frame `--frame` names has a verdict (or none is named), 1 where it has none and 2 for a bad
|
|
command line or an unreadable report.
|