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.
This commit is contained in:
1 parent
a08f61a80c
commit
89491a5949
1 file changed
+10
-4
+10
-4
@@ -118,6 +118,10 @@ impl UiRenderNode {
|
|||||||
ui: &mut UiData,
|
ui: &mut UiData,
|
||||||
ui_render: &mut UiRenderState,
|
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();
|
self.active.clear();
|
||||||
for (i, draws) in ui_render.layers.iter_mut() {
|
for (i, draws) in ui_render.layers.iter_mut() {
|
||||||
self.active.push(i);
|
self.active.push(i);
|
||||||
@@ -139,13 +143,16 @@ impl UiRenderNode {
|
|||||||
rlayer
|
rlayer
|
||||||
.primitives
|
.primitives
|
||||||
.resize_with(draws.primitives().len(), || ListBuffers::new(device));
|
.resize_with(draws.primitives().len(), || ListBuffers::new(device));
|
||||||
for ((list, draws), pipeline) in rlayer
|
for (id, (list, draws)) in rlayer
|
||||||
.primitives
|
.primitives
|
||||||
.iter_mut()
|
.iter_mut()
|
||||||
.zip(draws.primitives())
|
.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
|
rlayer
|
||||||
.textures
|
.textures
|
||||||
@@ -160,7 +167,6 @@ impl UiRenderNode {
|
|||||||
draws.updated = false;
|
draws.updated = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.build_pipelines(device, &ui.primitives);
|
|
||||||
if ui.masks.changed {
|
if ui.masks.changed {
|
||||||
ui.masks.changed = false;
|
ui.masks.changed = false;
|
||||||
if self.masks.update(device, queue, &ui.masks[..]) {
|
if self.masks.update(device, queue, &ui.masks[..]) {
|
||||||
|
|||||||
Reference in new issue
Block a user