Update to wgpu 0.11 (#209)
Co-authored-by: Jay Oster <jay@kodewerx.org>
This commit is contained in:
parent
a2529c63c3
commit
800dd931b7
|
@ -24,7 +24,7 @@ pollster = "0.2"
|
|||
raw-window-handle = "0.3"
|
||||
thiserror = "1.0"
|
||||
ultraviolet = "0.8"
|
||||
wgpu = "0.10"
|
||||
wgpu = "0.11"
|
||||
|
||||
[dev-dependencies]
|
||||
pixels-mocks = { path = "internals/pixels-mocks" }
|
||||
|
|
|
@ -23,7 +23,7 @@ fn vs_main(
|
|||
[[block]] struct Locals {
|
||||
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 bias: f32 = 0.2376; // Offset the circular time input so it is never 0
|
||||
|
|
|
@ -246,11 +246,7 @@ fn create_bind_group(
|
|||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 2,
|
||||
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
|
||||
buffer: time_buffer,
|
||||
offset: 0,
|
||||
size: None,
|
||||
}),
|
||||
resource: time_buffer.as_entire_binding(),
|
||||
},
|
||||
],
|
||||
})
|
||||
|
|
|
@ -12,9 +12,9 @@ default = ["optimize"]
|
|||
|
||||
[dependencies]
|
||||
env_logger = "0.9"
|
||||
imgui = "0.7"
|
||||
imgui-wgpu = "0.17"
|
||||
imgui-winit-support = { version = "0.7.1", default-features = false, features = ["winit-25"] }
|
||||
imgui = "0.8"
|
||||
imgui-wgpu = "0.18"
|
||||
imgui-winit-support = { version = "0.8", default-features = false, features = ["winit-25"] }
|
||||
log = "0.4"
|
||||
pixels = { path = "../.." }
|
||||
winit = "0.25"
|
||||
|
|
|
@ -93,8 +93,8 @@ impl Gui {
|
|||
// Draw windows and GUI elements here
|
||||
let mut about_open = false;
|
||||
ui.main_menu_bar(|| {
|
||||
ui.menu(imgui::im_str!("Help"), true, || {
|
||||
about_open = imgui::MenuItem::new(imgui::im_str!("About...")).build(&ui);
|
||||
ui.menu("Help", || {
|
||||
about_open = imgui::MenuItem::new("About...").build(&ui);
|
||||
});
|
||||
});
|
||||
if about_open {
|
||||
|
|
|
@ -8,7 +8,7 @@ struct VertexOutput {
|
|||
[[block]] struct Locals {
|
||||
transform: mat4x4<f32>;
|
||||
};
|
||||
[[group(0), binding(2)]] var r_locals: Locals;
|
||||
[[group(0), binding(2)]] var<uniform> r_locals: Locals;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn vs_main(
|
||||
|
|
|
@ -29,6 +29,7 @@ impl<'req, 'dev, 'win, W: HasRawWindowHandle> PixelsBuilder<'req, 'dev, 'win, W>
|
|||
/// let mut pixels = PixelsBuilder::new(256, 240, surface_texture)
|
||||
/// .request_adapter_options(wgpu::RequestAdapterOptions {
|
||||
/// power_preference: wgpu::PowerPreference::HighPerformance,
|
||||
/// force_fallback_adapter: false,
|
||||
/// compatible_surface: None,
|
||||
/// })
|
||||
/// .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(
|
||||
|| wgpu::RequestAdapterOptions {
|
||||
compatible_surface,
|
||||
force_fallback_adapter: false,
|
||||
power_preference:
|
||||
wgpu::util::power_preference_from_env().unwrap_or_default(),
|
||||
},
|
||||
|rao| wgpu::RequestAdapterOptions {
|
||||
compatible_surface: rao.compatible_surface.or(compatible_surface),
|
||||
force_fallback_adapter: false,
|
||||
power_preference: rao.power_preference,
|
||||
},
|
||||
));
|
||||
|
|
10
src/lib.rs
10
src/lib.rs
|
@ -284,7 +284,7 @@ impl Pixels {
|
|||
///
|
||||
/// # Errors
|
||||
///
|
||||
/// Returns an error when [`wgpu::Surface::get_current_frame`] fails.
|
||||
/// Returns an error when [`wgpu::Surface::get_current_texture`] fails.
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
|
@ -328,7 +328,7 @@ impl Pixels {
|
|||
///
|
||||
/// # 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.
|
||||
///
|
||||
/// # Example
|
||||
|
@ -367,13 +367,13 @@ impl Pixels {
|
|||
let frame = self
|
||||
.context
|
||||
.surface
|
||||
.get_current_frame()
|
||||
.get_current_texture()
|
||||
.or_else(|err| match err {
|
||||
wgpu::SurfaceError::Outdated => {
|
||||
// Reconfigure the surface to mitigate race condition on window resize.
|
||||
// See https://github.com/parasyte/pixels/issues/121
|
||||
self.reconfigure_surface();
|
||||
self.context.surface.get_current_frame()
|
||||
self.context.surface.get_current_texture()
|
||||
}
|
||||
err => Err(err),
|
||||
})
|
||||
|
@ -405,7 +405,6 @@ impl Pixels {
|
|||
);
|
||||
|
||||
let view = frame
|
||||
.output
|
||||
.texture
|
||||
.create_view(&wgpu::TextureViewDescriptor::default());
|
||||
|
||||
|
@ -413,6 +412,7 @@ impl Pixels {
|
|||
(render_function)(&mut encoder, &view, &self.context)?;
|
||||
|
||||
self.context.queue.submit(Some(encoder.finish()));
|
||||
frame.present();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ impl ScalingRenderer {
|
|||
ty: wgpu::BindingType::Buffer {
|
||||
ty: wgpu::BufferBindingType::Uniform,
|
||||
has_dynamic_offset: false,
|
||||
min_binding_size: None,
|
||||
min_binding_size: None, // TODO: More efficent to specify this
|
||||
},
|
||||
count: None,
|
||||
},
|
||||
|
@ -134,11 +134,7 @@ impl ScalingRenderer {
|
|||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 2,
|
||||
resource: wgpu::BindingResource::Buffer(wgpu::BufferBinding {
|
||||
buffer: &uniform_buffer,
|
||||
offset: 0,
|
||||
size: None,
|
||||
}),
|
||||
resource: uniform_buffer.as_entire_binding(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue