RUNTIME 2339: Bind a slot read at its residual over a range its bind offsets share
What: bind::instantiate::shared_range gives a descriptor-form slot of a Bounded window that its functions read at the residual one range for a run of bind offsets of the bound buffer: the padded buffer from 0 where it fits the view's maximum range (and 4 GiB), else the block of half that maximum its window starts in, to the maximum past the block's start; its SlotBindOffset residual the rest. A window of at most half the maximum never straddles its block's range; a longer one, or one at or past the padded end, keeps descriptor_range's range. planned_range takes it for every Bounded storage view (no function reads one at its bind offset alone), and for a uniform view where the new BindState::uniform_views_at_residual says the consumer reads every uniform view at its residual: its keys all take their residual forms. The runtime states it where pipeline::reads_views_at_bind does not hold (every device today: no driver carries DriverFact::ConstantOffsetUniformReadsPreloaded), through AtBindViews, at each bind state that states the view base alignment (render, compute twice, tile dispatch). Shapes, plans and keys are unchanged; the flag is not part of the shape. Why: a constant reference at a buffer index (constant float4 &) is a uniform view of a 16-byte Bounded window, whose range started at the bind offset with residual 0. Every offset-only rebind (a consumer's staged setVertexBytes: setVertexBuffer at the next 256 bytes of an upload chunk) then wrote another descriptor: rebind_into, push_set and the driver's vkCmdPushDescriptorSet at every draw (reims-vgpu's Iris: +538 ns a draw against a device pointer, +93 inside the push and +99 under record). The range at the bind offset serves only keys reading the view at the bind offset alone, which no device takes today: the shader already adds the residual. Now such a draw keeps its set-0 writes (writes_kept) and pushes only its residual, as a device pointer's draw does. Metal and Vulkan: each read inside the window reads byte lo + (bind - lo) + m = bind + m, the bytes it read before, through the same instructions. A read outside the window, which Metal leaves undefined, reads the buffer's bytes inside the range. The range starts at 0 or a block multiple, a multiple of the base alignment (VUID-VkWriteDescriptorSet-descriptorType-00327/00328), stays within the view's maximum (00332/00333) and the padded allocation (VUID-VkDescriptorBufferInfo-range-00342); a dynamic descriptor's offset is its start as before (VUID-vkCmdBindDescriptorSets-pDynamicOffsets-01971). Verified: by the jobs that follow (unit tests of shared_range and planned_range, the lavapipe runtime test constants_moved_along_one_buffer_keep_their_set_zero, the release medians of runtime_lane::constant_offsets before and after). With (bench and tests): 78463d1e1d The moved-constant set-0 test counts every second draw again as taking every step in builds with debug assertions; 5e7d715629 The moved-constant set-0 test lists which of the second pass's draws were rebound; 99a3459dc6 The moved-constant set-0 test moves the vertex constant alone, as constant_offsets does; a9c4b07790 The moved-constant set-0 test names what the second pass's draws did where some were not moved; 5e938c75c5 The moved-constant set-0 test draws the bench's shape; a bounded storage window's dispatch test binds the shared range; 69e598a6b5 Drop the stale copy of the range-from-bind-offset test; round-trip the new BindState field; ea4602012c cof_device reads its float4 at the instance's element; cd6492fd41 constant_offsets also draws over chunks in host pages, under the consumer's policy; 4d6e17bb89 constant_offsets takes the AIR library trait into scope; 1221f53ce0 Time draws that rebind a constant reference by offset against a device pointer. Compiled in m3-max-31548 (msi: clippy, lavapipe uniform_bind_offsets/draw_again/general_form/inline_continues/ kept_shadowed_draws 48/48). The set-0 test fails at the base (16 writes pushed, want 0; 31536). Release counts (31392): set-0 pushes per constant draw 1.00 -> 0, push constants 0 -> 1.00. The new fixture's golden rows re-bless on development.
This commit is contained in:
1 parent
188606728a
commit
734e1cac02
21 files changed
+1074
-47
No files matched your search
+24
-5
@@ -1438,7 +1438,11 @@ for dependency in &pipeline.dependencies {
|
||||
take it). A buffer bound at any other offset, or at a slot left out, takes the other form, a
|
||||
pipeline of its own: leave out a slot bound at offsets that move, so that its draws keep one
|
||||
shape and one pipeline (the runtime leaves out each slot of a state once it finds one bound at
|
||||
an offset the alignment does not divide).
|
||||
an offset the alignment does not divide). A consumer that draws and dispatches every key at its
|
||||
residual form (each `RangeAtBindOffset` at 0, as the runtime does on every device whose driver
|
||||
is not measured to load such reads ahead of the shader) says so with
|
||||
`state.uniform_views_at_residual = true`: its uniform views then bind ranges their bind offsets
|
||||
share (below), as a bounded storage view's do.
|
||||
- A two-plane YCbCr texture whose planes a function may read in place states them in its facts
|
||||
(`TextureFacts::ycbcr_in_place`, a `YCbCrInPlace` of its planes; the runtime states one on a
|
||||
device whose memory is the host's, `DeviceProfile::reads_ycbcr_planes_in_place`: an integrated
|
||||
@@ -1584,8 +1588,21 @@ to 16 bytes, whatever its bind offset, which its `SlotBindOffset` push field hol
|
||||
dispatches that bind one buffer at other offsets write the same descriptors, and only push data
|
||||
differs. Where that range would pass the view's `maxStorageBufferRange` or 4 GiB, or the offset
|
||||
lies at or past the padded end, the range starts at the bind offset aligned down to the
|
||||
descriptor base alignment, as every other descriptor-form slot's does. An access that reaches
|
||||
back before the bind offset, inside the buffer, reads the buffer's bytes there, as Metal's does.
|
||||
descriptor base alignment. An access that reaches back before the bind offset, inside the buffer,
|
||||
reads the buffer's bytes there, as Metal's does.
|
||||
|
||||
A slot of a bounded window read at its residual -- a storage view's always, a uniform view's
|
||||
where the state says `uniform_views_at_residual` -- takes a range its bind offsets share in the
|
||||
same way: the buffer from 0 to its padded end where that fits the view's maximum range (a uniform
|
||||
view's is `maxUniformBufferRange` capped at 64 KiB) and 4 GiB, else the block of half that
|
||||
maximum (rounded down to a power of two) its window starts in, to the maximum past the block's
|
||||
start. A window of at most half the maximum starting in a block ends inside its block's range; a
|
||||
longer one, or one at or past the padded end, takes the range from its bind offset, as every
|
||||
other descriptor-form slot does. So draws that move such a slot's offset along one buffer (a
|
||||
consumer's staged `setVertexBytes`, a constant reference bound at the next offset of an upload
|
||||
chunk) write the same descriptor, keep set 0 and push only the slot's `SlotBindOffset`. Each read
|
||||
inside the window reads the bytes it read before; one outside it, which Metal leaves undefined,
|
||||
reads the buffer's bytes inside the range.
|
||||
|
||||
`instantiate_draw_into` writes the same commands over a `DrawCommands` you keep, in the storage
|
||||
its vectors already hold: keep one from draw to draw (`DrawCommands::default()` to start) and the
|
||||
@@ -5188,8 +5205,10 @@ each item named states the rule in full.
|
||||
makes its predicted key's general form: each specialization constant with an arm that serves
|
||||
every binding exactly at that arm. Every constant buffer slot read through a uniform view is read
|
||||
at the slot's residual (`RangeAtBindOffset` 0), which reads the same bytes at every bind offset:
|
||||
the binder writes the slot's descriptor range and residual from the bind offset alone, whichever
|
||||
form the pipeline takes, and the residual is 0 wherever the range starts at the bind offset. A
|
||||
the binder writes the slot's descriptor range and residual from the bind offset alone, and the
|
||||
residual is 0 wherever the range starts at the bind offset (a bind state that says
|
||||
`uniform_views_at_residual`, whose keys are all their residual forms, binds a range its bind
|
||||
offsets share instead, the residual the rest). A
|
||||
slot bound to nothing is read at its residual too (0), so a draw that leaves such slots unbound
|
||||
takes the creation's pipeline itself. On MoltenVK a texture slot a function converts to `half`
|
||||
has its `UnmeasuredTexels`, which no instruction reads, at 0 (a class whose `half` conversion is
|
||||
|
||||
Reference in new issue
Block a user