Update to wgpu 0.11 (#209)

Co-authored-by: Jay Oster <jay@kodewerx.org>
This commit is contained in:
JMS55 2021-10-08 14:49:51 -04:00 committed by GitHub
parent a2529c63c3
commit 800dd931b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 19 additions and 24 deletions

View file

@ -24,7 +24,7 @@ pollster = "0.2"
raw-window-handle = "0.3" raw-window-handle = "0.3"
thiserror = "1.0" thiserror = "1.0"
ultraviolet = "0.8" ultraviolet = "0.8"
wgpu = "0.10" wgpu = "0.11"
[dev-dependencies] [dev-dependencies]
pixels-mocks = { path = "internals/pixels-mocks" } pixels-mocks = { path = "internals/pixels-mocks" }

View file

@ -23,7 +23,7 @@ fn vs_main(
[[block]] struct Locals { [[block]] struct Locals {
time: f32; time: f32;
}; };
[[group(0), binding(2)]] var r_locals: Locals; [[group(0), binding(2)]] var<uniform> r_locals: Locals;
let tau: f32 = 6.283185307179586476925286766559; let tau: f32 = 6.283185307179586476925286766559;
let bias: f32 = 0.2376; // Offset the circular time input so it is never 0 let bias: f32 = 0.2376; // Offset the circular time input so it is never 0

View file

@ -246,11 +246,7 @@ fn create_bind_group(
}, },
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 2, binding: 2,
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding { resource: time_buffer.as_entire_binding(),
buffer: time_buffer,
offset: 0,
size: None,
}),
}, },
], ],
}) })

View file

@ -12,9 +12,9 @@ default = ["optimize"]
[dependencies] [dependencies]
env_logger = "0.9" env_logger = "0.9"
imgui = "0.7" imgui = "0.8"
imgui-wgpu = "0.17" imgui-wgpu = "0.18"
imgui-winit-support = { version = "0.7.1", default-features = false, features = ["winit-25"] } imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-25"] }
log = "0.4" log = "0.4"
pixels = { path = "../.." } pixels = { path = "../.." }
winit = "0.25" winit = "0.25"

View file

@ -93,8 +93,8 @@ impl Gui {
// Draw windows and GUI elements here // Draw windows and GUI elements here
let mut about_open = false; let mut about_open = false;
ui.main_menu_bar(|| { ui.main_menu_bar(|| {
ui.menu(imgui::im_str!("Help"), true, || { ui.menu("Help", || {
about_open = imgui::MenuItem::new(imgui::im_str!("About...")).build(&ui); about_open = imgui::MenuItem::new("About...").build(&ui);
}); });
}); });
if about_open { if about_open {

View file

@ -8,7 +8,7 @@ struct VertexOutput {
[[block]] struct Locals { [[block]] struct Locals {
transform: mat4x4<f32>; transform: mat4x4<f32>;
}; };
[[group(0), binding(2)]] var r_locals: Locals; [[group(0), binding(2)]] var<uniform> r_locals: Locals;
[[stage(vertex)]] [[stage(vertex)]]
fn vs_main( fn vs_main(

View file

@ -29,6 +29,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
/// let mut pixels = PixelsBuilder::new(256, 240, surface_texture) /// let mut pixels = PixelsBuilder::new(256, 240, surface_texture)
/// .request_adapter_options(wgpu::RequestAdapterOptions { /// .request_adapter_options(wgpu::RequestAdapterOptions {
/// power_preference: wgpu::PowerPreference::HighPerformance, /// power_preference: wgpu::PowerPreference::HighPerformance,
/// force_fallback_adapter: false,
/// compatible_surface: None, /// compatible_surface: None,
/// }) /// })
/// .enable_vsync(false) /// .enable_vsync(false)
@ -200,11 +201,13 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
instance.request_adapter(&request_adapter_options.as_ref().map_or_else( instance.request_adapter(&request_adapter_options.as_ref().map_or_else(
|| wgpu::RequestAdapterOptions { || wgpu::RequestAdapterOptions {
compatible_surface, compatible_surface,
force_fallback_adapter: false,
power_preference: power_preference:
wgpu::util::power_preference_from_env().unwrap_or_default(), wgpu::util::power_preference_from_env().unwrap_or_default(),
}, },
|rao| wgpu::RequestAdapterOptions { |rao| wgpu::RequestAdapterOptions {
compatible_surface: rao.compatible_surface.or(compatible_surface), compatible_surface: rao.compatible_surface.or(compatible_surface),
force_fallback_adapter: false,
power_preference: rao.power_preference, power_preference: rao.power_preference,
}, },
)); ));

View file

@ -284,7 +284,7 @@ impl Pixels {
/// ///
/// # Errors /// # Errors
/// ///
/// Returns an error when [`wgpu::Surface::get_current_frame`] fails. /// Returns an error when [`wgpu::Surface::get_current_texture`] fails.
/// ///
/// # Example /// # Example
/// ///
@ -328,7 +328,7 @@ impl Pixels {
/// ///
/// # Errors /// # Errors
/// ///
/// Returns an error when either [`wgpu::Surface::get_current_frame`] or the provided render /// Returns an error when either [`wgpu::Surface::get_current_texture`] or the provided render
/// function fails. /// function fails.
/// ///
/// # Example /// # Example
@ -367,13 +367,13 @@ impl Pixels {
let frame = self let frame = self
.context .context
.surface .surface
.get_current_frame() .get_current_texture()
.or_else(|err| match err { .or_else(|err| match err {
wgpu::SurfaceError::Outdated => { wgpu::SurfaceError::Outdated => {
// Reconfigure the surface to mitigate race condition on window resize. // Reconfigure the surface to mitigate race condition on window resize.
// See https://github.com/parasyte/pixels/issues/121 // See https://github.com/parasyte/pixels/issues/121
self.reconfigure_surface(); self.reconfigure_surface();
self.context.surface.get_current_frame() self.context.surface.get_current_texture()
} }
err => Err(err), err => Err(err),
}) })
@ -405,7 +405,6 @@ impl Pixels {
); );
let view = frame let view = frame
.output
.texture .texture
.create_view(&wgpu::TextureViewDescriptor::default()); .create_view(&wgpu::TextureViewDescriptor::default());
@ -413,6 +412,7 @@ impl Pixels {
(render_function)(&mut encoder, &view, &self.context)?; (render_function)(&mut encoder, &view, &self.context)?;
self.context.queue.submit(Some(encoder.finish())); self.context.queue.submit(Some(encoder.finish()));
frame.present();
Ok(()) Ok(())
} }

View file

@ -114,7 +114,7 @@ impl ScalingRenderer {
ty: wgpu::BindingType::Buffer { ty: wgpu::BindingType::Buffer {
ty: wgpu::BufferBindingType::Uniform, ty: wgpu::BufferBindingType::Uniform,
has_dynamic_offset: false, has_dynamic_offset: false,
min_binding_size: None, min_binding_size: None, // TODO: More efficent to specify this
}, },
count: None, count: None,
}, },
@ -134,11 +134,7 @@ impl ScalingRenderer {
}, },
wgpu::BindGroupEntry { wgpu::BindGroupEntry {
binding: 2, binding: 2,
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding { resource: uniform_buffer.as_entire_binding(),
buffer: &uniform_buffer,
offset: 0,
size: None,
}),
}, },
], ],
}); });