Whether rt must capture a Managed texture's bytes at replaceRegion (rather than when the GPU copy
is next used) turns on how often a program writes one while a command buffer that used it may
still be running. The report now says.
- The player keeps, from the stream alone (replay/texwrites.rs): the textures and each view's
texture; each encoder's command buffer; the textures each command buffer used (an encoder call
naming the texture or a view of it, or an encoder made with an MTL...Descriptor object, or one
made on such an object, that names one); each texture's latest committed user per queue; and the
completions the stream records, which are only the program's CPU waits (waitUntilCompleted of a
command buffer or a later one of its queue, waitUntilSignaledValue:timeoutMS: reaching a value
one of its queue's command buffers signals). The play itself waits at each commit, so this is the
recording's order, not the play's.
- At each call on a texture that carries bytes (replaceRegion:...), blobs resolved, it asks the
backend whether the texture is Managed (Backend::managed_texture, default None; the rt backend
answers from the texture's descriptor) and counts the write, and where a committed user has no
recorded completion, counts it by the presents since that user's commit (0, 1, 2, 3+) and names
the first eight.
- Report::texture_writes (TextureWrites) carries the counts and the report's texture_writes line
says them, with the writes into textures whose storage the backend does not tell.
REPLAY-STREAM.md section 10 documents the line.
Verified: a replay test (Kept backend) writes a Managed texture used through a view by a committed
command buffer, before and after a present, writes a texture that is not Managed, and writes again
after the CPU waited: 3 writes, 2 with the user not seen complete (one per present bucket), the
first two named; clippy and the plays in the check job.
Metal's useHeap: names a heap the encoder's work may reach. rt had no such call, so the player
skipped and counted each one. ComputeCommandEncoder::use_heap takes the heap's block number (a
HeapRange's block, or the block a placement heap's buffers sit in) and keeps that block in the
command buffer until it retires, exactly as use_resource keeps a buffer's block (keep and the new
keep_block share one list). Metal states no retention for useHeap:, so keeping is the safe
reading. The call declares no access: a kernel that reaches a heap's resources through addresses
outside its slots already orders against every write since the last barrier. A number no handle
names answers Error::NoSuchBlock, as new_buffer's does.
The player's compute encoders now call use_heap with the heap's block, and still skip and count
a useHeap: of a skipped object. REPLAY-STREAM.md's skip list and the rt README say so.
Test: heap::every_device_holds_a_used_heap_until_its_command_buffer_retires takes a Private
block, uses it twice in one encoder (the command buffer holds it once), releases it while the
encoder is open (the command buffer still holds it, and a new use of its number answers
NoSuchBlock), commits, and waits for the block's last holder to go once the command buffer
retires. api_signatures.tsv regenerated (one new method); REFUSALS.md unchanged.
A play that hangs (gb's fault at frame 1095, b2's at 312) wrote no report: report.txt got its frame
and end lines only at the play's end, so every hung play left 0 frames in its timing table, and the
cold and warm plays of the frames before each fault could not be read.
- Player::until_frame(F) stops after frame F's present (frames counted from 0 as Report::frames
counts them), completes the work committed so far and reports as at the stream's end;
command-replay's --until-frame F sets it and says `until-frame F`.
- Player::with_frame_lines(out) writes each frame's lines (Report::frame_lines: its frame and end
lines) to out as the frame ends, flushed; command-replay passes its open report.txt and writes
the rest at the end (Report::lines_but_frames). Report::lines keeps every line, the completed
groups' first.
- The rt backend's report gets an `unwritten N` line: the Shared buffers made without bytes that a
compute encoder bound or used and whose command buffer committed before any recorded write,
upload or GPU pass reached their bytes since their making, with the first few named and the
command buffer that read each. It is where a recording that missed the program's writes shows
(b2's uniform ring #58725 had no recorded byte in its life). What reaches a buffer: an m2v.write
into it, into its block over it or into another buffer of the block over it; a blit or render
encoder call naming it or such a buffer (skipped encoders included); the commit of a dispatch
binding it. It counts and stops nothing (new_runtime/unwritten.rs, hooks in the make paths,
write, release, the encoder calls and the commit).
REPLAY-STREAM.md section 10 documents --until-frame, the per-frame lines and the unwritten line.
Verified: replay tests for the frame stop and the per-frame lines (Kept backend) and for the
unwritten count (the tracker alone: block writes, a blit naming, a write before the commit, a
release, a later commit, an alias made later); clippy and the device plays in the check job.
Record mode (job m3-max-44847 at 09c51a35ef, an Apple M3 Max, macOS 27.0.1) took the case's two
Metal facts:
- Plain Metal ran the pass: every step answered Ok, and the command buffer is Completed with no
error, over 3 runs folded into one outcome.
- Metal's API validation stopped it at the pass: "Compute Function(vwp_words): the offset into the
buffer src that is bound at Buffer index 0 must be a multiple of 4 but was set to 2.", and the
same for dst at index 1.
docs/CONFORMANCE-COVERAGE.md regenerated (scripts/conformance-coverage/coverage.py): 167 case
modules, 1,282 recordings.
Verified: the recording's facts as listed (read from the file); coverage.py --check passes.
The planner ruled that the bind-offset mask becomes a typed refusal. The binder pushed a bound
buffer's address, its gpuAddress plus the offset, rounded down to the alignment the kernel takes
it to have (FieldValue::BufferAddress's mask, from RuntimeFact::AddressAlignment), where Metal's
API validation refuses the bind offset ("must be a multiple of 4 but was set to 2" for a uint *
argument, probe vector_access_placement.m in the conformance crate). Plain Metal runs such a
dispatch at addresses of its own: an M3 Max reaches each element at its address rounded down to
the smaller of its alignment and 4. That is not the rounding the binder did for 8- and 16-byte
arguments.
The dispatch now refuses it with Refusal::BufferOffsetAlignment { index, offset, alignment }
before it records or keeps anything. check_alignment runs after the threadgroup size check and
before a kernel without effects returns, so both direct and indirect dispatches take it.
fill_parameters pushes each address as it is. A set_bytes copy sits at a multiple of 16 in the
ring, which every mask divides, so it is never refused.
Docs:
- docs/API.md: the identity-domain paragraph and the section 10 entry (renamed: "A dispatch that
reaches a buffer bound off its argument's alignment is refused"); no case names its slug.
- RuntimeFact::AddressAlignment's doc and the mechanism comment.
- The rt README paragraph and FieldValue::BufferAddress's doc.
- docs/REFUSALS.md regenerated (44 rt refusals); api_signatures.tsv gains the variant's row.
Tests (device, under --cfg m2v_gpu or m2v_cpu_icd):
- every_device_refuses_a_bound_address_off_its_alignment (was ..._rounds_a_bound_address_down_...):
at alignments 2, 4, 8 and 16, each of 17 binds 1 to 15 bytes past a multiple of 16 that the
alignment does not divide is refused and leaves the buffer unchanged, and the same buffer bound
at 48 runs. Without the check every one of the 17 dispatches returns Ok.
- an_argument_bound_off_its_alignment_is_refused (was ..._runs_at_the_address_rounded_down):
the translated vector_word_phases kernels with one argument off its alignment are refused,
naming the index, offset and alignment, and the command buffer completes with every buffer
unchanged.
The pool handed a take of up to a block length a whole pooled block and kept one ready block per
class, which the block-maker thread made again as soon as a take used it. A 16-byte Shared buffer
took the ready block, and the 16 MiB allocation that followed held the consumer's next pipeline
creation for its whole length on NVIDIA's driver.
Now each block is a range of one of its class's allocations, with its own VkBuffer:
- A take is a kept block of its length, else the first free range that fits, else the start of an
allocation made in the call: 16 MiB, or the block's own length where that is longer. Lengths
round up to 64 KiB (or bufferImageGranularity); a block starts at its length rounded up to a
power of two, up to 2 MiB.
- Device::new makes one 16 MiB allocation per class. After that, the block-maker thread makes
another only while the class's free bytes are under 8 MiB. A take never waits on it for memory.
- A take that no free range fits, while the class keeps blocks of other lengths, allocates at once.
It also asks the block-maker thread to give those blocks' bytes back, after the consumer's hook.
Only when its own allocation fails does it wait for those bytes, then look for a free range once
more.
- An allocation holding no live block is idle. A class keeps its idle allocations while their
bytes plus those of its allocations in use stay at or under the most bytes it had in use over the
last 10 seconds, and within an eighth of its memory type's heap. Past that it frees the oldest,
except the reserve that keeps 8 MiB free. The rule runs at takes and give-backs on an injectable
clock; there is no timer.
- Removed: the dedicated path, fits-and-fills-half, the 256 and 128 MiB idle bounds and the 64 MiB
Private block.
- Metrics: blocks_reused replaces dedicated_blocks_reused. New metrics: block_bytes_made, and the
vkAllocateMemory time on the consumer's threads (count, total, longest) apart from the
block-maker thread's.
Tests:
- Unit: rounding, base alignment, and the window and surplus rule.
- On device:
- the first allocations, and the trigger at 8 MiB free;
- kept blocks taken again with their number, address and mapping;
- an allocation beside kept blocks of other lengths, with their bytes given back;
- the failed-allocation path, at an answered maxMemoryAllocationCount;
- idle allocations following the window down, the reserve kept;
- a seeded 300-step stress of mixed takes and releases across both classes, each step under a
one-minute timeout.
- Tests that took a block of 1 byte and used more of it now take what they use.
- The replay's rt counters read the new metrics.
Verified: cargo fmt; api_signatures blessed; REFUSALS.md regenerated. Clippy, the suites and the
device legs follow as potluck jobs.
How a Managed buffer behaves depends on the recording device's hasUnifiedMemory: one copy where
it is true (a CPU write needs no didModifyRange), a GPU copy made at the buffer's making and
changed only by didModifyRange where it is false. The stream did not say which, and the rt backend
always made the runtime's Managed buffer: gb, recorded on a discrete GPU, wrote its no-copy
Managed buffers (#368205, #368202, #368214) once before first use with no didModifyRange, so their
GPU copies never got the bytes; b2, recorded with unified memory, relies on such writes legitimately.
The player now takes the form from the stream's new m2v.deviceIdentity record (it plays as nothing
and tells the backend hasUnifiedMemory through Backend::recorded_unified_memory), or for a stream
without one from command-replay's --managed one-copy|two-copy. One copy: every Managed buffer plays
as a Shared one. Two copies: the runtime's Managed buffer, its GPU copy from the bytes it was made
with: a copied buffer's, or the new create-time bytes a no-copy one's making now carries
(newBufferWithBytesNoCopy's first argument, a no-copy descriptor's contents). A stream with no
identity record gives none, so a no-copy buffer's GPU copy takes the writes recorded before its
first use (the commit of a command buffer whose encoder names it). With neither the record nor the
setting a Managed buffer stops the play with an error saying so. The report's managed line names
the form and its source, counts the Managed buffers and the no-copy ones with contents from first
use, not from create, and notes a two-copy recording played on a unified-memory device.
REPLAY-STREAM.md documents the identity record, the create-time bytes and the player's rule.
Verified: a replay test plays an identity record as nothing and sees the backend told
hasUnifiedMemory; the rt paths need a device play (gb on the 3090 next).
Rebasing the render encoder over 3201e09737 put both sides' Refusal
variants after HeapTexturePlace; the resolution kept both but dropped the
closing "}," of BufferCopyOverlap and the ")," of its Display arm, which the
two sides shared outside the conflict. The file did not parse
(signatures.py --check fell back to the translator's Limit). REFUSALS.md is
regenerated from the repaired file; signatures.py --check passes.
Verified: signatures.py --check rc=0 and refusal_surface.py locally; the
lint job compiles it.
CommandBuffer::render_command_encoder(&RenderPassDescriptor) is
renderCommandEncoderWithDescriptor:. It begins one vkCmdBeginRendering (dynamic
rendering, in the floor: floor.rs requires vulkan13.dynamicRendering) into the
pass's attachments, and end_encoding ends it with vkCmdEndRendering. Load and
store actions map one to one (Load/Clear/DontCare, Store/DontCare). A clear
color is a float in a float, normalized or sRGB channel (the device converts
it), and an integer channel's is truncated toward zero and saturated, NaN 0,
as Metal's; rotated formats and A8Unorm held in R8_UNORM go through the
format's rotation; a clear stencil keeps its low 8 bits. The render area is the
smallest attachment's level, cut to renderTargetWidth/Height where set.
Each attachment is one level and slice of a 2D texture, 2D array, cube or cube
array of one sample: the texture keeps an identity-swizzled image view of that
level and layer, made at the first pass and freed with the texture through the
reaper (new gauge attachment_views). A pass orders itself as a blit copy does,
two barriers: the first after every earlier command, moving shader-read-only
homes to the attachment layout (general and attachment homes render in place)
and paying an owed barrier; the second after the rendering, moving them home
and making the writes visible to every later command.
Refused as Metal's validation stops them: Refusal::AttachmentUsage,
AttachmentPlace, AttachmentFormat; past maxColorAttachments,
Limit::ColorAttachments. Not built, Gap::RenderPass naming RenderPassKind: a
depth attachment, more than one sample, a resolve, a 1D or 3D attachment, the
Unknown and CustomSampleDepthStore store actions, a clear of a format only a
shader clears, a pass with no attachment. The replay streams' passes (pass
census over gb and b2, counts only): one or two color attachments plus a
stencil in 11,187 of them, every attachment a level of a 2D texture of one
sample, no depth, no resolve, loads Load/Clear/DontCare, stores Store/DontCare.
Tests: tests::pass's host tests pin the action mapping and the clear values;
on_device clears a mip level of a shader-read texture (moved and back), an
integer texture and a stencil, loads and keeps, cuts the area, clears one
slice of a 2D array, and counts one pass alone as one submission, three
barriers, one pass and no bytes copied; each view is made once and freed with
its texture; refusals leave the command buffer open. README render encoder
section and known gaps; REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
The planner's ruling makes the rule two lines. An image-only kernel that does not observe its
threadgroup partition is declared: 16x16x1 on a grid one deep, the grid's tile (grid_tile) on a
deeper one, at MultiRegion 0 with the extent test. Every other such kernel runs today's remap:
256-lane workgroups, each one tile the region carries. The fold no longer serves buffer-touching
kernels. Image-only kernels used it only where the grid's tile is past the device's
maxComputeWorkGroupSize, and that class is too small to keep a form for, so those dispatches take
the remap too.
The census (replay's job m3-max-44582, both recorded streams): image-only non-observer
dispatches whose tile is past a depth of 64 (NVIDIA's, the floor's limit) are 6 dispatches,
1,760 threads in each stream, one (spec, tile) pair of tile 1x1x256. That is 0.0004% of the
image-only non-observer threads in one stream and 0.0033% in the other. No tile is past a side of
1,024.
Deleted: SpecKey::FoldedTile and the select that took it in place of the region's tile
(lower::dispatch), its binder entry, codec tag, signature row and API guide sentence; rt's
Variant::fold, Constant::FoldedTile, Choice::fold and Last::fold. The cache versions stay at this
branch's single bump (SEMANTICS_VERSION 2171, ARTIFACT_FORMAT_VERSION 535, now for
KernelFacts::image_only and the edge test under MultiRegion 0 alone). An image-only kernel's
pipeline per tile stays: its workgroup is the tile, so a deeper grid's first dispatch at a tile
makes it, and waits once, as the square device test's two-deep dispatch checks.
Verified: cargo fmt; docs/REFUSALS.md regenerated (unchanged). The dispatch-choice tests pin a
tiling kernel's grids of every depth in the remap's tiles, and a 1,024-deep column in them past
a depth of 64. The translator's engine test runs the edge kernel at MultiRegion 0 in 16x16x1
workgroups and at the grid's tile.
Both recordings' guest-RAM copies (gb 106 before frame 1095, b2 14 before frame 312) land in
Private buffers, and the rt backend skipped them, so the bytes and addresses they carry never
reached the GPU. A buffer-to-buffer copy now plays as rt's copy_from_buffer_to_buffer. A copy from
the guest's RAM, the recording's plumbing, plays as its pieces' bytes in a Shared staging place of
the backend's own, then a buffer copy into the target in the same blit encoder, so the GPU's order
holds. A buffer copy takes whole 4-byte words at 4-byte offsets: a piece's edge bytes up to whole
words come from the target's mapping where it has one; a piece with such edges into a buffer
with none is skipped and counted. The staging place is given back at the command buffer's commit
and is free once it completes, so the staging stays bounded by the work in flight
(staged_guest_ram_bytes counts it). The player times these copies in a column of its own
(`upload`), the recording's share and not the runtime's.
The replay's rt backend skips buffer-to-buffer copies and the guest-RAM
copies that need one, so their destinations are never written on rt: the lead
suspect for gb's hang and b2's device loss on the 780M. This builds the copy.
One vkCmdCopyBuffer region between the bytes shaders reach (a Managed buffer's
device copy where the device keeps one), between a fill's two barriers: the
first after every earlier command (paying an owed barrier, hazard sets start
again), the second making the write visible to every later command; a copy
into a Shared buffer marks the segment so its end reaches the host. The
command buffer keeps both buffers until it retires; textures over either
device copy are settled as the other copies settle them. A size of 0 records
nothing.
Refused: another device's buffer (OtherDevice); a range past either buffer's
end (new Refusal::BufferCopyRange, Metal's validation); an offset or size not a
multiple of 4 (new Refusal::BufferCopyUnaligned, Metal's documented macOS
rule); a source and destination sharing bytes, one buffer's overlapping ranges
or two buffers overlapping in one block (new Refusal::BufferCopyOverlap:
vkCmdCopyBuffer forbids it, VUID-vkCmdCopyBuffer-pRegions-00117, and the
runtime does not emulate it).
Tests: a host test pins the checks (offsets in the device buffer, adjacent
buffers of one block, size 0 anywhere, each refusal); on_device copies between
two buffers of one block and within one buffer, the bytes checked and
everything around kept, one copy alone one submission, three barriers, one
pass and no bytes copied; a copy into a Managed buffer lands in the bytes
shaders reach, brought to the host by a synchronize. README blit section;
REFUSALS.md and api_signatures regenerated.
Verified: the lint job and the device legs are the check.
The rt backend skipped every texture over a buffer, every texture view and every IOSurface
texture, and with them each dispatch and blit that bound one: words in the program's memory
then named textures the play never made. Textures over a buffer now play as the runtime's
(Buffer::new_texture) and views as its views (Texture::new_texture_view). An IOSurface texture,
a tiled texture over a buffer, and a texture or view the runtime answers with a typed gap become
an ordinary texture of the same descriptor, counted as a substitution (the recording's artefact,
not the runtime's). optimizeContentsForGPUAccess plays as nothing; the blits still not built are
counted by kind: buffer copies, guest-RAM copies in and out, texture syncs and mipmaps.
The report's second line says how far relocation reached: words relocated, words left at 4
past 8, address arguments, writes into objects with no recorded range, and the objects whose ID
differs from the recording's, which now make the play an error.
The relocation tests assert the writes of no address are counted.
On Device::from_queries' profile (PushWindow::Floor) a vertex function's push window is [0, 256)
and a fragment function's [push_base, 256), where push_base (a new LoweringInputs field, keyed
only when set) is the vertex function's push end rounded up to 8
(CompiledFunction::fragment_push_base). compile_render_pipeline compiles the fragment from the
vertex it compiled; rt sets the base from the lowered vertex before lowering the fragment. Under
the identity domains a vertex or fragment function whose fields do not fit is refused,
Unsupported(IdentityDomains) with maxPushConstantsSize's limit, never spilled. Link refuses a
fragment whose fields start inside the vertex function's, InvalidDescriptor(PushBase). The fixed
windows of Device::new (vertex [0, 64), fragment [64, 128)) and a compute kernel's are unchanged;
a mesh pipeline's fragment keeps its start past the mesh window.
Why: the planner ruled the dense layout over the census of gb and b2 (job m3-max-44421, every
content's functions resolved at its creation): 267 and 259 translated pairs, at most 248 bytes,
none over 256; four fragment bases (8/16/24/40), and no fragment function meeting two, so the base
costs no extra lowering. A fixed 128/128 split loses 3 pairs in each stream; the old 64-byte
windows spilled 6 into a parameter block.
Tests: push.rs pins each kind's window on both profiles (a compute kernel's does not move with a
render base) and places a fragment from its base to the floor's end; engine_identity_render
compiles colored_vertex + sampled_fragment on from_queries with the fragment's fields at 16, and
refuses the fragment compiled apart at base 0 (PushBase) until it compiles under the vertex's base.
The floor already refuses a device under 256 bytes (tests::floor, maxPushConstantsSize 255 and 64).
Verified: cargo fmt; api_signatures blessed, REFUSALS.md regenerated. Lint and legs follow.
A spike frame's wall time needs a split by cause before two runtimes can be compared on it. The
player now times, on its own thread, each kind of work: reading and decoding the stream and its
blobs, writing bytes into the runtime's memory, reading back, waiting for command buffers, the
calls that make or release resources (with the longest one), the calls that make libraries,
functions and pipeline states (with the longest one), every other runtime call, and reading the
runtime's counters; what is left is the player's own work. Beside them, a frame's GPU busy time
is the union of the GPU intervals of the command buffers it waited for, which a new Backend
method gives: both runtimes' GPUStartTime and GPUEndTime. The end line carries them, and the old
runtime's counters add its vkCreate*Pipelines and shader-cache nanoseconds.
A test plays three command buffers, two of them overlapping on the GPU, and checks the frame's
GPU busy time counts the overlap once and the end line holds the times.
The old runtime's shader cache defaulted to the per-user ~/.cache/metal2vulkan, which every earlier
run on the node had filled, while the new runtime's harness device kept no store: create_state's
first state and the first-use rows timed old warm against rt cold (jobs 44170, 44171: old's first
on the 2080 2.9-3.2 ms on its warm cache, 8.9-9.7 ms on a fresh one).
- old::system_default and rt::system_default take the store (None: the runtime's default, for the
tests).
- The command takes --store DIRECTORY: each session keeps its pipelines in
<DIRECTORY>/<place>-<runtime>; without it, a directory made for the run under the OS temp
directory and removed when it ends. Each runtime's line and each create_state row say
"store fresh" or "store warm, N files".
- The matrix gives each runtime's main run a fresh empty store beside its fresh driver cache, and
its warm run the same store; a re-timed row's runs take the harness's own fresh store.
- VALIDATION.md and the harness docs say so.
Verified: the matrix's harness script, rendered and run against a stand-in harness, passes a fresh
--store to each runtime's main run (cygpath'd on Windows); the build, clippy and the authored tests
in the check job.
The planner's ruling on long_4cb's red: rt reports the command buffers committed while an earlier
one runs complete together, at the group's last end, which the owner accepted. The mean over a
run's places counted that lateness: on the 2080, long_4cb's #2-#4 came at 96.2-97.3 ms where the
old runtime's came at 71.7, 83.7 and 95.6 ms, while the last's own (96.6-97.2 against 95.6-95.8
ms) is not late (jobs 44196, 44197). The rule holds for every row of several command buffers, so
frame_5cb's too.
- run::matrix_time is the steady time of each run's last command buffer's commit-to-complete
time.
- The harness's completed handler is given its lateness, from the command buffer's GPUEndTime to
the handler's start on the runtime's host clock (rt::host_time, the old runtime's host_time);
Report::late_us holds it by place, and the table prints late_us_p50 and late_us_p99 beside the
c2c columns, with a line by place. It is no record: no ceiling until the first host-time matrix
shows it on every GPU.
- The rt README's queue known gaps carry the measured lateness; VALIDATION.md and the harness
docs say the last command buffer's time.
Verified: the matrix_time unit test asserts the last place's time where the mean differs; the
check job builds and runs it.
A timing table must never come from a snapshotting play unnoticed: the device line reads
device NAME runtime old|rt snapshots yes|no for both runtimes.
Verified: cargo fmt only; clippy, replay tests and the release build next.
Old's play of gb on the 3090 with snapshots read 0.54 of 1.9 GB of stream in about 5 minutes
(m3-max-44322, cancelled before its 15-minute limit): the player's own splits and readbacks around
12,000 dispatches dominate it, and rt declines them, so their frame times and memory would not
compare. Player::without_snapshots takes none on any backend.
Verified: cargo fmt only; clippy, replay tests and the release build next.
A block was plain data (BlockInfo) owned by the device's claims map until release_block(id) or
the device's teardown, so a block whose number the consumer lost was held until the device died:
memory unreachable but held, a leak by construction, which the "zero at device drop" gauges do
not see (the player's play ran out of memory at frame 1074). The planner ruled the handle as
proposed:
- take_block returns Block, rt's own handle with no Metal counterpart, which derefs to the
block's BlockInfo. Clones share one claim (Claim); the drop of the last handle runs what
release_block ran: the device forgets the block's number and the work's pending upload counts
it, and the block is zeroed and kept or freed once no buffer, command buffer or upload uses it.
- The device keeps claims by number as weak references, now in the core (Core::claims), so every
call that takes a block number still does (new_buffer, new_managed_buffer, heap ranges); a
number whose handles are all gone answers Error::NoSuchBlock.
- release_block(block: Block) consumes a handle: the drop made explicit; another device's block
is Refusal::OtherDevice.
- The device's teardown frees every block still claimed after halt, that is after the consumer's
BlockMappings::unmap returned for each handed block (contract 6A's order: the claims' slots are
emptied only then); a handle dropped after the teardown finds its slot empty and does nothing.
The harness keeps each pooled block's handle and gives a dedicated block's to its buffer; the
replay backend keeps a stream block's handle in its object and a dedicated place's in the place.
rt's tests hold their handles where they used to hold numbers.
Tests (device cfg, command.rs): a dedicated block whose last handle drops with no release_block
while a held command buffer uses it answers NoSuchBlock for its number at once, stays live
(Gauges::blocks one up) until the command buffer completes, and is then freed (back to where it
was); of two clones, dropping one gives nothing back and the number still names the block,
releasing the other frees it; a handle that outlives its device finds every gauge zero after the
teardown, and its drop does nothing. README, the BlockInfo, NoSuchBlock and OtherDevice docs,
docs/REFUSALS.md and api_signatures.tsv follow.
Device::new_render_pipeline_state(&RenderPipelineDescriptor) is
newRenderPipelineStateWithDescriptor:error: without reflection. A state's content is the
translator's render_variant_key of its descriptor; render contents and compute kernels share the
one bounded map of 1,024 contents (kernel_map::Content), so a state of a held content costs the
key and a lookup. Each content lowers its vertex and fragment functions through the cache
directory's translations, and makes its triangle-class VkPipeline at creation through its own
pipeline file (the per-pipeline cache use is now one helper, made_through_cache, shared with the
compute path, and the layout's words one function, layout_words). A point or line class's
VkPipeline comes with the draws. Everything Vulkan 1.3 leaves dynamic is dynamic state; the
pipeline renders dynamically into the attachments' formats.
Built: one vertex and at most one fragment function, colour and stencil attachments, one sample.
Refused by Gap::RenderPipeline with a RenderPipelineKind: depth, multisample, amplification,
tessellation, synthesized stages, framebuffer fetch, imageblock, shader stencil, alpha to one,
step rate, numbered samplers, constant data, other specializations, dynamic state beyond 1.3,
and a feature or extension device creation does not enable. Gauges::render_contents counts the
contents alive.
The harness gains create_render_state, create_state's render twin: colored_vertex and
colored_fragment of the public examples fixture into one BGRA8Unorm attachment, the first
creation (a content unseen) timed apart, then 1,000 of the seen content, on old and new.
Tests (tests/render.rs, every device of the cfg's kind): a second state of a content lowers and
makes nothing and shares the first's; another format, a blended attachment and a stencil
attachment with two colours are contents of their own; depth, four samples and a constexpr
sampler are refused by kind with no pipeline; a device on a cache directory a device before it
used reads both lowerings and writes nothing.
The planner asks whether NVIDIA's first-pipeline cost is paid once per process or once per
kernel: each state's making's wall time, in order, with whether another specialization of its
kernel (a library's function by name) was made before. Backend::lines carries the backend's own
report lines; command-replay prints them after the player's.
Verified: cargo fmt only; build, clippy and replay tests next.
- The rt backend dropped a released m2v block or heap without Device::release_block, so every
block gb made and released stayed allocated; the 3090 play stopped at frame 1074 on
vkAllocateMemory (m3-max-44161).
- The old backend skips a library from source (no device here compiles Metal source), what is
made of a skipped object, and the draws of a render encoder whose pipeline state is one, all
counted; it takes MTLRenderPassDescriptor.renderPassDescriptor and the copyFromBuffer:...
toTexture: form without options. Those were the scratch player's alone, so old could not play
gb from development.
- Each frame's end line: wall nanoseconds, VmRSS, and the backend's gauges as they stand (rt's
live blocks, buffers, textures, pipelines, kernels, command buffers, spilled bytes and the bytes
of the blocks the backend holds by class; old's live, empty and dedicated memory blocks). Old's
counters add device memory allocated and pooled blocks made and freed. The skipped and gaps
lines are printed for both backends, before ok or error as documented.
Verified: cargo fmt only so far; build, clippy and the replay tests run next on msi.
A workload whose size follows the device (long_4cb) was sized by whichever runtime ran it first in
its process. The matrix times each runtime in its own process, so each sized it from its own base
time, and they could run different work: the RX 550's long_4cb ran at different sizes on the two
runtimes at 594b86d1f2, and its ratio compared unlike runs.
- run_each takes the size where the caller gives one (ScaledTo::base_us is then None) and times no
base; a size for a workload of one size is an error.
- The command takes --size NAME=N (repeatable; a name it does not know is an error) and prints each
sized row's size as an `M2V-MATRIX size harness-<runtime>/<row> <size>` record.
- The matrix reads the first runtime's "sized to" lines and passes them as --size to every later
run: the main run, the warm run and the re-timed pairs.
- results.harness_budget fails a row whose two runtimes' size records differ (or only one has
one), uncompared; `size` is a record kind.
Verified: python3 scripts/matrix/test_results.py, 29 OK; with the size check removed, the new test
fails (negative control). The matrix's harness script, rendered and run against a stand-in harness,
passes `--size long_4cb=4096` from the first runtime's line to the second's run. Harness unit test
a_scaled_workload_given_its_size_runs_at_it_and_times_no_base: build and run in the check job.
The `time` record kind is what a program waits on, timed on the host (commit-to-complete where the
workload times it, else the wall time a run adds), since the harness's matrix_time change on this
branch; the harness budget lists no ceiling now, and one is given only by a ruling after the work
on its row. The doc said GPU time and measured-ratio ceilings.
Verified: the text only; python3 scripts/matrix/test_results.py, 28 OK on this branch.
A pooled block's length is now per memory class, MemoryClass::block_len: 16 MiB Shared and
64 MiB Private on every device. It replaces the one 256 MiB BLOCK_LEN. take_block gives a
pooled block up to the class's length and a dedicated one past it. Textures are placed in
texture blocks up to the Private length. The harness and the replay player's places take
blocks of the class's length.
Why: a driver may hold the device's other calls for the whole of a block's
vkAllocateMemory, and the hold grows with the bytes, so the length sets how long one hold
lasts. On an RTX 3090 (NVIDIA's Linux driver, probe at 70d7cae48e, jobs 44050 and 44053
with the RTX 2080), a pipeline creation beside a Shared block's making took 40-45 ms at
256 MiB and 6-8 ms at 16 MiB (3-4 ms settled). 16 MiB is the largest piece a guest's
allocator takes. Private holds less: 3.4-4.6 ms beside a 64 MiB block, at most 1 ms more
than beside a 32 MiB one. At 64 MiB, a texture or a Managed buffer's device copy of 32 MiB
takes a pooled block.
Tests: every_device_pools_16_mib_shared_and_64_mib_private_blocks covers the lengths, the
dedicated block past each, and a 32 MiB texture placed in a texture block. The memory,
command, places, spill and upload tests use the class's length. The memory test reads a
Private block back a Shared block's length at a time. API table re-blessed (the BLOCK_LEN
const goes, MemoryClass::block_len comes).
Where the device's linear image does not hold a texture over a Managed buffer's device copy in
place (another pitch, an offset off the image's memory alignment, a format or usage the linear
tiling lacks), the texture was refused (Gap::TextureOverBuffer). It is now an optimal image of
its own, copied from and to the device copy only at Metal's own Managed events, with no tracking
of commands:
- in, from the device copy, by the upload that leads the next submission using the texture,
where a did_modify_range met its range (after the upload's copy of that range) or submitted
device work wrote the buffer (a binding whose compiled interface writes it: the translator's
uses, not the declared access; a blit or fill into it) or another texture over a range that
meets its;
- back, where device work wrote the texture, before the next reader of the device copy (a
binding that reaches the buffer, a blit from or into it, a copy into another texture over a
range that meets its, a synchronize_resource, a did_modify_range over it). A reader recorded
after the write takes it in its own commands; the upload that leads a submission, which runs
before the submission's commands, takes it only once the write's segment was submitted
(Segment::managed_wrote; the segment's submission settles each write it made).
The buffer keeps each such texture's entry (ManagedOvers). A texture released while its copy
back is owed leaves its image with the buffer until a reader takes it or the buffer is released;
a lookup by id skips a released entry, whose id a texture made since may hold. The Shared rules
(crate::over's per-submission copies) now apply only to textures over a buffer of no device copy
(copied_shared). The planner ruled that Managed keeps its device side; this is that side's copy
form.
Tests (device cfg): the Managed device test (100 uses copy in once; a modify over the range
copies once, one outside it not at all; a kernel's write owes one copy, a read none; a written
texture read through its buffer by a blit; a synchronize; two textures over one range; a
released texture whose buffer goes copies nothing back and frees its image; one released before
a kernel reads its buffer goes back first), and a kernel that declares a Managed buffer
read-write and never touches it owes no copy. README, Gap::TextureOverBuffer's doc and
docs/REFUSALS.md follow.
Verified: lint m3-max-44117 and device legs m3-max-44136 (780M HawkPoint, 3090), 44137 (RX 550),
44138 (XTX, 2080, 780M Phoenix, lavapipe), 85/85 each with the validation layer on, on the same
tree based on ed6d11d477. The Managed tests ran on the six GPUs and took the Shared rule on
lavapipe. An earlier form, which marked a write's copy back owed at its encoding, failed the last
step on five GPUs (m3-max-44101, 44102, 44103): the upload leading the write's own submission
took it before the write ran.
The translator states on a pipeline's interface whether some stage writes memory another
invocation or a later command can read (PipelineInterface::writes_memory, the union of the
stages' StageInterface::writes_memory: a store to a buffer or through a device address, a
texture write or an atomic update, in the entry or any function it calls; the
ExecutionStatus words are the product's and do not count). The cache's artifact format and
semantics versions move with the new field.
rt reads it into the compute state's interface. A dispatch of a kernel without it, direct
or indirect, is checked as Metal checks it and then records nothing: no bind, no push, no
vkCmdDispatch, and the indirect buffer is not kept or read. Metrics gains
dispatches_without_effects, which counts them. Such a kernel has no effect a program can
observe, so the only difference is less GPU and encode time than Metal's.
Tests: the translator's a_compute_pipeline_states_whether_its_kernel_writes_memory (a kernel
that returns at once, one that only reads, one that writes only its own thread's array: no;
a store behind a branch, a noinline callee's store: yes, on the function and the linked
pipeline, each validated), and rt's
every_device_records_nothing_for_a_dispatch_of_a_kernel_without_effects (a direct, an
indirect and an unbound dispatch of a kernel the interface says writes nothing leave the
buffer unchanged and count three).
Where the in-place linear image does not hold a texture over a Shared buffer (or a Managed one
without a device copy) for its pitch, place, memory type or format features, the texture is now
an optimal image of its own instead of a Gap::TextureOverBuffer. The device copies the buffer's
bytes into it and back, one vkCmdCopyBufferToImage or vkCmdCopyImageToBuffer region a texture,
with no CPU copy (crate::over):
- in, once a submission: the upload that leads it copies into every such texture a segment uses
before any command of the segment wrote the buffer; inside a segment, a use after a write of
the buffer copies in again first; a segment leaning on the leading copy for a buffer an earlier
segment of the held group wrote leads a new group;
- back, after a write of the texture: before the next command of the segment that reaches the
buffer, and at the segment's end, whose end barrier then reaches the host.
Commands track what they write only while such a texture lives (a device count); a command
recorded while none lived counts as a write through an unbound address, so a texture made later
never leans on a copy that could precede it. Each copy counts in Metrics::over_copies and its
bytes in bytes_copied. The accepted difference (a CPU write between two held members' commits
races an uncompleted command buffer, which Metal leaves undefined) is stated at the rule and in
the README.
A texture over a Managed buffer's device copy that the linear image does not take stays a
Gap::TextureOverBuffer: the Managed branch waits on the measurement of whether a Managed buffer
keeps a device side at all.
Tests: tests::copy_over (every device under the device cfgs): a render target over a Shared
buffer at one alignment past the device's pitch copies in once per command buffer and takes the
host's writes; a fill then a use in one command buffer copies once, after the fill; a fill and a
use in two command buffers committed back to back takes the filled bytes; a blit's write to the
texture is in the buffer once the command buffer completes.
A view of such a texture shares its parent's image and id, so it is tracked and copied as its
parent; the live count counts the parent alone. An ended segment keeps its tracking, cut to the
textures that lean on the leading copy, for the submit thread to read in place.
They are generated from the whole case set, and the set grew on `development`
while this branch was in flight, so the copy committed here counted a smaller
one.
Verified: regenerating at this tip leaves no change beyond the `Generated at`
stamp.
A command buffer's encoders run in order and a queue's command buffers in commit
order, each encoder's writes reaching the commands after it through the barrier
at its end or its segment's end, so a wait after an update already sees them. A
fence keeps the first queue whose encoder uses it; a use on another queue is
Gap::FenceOtherQueue, as Metal's fence orders one queue and MTLEvent orders
queues. Another device's fence is Refusal::OtherDevice.
Test: every_device_orders_a_wait_after_an_update_and_records_nothing_for_either
fills a buffer in one command buffer and updates the fence from a blit and a
compute encoder, waits in a second committed before the first completes and
copies the buffer out, and counts the same submissions, barriers, bytes copied
and passes with the fence calls as without; a second queue's compute and blit
encoders get the gap. REFUSALS.md and api_signatures.tsv regenerated.
The in-place linear image binds in the bytes shaders reach: a Managed buffer's device copy
where it has one, so replace_region writes the consumer's bytes and copies the rows' span
into the copy as did_modify_range does, and get_bytes reads the consumer's bytes as Metal
reads a Managed texture's CPU copy. A blit or dispatch that writes a texture over a Shared
buffer marks its segment's end to reach the host, as a write to the buffer does.
The device test (tests/over.rs) checks the alignment answer, the in-place texture over a
Shared and a Managed buffer (nothing allocated or staged, the image the buffer's bytes as the
host changes them, replace_region and get_bytes, a blit's write reaching the host), the
layout refusals and the gap.
Texture::new_texture_view(pixel_format, texture_type, levels, slices, index) is
newTextureViewWithPixelFormat:textureType:levels:slices: (and, with the
texture's own type and every level and slice, newTextureViewWithPixelFormat:).
A view is a TextureInner over its parent's image: its own sampled and storage
image views of the subresource range, its own index and elements of set 1, no
image, memory or copy. It keeps its first parent (a view of a view composes
the ranges), shares the parent's resource id so hazards between them are one
texture's, and reports Metal's view descriptor: the extent of its first level,
its levels and slices (probe texture_view_rules.m, job m3-max-43677: width 4
for levels 1..3 of an 8-wide texture, arrayLength 2 for slices 1..3).
place() takes the texture's base level and layer, so blit copies,
replace_region and get_bytes through a view reach the parent's levels and
slices under it. The view's image views go to the reaper (Free::Views) when it
drops; Gauges::textures counts views until then.
Built, from replay's compute-bound views (gb 18, b2 19): the parent's own
pixel format over every slice in its type, a slice subrange of a 1D or 2D
array, one slice of a 2D array as a 2D texture, each over any level
subrange. Refused as Metal's validation stops them (job m3-max-43677):
Refusal::TextureViewRange (empty or past ranges) and
Refusal::TextureViewFormat (another format without PixelFormatView usage).
Not built: Gap::TextureView naming the kind (TextureViewKind: PixelFormat,
TextureType, Slices, Swizzle).
Test (device cfgs): tests::view::every_device_views_levels_and_slices_of_a_texture:
six views and a view of a view report Metal's descriptor and read Metal's
bytes (the probe's FNV-1a 64 of each view's level 0 copied out), each view
costs 0 submissions, 0 blocks and 0 bytes copied; the three range refusals,
the format refusal and four gap kinds; views outlive their parents' handles
and every gauge falls to zero. The blit tests' Side carries the base.
README, REFUSALS.md and the signatures table updated.
A stream's heap offsets and heap sizes are the recording device's answers. On another device a
texture can be larger: b2 on an NVIDIA GPU stopped at a heap texture whose image the old runtime
makes 7.47 MB in a 5.9 MB heap. A live program lays its heap out by the device's
heapTextureSizeAndAlignWithDescriptor: and heapBufferSizeAndAlignWithLength:options:, so the player
now does the same: before it plays, it reads every placement in each placement heap ahead, asks the
backend the size and alignment of each (a texture's of its descriptor as its making call and setters
left it), and moves each offset up until the resources below it end and it is aligned, growing the
heap to hold them. Resources at one offset still share it; where every answer fits the stream's
layout, nothing moves. The report says what moved (`relaid HEAPS moved OFFSETS grown BYTES`).
The backend gains heap_size_and_align; the old runtime's answers through its own queries, with the
texture descriptor's making and setters shared with its play of those calls.
Verified: not yet built; a unit test on the keeping backend covers a texture larger than its room
(the buffer above it moves, the heap grows), a texture made again at its offset, a heap where every
answer fits, and the descriptor calls the backend is asked with.
BlitCommandEncoder::synchronize_resource is synchronizeResource:. Of a Managed
buffer with a device copy (Shared memory not device-local) it records one
vkCmdCopyBuffer of the copy into the consumer's bytes between the two barriers a
fill records, and marks the segment so its end barrier reaches the host: the
host reads the GPU's writes before the call once the command buffer completes or
it sees an event signaled after it. A buffer without a device copy is read by
the host where shaders write it, and a texture has no bytes the host reads
apart from its image (no texture has named bytes on development yet): for
those the call records nothing. Every call is counted in the new
Metrics::synchronizations and is no submission of its own.
Metal's validation stops a synchronize of a Shared or Private buffer or
texture (probe blit_synchronize_rules.m, job m3-max-43632: "synchronizeResource:
only applies when ... == MTLResourceStorageModeManaged"); rt keeps no storage
mode for those and records nothing, as the old runtime does. The probe's
Managed buffer, filled 4..12 with 0xab and synchronized, hashes
5d28bc84b408472d, the bytes the test asserts.
The barrier after a blit's write into a buffer is one helper now (fill, buffer
copy, synchronize); a buffer copy's source stage widens from COPY to
ALL_TRANSFER.
Tests (device cfgs): every_device_synchronizes_a_managed_buffer (a fill alone
leaves the host's bytes where the buffer has a device copy; fill + synchronize
gives Metal's bytes at 1 submission, 5 barriers with a device copy and 3
without, 0 bytes copied, 1 synchronization, 1 host reach; a texture's
synchronize records no barrier) and
every_device_reaches_the_host_only_after_a_blit_writes_shared_memory (the
wrote_host invariant for blit encoders: fills and copies into Private memory
or a texture reach no host, into a Shared buffer they do). README,
REFUSALS.md and the signatures table updated; the README drops the line that
said synchronizeResource comes with blit encoders, and names
synchronizeTexture:slice:level: as not built (no recorded stream calls it).
vkGetDescriptorSetLayoutSupport is Vulkan's answer to whether a set layout can be made; the
limits the floor checks do not promise it. MoltenVK 1.4.2 on an M3 Max reports set 1's layout
(65,536 sampled images, 4,096 storage images, three arrays of 4,000 samplers, update after bind)
unsupported, and the validation layer then names VUID-vkCreateDescriptorSetLayout-support-09582
at device creation (probe job m3-max-43634).
Arrays::make asks it for the empty set 0 and for set 1 before making either; an unsupported one
refuses the device with Error::BelowFloor and the new Missing::SetLayout { set }. Vulkan answers
it only for a created device, so PhysicalDevice::check cannot. Set 1's layout is built in one
place, with_arrays_layout, for the query and the creation.
Tests: every_device_supports_the_runtimes_set_layouts (each device of the cfg's kind supports
both), a_set_layout_the_device_does_not_support_is_named. README floor section, REFUSALS.md and
api_signatures.tsv regenerated.
Development's Managed buffers (ee7c4a5173) replaced held_block with held and device_range: a
Managed buffer's GPU side is its device copy where the Shared type is not device-local. A blit copy
or fill now records against device_range's VkBuffer and offset (alignment checked from that
offset) and keeps the buffer through Building::keep, which keeps a device copy too; is_shared
answers false for a buffer with a device copy, so only a copy or fill into the bytes the host
reads marks the segment. The lint of a172c73d93 (m3-max-43607) was cancelled before it compiled:
held_block no longer exists. Docs say 'the bytes shaders reach' where they said the block.
fill_buffer (fillBuffer:range:value:) records vkCmdFillBuffer of the byte four times over in each
word against the buffer's own range of its block, between the two barriers a copy records (the
second from every transfer stage's writes to every later command), and a fill of a Shared buffer
marks the segment so its end barrier reaches the host.
Probe blit_fill_rules.m on an Apple M3 Max, macOS 27.0.1: Metal's validation stops an empty range
and one past the buffer's end (job m3-max-43573), Refusal::FillRange; it takes ranges of no whole
words (job m3-max-43571), which vkCmdFillBuffer cannot write: Gap::FillAlignment until a replay
stream makes one.
Tests: the range checks (offset from the buffer's place in its block, empty, past the end,
reversed, unaligned start, length or block offset); a device test filling 4..12 of a 64-byte
Shared buffer with 0xab, its bytes plain Metal's FNV-1a 64 (job m3-max-43571), at one submission,
three barriers, no byte of the runtime's own.
copy_from_buffer (copyFromBuffer:sourceOffset:sourceBytesPerRow:sourceBytesPerImage:sourceSize:
toTexture:destinationSlice:destinationLevel:destinationOrigin:) and copy_from_texture_to_buffer
(copyFromTexture:sourceSlice:sourceLevel:sourceOrigin:sourceSize:toBuffer:destinationOffset:
destinationBytesPerRow:destinationBytesPerImage:) record vkCmdCopyBufferToImage or
vkCmdCopyImageToBuffer against the buffer's own range of its block, nothing staged, between the
two barriers a texture copy records. One region per image of the region, each at its own offset
(offset + image x bytesPerImage), so an image stride of no whole number of rows copies too;
bufferRowLength is bytesPerRow in texels, 0 for one row. The second barrier also makes a buffer
write visible to every later command, and a write into a Shared buffer marks the segment, whose
end barrier reaches the host. BufferLayout carries the offset and the two strides.
Refusals follow probe blit_buffer_copy_rules.m on an Apple M3 Max, macOS 27.0.1 (jobs
m3-max-43541, m3-max-43545): Metal's validation stops an offset or a row stride of no whole
texels, rows or images closer than the region's and a region past the buffer's end
(Refusal::BufferCopyLayout); it takes an R8Unorm offset of 2, a row stride of 0 for one row, image
strides of no whole rows, and bytesPerImage on 2D and 1D-array copies. Where Metal takes bytes a
copy command cannot address (a depth or stencil offset not a multiple of 4, as a 16-bit depth at
2; a compressed offset or row stride of no whole blocks, as BC1 rows 20 apart, which Metal takes)
it is Gap::BufferCopyAlignment. TextureBytes and FloatDepthUpload now name the blit copies too.
Tests: pure checks of the regions (padded rows, one row, a 3D region's images at their own
offsets, a 1D array slice, BC1 blocks) and of each refusal and gap; a device test copying into a
mipmap level, out of an array slice and a 3D region at padded strides, into a 1D array slice and
BC1 blocks, each result held to plain Metal's FNV-1a 64 (probe blit_copy_layouts.m, job
m3-max-43555, plain and under the validation layer), and one copy into a Shared buffer alone at
one submission, three barriers, no byte of the runtime's own.
A heap is a range of a Private block the consumer took at the heap's creation
(HeapRange: block, offset, length), as the plan decided: one Private range per
heap, resources at the offsets the guest's first-fit allocator picks.
Device::heap_texture_size_and_align answers heapTextureSizeAndAlignWithDescriptor:
with this device's image requirements (vkGetDeviceImageMemoryRequirements of the
same create info new_texture uses), never Metal's: the size rounded up to and
the alignment raised to bufferImageGranularity, so a buffer placed by the same
answers never shares a granularity page with the image. Replay showed why: one
vendor's image for a recorded heap texture is larger than the recording
device's (7.47 MB in a 5.9 MB heap), so the guest places by this answer.
Device::new_heap_texture binds the image at the heap offset: no allocation and
no texture block, bytes not zeroed (as Metal's heap textures), aliasing allowed.
A placement past the heap's end, an offset in the block off the image's
alignment, or a heap range past its block is Refusal::HeapTexturePlace at
creation; the image is never bound outside its heap. A Shared block, or an image
that requires an allocation of its own or does not take the Private type, is
Gap::HeapTexture (every optimal image measured takes the Private type). The
image holds the block, so a released block returns to the pool only once its
heap textures' images are gone.
new_texture's checks move into Device::prepare, shared with the size query, and
the image's create info into image_info. README: heap textures leave the
not-built line; REFUSALS.md and the signatures table updated.
Test: tests::heap::every_device_places_heap_textures_at_the_consumer_s_offsets
(answer equals the image's own size rounded to granularity; first-fit
placements allocate nothing and keep their own bytes; an alias; refusals for
past the end, off the alignment, a heap past its block, and a Shared block).
A Managed texture is a Private image plus a range the consumer names, on every
device. Device::new_managed_texture takes a Shared buffer and, per level and
slice, a BytesPlace (offset, bytes per row, bytes per image) laid out as the
consumer chooses; rt never picks the layout. Places that a buffer-to-image copy
cannot read in place (rows not whole texel blocks apart, images not whole rows
apart, a first byte off the block's bytes or off 4 for depth/stencil, a level
leaving the buffer, a wrong count, a buffer the host does not reach) are
refused with Refusal::ManagedTextureBytes.
Texture::upload_region(region, level, slice) records one vkCmdCopyBufferToImage
from the named place into the image in the upload, ahead of every command
buffer committed after the call on every queue, as did_modify_range copies a
Managed buffer: no CPU copy, no staging. On such a texture replace_region
writes the named bytes (Metal's CPU copy) and uploads them; get_bytes reads the
named bytes with no submission. The texture copy's record() now takes a buffer
and region, so staging and named copies share it.
README, the API.md accepted difference (the copy reads the bytes when the GPU
reaches it), REFUSALS.md and the signatures table updated.
Test: tests::managed::every_device_copies_a_managed_texture_s_named_regions
(whole-level uploads, a sub-region upload with an unmarked change outside it,
get_bytes reading the named bytes, replace_region writing them, six refusals).