Skip to content

Commit

Permalink
Update to wgpu 0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
niklaskorz authored and hasenbanck committed Aug 19, 2021
1 parent 860af76 commit 70cc048
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ homepage = "https://github.com/hasenbanck/egui_wgpu_backend"
repository = "https://github.com/hasenbanck/egui_wgpu_backend"
license = "MIT OR Apache-2.0"
readme = "README.md"
resolver = "2"

[features]
default = []
web = []

[dependencies]
epi = "0.13"
wgpu = "0.9"
wgpu = "0.10"
bytemuck = "1.7"
28 changes: 14 additions & 14 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ impl RenderPass {
let shader = wgpu::ShaderModuleDescriptor {
label: Some("egui_shader"),
source: wgpu::ShaderSource::Wgsl(Cow::Borrowed(include_str!("shader/egui.wgsl"))),
flags: wgpu::ShaderFlags::VALIDATION,
};
let module = device.create_shader_module(&shader);

Expand All @@ -121,7 +120,7 @@ impl RenderPass {
contents: bytemuck::cast_slice(&[UniformBuffer {
screen_size: [0.0, 0.0],
}]),
usage: wgpu::BufferUsage::UNIFORM | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::UNIFORM | wgpu::BufferUsages::COPY_DST,
});
let uniform_buffer = SizedBuffer {
buffer: uniform_buffer,
Expand All @@ -133,7 +132,7 @@ impl RenderPass {
label: Some("egui_uniform_bind_group_layout"),
entries: &[wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::VERTEX,
visibility: wgpu::ShaderStages::VERTEX,
ty: wgpu::BindingType::Buffer {
has_dynamic_offset: false,
min_binding_size: None,
Expand Down Expand Up @@ -162,7 +161,7 @@ impl RenderPass {
entries: &[
wgpu::BindGroupLayoutEntry {
binding: 0,
visibility: wgpu::ShaderStage::FRAGMENT,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Texture {
multisampled: false,
sample_type: wgpu::TextureSampleType::Float { filterable: true },
Expand All @@ -172,7 +171,7 @@ impl RenderPass {
},
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStage::FRAGMENT,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler {
filtering: true,
comparison: false,
Expand Down Expand Up @@ -200,7 +199,7 @@ impl RenderPass {
module: &module,
buffers: &[wgpu::VertexBufferLayout {
array_stride: 5 * 4,
step_mode: wgpu::InputStepMode::Vertex,
step_mode: wgpu::VertexStepMode::Vertex,
// 0: vec2 position
// 1: vec2 texture coordinates
// 2: uint color
Expand Down Expand Up @@ -240,7 +239,7 @@ impl RenderPass {
operation: wgpu::BlendOperation::Add,
},
}),
write_mask: wgpu::ColorWrite::ALL,
write_mask: wgpu::ColorWrites::ALL,
}],
}),
});
Expand Down Expand Up @@ -440,14 +439,15 @@ impl RenderPass {
sample_count: 1,
dimension: wgpu::TextureDimension::D2,
format: wgpu::TextureFormat::Rgba8UnormSrgb,
usage: wgpu::TextureUsage::SAMPLED | wgpu::TextureUsage::COPY_DST,
usage: wgpu::TextureUsages::TEXTURE_BINDING | wgpu::TextureUsages::COPY_DST,
});

queue.write_texture(
wgpu::ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin: wgpu::Origin3d::ZERO,
aspect: wgpu::TextureAspect::All,
},
egui_texture.pixels.as_slice(),
wgpu::ImageDataLayout {
Expand Down Expand Up @@ -618,7 +618,7 @@ impl RenderPass {
let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("egui_index_buffer"),
contents: data,
usage: wgpu::BufferUsage::INDEX | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::INDEX | wgpu::BufferUsages::COPY_DST,
});
self.index_buffers.push(SizedBuffer {
buffer,
Expand All @@ -633,7 +633,7 @@ impl RenderPass {
let buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some("egui_vertex_buffer"),
contents: data,
usage: wgpu::BufferUsage::VERTEX | wgpu::BufferUsage::COPY_DST,
usage: wgpu::BufferUsages::VERTEX | wgpu::BufferUsages::COPY_DST,
});

self.vertex_buffers.push(SizedBuffer {
Expand All @@ -656,17 +656,17 @@ impl RenderPass {
let (buffer, storage, name) = match buffer_type {
BufferType::Index => (
&mut self.index_buffers[index],
wgpu::BufferUsage::INDEX,
wgpu::BufferUsages::INDEX,
"index",
),
BufferType::Vertex => (
&mut self.vertex_buffers[index],
wgpu::BufferUsage::VERTEX,
wgpu::BufferUsages::VERTEX,
"vertex",
),
BufferType::Uniform => (
&mut self.uniform_buffer,
wgpu::BufferUsage::UNIFORM,
wgpu::BufferUsages::UNIFORM,
"uniform",
),
};
Expand All @@ -676,7 +676,7 @@ impl RenderPass {
buffer.buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor {
label: Some(format!("egui_{}_buffer", name).as_str()),
contents: bytemuck::cast_slice(data),
usage: storage | wgpu::BufferUsage::COPY_DST,
usage: storage | wgpu::BufferUsages::COPY_DST,
});
} else {
queue.write_buffer(&buffer.buffer, 0, data);
Expand Down

0 comments on commit 70cc048

Please sign in to comment.