Skip to content

Commit

Permalink
Check OpenGL version earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoxc committed Oct 23, 2023
1 parent 16bfa4d commit 885cd14
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions wgpu-hal/src/gles/adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,27 +228,6 @@ impl super::Adapter {
return None;
}

let shading_language_version = {
let sl_version = unsafe { gl.get_parameter_string(glow::SHADING_LANGUAGE_VERSION) };
log::info!("SL version: {}", &sl_version);
if full_ver.is_some() {
let (sl_major, sl_minor) = Self::parse_full_version(&sl_version).ok()?;
let mut value = sl_major as u16 * 100 + sl_minor as u16 * 10;
// Naga doesn't think it supports GL 460+, so we cap it at 450
if value > 450 {
value = 450;
}
naga::back::glsl::Version::Desktop(value)
} else {
let (sl_major, sl_minor) = Self::parse_version(&sl_version).ok()?;
let value = sl_major as u16 * 100 + sl_minor as u16 * 10;
naga::back::glsl::Version::Embedded {
version: value,
is_webgl: cfg!(target_arch = "wasm32"),
}
}
};

log::trace!("Supported GL Extensions: {:#?}", extensions);

if let Some(es_ver) = es_ver {
Expand All @@ -273,6 +252,27 @@ impl super::Adapter {
}
}

let shading_language_version = {
let sl_version = unsafe { gl.get_parameter_string(glow::SHADING_LANGUAGE_VERSION) };
log::info!("SL version: {}", &sl_version);
if full_ver.is_some() {
let (sl_major, sl_minor) = Self::parse_full_version(&sl_version).ok()?;
let mut value = sl_major as u16 * 100 + sl_minor as u16 * 10;
// Naga doesn't think it supports GL 460+, so we cap it at 450
if value > 450 {
value = 450;
}
naga::back::glsl::Version::Desktop(value)
} else {
let (sl_major, sl_minor) = Self::parse_version(&sl_version).ok()?;
let value = sl_major as u16 * 100 + sl_minor as u16 * 10;
naga::back::glsl::Version::Embedded {
version: value,
is_webgl: cfg!(target_arch = "wasm32"),
}
}
};

let supported = |(req_es_major, req_es_minor), (req_full_major, req_full_minor)| {
let es_supported = es_ver
.map(|es_ver| es_ver >= (req_es_major, req_es_minor))
Expand Down

0 comments on commit 885cd14

Please sign in to comment.