Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to wgpu 0.10 #32

Merged
merged 2 commits into from
Aug 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion src/shader/egui.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn linear_from_srgb(srgb: vec3<f32>) -> vec3<f32> {
let cutoff = srgb < vec3<f32>(10.31475);
let lower = srgb / vec3<f32>(3294.6);
let higher = pow((srgb + vec3<f32>(14.025)) / vec3<f32>(269.025), vec3<f32>(2.4));
return select(lower, higher, cutoff);
return select(higher, lower, cutoff);
}

[[stage(vertex)]]
Expand Down