Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Bottom level categories:

#### General

- `SurfaceTexture::present()` has been replaced by `Queue::present(surface_texture)`. By @inner-daemons and @atlv24 in [#9361](https://github.com/gfx-rs/wgpu/pull/9361).
- `Features::CLIP_DISTANCE`, `naga::Capabilities::CLIP_DISTANCE`, and `naga::BuiltIn::ClipDistance` have been renamed to `CLIP_DISTANCES` and `ClipDistances` (viz., pluralized) as appropriate, to match the WebGPU spec. By @ErichDonGubler in [#9267](https://github.com/gfx-rs/wgpu/pull/9267).
- Added more granular limits for mesh shaders. By @inner-daemons in [#8739](https://github.com/gfx-rs/wgpu/pull/8739).
- Added new `InvalidWorkgroupSizeError`, which is now used by `DrawError::InvalidGroupSize` and `StageError::InvalidWorkgroupSize`. By @andyleiserson in [#9357](https://github.com/gfx-rs/wgpu/pull/9357).
Expand All @@ -99,6 +100,7 @@ Bottom level categories:

#### General

- Fix `SYNC-HAZARD-WRITE-AFTER-PRESENT` on Vulkan when a surface texture is presented without being rendered to. By @inner-daemons and @atlv24 in [#9361](https://github.com/gfx-rs/wgpu/pull/9361).
- Fix incorrect checks for dynamic binding bounds when calling an encoder's `set_bind_group` in passes and bundles. By @ErichDonGubler in [#9308](https://github.com/gfx-rs/wgpu/pull/9308).

#### naga
Expand Down
10 changes: 10 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/bug-repro/01_texture_atomic_bug/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,6 @@ impl State {
}

self.queue.submit([enc.finish()]);
frame.present();
self.queue.present(frame);
}
}
11 changes: 11 additions & 0 deletions examples/bug-repro/02_present_bugs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "wgpu-bug-repro-02-present-bugs"
edition = "2021"
rust-version = "1.87"
publish = false

[dependencies]
env_logger = "0.11"
pollster = "0.4"
wgpu.workspace = true
winit = "0.30.8"
145 changes: 145 additions & 0 deletions examples/bug-repro/02_present_bugs/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
//! Repro for various issues with queue presentation
//!
//! The 2 current bugs being tested are presentation after no usage of surface texture
//! and queue destruction immediately after present

use std::sync::Arc;

use winit::application::ApplicationHandler;
use winit::event::WindowEvent;
use winit::event_loop::{ActiveEventLoop, EventLoop};
use winit::window::{Window, WindowId};

fn main() {
env_logger::init();
let event_loop = EventLoop::new().unwrap();
event_loop.set_control_flow(winit::event_loop::ControlFlow::Poll);
let mut app = App::default();
event_loop.run_app(&mut app).unwrap();
}

#[derive(Default)]
struct App {
state: Option<State>,
}

struct State {
window: Arc<Window>,
instance: wgpu::Instance,
device: wgpu::Device,
queue: Option<wgpu::Queue>,
surface: wgpu::Surface<'static>,
surface_config: wgpu::SurfaceConfiguration,
}

impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
if self.state.is_some() {
return;
}
let window = Arc::new(
event_loop
.create_window(Window::default_attributes().with_title("Presentation bugs"))
.unwrap(),
);
self.state = Some(State::new(window));
}

fn window_event(
&mut self,
event_loop: &ActiveEventLoop,
_window_id: WindowId,
event: WindowEvent,
) {
let Some(state) = &mut self.state else { return };
match event {
WindowEvent::CloseRequested => event_loop.exit(),
WindowEvent::Resized(size) if size.width > 0 && size.height > 0 => {
state.surface_config.width = size.width;
state.surface_config.height = size.height;
state
.surface
.configure(&state.device, &state.surface_config);
}
WindowEvent::RedrawRequested => {
let frame = match state.surface.get_current_texture() {
wgpu::CurrentSurfaceTexture::Success(f) => f,
wgpu::CurrentSurfaceTexture::Suboptimal(_)
| wgpu::CurrentSurfaceTexture::Outdated => {
state
.surface
.configure(&state.device, &state.surface_config);
return;
}
wgpu::CurrentSurfaceTexture::Lost => {
state.surface =
state.instance.create_surface(state.window.clone()).unwrap();
state
.surface
.configure(&state.device, &state.surface_config);
return;
}
_ => return,
};
let Some(queue) = state.queue.take() else {
return;
};
// Immediately present the surface texture (with nothing on it) and then drop the queue, which should cause a full wait.
queue.present(frame);
event_loop.exit();
}
_ => {}
}
}

fn about_to_wait(&mut self, _event_loop: &ActiveEventLoop) {
if let Some(state) = &self.state {
state.window.request_redraw();
}
}
}

impl State {
fn new(window: Arc<Window>) -> Self {
let size = window.inner_size();
let width = size.width.max(1);
let height = size.height.max(1);

let mut instance_desc = wgpu::InstanceDescriptor::new_without_display_handle_from_env();
instance_desc.flags |= wgpu::InstanceFlags::advanced_debugging();
let instance = wgpu::Instance::new(instance_desc);
let surface = instance.create_surface(window.clone()).unwrap();
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
compatible_surface: Some(&surface),
..Default::default()
}))
.expect("No adapter");

