-
-
Notifications
You must be signed in to change notification settings - Fork 4k
[Merged by Bors] - Update wgpu
to 0.14.0, naga
to 0.10.0
, winit
to 0.27.4, raw-window-handle
to 0.5.0, ndk
to 0.7
#6218
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
Closed
Closed
Changes from 8 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
21450ce
Update `wgpu` to 0.14.0, `winit` to 0.27.4, `raw-window-handle` to 0.5.0
VitalyAnkh b08d6fc
Apply suggestions from code reviewer @torsteingrindvik
VitalyAnkh 27e1eb2
rebase
VitalyAnkh 1437e12
cargo fmt --all
VitalyAnkh 6b280eb
deny old duplicate dependencies other than new ones
VitalyAnkh 600489e
add doc for `bevy::window:CursorGrabMode`
VitalyAnkh 624f7f8
improve doc
VitalyAnkh 76c99ee
improve doc
VitalyAnkh c4a05ec
fix deny.toml comments
VitalyAnkh de211bf
move cursor grab mode convert function to `bevy_winit::converters`
VitalyAnkh 807b29c
fix deny.toml
VitalyAnkh 8d70c22
Update crates/bevy_render/src/view/window.rs
VitalyAnkh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
use raw_window_handle::{ | ||
HasRawDisplayHandle, HasRawWindowHandle, RawDisplayHandle, RawWindowHandle, | ||
}; | ||
|
||
/// A wrapper over [`RawWindowHandle`] and [`RawDisplayHandle`] that allows us to safely pass it across threads. | ||
/// | ||
/// Depending on the platform, the underlying pointer-containing handle cannot be used on all threads, | ||
/// and so we cannot simply make it (or any type that has a safe operation to get a [`RawWindowHandle`] or [`RawDisplayHandle`]) | ||
/// thread-safe. | ||
#[derive(Debug, Clone)] | ||
pub struct RawHandleWrapper { | ||
pub window_handle: RawWindowHandle, | ||
pub display_handle: RawDisplayHandle, | ||
} | ||
|
||
impl RawHandleWrapper { | ||
/// Returns a [`HasRawWindowHandle`] + [`HasRawDisplayHandle`] impl, which exposes [`RawWindowHandle`] and [`RawDisplayHandle`]. | ||
/// | ||
/// # Safety | ||
/// | ||
/// Some platforms have constraints on where/how this handle can be used. For example, some platforms don't support doing window | ||
/// operations off of the main thread. The caller must ensure the [`RawHandleWrapper`] is only used in valid contexts. | ||
pub unsafe fn get_handle(&self) -> ThreadLockedRawWindowHandleWrapper { | ||
ThreadLockedRawWindowHandleWrapper(self.clone()) | ||
} | ||
|
||
pub fn get_display_handle(&self) -> RawDisplayHandle { | ||
self.display_handle | ||
} | ||
|
||
pub fn get_window_handle(&self) -> RawWindowHandle { | ||
self.window_handle | ||
} | ||
} | ||
|
||
// SAFETY: [`RawHandleWrapper`] is just a normal "raw pointer", which doesn't impl Send/Sync. However the pointer is only | ||
// exposed via an unsafe method that forces the user to make a call for a given platform. (ex: some platforms don't | ||
// support doing window operations off of the main thread). | ||
// A recommendation for this pattern (and more context) is available here: | ||
// https://github.com/rust-windowing/raw-window-handle/issues/59 | ||
unsafe impl Send for RawHandleWrapper {} | ||
unsafe impl Sync for RawHandleWrapper {} | ||
|
||
/// A [`RawHandleWrapper`] that cannot be sent across threads. | ||
/// | ||
/// This safely exposes [`RawWindowHandle`] and [`RawDisplayHandle`], but care must be taken to ensure that the construction itself is correct. | ||
/// | ||
/// This can only be constructed via the [`RawHandleWrapper::get_handle()`] method; | ||
/// be sure to read the safety docs there about platform-specific limitations. | ||
/// In many cases, this should only be constructed on the main thread. | ||
pub struct ThreadLockedRawWindowHandleWrapper(RawHandleWrapper); | ||
|
||
// SAFETY: the caller has validated that this is a valid context to get [`RawHandleWrapper`] | ||
// as otherwise an instance of this type could not have been constructed | ||
// NOTE: we cannot simply impl HasRawWindowHandle for RawHandleWrapper, | ||
// as the `raw_window_handle` method is safe. We cannot guarantee that all calls | ||
// of this method are correct (as it may be off the main thread on an incompatible platform), | ||
// and so exposing a safe method to get a [`RawWindowHandle`] directly would be UB. | ||
unsafe impl HasRawWindowHandle for ThreadLockedRawWindowHandleWrapper { | ||
fn raw_window_handle(&self) -> RawWindowHandle { | ||
self.0.get_window_handle() | ||
} | ||
} | ||
|
||
// SAFETY: the caller has validated that this is a valid context to get [`RawDisplayHandle`] | ||
// as otherwise an instance of this type could not have been constructed | ||
// NOTE: we cannot simply impl HasRawDisplayHandle for RawHandleWrapper, | ||
// as the `raw_display_handle` method is safe. We cannot guarantee that all calls | ||
// of this method are correct (as it may be off the main thread on an incompatible platform), | ||
// and so exposing a safe method to get a [`RawDisplayHandle`] directly would be UB. | ||
unsafe impl HasRawDisplayHandle for ThreadLockedRawWindowHandleWrapper { | ||
fn raw_display_handle(&self) -> RawDisplayHandle { | ||
self.0.get_display_handle() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.