summaryrefslogtreecommitdiffstats
path: root/wgpu/src/image
diff options
context:
space:
mode:
authorLibravatar Dispersia <dispersias@gmail.com>2021-04-11 18:55:57 -0700
committerLibravatar Dispersia <dispersias@gmail.com>2021-04-11 18:55:57 -0700
commit9a2c78c4059d2be37d10adda397fb6e64f38ac02 (patch)
treef529faa116378e7ab447b40bd93bf5811c3dfca8 /wgpu/src/image
parent4b8ba8309f6645cdcb5bd605f8dd88097f8ee5a7 (diff)
downloadiced-9a2c78c4059d2be37d10adda397fb6e64f38ac02.tar.gz
iced-9a2c78c4059d2be37d10adda397fb6e64f38ac02.tar.bz2
iced-9a2c78c4059d2be37d10adda397fb6e64f38ac02.zip
Upgrade wgpu
Diffstat (limited to '')
-rw-r--r--wgpu/src/image.rs59
-rw-r--r--wgpu/src/image/atlas.rs24
2 files changed, 42 insertions, 41 deletions
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::<Vertex>() 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,
diff --git a/wgpu/src/image/atlas.rs b/wgpu/src/image/atlas.rs
index 660ebe44..4855fa4a 100644
--- a/wgpu/src/image/atlas.rs
+++ b/wgpu/src/image/atlas.rs
@@ -4,6 +4,8 @@ mod allocation;
mod allocator;
mod layer;
+use std::num::NonZeroU32;
+
pub use allocation::Allocation;
pub use entry::Entry;
pub use layer::Layer;
@@ -24,7 +26,7 @@ impl Atlas {
let extent = wgpu::Extent3d {
width: SIZE,
height: SIZE,
- depth: 1,
+ depth_or_array_layers: 1,
};
let texture = device.create_texture(&wgpu::TextureDescriptor {
@@ -294,19 +296,19 @@ impl Atlas {
let extent = wgpu::Extent3d {
width,
height,
- depth: 1,
+ depth_or_array_layers: 1,
};
encoder.copy_buffer_to_texture(
- wgpu::BufferCopyView {
+ wgpu::ImageCopyBuffer {
buffer,
- layout: wgpu::TextureDataLayout {
+ layout: wgpu::ImageDataLayout {
offset: offset as u64,
- bytes_per_row: 4 * image_width + padding,
- rows_per_image: image_height,
+ bytes_per_row: NonZeroU32::new(4 * image_width + padding),
+ rows_per_image: NonZeroU32::new(image_height),
},
},
- wgpu::TextureCopyView {
+ wgpu::ImageCopyTexture {
texture: &self.texture,
mip_level: 0,
origin: wgpu::Origin3d {
@@ -334,7 +336,7 @@ impl Atlas {
size: wgpu::Extent3d {
width: SIZE,
height: SIZE,
- depth: self.layers.len() as u32,
+ depth_or_array_layers: self.layers.len() as u32,
},
mip_level_count: 1,
sample_count: 1,
@@ -355,7 +357,7 @@ impl Atlas {
}
encoder.copy_texture_to_texture(
- wgpu::TextureCopyView {
+ wgpu::ImageCopyTexture {
texture: &self.texture,
mip_level: 0,
origin: wgpu::Origin3d {
@@ -364,7 +366,7 @@ impl Atlas {
z: i as u32,
},
},
- wgpu::TextureCopyView {
+ wgpu::ImageCopyTexture {
texture: &new_texture,
mip_level: 0,
origin: wgpu::Origin3d {
@@ -376,7 +378,7 @@ impl Atlas {
wgpu::Extent3d {
width: SIZE,
height: SIZE,
- depth: 1,
+ depth_or_array_layers: 1,
},
);
}