Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

always increment quad, mesh, text and image layer counts in wgpu layer rendering #2701

Merged
merged 2 commits into from
Jan 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
7 changes: 7 additions & 0 deletions wgpu/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 7 additions & 0 deletions wgpu/src/triangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading