From 9732854fd4f30e6aed4dcce3b141954bd752ac47 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Tue, 5 Dec 2023 21:30:07 +0100 Subject: [PATCH] Update to wgpu 0.18 (#398) * Disable the with_bevy package --- Cargo.toml | 6 +++--- README.md | 2 +- examples/headless/src/main.rs | 1 - examples/with_bevy/src/main.rs | 1 - examples/with_winit/src/lib.rs | 4 ---- src/lib.rs | 26 +++++++++++++++----------- src/util.rs | 1 + src/wgpu_engine.rs | 6 +++--- 8 files changed, 23 insertions(+), 24 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ed84f934b..7f26010db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ members = [ "examples/headless", "examples/with_winit", - "examples/with_bevy", + # "examples/with_bevy", # Disable for now until bevy is using wpgu 0.18 "examples/run_wasm", "examples/scenes", ] @@ -61,7 +61,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 @@ -69,4 +69,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 a48d41cb0..33165f9f7 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, antialiasing_support: vello::AaSupport::area_only(), }, diff --git a/examples/with_bevy/src/main.rs b/examples/with_bevy/src/main.rs index 4180c687a..04234cea8 100644 --- a/examples/with_bevy/src/main.rs +++ b/examples/with_bevy/src/main.rs @@ -30,7 +30,6 @@ impl FromWorld for VelloRenderer { device.wgpu_device(), RendererOptions { surface_format: None, - timestamp_period: queue.0.get_timestamp_period(), antialiasing_support: vello::AaSupport::area_only(), use_cpu: false, }, diff --git a/examples/with_winit/src/lib.rs b/examples/with_winit/src/lib.rs index a9f54d9ab..a93fffaf1 100644 --- a/examples/with_winit/src/lib.rs +++ b/examples/with_winit/src/lib.rs @@ -87,7 +87,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: use_cpu, antialiasing_support: vello::AaSupport::all(), }, @@ -515,9 +514,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, antialiasing_support: vello::AaSupport::all(), }, diff --git a/src/lib.rs b/src/lib.rs index b2554c2b1..515e9d6e4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,7 +56,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; @@ -132,10 +132,6 @@ pub struct RendererOptions { /// 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, - /// If true, run all stages up to fine rasterization on the CPU. // TODO: Consider evolving this so that the CPU stages can be configured dynamically via // `RenderParams`. @@ -155,8 +151,7 @@ impl Renderer { let blit = options .surface_format .map(|surface_format| BlitPipeline::new(device, surface_format)); - #[cfg(feature = "wgpu-profiler")] - let timestamp_period = options.timestamp_period; + Ok(Self { options, engine, @@ -165,7 +160,9 @@ impl Renderer { target: None, // Use 3 pending frames #[cfg(feature = "wgpu-profiler")] - profiler: GpuProfiler::new(3, timestamp_period, device.features()), + profiler: GpuProfiler::new(GpuProfilerSettings { + ..Default::default() + })?, #[cfg(feature = "wgpu-profiler")] profile_result: None, }) @@ -254,10 +251,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, &[]); @@ -399,10 +398,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, &[]); @@ -415,7 +416,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 4622d413c..ac40c967a 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, diff --git a/src/wgpu_engine.rs b/src/wgpu_engine.rs index 1f2fce0ee..3ae8a3fba 100644 --- a/src/wgpu_engine.rs +++ b/src/wgpu_engine.rs @@ -408,7 +408,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).expect("We opened a scope"); } } } @@ -457,7 +457,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).expect("We opened a scope"); } } } @@ -496,7 +496,7 @@ impl WgpuEngine { } } #[cfg(feature = "wgpu-profiler")] - profiler.end_scope(&mut encoder); + profiler.end_scope(&mut encoder).expect("We opened a scope"); queue.submit(Some(encoder.finish())); for id in free_bufs { if let Some(buf) = self.bind_map.buf_map.remove(&id) {