-
-
Notifications
You must be signed in to change notification settings - Fork 477
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
Implement priority hints for EGL #1700
base: master
Are you sure you want to change the base?
Changes from all commits
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 |
---|---|---|
|
@@ -201,6 +201,19 @@ impl ContextAttributesBuilder { | |
self | ||
} | ||
|
||
/// Sets the priority hint, which might not be honored if the API does not | ||
/// support it, if there are constraints on the number of high priority | ||
/// contexts available in the system, or system policy limits access to | ||
/// high priority contexts to appropriate system privilege level | ||
/// | ||
/// # Api-specific | ||
/// | ||
/// - Only EGL at the moment implements context priorities. | ||
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. I'd probably use the notation with not supported we use everywhere else, so say that |
||
pub fn with_priority(mut self, priority: Priority) -> Self { | ||
self.attributes.priority = priority; | ||
self | ||
} | ||
|
||
/// Build the context attributes. | ||
/// | ||
/// The `raw_window_handle` isn't required and here for WGL compatibility. | ||
|
@@ -228,6 +241,8 @@ pub struct ContextAttributes { | |
|
||
pub(crate) api: Option<ContextApi>, | ||
|
||
pub(crate) priority: Priority, | ||
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. Given that drivers could confuse things, can we use |
||
|
||
pub(crate) shared_context: Option<RawContext>, | ||
|
||
pub(crate) raw_window_handle: Option<RawWindowHandle>, | ||
|
@@ -608,6 +623,22 @@ pub enum RawContext { | |
Cgl(*const ffi::c_void), | ||
} | ||
|
||
/// Priority hint | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] | ||
pub enum Priority { | ||
/// Lowest priority, contexts using this priority give way for most other | ||
/// contexts. | ||
Low, | ||
/// Default priority. | ||
#[default] | ||
Medium, | ||
/// High priority is usually required for VR applications. | ||
High, | ||
/// Realtime priority contexts are executed immediately and preempt any | ||
/// current context running. But will fallback to high if not supported. | ||
Realtime, | ||
} | ||
|
||
/// Pick `GlProfile` and `Version` based on the provided params. | ||
#[cfg(any(egl_backend, glx_backend, wgl_backend))] | ||
pub(crate) fn pick_profile( | ||
|
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.
Put a
match
on a separate line please and then just push withas
casting.