diff options
author | 2023-05-25 10:27:27 -0700 | |
---|---|---|
committer | 2023-05-29 12:14:11 -0700 | |
commit | 3f141459a66fe66e6dc25d579d0cda80662f0895 (patch) | |
tree | c398cb4801bbfe9da148744ad8da3986c624a808 /wgpu/src/quad.rs | |
parent | 75110b9c0e82f37f3c75ce276216db5dbcb4ff1b (diff) | |
download | iced-3f141459a66fe66e6dc25d579d0cda80662f0895.tar.gz iced-3f141459a66fe66e6dc25d579d0cda80662f0895.tar.bz2 iced-3f141459a66fe66e6dc25d579d0cda80662f0895.zip |
Fixed issue where quads of different types were not ordered.
Diffstat (limited to 'wgpu/src/quad.rs')
-rw-r--r-- | wgpu/src/quad.rs | 43 |
1 files changed, 32 insertions, 11 deletions
diff --git a/wgpu/src/quad.rs b/wgpu/src/quad.rs index 0125ec0b..a05e5468 100644 --- a/wgpu/src/quad.rs +++ b/wgpu/src/quad.rs @@ -1,6 +1,6 @@ use crate::core::Rectangle; use crate::graphics::Transformation; -use crate::layer; +use crate::layer::{self, quad}; use std::mem; use wgpu::util::DeviceExt; @@ -87,6 +87,7 @@ impl Pipeline { &'a self, layer: usize, bounds: Rectangle<u32>, + ordering: &Vec<(quad::Order, usize)>, render_pass: &mut wgpu::RenderPass<'a>, ) { if let Some(layer) = self.layers.get(layer) { @@ -102,14 +103,30 @@ impl Pipeline { ); render_pass.set_vertex_buffer(0, self.vertices.slice(..)); - if layer.solid.instance_count > 0 { - render_pass.set_pipeline(&self.solid.pipeline); - layer.solid.draw(&layer.constants, render_pass); - } - - if layer.gradient.instance_count > 0 { - render_pass.set_pipeline(&self.gradient.pipeline); - layer.gradient.draw(&layer.constants, render_pass); + let mut solid_offset = 0; + let mut gradient_offset = 0; + + for (quad_order, count) in ordering { + match quad_order { + quad::Order::Solid => { + render_pass.set_pipeline(&self.solid.pipeline); + layer.solid.draw( + &layer.constants, + render_pass, + solid_offset..(solid_offset + count), + ); + solid_offset += count; + } + quad::Order::Gradient => { + render_pass.set_pipeline(&self.gradient.pipeline); + layer.gradient.draw( + &layer.constants, + render_pass, + gradient_offset..(gradient_offset + count), + ); + gradient_offset += count; + } + } } } } @@ -198,6 +215,7 @@ mod solid { use crate::layer::quad; use crate::quad::{color_target_state, Vertex, INDICES, INITIAL_INSTANCES}; use crate::Buffer; + use std::ops::Range; #[derive(Debug)] pub struct Pipeline { @@ -229,6 +247,7 @@ mod solid { &'a self, constants: &'a wgpu::BindGroup, render_pass: &mut wgpu::RenderPass<'a>, + range: Range<usize>, ) { #[cfg(feature = "tracing")] let _ = tracing::info_span!("Wgpu::Quad::Solid", "DRAW").entered(); @@ -239,7 +258,7 @@ mod solid { render_pass.draw_indexed( 0..INDICES.len() as u32, 0, - 0..self.instance_count as u32, + range.start as u32..range.end as u32, ); } } @@ -327,6 +346,7 @@ mod gradient { use crate::layer::quad; use crate::quad::{color_target_state, Vertex, INDICES, INITIAL_INSTANCES}; use crate::Buffer; + use std::ops::Range; #[derive(Debug)] pub struct Pipeline { @@ -358,6 +378,7 @@ mod gradient { &'a self, constants: &'a wgpu::BindGroup, render_pass: &mut wgpu::RenderPass<'a>, + range: Range<usize>, ) { #[cfg(feature = "tracing")] let _ = @@ -369,7 +390,7 @@ mod gradient { render_pass.draw_indexed( 0..INDICES.len() as u32, 0, - 0..self.instance_count as u32, + range.start as u32..range.end as u32, ); } } |