From 209932c8e2fad16469962c42ec420637152e9b6d Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Thu, 26 Oct 2023 16:53:37 +0100 Subject: [PATCH] Update to wgpu 0.18 --- Cargo.toml | 4 ++-- README.md | 2 +- examples/headless/src/main.rs | 1 - examples/with_winit/src/lib.rs | 3 --- src/lib.rs | 22 ++++++++++++++-------- src/util.rs | 2 ++ src/wgpu_engine.rs | 7 ++++--- 7 files changed, 23 insertions(+), 18 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2cc9b4ad0..e75b4e897 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ fello = { git = "https://github.com/dfrg/fount", rev = "dadbcf75695f035ca46766bf peniko = { git = "https://github.com/linebender/peniko", rev = "629fc3325b016a8c98b1cd6204cb4ddf1c6b3daa" } # NOTE: Make sure to keep this in sync with the version badge in README.md -wgpu = { version = "0.17" } +wgpu = { version = "0.18" } # Used for examples @@ -65,4 +65,4 @@ clap = "4.1.0" anyhow = "1.0" instant = { version = "0.1.12", features = ["wasm-bindgen"] } pollster = "0.3.0" -wgpu-profiler = "0.13" +wgpu-profiler = "0.15" diff --git a/README.md b/README.md index 89ca52651..6eaa5ec52 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![Xi Zulip](https://img.shields.io/badge/Xi%20Zulip-%23gpu-blue?logo=Zulip)](https://xi.zulipchat.com/#narrow/stream/197075-gpu) [![dependency status](https://deps.rs/repo/github/linebender/vello/status.svg)](https://deps.rs/repo/github/linebender/vello) [![MIT/Apache 2.0](https://img.shields.io/badge/license-MIT%2FApache-blue.svg)](#license) -[![wgpu version](https://img.shields.io/badge/wgpu-v0.17-orange.svg)](https://crates.io/crates/wgpu) +[![wgpu version](https://img.shields.io/badge/wgpu-v0.18-orange.svg)](https://crates.io/crates/wgpu) diff --git a/examples/headless/src/main.rs b/examples/headless/src/main.rs index 802f9070d..f8ce7e78c 100644 --- a/examples/headless/src/main.rs +++ b/examples/headless/src/main.rs @@ -89,7 +89,6 @@ async fn render(mut scenes: SceneSet, index: usize, args: &Args) -> Result<()> { device, &RendererOptions { surface_format: None, - timestamp_period: queue.get_timestamp_period(), use_cpu: false, }, ) diff --git a/examples/with_winit/src/lib.rs b/examples/with_winit/src/lib.rs index b3b63177a..118498c00 100644 --- a/examples/with_winit/src/lib.rs +++ b/examples/with_winit/src/lib.rs @@ -494,9 +494,6 @@ fn run( &render_cx.devices[id].device, &RendererOptions { surface_format: Some(render_state.surface.format), - timestamp_period: render_cx.devices[id] - .queue - .get_timestamp_period(), use_cpu, }, ) diff --git a/src/lib.rs b/src/lib.rs index 006accd3c..367da735b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -54,7 +54,7 @@ pub use vello_encoding::BumpAllocators; #[cfg(feature = "wgpu")] use wgpu::{Device, Queue, SurfaceTexture, TextureFormat, TextureView}; #[cfg(feature = "wgpu-profiler")] -use wgpu_profiler::GpuProfiler; +use wgpu_profiler::{GpuProfiler, GpuProfilerSettings}; /// Catch-all error type. pub type Error = Box; @@ -106,9 +106,6 @@ pub struct RendererOptions { /// The format of the texture used for surfaces with this renderer/device /// If None, the renderer cannot be used with surfaces pub surface_format: Option, - /// The timestamp period from [`wgpu::Queue::get_timestamp_period`] - /// Used when the wgpu-profiler feature is enabled - pub timestamp_period: f32, pub use_cpu: bool, } @@ -131,7 +128,9 @@ impl Renderer { target: None, // Use 3 pending frames #[cfg(feature = "wgpu-profiler")] - profiler: GpuProfiler::new(3, render_options.timestamp_period, device.features()), + profiler: GpuProfiler::new(GpuProfilerSettings { + ..Default::default() + })?, #[cfg(feature = "wgpu-profiler")] profile_result: None, #[cfg(feature = "hot_reload")] @@ -222,10 +221,12 @@ impl Renderer { resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::default()), - store: true, + store: wgpu::StoreOp::Store, }, })], depth_stencil_attachment: None, + occlusion_query_set: None, + timestamp_writes: None, }); render_pass.set_pipeline(&blit.pipeline); render_pass.set_bind_group(0, &bind_group, &[]); @@ -370,10 +371,12 @@ impl Renderer { resolve_target: None, ops: wgpu::Operations { load: wgpu::LoadOp::Clear(wgpu::Color::default()), - store: true, + store: wgpu::StoreOp::Store, }, })], depth_stencil_attachment: None, + timestamp_writes: None, + occlusion_query_set: None, }); render_pass.set_pipeline(&blit.pipeline); render_pass.set_bind_group(0, &bind_group, &[]); @@ -386,7 +389,10 @@ impl Renderer { #[cfg(feature = "wgpu-profiler")] self.profiler.end_frame().unwrap(); #[cfg(feature = "wgpu-profiler")] - if let Some(result) = self.profiler.process_finished_frame() { + if let Some(result) = self + .profiler + .process_finished_frame(queue.get_timestamp_period()) + { self.profile_result = Some(result); } Ok(bump) diff --git a/src/util.rs b/src/util.rs index 85235e99c..1d7cd98e6 100644 --- a/src/util.rs +++ b/src/util.rs @@ -42,6 +42,7 @@ impl RenderContext { let instance = Instance::new(wgpu::InstanceDescriptor { backends: wgpu::Backends::PRIMARY, dx12_shader_compiler: wgpu::Dx12Compiler::Fxc, + ..Default::default() }); Ok(Self { instance, @@ -137,6 +138,7 @@ impl RenderContext { .await?; let features = adapter.features(); let limits = Limits::default(); + #[allow(unused)] let mut maybe_features = wgpu::Features::CLEAR_TEXTURE; #[cfg(feature = "wgpu-profiler")] { diff --git a/src/wgpu_engine.rs b/src/wgpu_engine.rs index c5359c1bb..145e2e75f 100644 --- a/src/wgpu_engine.rs +++ b/src/wgpu_engine.rs @@ -30,6 +30,7 @@ pub struct WgpuEngine { struct Shader { pipeline: ComputePipeline, bind_group_layout: BindGroupLayout, + #[allow(unused)] label: &'static str, cpu_shader: Option, } @@ -347,7 +348,7 @@ impl WgpuEngine { cpass.set_bind_group(0, &bind_group, &[]); cpass.dispatch_workgroups(wg_size.0, wg_size.1, wg_size.2); #[cfg(feature = "wgpu-profiler")] - profiler.end_scope(&mut cpass); + profiler.end_scope(&mut cpass).unwrap(); } } Command::DispatchIndirect(shader_id, proxy, offset, bindings) => { @@ -393,7 +394,7 @@ impl WgpuEngine { .ok_or("buffer for indirect dispatch not in map")?; cpass.dispatch_workgroups_indirect(buf, *offset); #[cfg(feature = "wgpu-profiler")] - profiler.end_scope(&mut cpass); + profiler.end_scope(&mut cpass).unwrap(); } } Command::Download(proxy) => { @@ -431,7 +432,7 @@ impl WgpuEngine { } } #[cfg(feature = "wgpu-profiler")] - profiler.end_scope(&mut encoder); + profiler.end_scope(&mut encoder).unwrap(); queue.submit(Some(encoder.finish())); for id in free_bufs { if let Some(buf) = self.bind_map.buf_map.remove(&id) {