-
Notifications
You must be signed in to change notification settings - Fork 1.2k
WinRT #9214
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
base: trunk
Are you sure you want to change the base?
WinRT #9214
Changes from all commits
3109cae
d1393ae
f4e62e7
74f3af3
bb9915a
7f2d6c8
815b85f
21f4c65
50ee8a7
cf7bc90
6958830
506a544
a4f422b
570dd89
ce47dfe
a13afb3
8197924
4d36adf
864d9c2
27a3275
c614858
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,6 +29,11 @@ type EglInstance = khronos_egl::Instance<khronos_egl::Static>; | |
|
|
||
| type EglLabel = *const ffi::c_void; | ||
|
|
||
| #[cfg(unix)] | ||
| type WaylandWindow = *mut wayland_sys::egl::wl_egl_window; | ||
| #[cfg(not(unix))] | ||
| type WaylandWindow = *mut ffi::c_void; | ||
|
|
||
| #[allow(clippy::upper_case_acronyms)] | ||
| type EGLDEBUGPROCKHR = Option< | ||
| unsafe extern "system" fn( | ||
|
|
@@ -78,6 +83,62 @@ unsafe extern "system" fn egl_debug_proc( | |
| log::log!(log_severity, "EGL '{command}' code 0x{error:x}: {message}",); | ||
| } | ||
|
|
||
| #[cfg(unix)] | ||
| unsafe fn resize_wayland_window(window: WaylandWindow, width: i32, height: i32) { | ||
| wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_resize, | ||
| window, | ||
| width, | ||
| height, | ||
| 0, | ||
| 0, | ||
| ); | ||
| } | ||
|
|
||
| #[cfg(not(unix))] | ||
| unsafe fn resize_wayland_window(_window: WaylandWindow, _width: i32, _height: i32) { | ||
| unreachable!("Wayland EGL windows are only available on unix targets"); | ||
| } | ||
|
|
||
| #[cfg(unix)] | ||
| unsafe fn create_wayland_window( | ||
| surface: *mut ffi::c_void, | ||
| width: i32, | ||
| height: i32, | ||
| ) -> WaylandWindow { | ||
| wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_create, | ||
| surface.cast(), | ||
| width, | ||
| height, | ||
| ) | ||
| } | ||
|
|
||
| #[cfg(not(unix))] | ||
| unsafe fn create_wayland_window( | ||
| _surface: *mut ffi::c_void, | ||
| _width: i32, | ||
| _height: i32, | ||
| ) -> WaylandWindow { | ||
| unreachable!("Wayland EGL windows are only available on unix targets"); | ||
| } | ||
|
|
||
| #[cfg(unix)] | ||
| unsafe fn destroy_wayland_window(window: WaylandWindow) { | ||
| wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_destroy, | ||
| window, | ||
| ); | ||
| } | ||
|
|
||
| #[cfg(not(unix))] | ||
| unsafe fn destroy_wayland_window(_window: WaylandWindow) { | ||
| unreachable!("Wayland EGL windows are only available on unix targets"); | ||
| } | ||
|
|
||
| #[derive(Clone, Copy, Debug)] | ||
| enum SrgbFrameBufferKind { | ||
| /// No support for SRGB surface | ||
|
|
@@ -442,6 +503,10 @@ impl Inner { | |
|
|
||
| let (config, supports_native_window) = choose_config(&egl, display, srgb_kind)?; | ||
|
|
||
| #[cfg(all(windows, target_vendor = "uwp"))] | ||
| let supports_opengl = false; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is OGL not supported on UWP? Then whats the point of all of these GLES changes when you could just disable the backend? |
||
|
|
||
| #[cfg(not(all(windows, target_vendor = "uwp")))] | ||
| let supports_opengl = if version >= (1, 4) { | ||
| let client_apis = egl | ||
| .query_string(Some(display), khronos_egl::CLIENT_APIS) | ||
|
|
@@ -900,6 +965,7 @@ impl crate::Instance for Instance { | |
| (Rwh::Xlib(_), _) => {} | ||
| (Rwh::Xcb(_), _) => {} | ||
| (Rwh::Win32(_), _) => {} | ||
| (Rwh::WinRt(_), _) => {} | ||
| (Rwh::AppKit(_), _) => {} | ||
| (Rwh::OhosNdk(_), _) => {} | ||
| #[cfg(target_os = "android")] | ||
|
|
@@ -1052,7 +1118,7 @@ impl super::Device { | |
| #[derive(Debug)] | ||
| pub struct Swapchain { | ||
| surface: khronos_egl::Surface, | ||
| wl_window: Option<*mut wayland_sys::egl::wl_egl_window>, | ||
| wl_window: Option<WaylandWindow>, | ||
| framebuffer: glow::Framebuffer, | ||
| renderbuffer: glow::Renderbuffer, | ||
| /// Extent because the window lies | ||
|
|
@@ -1160,10 +1226,7 @@ impl Surface { | |
| unsafe fn unconfigure_impl( | ||
| &self, | ||
| device: &super::Device, | ||
| ) -> Option<( | ||
| khronos_egl::Surface, | ||
| Option<*mut wayland_sys::egl::wl_egl_window>, | ||
| )> { | ||
| ) -> Option<(khronos_egl::Surface, Option<WaylandWindow>)> { | ||
| let gl = &device.shared.context.lock(); | ||
| match self.swapchain.write().take() { | ||
| Some(sc) => { | ||
|
|
@@ -1196,15 +1259,13 @@ impl crate::Surface for Surface { | |
| let (surface, wl_window) = match unsafe { self.unconfigure_impl(device) } { | ||
| Some((sc, wl_window)) => { | ||
| if let Some(window) = wl_window { | ||
| wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_resize, | ||
| window, | ||
| config.extent.width as i32, | ||
| config.extent.height as i32, | ||
| 0, | ||
| 0, | ||
| ); | ||
| unsafe { | ||
| resize_wayland_window( | ||
| window, | ||
| config.extent.width as i32, | ||
| config.extent.height as i32, | ||
| ) | ||
| }; | ||
| } | ||
|
|
||
| (sc, wl_window) | ||
|
|
@@ -1231,13 +1292,13 @@ impl crate::Surface for Surface { | |
| (WindowKind::Unknown, Rwh::OhosNdk(handle)) => handle.native_window.as_ptr(), | ||
| #[cfg(unix)] | ||
| (WindowKind::Wayland, Rwh::Wayland(handle)) => { | ||
| let window = wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_create, | ||
| handle.surface.as_ptr().cast(), | ||
| config.extent.width as i32, | ||
| config.extent.height as i32, | ||
| ); | ||
| let window = unsafe { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you modifying wayland code? |
||
| create_wayland_window( | ||
| handle.surface.as_ptr().cast(), | ||
| config.extent.width as i32, | ||
| config.extent.height as i32, | ||
| ) | ||
| }; | ||
| wl_window = Some(window); | ||
| window.cast() | ||
| } | ||
|
|
@@ -1246,6 +1307,7 @@ impl crate::Surface for Surface { | |
| (WindowKind::Unknown, Rwh::Win32(handle)) => { | ||
| handle.hwnd.get() as *mut ffi::c_void | ||
| } | ||
| (WindowKind::Unknown, Rwh::WinRt(handle)) => handle.core_window.as_ptr(), | ||
| (WindowKind::Unknown, Rwh::AppKit(handle)) => { | ||
| #[cfg(not(target_os = "macos"))] | ||
| let window_ptr = handle.ns_view.as_ptr(); | ||
|
|
@@ -1397,11 +1459,7 @@ impl crate::Surface for Surface { | |
| .destroy_surface(self.egl.display, surface) | ||
| .unwrap(); | ||
| if let Some(window) = wl_window { | ||
| wayland_sys::ffi_dispatch!( | ||
| wayland_sys::egl::wayland_egl_handle(), | ||
| wl_egl_window_destroy, | ||
| window, | ||
| ); | ||
| unsafe { destroy_wayland_window(window) }; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -80,13 +80,13 @@ we don't bother with that combination. | |
| */ | ||
|
|
||
| ///cbindgen:ignore | ||
| #[cfg(not(any(windows, webgl)))] | ||
| #[cfg(any(all(windows, target_vendor = "uwp"), not(any(windows, webgl))))] | ||
| mod egl; | ||
| #[cfg(Emscripten)] | ||
| mod emscripten; | ||
| #[cfg(webgl)] | ||
| mod web; | ||
| #[cfg(windows)] | ||
| #[cfg(all(windows, not(target_vendor = "uwp")))] | ||
| mod wgl; | ||
|
|
||
| mod adapter; | ||
|
|
@@ -98,19 +98,19 @@ mod queue; | |
|
|
||
| pub use fence::Fence; | ||
|
|
||
| #[cfg(not(any(windows, webgl)))] | ||
| #[cfg(any(all(windows, target_vendor = "uwp"), not(any(windows, webgl))))] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stuff like this probably belongs in the build.rs which declares some cfg aliases. It will get annoying to copy this everywhere. |
||
| pub use self::egl::{AdapterContext, AdapterContextLock}; | ||
| #[cfg(not(any(windows, webgl)))] | ||
| #[cfg(any(all(windows, target_vendor = "uwp"), not(any(windows, webgl))))] | ||
| pub use self::egl::{Instance, Surface}; | ||
|
|
||
| #[cfg(webgl)] | ||
| pub use self::web::AdapterContext; | ||
| #[cfg(webgl)] | ||
| pub use self::web::{Instance, Surface}; | ||
|
|
||
| #[cfg(windows)] | ||
| #[cfg(all(windows, not(target_vendor = "uwp")))] | ||
| use self::wgl::AdapterContext; | ||
| #[cfg(windows)] | ||
| #[cfg(all(windows, not(target_vendor = "uwp")))] | ||
| pub use self::wgl::{Instance, Surface}; | ||
|
|
||
| use alloc::{boxed::Box, string::String, string::ToString as _, sync::Arc, vec::Vec}; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be documented on the Dx12SwapchainKind variant