Skip to content

Commit

Permalink
Seperate GLES and GL version selection (#5657)
Browse files Browse the repository at this point in the history
* Seperate GLES and GL version selection

* Add info when gles minor version is specified and not used
  • Loading branch information
valaphee authored May 4, 2024
1 parent 0d70a73 commit 8084eb6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
36 changes: 20 additions & 16 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,22 +549,28 @@ impl Inner {
let mut khr_context_flags = 0;
let supports_khr_context = display_extensions.contains("EGL_KHR_create_context");

//TODO: make it so `Device` == EGL Context
let mut context_attributes = vec![
khronos_egl::CONTEXT_MAJOR_VERSION,
3, // Request GLES 3.0 or higher
];

if force_gles_minor_version != wgt::Gles3MinorVersion::Automatic {
let mut context_attributes = vec![];
if supports_opengl {
context_attributes.push(khronos_egl::CONTEXT_MAJOR_VERSION);
context_attributes.push(3);
context_attributes.push(khronos_egl::CONTEXT_MINOR_VERSION);
context_attributes.push(match force_gles_minor_version {
wgt::Gles3MinorVersion::Version0 => 0,
wgt::Gles3MinorVersion::Version1 => 1,
wgt::Gles3MinorVersion::Version2 => 2,
_ => unreachable!(),
});
context_attributes.push(3);
if force_gles_minor_version != wgt::Gles3MinorVersion::Automatic {
log::warn!("Ignoring specified GLES minor version as OpenGL is used");
}
} else {
context_attributes.push(khronos_egl::CONTEXT_MAJOR_VERSION);
context_attributes.push(3); // Request GLES 3.0 or higher
if force_gles_minor_version != wgt::Gles3MinorVersion::Automatic {
context_attributes.push(khronos_egl::CONTEXT_MINOR_VERSION);
context_attributes.push(match force_gles_minor_version {
wgt::Gles3MinorVersion::Automatic => unreachable!(),
wgt::Gles3MinorVersion::Version0 => 0,
wgt::Gles3MinorVersion::Version1 => 1,
wgt::Gles3MinorVersion::Version2 => 2,
});
}
}

if flags.contains(wgt::InstanceFlags::DEBUG) {
if version >= (1, 5) {
log::debug!("\tEGL context: +debug");
Expand Down Expand Up @@ -594,8 +600,6 @@ impl Inner {
// because it's for desktop GL only, not GLES.
log::warn!("\tEGL context: -robust access");
}

//TODO do we need `khronos_egl::CONTEXT_OPENGL_NOTIFICATION_STRATEGY_EXT`?
}
if khr_context_flags != 0 {
context_attributes.push(EGL_CONTEXT_FLAGS_KHR);
Expand Down
2 changes: 1 addition & 1 deletion wgpu-types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7094,7 +7094,7 @@ pub struct InstanceDescriptor {
pub flags: InstanceFlags,
/// Which DX12 shader compiler to use.
pub dx12_shader_compiler: Dx12Compiler,
/// Which OpenGL ES 3 minor version to request.
/// Which OpenGL ES 3 minor version to request. Will be ignored if OpenGL is available.
pub gles_minor_version: Gles3MinorVersion,
}

Expand Down

0 comments on commit 8084eb6

Please sign in to comment.