From 89491a5949b651d2702f82ca124a5ada64bedf94 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sun, 13 Sep 2026 14:32:02 -0400 Subject: [PATCH] Build pipelines before the layers that need them Reviewing the previous fix, which was itself unreviewed. `update` gave each list the bind group layout of the pipeline that draws it by zipping the layer's lists against `self.primitives`, but built those pipelines afterwards -- so on any pass where one did not exist yet the zip yielded nothing, and those lists kept no bind group and drew nothing. Measured on startup: four layers had content while `self.primitives` was still empty. It only looked right because those layers were marked dirty again on a later frame and rebuilt then. `build_pipelines` now runs before the layers, and the pairing is indexed rather than zipped, so a primitive drawn before it was registered panics instead of silently leaving its list unbuilt. --- core/src/render/mod.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/render/mod.rs b/core/src/render/mod.rs index 37e61b5..9fe0777 100644 --- a/core/src/render/mod.rs +++ b/core/src/render/mod.rs @@ -118,6 +118,10 @@ impl UiRenderNode { ui: &mut UiData, ui_render: &mut UiRenderState, ) { + // Before the layers: a list is given the bind group layout of the + // pipeline that will draw it, so every registered primitive needs one + // by the time a layer is reached. + self.build_pipelines(device, &ui.primitives); self.active.clear(); for (i, draws) in ui_render.layers.iter_mut() { self.active.push(i); @@ -139,13 +143,16 @@ impl UiRenderNode { rlayer .primitives .resize_with(draws.primitives().len(), || ListBuffers::new(device)); - for ((list, draws), pipeline) in rlayer + for (id, (list, draws)) in rlayer .primitives .iter_mut() .zip(draws.primitives()) - .zip(&self.primitives) + .enumerate() { - list.update(device, queue, &pipeline.data_layout, draws); + // Indexed, not zipped: a missing pipeline should say so + // rather than quietly leave the list unbuilt. + let layout = &self.primitives[id].data_layout; + list.update(device, queue, layout, draws); } rlayer .textures @@ -160,7 +167,6 @@ impl UiRenderNode { draws.updated = false; } } - self.build_pipelines(device, &ui.primitives); if ui.masks.changed { ui.masks.changed = false; if self.masks.update(device, queue, &ui.masks[..]) {