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

Bump raw window handle to 0.6.0 #4202

Merged
merged 52 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
baf15b9
dep: bumping raw-window-handle to 0.6
TornaxO7 Oct 3, 2023
5f82c02
updating some casts
TornaxO7 Oct 3, 2023
0f161dd
fixing more casts
TornaxO7 Oct 3, 2023
4ba013a
removing deprecated traits of `raw-window-handle`
TornaxO7 Oct 3, 2023
6d72872
fixing `DynContext::instance_create_surface`
TornaxO7 Oct 3, 2023
b33e096
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 3, 2023
5eef0dc
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 12, 2023
9d200d8
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 21, 2023
b63ff42
dependencies: bumping `winit` up to `0.29.2`
TornaxO7 Oct 21, 2023
9b99e72
fix: `examples/common/src/framework.rs`
TornaxO7 Oct 23, 2023
a5b8244
fix: `examples/uniform-values/src/main.rs`
TornaxO7 Oct 23, 2023
5676afb
fix: `examples/hello-windows/src/main.rs`
TornaxO7 Oct 23, 2023
c2c2346
fix: `examples/hello-triangle/src/main.rs`
TornaxO7 Oct 23, 2023
b99cab0
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 23, 2023
ddbbcc2
make `cargo clippy` happy
TornaxO7 Oct 23, 2023
6105633
`cargo fmt`
TornaxO7 Oct 23, 2023
025b20b
updating `wgpu-hal/Cargo.toml`, fix `wgpu-hal/examples/halmark/main.rs`
TornaxO7 Oct 23, 2023
76d3175
fix `wgpu-hal/examples/halmark/main.rs`
TornaxO7 Oct 23, 2023
81084f3
make `cargo clippy --all-targets` happy
TornaxO7 Oct 23, 2023
b0c44f7
Get and cast value from HWND
junglie85 Oct 24, 2023
6d0fa16
Merge pull request #1 from junglie85/winit_raw_window_handle_windows
TornaxO7 Oct 24, 2023
55ae059
winit: fix tests
TornaxO7 Oct 25, 2023
b2c475d
examples: removing scale-factor-changed-event from framework
TornaxO7 Oct 25, 2023
298b7db
Merge branch 'bump_raw_window_handle_to_6_0_0' of github.com:TornaxO7…
TornaxO7 Oct 25, 2023
f8002f4
example-framework: removing `resize_window` function
TornaxO7 Oct 25, 2023
a645c71
examples/bunnymark, examples/common/src/framework: refactor code
TornaxO7 Oct 25, 2023
b338b24
`cargo fmt`
TornaxO7 Oct 25, 2023
b5d4984
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 25, 2023
f44074e
updating `Cargo.lock`
TornaxO7 Oct 25, 2023
ec16a2f
examples/common/src/framework.rs: removing unused function
TornaxO7 Oct 25, 2023
1a3388d
player/src/bin/play.rs: fix `winit` feature code
TornaxO7 Oct 25, 2023
62a6928
`cargo fmt`
TornaxO7 Oct 25, 2023
0e8afde
`cargo fmt` and fix `cargo clippy --all-targets`
TornaxO7 Oct 25, 2023
57d3555
`cargo clippy`: ignoring `window` argument
TornaxO7 Oct 25, 2023
352fca1
examples/common/src/framework.rs: removing unused attribute `window`
TornaxO7 Oct 25, 2023
f3b76dd
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 26, 2023
d1410e4
Merge branch 'trunk' of github.com:gfx-rs/wgpu into bump_raw_window_h…
TornaxO7 Oct 26, 2023
edd5de2
naga/tests/wgsl-errors.rs: reverting `cargo clippy` suggestion
TornaxO7 Oct 26, 2023
1bc4108
fixing types
TornaxO7 Oct 26, 2023
30bc824
metal: updating types
TornaxO7 Oct 26, 2023
efff848
`cargo fmt`
TornaxO7 Oct 26, 2023
64820fb
ios: fixing types
TornaxO7 Oct 26, 2023
5c49a77
examples/src/framework, webassembly: add `.expect` for getting canvas
TornaxO7 Oct 26, 2023
67bc63b
examples/common/src/framework: removing mut
TornaxO7 Oct 26, 2023
a1dbf5f
`cargo fmt`
TornaxO7 Oct 26, 2023
cfec502
adding missing `expect`
TornaxO7 Oct 26, 2023
5968aaf
`cargo fmt`
TornaxO7 Oct 26, 2023
be89abc
adding missing `.unwrap()`
TornaxO7 Oct 26, 2023
8e1e834
Merge branch 'trunk' into bump_raw_window_handle_to_6_0_0
cwfitzgerald Oct 26, 2023
a606b72
Merge remote-tracking branch 'upstream/trunk' into bump_raw_window_ha…
cwfitzgerald Oct 27, 2023
d404cda
Fix Clippy Warning
cwfitzgerald Oct 27, 2023
be75a66
Make coverage failure not fail the job
cwfitzgerald Oct 27, 2023
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
22 changes: 14 additions & 8 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 @@ -85,7 +85,7 @@ pico-args = { version = "0.5.0", features = ["eq-separator", "short-space-opt",
png = "0.17.10"
pollster = "0.3"
profiling = { version = "1", default-features = false }
raw-window-handle = "0.5"
raw-window-handle = "0.6"
renderdoc-sys = "1.0.0"
ron = "0.8"
serde = "1"
Expand Down
2 changes: 1 addition & 1 deletion wgpu-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ log = "0.4"
# parking_lot 0.12 switches from `winapi` to `windows`; permit either
parking_lot = ">=0.11,<0.13"
profiling = { version = "1", default-features = false }
raw-window-handle = { version = "0.5", optional = true }
raw-window-handle = { version = "0.6", optional = true }
ron = { version = "0.8", optional = true }
serde = { version = "1", features = ["serde_derive"], optional = true }
smallvec = "1"
Expand Down
2 changes: 1 addition & 1 deletion wgpu-hal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ required-features = ["gles"]
bitflags = "2"
parking_lot = ">=0.11,<0.13"
profiling = { version = "1", default-features = false }
raw-window-handle = "0.5"
raw-window-handle = "0.6"
thiserror = "1"

# backends common
Expand Down
16 changes: 8 additions & 8 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ impl crate::Instance<super::Api> for Instance {
(Rwh::Wayland(_), raw_window_handle::RawDisplayHandle::Wayland(display_handle)) => {
if inner
.wl_display
.map(|ptr| ptr != display_handle.display)
.map(|ptr| ptr != display_handle.display.as_ptr())
.unwrap_or(true)
{
/* Wayland displays are not sharable between surfaces so if the
Expand All @@ -943,7 +943,7 @@ impl crate::Instance<super::Api> for Instance {
.unwrap()
.get_platform_display(
EGL_PLATFORM_WAYLAND_KHR,
display_handle.display,
display_handle.display.as_ptr(),
&display_attributes,
)
.unwrap();
Expand All @@ -956,7 +956,7 @@ impl crate::Instance<super::Api> for Instance {
)?;

let old_inner = std::mem::replace(inner.deref_mut(), new_inner);
inner.wl_display = Some(display_handle.display);
inner.wl_display = Some(display_handle.display.as_ptr());

drop(old_inner);
}
Expand Down Expand Up @@ -1196,24 +1196,24 @@ impl crate::Surface<super::Api> for Surface {
&mut temp_xcb_handle as *mut _ as *mut std::ffi::c_void
}
(WindowKind::AngleX11, Rwh::Xcb(handle)) => {
handle.window as *mut std::ffi::c_void
handle.window.get() as *mut std::ffi::c_void
}
(WindowKind::Unknown, Rwh::AndroidNdk(handle)) => handle.a_native_window,
(WindowKind::Unknown, Rwh::AndroidNdk(handle)) => handle.a_native_window.as_ptr(),
(WindowKind::Wayland, Rwh::Wayland(handle)) => {
let library = &self.wsi.display_owner.as_ref().unwrap().library;
let wl_egl_window_create: libloading::Symbol<WlEglWindowCreateFun> =
unsafe { library.get(b"wl_egl_window_create") }.unwrap();
let window = unsafe { wl_egl_window_create(handle.surface, 640, 480) }
let window = unsafe { wl_egl_window_create(handle.surface.as_ptr(), 640, 480) }
as *mut _ as *mut std::ffi::c_void;
wl_window = Some(window);
window
}
#[cfg(target_os = "emscripten")]
(WindowKind::Unknown, Rwh::Web(handle)) => handle.id as *mut std::ffi::c_void,
(WindowKind::Unknown, Rwh::Win32(handle)) => handle.hwnd,
(WindowKind::Unknown, Rwh::Win32(handle)) => handle.hwnd.get() as * mut std::ffi::c_void,
(WindowKind::Unknown, Rwh::AppKit(handle)) => {
#[cfg(not(target_os = "macos"))]
let window_ptr = handle.ns_view;
let window_ptr = handle.ns_view.as_ptr();
#[cfg(target_os = "macos")]
let window_ptr = {
use objc::{msg_send, runtime::Object, sel, sel_impl};
Expand Down
10 changes: 6 additions & 4 deletions wgpu-hal/src/vulkan/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -740,15 +740,17 @@ impl crate::Instance<super::Api> for super::Instance {

match (window_handle, display_handle) {
(Rwh::Wayland(handle), Rdh::Wayland(display)) => {
self.create_surface_from_wayland(display.display, handle.surface)
self.create_surface_from_wayland(display.display.as_ptr(), handle.surface.as_ptr())
}
(Rwh::Xlib(handle), Rdh::Xlib(display)) => {
self.create_surface_from_xlib(display.display as *mut _, handle.window)
let display = display.display.expect("Display pointer is not set.");
self.create_surface_from_xlib(display.as_ptr() as *mut *const c_void, handle.window)
}
(Rwh::Xcb(handle), Rdh::Xcb(display)) => {
self.create_surface_from_xcb(display.connection, handle.window)
let connection = display.connection.expect("Pointer to X-Server is not set.");
self.create_surface_from_xcb(connection.as_ptr(), handle.window.get())
}
(Rwh::AndroidNdk(handle), _) => self.create_surface_android(handle.a_native_window),
(Rwh::AndroidNdk(handle), _) => self.create_surface_android(handle.a_native_window.as_ptr()),
#[cfg(windows)]
(Rwh::Win32(handle), _) => {
use winapi::um::libloaderapi::GetModuleHandleW;
Expand Down
2 changes: 1 addition & 1 deletion wgpu/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ arrayvec.workspace = true
log.workspace = true
parking_lot.workspace = true
profiling.workspace = true
raw-window-handle.workspace = true
raw-window-handle = { workspace = true, features = ["std"] }
serde = { workspace = true, features = ["derive"], optional = true }
smallvec.workspace = true
static_assertions.workspace = true
Expand Down
24 changes: 21 additions & 3 deletions wgpu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1937,15 +1937,27 @@ impl Instance {
/// - On web: will panic if the `raw_window_handle` does not properly refer to a
/// canvas element.
pub unsafe fn create_surface<
W: raw_window_handle::HasRawWindowHandle + raw_window_handle::HasRawDisplayHandle,
W: raw_window_handle::HasWindowHandle + raw_window_handle::HasDisplayHandle,
>(
&self,
window: &W,
) -> Result<Surface, CreateSurfaceError> {
let raw_display_handle = window
.display_handle()
.map_err(|e| CreateSurfaceError {
inner: CreateSurfaceErrorKind::RawHandle(e)
})?
.as_raw();
let raw_window_handle = window
.window_handle()
.map_err(|e| CreateSurfaceError {
inner: CreateSurfaceErrorKind::RawHandle(e)
})?
.as_raw();
cwfitzgerald marked this conversation as resolved.
Show resolved Hide resolved
let (id, data) = DynContext::instance_create_surface(
&*self.context,
raw_window_handle::HasRawDisplayHandle::raw_display_handle(window),
raw_window_handle::HasRawWindowHandle::raw_window_handle(window),
raw_display_handle,
raw_window_handle
)?;
Ok(Surface {
context: Arc::clone(&self.context),
Expand Down Expand Up @@ -2900,6 +2912,10 @@ enum CreateSurfaceErrorKind {
/// Error from WebGPU surface creation.
#[allow(dead_code)] // may be unused depending on target and features
Web(String),

/// Error when trying to get a [`DisplayHandle`] or a [`WindowHandle`] from
/// `raw_window_handle`.
RawHandle(raw_window_handle::HandleError),
}
static_assertions::assert_impl_all!(CreateSurfaceError: Send, Sync);

Expand All @@ -2913,6 +2929,7 @@ impl fmt::Display for CreateSurfaceError {
))]
CreateSurfaceErrorKind::Hal(e) => e.fmt(f),
CreateSurfaceErrorKind::Web(e) => e.fmt(f),
CreateSurfaceErrorKind::RawHandle(e) => e.fmt(f),
}
}
}
Expand All @@ -2927,6 +2944,7 @@ impl error::Error for CreateSurfaceError {
))]
CreateSurfaceErrorKind::Hal(e) => e.source(),
CreateSurfaceErrorKind::Web(_) => None,
CreateSurfaceErrorKind::RawHandle(e) => e.source(),
}
}
}
Expand Down
Loading