diff --git a/d3d12/crates/leonida-gpu/src/draw.rs b/d3d12/crates/leonida-gpu/src/draw.rs index 812766e082..055622e6d0 100644 --- a/d3d12/crates/leonida-gpu/src/draw.rs +++ b/d3d12/crates/leonida-gpu/src/draw.rs @@ -3081,6 +3081,21 @@ impl State { self.views_untold = false; // (Clears the cache if the switch changed since the last call.) self.cache.sync(); + // The depth target a draw only tests, for the views of it that the + // draw's shaders read (`readable`). Primed before the textures picked + // by index are brought up to date: that pass reads a picked view of + // this target through `readable` too, and the state it leaves has to + // keep `SHADER_RESOURCE` (`State::prepare_for`). + // The bake list runs that same pass (`early_textures` → `heap_textures` + // on `bake_list`), so it can now record the combined-state barrier for + // this target too: the same state, tracked per list, and the draw's own + // list gets its transition in `prepare_for`. + let tested = if !compute && self.depth_state == DEPTH_READ { + self.depth + } else { + 0 + }; + TESTED_DEPTH.set((tested, false)); // Textures picked by index, before anything asks for them. self.early_textures(list, p, compute); if crate::host::walls_trace() { @@ -3137,14 +3152,6 @@ impl State { self.host_roots = [0; 2]; self.cache.heaps_changed(); } - // The depth target a draw only tests, for the views of it that the - // draw's shaders read (`readable`). - let tested = if !compute && self.depth_state == DEPTH_READ { - self.depth - } else { - 0 - }; - TESTED_DEPTH.set((tested, false)); let root = p.root.as_raw() as usize; if self.host_roots[usize::from(compute)] != root { // SAFETY: an open list and a live root signature.