Draw textures separately, and keep them out of Primitives
Interleaving textures with primitives was solving a problem that does not exist: within a layer, order is already undefined because freeing an instance swap-removes it, and layering is what layers are for. So the run batching is gone. A layer is now `LayerDraws`: a `Primitives` and a texture `InstanceList` side by side, with `updated` covering both. `Primitives` holds only primitives again -- its instance list plus the group-1 data those instances read -- and `InstanceList` is the shared push/free/apply_free the two lists have in common rather than a second copy of it. `PrimitiveHandle` names which list with `InstanceKind`, and `PrimitiveChange` carries the same, since the two index independently. The handle no longer carries a group-1 index at all: a primitive instance already records where its entry is. The renderer gives each layer a second instance buffer and draws its textures one at a time after the instanced draw, each binding its own group 2. Review fixes alongside: `GlyphAtlas::allocate` returns the `PageUpload` it reserved instead of a bare tuple; a page or image region uploads through a new `write_region`, which passes the row stride to `write_texture` rather than copying the rectangle out first. Verified by replaying taps into the `tabs` example: three images added and one deleted leaves two drawn with two live texture slots, and the masked text-edit tab still clips, with the images freed on tab switch.
This commit is contained in:
1 parent
f5864da3c4
commit
b3d3da5dab
10 files changed
+282
-241
No files matched your search
@@ -1,13 +1,13 @@
|
||||
use crate::{
|
||||
ActiveData, Axis, IdLike, MaskIdx, Painter, PixelRegion, PrimitiveLayers, SizeCtx,
|
||||
StrongWidget, UiRegion, UiRsc, UiVec2, WidgetId, Widgets,
|
||||
ActiveData, Axis, DrawLayers, IdLike, MaskIdx, Painter, PixelRegion, SizeCtx, StrongWidget,
|
||||
UiRegion, UiRsc, UiVec2, WidgetId, Widgets,
|
||||
ui::cache::Cache,
|
||||
util::{HashMap, HashSet, Vec2, forget_ref},
|
||||
};
|
||||
|
||||
pub struct UiRenderState {
|
||||
pub active: HashMap<WidgetId, ActiveData>,
|
||||
pub layers: PrimitiveLayers,
|
||||
pub layers: DrawLayers,
|
||||
pub(super) output_size: Vec2,
|
||||
pub cache: Cache,
|
||||
|
||||
@@ -243,14 +243,11 @@ impl UiRenderState {
|
||||
}
|
||||
|
||||
pub fn debug_layers(&self) {
|
||||
for ((idx, depth), primitives) in self.layers.iter_depth() {
|
||||
for ((idx, depth), draws) in self.layers.iter_depth() {
|
||||
let indent = " ".repeat(depth * 2);
|
||||
let len = primitives.instances().len();
|
||||
print!("{indent}{idx}: {len} primitives");
|
||||
if len >= 1 {
|
||||
print!(" ({})", primitives.instances()[0].binding);
|
||||
}
|
||||
println!();
|
||||
let primitives = draws.primitives.instances().len();
|
||||
let textures = draws.textures.instances().len();
|
||||
println!("{indent}{idx}: {primitives} primitives, {textures} textures");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user