mirror of
https://github.com/italicsjenga/winit-sonoma-fix.git
synced 2024-12-24 22:31:30 +11:00
Merge pull request #500 from tomaka/no-error
Add support for the EGL_KHR_create_context_no_error extension
This commit is contained in:
commit
86300dfb79
|
@ -22,7 +22,7 @@ shared_library = "0.1.0"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
gl_generator = "0.0.26"
|
gl_generator = "0.0.26"
|
||||||
khronos_api = "0.0.5"
|
khronos_api = "0.0.6"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
clock_ticks = "0.0.5"
|
clock_ticks = "0.0.5"
|
||||||
|
|
6
build.rs
6
build.rs
|
@ -45,6 +45,7 @@ fn main() {
|
||||||
vec![
|
vec![
|
||||||
"EGL_KHR_create_context".to_string(),
|
"EGL_KHR_create_context".to_string(),
|
||||||
"EGL_EXT_create_context_robustness".to_string(),
|
"EGL_EXT_create_context_robustness".to_string(),
|
||||||
|
"EGL_KHR_create_context_no_error".to_string(),
|
||||||
],
|
],
|
||||||
"1.5", "core", &mut file).unwrap();
|
"1.5", "core", &mut file).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -81,6 +82,7 @@ fn main() {
|
||||||
vec![
|
vec![
|
||||||
"EGL_KHR_create_context".to_string(),
|
"EGL_KHR_create_context".to_string(),
|
||||||
"EGL_EXT_create_context_robustness".to_string(),
|
"EGL_EXT_create_context_robustness".to_string(),
|
||||||
|
"EGL_KHR_create_context_no_error".to_string(),
|
||||||
],
|
],
|
||||||
"1.5", "core", &mut file).unwrap();
|
"1.5", "core", &mut file).unwrap();
|
||||||
}
|
}
|
||||||
|
@ -92,7 +94,9 @@ fn main() {
|
||||||
gl_generator::Fallbacks::All,
|
gl_generator::Fallbacks::All,
|
||||||
khronos_api::EGL_XML,
|
khronos_api::EGL_XML,
|
||||||
vec![
|
vec![
|
||||||
"EGL_KHR_create_context".to_string()
|
"EGL_KHR_create_context".to_string(),
|
||||||
|
"EGL_EXT_create_context_robustness".to_string(),
|
||||||
|
"EGL_KHR_create_context_no_error".to_string(),
|
||||||
],
|
],
|
||||||
"1.5", "core", &mut file).unwrap();
|
"1.5", "core", &mut file).unwrap();
|
||||||
}
|
}
|
||||||
|
|
|
@ -349,7 +349,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
format!("")
|
format!("")
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut context_attributes = vec![];
|
let mut context_attributes = Vec::with_capacity(10);
|
||||||
let mut flags = 0;
|
let mut flags = 0;
|
||||||
|
|
||||||
if egl_version >= &(1, 5) ||
|
if egl_version >= &(1, 5) ||
|
||||||
|
@ -361,30 +361,62 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
context_attributes.push(ffi::egl::CONTEXT_MINOR_VERSION as i32);
|
context_attributes.push(ffi::egl::CONTEXT_MINOR_VERSION as i32);
|
||||||
context_attributes.push(version.1 as i32);
|
context_attributes.push(version.1 as i32);
|
||||||
|
|
||||||
if egl_version >= &(1, 5) ||
|
// handling robustness
|
||||||
extensions.contains("EGL_EXT_create_context_robustness ") ||
|
let supports_robustness = egl_version >= &(1, 5) ||
|
||||||
extensions.ends_with("EGL_EXT_create_context_robustness")
|
extensions.contains("EGL_EXT_create_context_robustness ") ||
|
||||||
{
|
extensions.ends_with("EGL_EXT_create_context_robustness");
|
||||||
match gl_robustness {
|
|
||||||
Robustness::RobustNoResetNotification | Robustness::TryRobustNoResetNotification => {
|
match gl_robustness {
|
||||||
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY as libc::c_int);
|
Robustness::NotRobust => (),
|
||||||
|
|
||||||
|
Robustness::NoError => {
|
||||||
|
if extensions.contains("EGL_KHR_create_context_no_error ") ||
|
||||||
|
extensions.ends_with("EGL_KHR_create_context_no_error")
|
||||||
|
{
|
||||||
|
context_attributes.push(ffi::egl::CONTEXT_OPENGL_NO_ERROR_KHR as libc::c_int);
|
||||||
|
context_attributes.push(1);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Robustness::RobustNoResetNotification => {
|
||||||
|
if supports_robustness {
|
||||||
|
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
|
||||||
|
as libc::c_int);
|
||||||
context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
|
context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
|
||||||
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
},
|
} else {
|
||||||
Robustness::RobustLoseContextOnReset | Robustness::TryRobustLoseContextOnReset => {
|
return Err(CreationError::NotSupported);
|
||||||
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY as libc::c_int);
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Robustness::TryRobustNoResetNotification => {
|
||||||
|
if supports_robustness {
|
||||||
|
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
|
||||||
|
as libc::c_int);
|
||||||
|
context_attributes.push(ffi::egl::NO_RESET_NOTIFICATION as libc::c_int);
|
||||||
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
Robustness::RobustLoseContextOnReset => {
|
||||||
|
if supports_robustness {
|
||||||
|
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
|
||||||
|
as libc::c_int);
|
||||||
context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
|
context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
|
||||||
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
},
|
} else {
|
||||||
Robustness::NotRobust => ()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
match gl_robustness {
|
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::NotSupported);
|
||||||
},
|
}
|
||||||
_ => ()
|
},
|
||||||
}
|
|
||||||
|
Robustness::TryRobustLoseContextOnReset => {
|
||||||
|
if supports_robustness {
|
||||||
|
context_attributes.push(ffi::egl::CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY
|
||||||
|
as libc::c_int);
|
||||||
|
context_attributes.push(ffi::egl::LOSE_CONTEXT_ON_RESET as libc::c_int);
|
||||||
|
flags = flags | ffi::egl::CONTEXT_OPENGL_ROBUST_ACCESS as libc::c_int;
|
||||||
|
}
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
if gl_debug {
|
if gl_debug {
|
||||||
|
@ -400,6 +432,7 @@ unsafe fn create_context(egl: &ffi::egl::Egl, display: ffi::egl::types::EGLDispl
|
||||||
context_attributes.push(flags);
|
context_attributes.push(flags);
|
||||||
|
|
||||||
} else if egl_version >= &(1, 3) && api == Api::OpenGlEs {
|
} else if egl_version >= &(1, 3) && api == Api::OpenGlEs {
|
||||||
|
// robustness is not supported
|
||||||
match gl_robustness {
|
match gl_robustness {
|
||||||
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
Robustness::RobustNoResetNotification | Robustness::RobustLoseContextOnReset => {
|
||||||
return Err(CreationError::NotSupported);
|
return Err(CreationError::NotSupported);
|
||||||
|
|
|
@ -246,7 +246,8 @@ fn create_context(glx: &ffi::glx::Glx, extra_functions: &ffi::glx_extra::Glx, ex
|
||||||
attributes.push(ffi::glx_extra::LOSE_CONTEXT_ON_RESET_ARB as libc::c_int);
|
attributes.push(ffi::glx_extra::LOSE_CONTEXT_ON_RESET_ARB as libc::c_int);
|
||||||
flags = flags | ffi::glx_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
|
flags = flags | ffi::glx_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
|
||||||
},
|
},
|
||||||
Robustness::NotRobust => ()
|
Robustness::NotRobust => (),
|
||||||
|
Robustness::NoError => (),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match robustness {
|
match robustness {
|
||||||
|
|
|
@ -281,7 +281,8 @@ unsafe fn create_context(extra: Option<(&gl::wgl_extra::Wgl, &BuilderAttribs<'st
|
||||||
attributes.push(gl::wgl_extra::LOSE_CONTEXT_ON_RESET_ARB as libc::c_int);
|
attributes.push(gl::wgl_extra::LOSE_CONTEXT_ON_RESET_ARB as libc::c_int);
|
||||||
flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
|
flags = flags | gl::wgl_extra::CONTEXT_ROBUST_ACCESS_BIT_ARB as libc::c_int;
|
||||||
},
|
},
|
||||||
Robustness::NotRobust => ()
|
Robustness::NotRobust => (),
|
||||||
|
Robustness::NoError => (),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
match builder.gl_robustness {
|
match builder.gl_robustness {
|
||||||
|
|
|
@ -205,6 +205,13 @@ pub enum Robustness {
|
||||||
/// shaders.
|
/// shaders.
|
||||||
NotRobust,
|
NotRobust,
|
||||||
|
|
||||||
|
/// The driver doesn't check anything. This option is very dangerous. Please know what you're
|
||||||
|
/// doing before using it. See the `GL_KHR_no_error` extension.
|
||||||
|
///
|
||||||
|
/// Since this option is purely an optimisation, no error will be returned if the backend
|
||||||
|
/// doesn't support it. Instead it will automatically fall back to `NotRobust`.
|
||||||
|
NoError,
|
||||||
|
|
||||||
/// Everything is checked to avoid any crash. The driver will attempt to avoid any problem,
|
/// Everything is checked to avoid any crash. The driver will attempt to avoid any problem,
|
||||||
/// but if a problem occurs the behavior is implementation-defined. You are just guaranteed not
|
/// but if a problem occurs the behavior is implementation-defined. You are just guaranteed not
|
||||||
/// to get a crash.
|
/// to get a crash.
|
||||||
|
|
Loading…
Reference in a new issue