A draw that binds a zero region of its own is not rebound

A function that reads a writable buffer binding with nothing bound to it reads a fresh
zero-filled region of the command buffer's upload arena at every draw (binding::write_info's
neutral zero buffer for a non-uniform binding). A draw rebound keeps the kept draw's set-0 writes
at every slot but the changed ones, so it bound the kept draw's region, which that draw may have
written, where every step binds a new one. In debug builds the check of a rebound draw panicked
with 'a draw rebound worked out other set-0 writes than its every step' (draw_again.rs:804). A
consumer's tests hit it: draws after the private setters with no vertex buffer bound, whose
vertex function reads its buffer 0 unbound, rebound across direct and indexed calls since
RV 2112.

binding::binds_own_zeros tells such a plan, and a draw of it keeps no rebinds
(Kept::rebinds false): it takes every step, as before RV 2112's reargued rebounds.

Verified: runtime_lane::provoking::draws_after_the_private_setters_rebind_what_every_step_binds,
with the vertex buffer left unbound, panics at draw_again.rs:804 on lavapipe before this change
(job m3-max-21076).
This commit is contained in:
Anees Iqbal committed 2026-11-12 06:54:15 -08:00
1 parent 3b4112a56b
commit 8b551b05f0
3 files changed
+29 -11

No files matched your search

@@ -2257,6 +2257,21 @@ fn read_only_buffer(ty: vk::DescriptorType) -> bool {
)
}
/// Whether `plan` binds a zero region of each command's own: at a writable buffer binding that
/// nothing is bound to ([`read_only_buffer`]), a fresh region of the command buffer's upload
/// arena at every draw (`write_info`). A draw rebound keeps the kept draw's set-0 writes at every
/// slot but those that changed (`rebind_into`), so it would bind the kept draw's region, which
/// that draw may have written: such a draw is not rebound (`render/draw_again/rebound.rs`).
pub(super) fn binds_own_zeros(plan: &BindingPlan) -> bool {
plan.descriptors.iter().any(|write| {
let neutral = matches!(
write.source,
WriteSource::Neutral(NeutralResource::ZeroBuffer { .. } | NeutralResource::Sink { .. })
);
neutral && !read_only_buffer(write.ty.into())
})
}
/// The range `command` plans for its buffer write at `key` (set and binding).
fn planned_range(command: &Command<'_>, key: (u32, u32)) -> Result<BufferRange, Error> {
(command.descriptor_ranges.iter())
+5 -4
View File
@@ -11109,9 +11109,9 @@ impl RenderLowering {
created: created.clone(),
});
// What a draw rebound takes of it (`render/draw_again/rebound.rs`), where its state made
// no visible-function table: set-0 writes that hold no keeper, its plan's uses alone,
// no push hole, and its one recording's parts (its variant and plan are the bind
// state's kept settle).
// no visible-function table: set-0 writes that hold no keeper and no zero region of its
// own (`binding::binds_own_zeros`), its plan's uses alone, no push hole, and its one
// recording's parts (its variant and plan are the bind state's kept settle).
let recorded = match (&draw_states, &draw_pipeline, vk_draws) {
(DrawStates::Whole([state]), DrawPipeline::Made(made), [(index, _, command)]) => {
Some(draw_again::KeptRecording {
@@ -11130,7 +11130,8 @@ impl RenderLowering {
let rebinds = function_tables.is_empty()
&& uses.len() == plan_uses
&& bound.holes.is_empty()
&& writes.iter().all(|write| write.held.is_none());
&& writes.iter().all(|write| write.held.is_none())
&& !binding::binds_own_zeros(&plan);
let recorded = recorded.filter(|_| rebinds);
let rebinds = recorded.is_some();
if let Some(recorded) = recorded {
@@ -9,8 +9,9 @@
//! set the encoder's render state, what it decides derived again as the kept draw's
//! (`Kept::stated`, `restated.rs`), each table's changes since the kept draw read
//! it still listed (`argument_table::Changes`, at most [`SLOTS`] slots), where the kept draw kept
//! what this takes ([`KeptStorage`]: a draw whose set-0 writes hold no keeper, of no use beyond
//! its plan's and its draw's own, and of a state that made no visible-function table); or the
//! what this takes ([`KeptStorage`]: a draw whose set-0 writes hold no keeper and no zero region
//! of its own, `binding::binds_own_zeros`, of no use beyond its plan's and its draw's own, and of
//! a state that made no visible-function table); or the
//! kept draw of other arguments alone, of something to draw (below), after such calls or none.
//! The kept
//! bind state takes the changed slots (`ArgumentTable::refresh_changed`), and the draw goes on
@@ -112,11 +113,12 @@
//! one (`render/carried.rs`), is rebound as one after draws of other states and calls that set
//! the render state, through no record: its tables' stamps are the encoder's first ones, so it
//! brings in every slot the encoder's calls bound since its opening, whatever table its bind
//! state was read from. It stops where that state holds a slot none of them bound (it holds
//! only the slots its pipeline state reads: `argument_table::ReadSlots`), or a
//! threadgroup memory length or acceleration structure (`WorkCounts::draws_carry_stopped_stale`:
//! a new encoder inherits no binding), where it samples a texture an attachment of its pass
//! renders (`draws_carry_stopped_attached`), or at any other stop (`draws_carry_stopped_other`).
//! state was read from. It stops where that state holds a slot none of them bound (of texture
//! and sampler slots it holds only those its pipeline state reads: `argument_table::ReadSlots`),
//! or a threadgroup memory length or acceleration structure
//! (`WorkCounts::draws_carry_stopped_stale`: a new encoder inherits no binding), where it samples
//! a texture an attachment of its pass renders (`draws_carry_stopped_attached`), or at any other
//! stop (`draws_carry_stopped_other`).
//! Its uses are made again whole; it begins its pass's first instance as every step's first draw
//! does (`RenderLowering::inline_begin`), and records every state command it sets into that
//! instance's command buffer, whose record holds none (`WorkCounts::draws_rebound_carried`).