From be14aca07506385a209e89cd99256744a7ec3c0f Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Mon, 24 Feb 2020 20:08:40 +0100 Subject: Make output format of `iced_wgpu` configurable --- wgpu/src/triangle.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'wgpu/src/triangle.rs') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index d149eebc..fe34040e 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -61,6 +61,7 @@ impl Buffer { impl Pipeline { pub fn new( device: &mut wgpu::Device, + format: wgpu::TextureFormat, antialiasing: Option, ) -> Pipeline { let constant_layout = @@ -127,7 +128,7 @@ impl Pipeline { }), primitive_topology: wgpu::PrimitiveTopology::TriangleList, color_states: &[wgpu::ColorStateDescriptor { - format: wgpu::TextureFormat::Bgra8UnormSrgb, + format, color_blend: wgpu::BlendDescriptor { src_factor: wgpu::BlendFactor::SrcAlpha, dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, @@ -169,7 +170,7 @@ impl Pipeline { Pipeline { pipeline, - blit: antialiasing.map(|a| msaa::Blit::new(device, a)), + blit: antialiasing.map(|a| msaa::Blit::new(device, format, a)), constants: constant_bind_group, uniforms_buffer: constants_buffer, vertex_buffer: Buffer::new( -- cgit From 96f75eae4d4d19eeff8e55201822388d34445ec6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Fri, 28 Feb 2020 19:38:17 +0100 Subject: Fix offsets of buffer uploads in triangle pipeline --- wgpu/src/triangle.rs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'wgpu/src/triangle.rs') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index fe34040e..0a118bd2 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -248,7 +248,7 @@ impl Pipeline { &vertex_buffer, 0, &self.vertex_buffer.raw, - last_vertex as u64, + (std::mem::size_of::() * last_vertex) as u64, (std::mem::size_of::() * mesh.vertices.len()) as u64, ); @@ -256,7 +256,7 @@ impl Pipeline { &index_buffer, 0, &self.index_buffer.raw, - last_index as u64, + (std::mem::size_of::() * last_index) as u64, (std::mem::size_of::() * mesh.indices.len()) as u64, ); @@ -313,27 +313,30 @@ impl Pipeline { depth_stencil_attachment: None, }); + render_pass.set_pipeline(&self.pipeline); + render_pass.set_scissor_rect( + bounds.x, + bounds.y, + bounds.width, + bounds.height, + ); + for (i, (vertex_offset, index_offset, indices)) in - offsets.drain(..).enumerate() + offsets.into_iter().enumerate() { - render_pass.set_pipeline(&self.pipeline); render_pass.set_bind_group( 0, &self.constants, &[(std::mem::size_of::() * i) as u64], ); + render_pass .set_index_buffer(&self.index_buffer.raw, index_offset); + render_pass.set_vertex_buffers( 0, &[(&self.vertex_buffer.raw, vertex_offset)], ); - render_pass.set_scissor_rect( - bounds.x, - bounds.y, - bounds.width, - bounds.height, - ); render_pass.draw_indexed(0..indices as u32, 0, 0..1); } -- cgit From 3062c190bbcc82f30eaabc086a4e5014e320c8b6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 4 Mar 2020 22:32:23 +0100 Subject: Fix offsets in `triangle` pipeline Yes, again... --- wgpu/src/triangle.rs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'wgpu/src/triangle.rs') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 0a118bd2..85ed4bd5 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -330,12 +330,17 @@ impl Pipeline { &[(std::mem::size_of::() * i) as u64], ); - render_pass - .set_index_buffer(&self.index_buffer.raw, index_offset); + render_pass.set_index_buffer( + &self.index_buffer.raw, + index_offset * std::mem::size_of::() as u64, + ); render_pass.set_vertex_buffers( 0, - &[(&self.vertex_buffer.raw, vertex_offset)], + &[( + &self.vertex_buffer.raw, + vertex_offset * std::mem::size_of::() as u64, + )], ); render_pass.draw_indexed(0..indices as u32, 0, 0..1); -- cgit From b74e7e7353d69ffb54cf0c0f0574ea7abf0f3a68 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 7 Mar 2020 23:45:54 +0100 Subject: Implement `Primitive::Cached` --- wgpu/src/triangle.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'wgpu/src/triangle.rs') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index 85ed4bd5..be61cc15 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -1,7 +1,7 @@ //! Draw meshes of triangles. use crate::{settings, Transformation}; use iced_native::{Point, Rectangle}; -use std::{mem, sync::Arc}; +use std::mem; mod msaa; @@ -194,7 +194,7 @@ impl Pipeline { target_width: u32, target_height: u32, transformation: Transformation, - meshes: &Vec<(Point, Arc)>, + meshes: &Vec<(Point, &Mesh2D)>, bounds: Rectangle, ) { // This looks a bit crazy, but we are just counting how many vertices -- cgit From 38d967c414af2187b112c654082df7083e0ee7e5 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sat, 7 Mar 2020 23:47:55 +0100 Subject: Take a slice in `iced_wgpu::triangle` pipeline --- wgpu/src/triangle.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu/src/triangle.rs') diff --git a/wgpu/src/triangle.rs b/wgpu/src/triangle.rs index be61cc15..51a6f954 100644 --- a/wgpu/src/triangle.rs +++ b/wgpu/src/triangle.rs @@ -194,7 +194,7 @@ impl Pipeline { target_width: u32, target_height: u32, transformation: Transformation, - meshes: &Vec<(Point, &Mesh2D)>, + meshes: &[(Point, &Mesh2D)], bounds: Rectangle, ) { // This looks a bit crazy, but we are just counting how many vertices -- cgit