-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Crash on nvidia cards since wgpu 28 #9003
Copy link
Copy link
Closed
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlytype: bugSomething isn't workingSomething isn't working
Description
Description
The following code:
use std::sync::Arc;
use winit::{
application::ApplicationHandler,
event::WindowEvent,
event_loop::{ActiveEventLoop, EventLoop},
window::{Window, WindowId},
};
#[derive(Default)]
struct App {
state: Option<State>,
}
struct State {
window: Arc<Window>,
surface: wgpu::Surface<'static>,
queue: wgpu::Queue,
}
fn main() {
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();
}
impl ApplicationHandler for App {
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
let window = Arc::new(
event_loop
.create_window(Window::default_attributes().with_title("wgpu crash test"))
.unwrap(),
);
let instance = wgpu::Instance::new(&Default::default());
let surface = instance.create_surface(window.clone()).unwrap();
let adapter = pollster::block_on(instance.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
compatible_surface: Some(&surface),
force_fallback_adapter: false,
}))
.unwrap();
let (device, queue) = pollster::block_on(adapter.request_device(&wgpu::DeviceDescriptor {
..Default::default()
}))
.unwrap();
let size = window.inner_size();
let config = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: surface.get_capabilities(&adapter).formats[0],
width: size.width.max(1),
height: size.height.max(1),
present_mode: wgpu::PresentMode::Fifo,
alpha_mode: wgpu::CompositeAlphaMode::Auto,
view_formats: vec![],
desired_maximum_frame_latency: 1,
};
surface.configure(&device, &config);
let queue2 = queue.clone();
std::thread::spawn(move || {
loop {
queue2.submit([]);
}
});
self.state = Some(State {
window,
surface,
queue,
});
}
fn window_event(&mut self, _: &ActiveEventLoop, _id: WindowId, event: WindowEvent) {
let Some(state) = &mut self.state else {
return;
};
if event == WindowEvent::RedrawRequested {
// Just get and present - no rendering
let frame = state.surface.get_current_texture().unwrap();
state.queue.submit([]);
frame.present();
state.window.request_redraw();
}
}
}
[package]
name = "wgpu_repro"
version = "0.1.0"
edition = "2024"
[dependencies]
wgpu = "28"
# wgpu = "27" # works!
pollster = "0.4"
winit = "0.30"Crashes on wgpu 28 when requesting my dedicated GPU. It does not crash on my integrated AMD card. On wgpu 27, neither my AMD or nvidia card crash.
Platform
Linux (Arch) and Windows reproduce the crash, on nvidia GPUs. macOS and my integrated AMD GPU do not.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
area: correctnessWe're behaving incorrectlyWe're behaving incorrectlytype: bugSomething isn't workingSomething isn't working