From 9a2c78c4059d2be37d10adda397fb6e64f38ac02 Mon Sep 17 00:00:00 2001 From: Dispersia Date: Sun, 11 Apr 2021 18:55:57 -0700 Subject: Upgrade wgpu --- wgpu/src/image.rs | 59 +++++++++++++++++++++++++++---------------------------- 1 file changed, 29 insertions(+), 30 deletions(-) (limited to 'wgpu/src/image.rs') diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 5511565e..713af209 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -134,28 +134,26 @@ impl Pipeline { bind_group_layouts: &[&constant_layout, &texture_layout], }); - let vs_module = device.create_shader_module(&wgpu::include_spirv!( - "shader/image.vert.spv" - )); - - let fs_module = device.create_shader_module(&wgpu::include_spirv!( - "shader/image.frag.spv" - )); + let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { + label: Some("iced_wgpu::image::shader"), + source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader/image.wgsl"))), + flags: wgpu::ShaderFlags::all() + }); let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { label: Some("iced_wgpu::image pipeline"), layout: Some(&layout), vertex: wgpu::VertexState { - module: &vs_module, - entry_point: "main", + module: &shader, + entry_point: "vs_main", buffers: &[ wgpu::VertexBufferLayout { array_stride: mem::size_of::() as u64, step_mode: wgpu::InputStepMode::Vertex, attributes: &[wgpu::VertexAttribute { shader_location: 0, - format: wgpu::VertexFormat::Float2, + format: wgpu::VertexFormat::Float32x2, offset: 0, }], }, @@ -165,27 +163,27 @@ impl Pipeline { attributes: &[ wgpu::VertexAttribute { shader_location: 1, - format: wgpu::VertexFormat::Float2, + format: wgpu::VertexFormat::Float32x2, offset: 0, }, wgpu::VertexAttribute { shader_location: 2, - format: wgpu::VertexFormat::Float2, + format: wgpu::VertexFormat::Float32x2, offset: 4 * 2, }, wgpu::VertexAttribute { shader_location: 3, - format: wgpu::VertexFormat::Float2, + format: wgpu::VertexFormat::Float32x2, offset: 4 * 4, }, wgpu::VertexAttribute { shader_location: 4, - format: wgpu::VertexFormat::Float2, + format: wgpu::VertexFormat::Float32x2, offset: 4 * 6, }, wgpu::VertexAttribute { shader_location: 5, - format: wgpu::VertexFormat::Uint, + format: wgpu::VertexFormat::Uint32, offset: 4 * 8, }, ], @@ -193,27 +191,28 @@ impl Pipeline { ], }, fragment: Some(wgpu::FragmentState { - module: &fs_module, - entry_point: "main", + module: &shader, + entry_point: "fs_main", targets: &[wgpu::ColorTargetState { format, - color_blend: wgpu::BlendState { - src_factor: wgpu::BlendFactor::SrcAlpha, - dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, - operation: wgpu::BlendOperation::Add, - }, - alpha_blend: wgpu::BlendState { - src_factor: wgpu::BlendFactor::One, - dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, - operation: wgpu::BlendOperation::Add, - }, + blend: Some(wgpu::BlendState { + color: wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::SrcAlpha, + dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, + operation: wgpu::BlendOperation::Add, + }, + alpha: wgpu::BlendComponent { + src_factor: wgpu::BlendFactor::One, + dst_factor: wgpu::BlendFactor::OneMinusSrcAlpha, + operation: wgpu::BlendOperation::Add, + }, + }), write_mask: wgpu::ColorWrite::ALL, }], }), primitive: wgpu::PrimitiveState { topology: wgpu::PrimitiveTopology::TriangleList, front_face: wgpu::FrontFace::Cw, - cull_mode: wgpu::CullMode::None, ..Default::default() }, depth_stencil: None, @@ -424,8 +423,8 @@ impl Pipeline { encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("iced_wgpu::image render pass"), color_attachments: &[ - wgpu::RenderPassColorAttachmentDescriptor { - attachment: target, + wgpu::RenderPassColorAttachment { + view: target, resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Load, -- cgit From 0722d5e3ec307fd82a1cc76593d17d83cf828943 Mon Sep 17 00:00:00 2001 From: Dispersia Date: Mon, 12 Apr 2021 23:07:58 -0700 Subject: add temporary fix for image wgsl --- wgpu/src/image.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'wgpu/src/image.rs') diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 713af209..45b63701 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -183,7 +183,7 @@ impl Pipeline { }, wgpu::VertexAttribute { shader_location: 5, - format: wgpu::VertexFormat::Uint32, + format: wgpu::VertexFormat::Sint32, offset: 4 * 8, }, ], -- cgit From 983aa1b3665c6b546700767d21d73de72372ddad Mon Sep 17 00:00:00 2001 From: Dispersia Date: Mon, 12 Apr 2021 23:23:47 -0700 Subject: Run cargo fmt --- wgpu/src/image.rs | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) (limited to 'wgpu/src/image.rs') diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 45b63701..78f70dd8 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -134,11 +134,14 @@ impl Pipeline { bind_group_layouts: &[&constant_layout, &texture_layout], }); - let shader = device.create_shader_module(&wgpu::ShaderModuleDescriptor { - label: Some("iced_wgpu::image::shader"), - source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed(include_str!("shader/image.wgsl"))), - flags: wgpu::ShaderFlags::all() - }); + let shader = + device.create_shader_module(&wgpu::ShaderModuleDescriptor { + label: Some("iced_wgpu::image::shader"), + source: wgpu::ShaderSource::Wgsl(std::borrow::Cow::Borrowed( + include_str!("shader/image.wgsl"), + )), + flags: wgpu::ShaderFlags::all(), + }); let pipeline = device.create_render_pipeline(&wgpu::RenderPipelineDescriptor { @@ -422,16 +425,14 @@ impl Pipeline { let mut render_pass = encoder.begin_render_pass(&wgpu::RenderPassDescriptor { label: Some("iced_wgpu::image render pass"), - color_attachments: &[ - wgpu::RenderPassColorAttachment { - view: target, - resolve_target: None, - ops: wgpu::Operations { - load: wgpu::LoadOp::Load, - store: true, - }, + color_attachments: &[wgpu::RenderPassColorAttachment { + view: target, + resolve_target: None, + ops: wgpu::Operations { + load: wgpu::LoadOp::Load, + store: true, }, - ], + }], depth_stencil_attachment: None, }); -- cgit From cf6af4c2560f5996bc533402ac3e4289c0c94702 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Date: Wed, 19 May 2021 17:11:51 +0700 Subject: Use latest `wgpu` releases instead of patched sources --- wgpu/src/image.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'wgpu/src/image.rs') diff --git a/wgpu/src/image.rs b/wgpu/src/image.rs index 78f70dd8..cd7b3d23 100644 --- a/wgpu/src/image.rs +++ b/wgpu/src/image.rs @@ -97,11 +97,13 @@ impl Pipeline { entries: &[ wgpu::BindGroupEntry { binding: 0, - resource: wgpu::BindingResource::Buffer { - buffer: &uniforms_buffer, - offset: 0, - size: None, - }, + resource: wgpu::BindingResource::Buffer( + wgpu::BufferBinding { + buffer: &uniforms_buffer, + offset: 0, + size: None, + }, + ), }, wgpu::BindGroupEntry { binding: 1, -- cgit