summaryrefslogtreecommitdiffstats
path: root/wgpu
diff options
context:
space:
mode:
authorLibravatar Héctor <hector@hecrj.dev>2025-01-26 03:50:22 +0100
committerLibravatar GitHub <noreply@github.com>2025-01-26 03:50:22 +0100
commitc0db7b8e1f6a9d5042530a5b98ec95f492ff6bf7 (patch)
treedbebfc7cdb9922f61dc8bc49610df7603ad558f2 /wgpu
parentca61706cfd9da6306626793443f90ad2bf2dab51 (diff)
parent2c733d96acd4b5ee5ca2ddeac1646d584f7fe112 (diff)
downloadiced-c0db7b8e1f6a9d5042530a5b98ec95f492ff6bf7.tar.gz
iced-c0db7b8e1f6a9d5042530a5b98ec95f492ff6bf7.tar.bz2
iced-c0db7b8e1f6a9d5042530a5b98ec95f492ff6bf7.zip
Merge pull request #2701 from edwloef/2700-fix
always increment quad, mesh, text and image layer counts in wgpu layer rendering
Diffstat (limited to 'wgpu')
-rw-r--r--wgpu/src/lib.rs25
-rw-r--r--wgpu/src/text.rs7
-rw-r--r--wgpu/src/triangle.rs7
3 files changed, 34 insertions, 5 deletions
diff --git a/wgpu/src/lib.rs b/wgpu/src/lib.rs
index d79f0dc8..e6e435af 100644
--- a/wgpu/src/lib.rs
+++ b/wgpu/src/lib.rs
@@ -268,13 +268,28 @@ impl Renderer {
let scale = Transformation::scale(scale_factor);
for layer in self.layers.iter() {
- let Some(physical_bounds) =
- physical_bounds.intersection(&(layer.bounds * scale))
+ let Some(scissor_rect) = physical_bounds
+ .intersection(&(layer.bounds * scale))
+ .and_then(Rectangle::snap)
else {
- continue;
- };
+ if !layer.quads.is_empty() {
+ quad_layer += 1;
+ }
+
+ if !layer.triangles.is_empty() {
+ mesh_layer +=
+ triangle::Pipeline::layer_count(&layer.triangles);
+ }
+
+ if !layer.text.is_empty() {
+ text_layer += text::Pipeline::layer_count(&layer.text);
+ }
+
+ #[cfg(any(feature = "svg", feature = "image"))]
+ if !layer.images.is_empty() {
+ image_layer += 1;
+ }
- let Some(scissor_rect) = physical_bounds.snap() else {
continue;
};
diff --git a/wgpu/src/text.rs b/wgpu/src/text.rs
index 591bc0b7..d7e2e2ae 100644
--- a/wgpu/src/text.rs
+++ b/wgpu/src/text.rs
@@ -302,6 +302,13 @@ impl Pipeline {
}
}
+ pub fn layer_count(batch: &Batch) -> usize {
+ batch
+ .iter()
+ .filter(|item| matches!(item, Item::Group { .. }))
+ .count()
+ }
+
pub fn prepare(
&mut self,
device: &wgpu::Device,
diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs
index ab88be3b..ac0b2215 100644
--- a/wgpu/src/triangle.rs
+++ b/wgpu/src/triangle.rs
@@ -177,6 +177,13 @@ impl Pipeline {
}
}
+ pub fn layer_count(items: &[Item]) -> usize {
+ items
+ .iter()
+ .filter(|item| matches!(item, Item::Group { .. }))
+ .count()
+ }
+
pub fn prepare(
&mut self,
device: &wgpu::Device,