From 5029aa196d0527b80502f19dab97450c83381586 Mon Sep 17 00:00:00 2001 From: Ben Hansen Date: Tue, 23 Feb 2021 21:04:42 -0700 Subject: [PATCH] migrated gifs showcase --- code/showcase/framework/src/pipeline.rs | 17 +++++---------- code/showcase/gifs/src/main.rs | 29 +++++++++++++------------ docs/showcase/gifs/README.md | 1 + 3 files changed, 21 insertions(+), 26 deletions(-) diff --git a/code/showcase/framework/src/pipeline.rs b/code/showcase/framework/src/pipeline.rs index 697444dc..6336b916 100644 --- a/code/showcase/framework/src/pipeline.rs +++ b/code/showcase/framework/src/pipeline.rs @@ -16,7 +16,7 @@ pub struct RenderPipelineBuilder<'a> { index_format: wgpu::IndexFormat, vertex_buffers: Vec>, sample_count: u32, - sample_mask: u32, + sample_mask: u64, alpha_to_coverage_enabled: bool, } @@ -159,7 +159,7 @@ impl<'a> RenderPipelineBuilder<'a> { } #[allow(dead_code)] - pub fn sample_mask(&mut self, sm: u32) -> &mut Self { + pub fn sample_mask(&mut self, sm: u64) -> &mut Self { self.sample_mask = sm; self } @@ -227,17 +227,10 @@ impl<'a> RenderPipelineBuilder<'a> { }, depth_stencil: self.depth_stencil.clone(), multisample: wgpu::MultisampleState { - count: 1, - mask: !0, - alpha_to_coverage_enabled: false, + count: self.sample_count, + mask: self.sample_mask, + alpha_to_coverage_enabled: self.alpha_to_coverage_enabled, }, - // vertex_state: wgpu::VertexStateDescriptor { - // index_format: self.index_format, - // vertex_buffers: &self.vertex_buffers, - // }, - // sample_count: self.sample_count, - // sample_mask: self.sample_mask, - // alpha_to_coverage_enabled: self.alpha_to_coverage_enabled, }); Ok(pipeline) } diff --git a/code/showcase/gifs/src/main.rs b/code/showcase/gifs/src/main.rs index 547d9202..688238c1 100644 --- a/code/showcase/gifs/src/main.rs +++ b/code/showcase/gifs/src/main.rs @@ -12,9 +12,9 @@ async fn run() { let (device, queue) = adapter .request_device( &wgpu::DeviceDescriptor { + label: Some("Device"), features: wgpu::Features::empty(), limits: wgpu::Limits::default(), - shader_validation: true, }, None, // Trace path ) @@ -79,6 +79,7 @@ async fn run() { device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: None }); let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("GIF Pass"), color_attachments: &[wgpu::RenderPassColorAttachmentDescriptor { attachment: &render_target.view, resolve_target: None, @@ -181,12 +182,20 @@ fn create_render_pipeline( vertex: wgpu::VertexState { module: &vs_module, entry_point: "main", + buffers: &[], }, fragment: Some(wgpu::FragmentState { module: &fs_module, entry_point: "main", + targets: &[ + wgpu::ColorTargetState { + format: target.desc.format, + color_blend: wgpu::BlendState::REPLACE, + alpha_blend: wgpu::BlendState::REPLACE, + write_mask: wgpu::ColorWrite::ALL, + } + ] }), - rasterization_state: None, primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, strip_index_format: None, @@ -195,20 +204,12 @@ fn create_render_pipeline( // Setting this to anything other than Fill requires Features::NON_FILL_POLYGON_MODE polygon_mode: wgpu::PolygonMode::Fill, }, - color_states: &[wgpu::ColorStateDescriptor { - format: target.desc.format, - color_blend: wgpu::BlendDescriptor::REPLACE, - alpha_blend: wgpu::BlendDescriptor::REPLACE, - write_mask: wgpu::ColorWrite::ALL, - }], depth_stencil: None, - vertex_state: wgpu::VertexStateDescriptor { - index_format: wgpu::IndexFormat::Uint16, - vertex_buffers: &[], + multisample: wgpu::MultisampleState { + count: 1, + mask: !0, + alpha_to_coverage_enabled: false, }, - sample_count: 1, - sample_mask: !0, - alpha_to_coverage_enabled: false, }); render_pipeline diff --git a/docs/showcase/gifs/README.md b/docs/showcase/gifs/README.md index 5002fcb9..1dad2453 100644 --- a/docs/showcase/gifs/README.md +++ b/docs/showcase/gifs/README.md @@ -98,6 +98,7 @@ for c in &colors { }); let mut rpass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { + label: Some("GIF Pass"), color_attachments: &[ wgpu::RenderPassColorAttachmentDescriptor { attachment: &render_target.view,