Skip to content

Commit

Permalink
Update to wgpu 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
DJMcNab committed Oct 26, 2023
1 parent 9a6ef95 commit 209932c
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 18 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ 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
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"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
<!-- [![Crates.io](https://img.shields.io/crates/v/vello.svg)](https://crates.io/crates/vello) -->
<!-- [![Docs](https://docs.rs/vello/badge.svg)](https://docs.rs/vello) -->
<!-- [![Build status](https://github.com/linebender/vello/workflows/CI/badge.svg)](https://github.com/linebender/vello/actions) -->
Expand Down
1 change: 0 additions & 1 deletion examples/headless/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)
Expand Down
3 changes: 0 additions & 3 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
)
Expand Down
22 changes: 14 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>;
Expand Down Expand Up @@ -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<TextureFormat>,
/// 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,
}

Expand All @@ -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")]
Expand Down Expand Up @@ -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, &[]);
Expand Down Expand Up @@ -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, &[]);
Expand All @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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")]
{
Expand Down
7 changes: 4 additions & 3 deletions src/wgpu_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub struct WgpuEngine {
struct Shader {
pipeline: ComputePipeline,
bind_group_layout: BindGroupLayout,
#[allow(unused)]
label: &'static str,
cpu_shader: Option<fn(u32, &[CpuBinding])>,
}
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 209932c

Please sign in to comment.