Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to wgpu 0.18 #398

Merged
merged 2 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
]
Expand Down Expand Up @@ -61,12 +61,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,
antialiasing_support: vello::AaSupport::area_only(),
},
Expand Down
1 change: 0 additions & 1 deletion examples/with_bevy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
4 changes: 0 additions & 4 deletions examples/with_winit/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
},
Expand Down Expand Up @@ -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(),
},
Expand Down
26 changes: 15 additions & 11 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<dyn std::error::Error>;
Expand Down Expand Up @@ -132,10 +132,6 @@ pub struct RendererOptions {
/// 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,

/// 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`.
Expand All @@ -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,
Expand All @@ -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,
})
Expand Down Expand Up @@ -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, &[]);
Expand Down Expand Up @@ -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, &[]);
Expand All @@ -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)
Expand Down
1 change: 1 addition & 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
6 changes: 3 additions & 3 deletions src/wgpu_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}
Expand Down Expand Up @@ -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");
}
}
}
Expand Down Expand Up @@ -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) {
Expand Down