Skip to content
Draft
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 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ pp-rs = "0.2.1"
profiling = { version = "1.0.1", default-features = false }
quote = "1.0.38"
raw-window-handle = { version = "0.6.2", default-features = false }
rwh_05 = { version = "0.5.2", package = "raw-window-handle" } # temporary compatibility for glutin-winit
rwh_05 = { version = "0.5.2", package = "raw-window-handle" } # temporary compatibility for glutin-winit
rayon = "1.3"
regex-lite = "0.1"
renderdoc-sys = "1"
Expand Down
1 change: 1 addition & 0 deletions deno_webgpu/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ impl GPU {
gl: wgpu_types::GlBackendOptions::default(),
noop: wgpu_types::NoopBackendOptions::default(),
},
display: None,
},
)));
state.borrow::<Instance>()
Expand Down
7 changes: 5 additions & 2 deletions examples/features/src/framework.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::sync::Arc;

use wgpu::{Instance, Surface};
use wgpu::{rwh::HasDisplayHandle, Instance, Surface};
use winit::{
dpi::PhysicalSize,
event::{Event, KeyEvent, StartCause, WindowEvent},
Expand Down Expand Up @@ -268,7 +268,10 @@ impl ExampleContext {
async fn init_async<E: Example>(surface: &mut SurfaceWrapper, window: Arc<Window>) -> Self {
log::info!("Initializing wgpu...");

let instance = wgpu::Instance::new(&wgpu::InstanceDescriptor::from_env_or_default());
let mut desc = wgpu::InstanceDescriptor::from_env_or_default();
// XXX: Could also come from EventLoop before Window is created
desc.display = Some(window.display_handle().unwrap().as_raw());
let instance = wgpu::Instance::new(&desc);
surface.pre_adapter(&instance, window);

let adapter = get_adapter_with_capabilities_or_from_env(
Expand Down
1 change: 1 addition & 0 deletions tests/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ pub fn initialize_instance(backends: wgpu::Backends, params: &TestParameters) ->
// TODO(https://github.com/gfx-rs/wgpu/issues/7119): Enable noop backend?
noop: wgpu::NoopBackendOptions::default(),
},
display: None,
})
}

Expand Down
1 change: 1 addition & 0 deletions tests/tests/wgpu-validation/api/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ mod request_adapter_error {
flags: wgpu::InstanceFlags::default(),
memory_budget_thresholds: wgpu::MemoryBudgetThresholds::default(),
backend_options: wgpu::BackendOptions::default(),
display: None,
}
}

Expand Down
5 changes: 5 additions & 0 deletions wgpu-core/src/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use alloc::{
};

use hashbrown::HashMap;
use raw_window_handle::DisplayHandle;
use thiserror::Error;
use wgt::error::{ErrorType, WebGpuError};

Expand Down Expand Up @@ -131,6 +132,10 @@ impl Instance {
flags: self.flags,
memory_budget_thresholds: instance_desc.memory_budget_thresholds,
backend_options: instance_desc.backend_options.clone(),
display: instance_desc
.display
// XXX: This assigns a bogus lifetime. hal::InstanceDescriptor should also take Raw?
.map(|r| unsafe { DisplayHandle::borrow_raw(r) }),
};

use hal::Instance as _;
Expand Down
4 changes: 4 additions & 0 deletions wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ gles = [
"dep:hashbrown",
"dep:js-sys",
"dep:khronos-egl",
"dep:wayland-sys",
"dep:libloading",
"dep:log",
"dep:ndk-sys",
Expand Down Expand Up @@ -245,6 +246,9 @@ renderdoc-sys = { workspace = true, optional = true }
[target.'cfg(unix)'.dependencies]
# Backend: Vulkan
libc = { workspace = true, optional = true }
# backend: GLES
# XXX: Using crate to copy from glutin. Better yet, use wayland-client or replace entire backend with glutin entirely.
wayland-sys = { version = "0.31", features = ["client", "dlopen", "egl"], optional = true }

#########################
### Platform: Windows ###
Expand Down
7 changes: 5 additions & 2 deletions wgpu-hal/examples/halmark/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,24 @@ struct Example<A: hal::Api> {

impl<A: hal::Api> Example<A> {
fn init(window: &winit::window::Window) -> Result<Self, Box<dyn std::error::Error>> {
// XXX: Could be from the EventLoop as well
let raw_display_handle = window.display_handle()?;

let instance_desc = hal::InstanceDescriptor {
name: "example",
flags: wgpu_types::InstanceFlags::from_build_config().with_env(),
memory_budget_thresholds: wgpu_types::MemoryBudgetThresholds::default(),
// Can't rely on having DXC available, so use FXC instead
backend_options: wgpu_types::BackendOptions::default(),
display: Some(raw_display_handle),
};
let instance = unsafe { A::Instance::init(&instance_desc)? };
let surface = {
let raw_window_handle = window.window_handle()?.as_raw();
let raw_display_handle = window.display_handle()?.as_raw();

unsafe {
instance
.create_surface(raw_display_handle, raw_window_handle)
.create_surface(raw_display_handle.as_raw(), raw_window_handle)
.unwrap()
}
};
Expand Down
8 changes: 6 additions & 2 deletions wgpu-hal/examples/ray-traced-triangle/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ impl<A: hal::Api> Example<A> {
log::info!("using index buffer")
}

// XXX: Could be from the EventLoop as well
let raw_display_handle = window.display_handle()?;

let instance_desc = hal::InstanceDescriptor {
name: "example",
flags: wgpu_types::InstanceFlags::default(),
Expand All @@ -245,15 +248,16 @@ impl<A: hal::Api> Example<A> {
},
..Default::default()
},
// XXX: Coudla
display: Some(raw_display_handle),
};
let instance = unsafe { A::Instance::init(&instance_desc)? };
let surface = {
let raw_window_handle = window.window_handle()?.as_raw();
let raw_display_handle = window.display_handle()?.as_raw();

unsafe {
instance
.create_surface(raw_display_handle, raw_window_handle)
.create_surface(raw_display_handle.as_raw(), raw_window_handle)
.unwrap()
}
};
Expand Down
Loading
Loading