println!("Adapter: {:?}", adapter.get_info().name);

let (device, queue) =
pollster::block_on(adapter.request_device(&Default::default())).unwrap();

let surface_format = surface.get_capabilities(&adapter).formats[0];
let surface_config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: surface_format,
width,
height,
present_mode: wgpu::PresentMode::AutoVsync,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
desired_maximum_frame_latency: 2,
};
surface.configure(&device, &surface_config);

State {
window,
instance,
device,
queue: Some(queue),
surface,
surface_config,
}
}
}
2 changes: 1 addition & 1 deletion examples/features/src/framework.rs
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ impl<E: Example> ApplicationHandler<AppAction> for App<E> {
if let Some(window) = &self.window {
window.pre_present_notify();
}
frame.present();
context.queue.present(frame);
}

if let Some(window) = &self.window {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_triangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ impl ApplicationHandler<TriangleAction> for App {
if let Some(window) = &self.window {
window.pre_present_notify();
}
frame.present();
wgpu_state.queue.present(frame);
}
WindowEvent::Occluded(is_occluded) => {
if !is_occluded {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/hello_windows/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ impl ApplicationHandler for App {

queue.submit(Some(encoder.finish()));
viewport.desc.window.pre_present_notify();
frame.present();
queue.present(frame);
}
}
WindowEvent::Occluded(is_occluded) => {
Expand Down
2 changes: 1 addition & 1 deletion examples/features/src/uniform_values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl ApplicationHandler<UniformAction> for App {
if let Some(window) = &self.window {
window.pre_present_notify();
}
frame.present();
wgpu_ctx.queue.present(frame);
}
WindowEvent::Occluded(is_occluded) => {
if !is_occluded {
Expand Down
2 changes: 1 addition & 1 deletion examples/standalone/02_hello_window/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl State {
// Submit the command in the queue to execute
self.queue.submit([encoder.finish()]);
self.window.pre_present_notify();
surface_texture.present();
self.queue.present(surface_texture);
}
}

Expand Down
4 changes: 4 additions & 0 deletions examples/standalone/custom_backend/src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ impl QueueInterface for CustomQueue {
fn compact_blas(&self, _blas: &DispatchBlas) -> (Option<u64>, DispatchBlas) {
unimplemented!()
}

fn present(&self, _detail: &wgpu::custom::DispatchSurfaceOutputDetail) {
unimplemented!()
}
}

#[derive(Debug)]
Expand Down
Loading
Loading