mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
webgl: Use glow::Context::supported_extensions()
to implement getSupportedExtensions()
(#36911)
Not only does this simplify the code, it fixes a problem where we were attempting to use an OpenGL 3.0 API on an incompatible GL context. Testing: There are already tests for `getSupportedExtensions()` in the WebGL suite, but effectively testing this requires drivers that do not support a particular version of OpenGL, so it is a bit hard to actually test. Fixes: #36852. Signed-off-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
1a2e0a77d9
commit
d39b9f05ff
3 changed files with 7 additions and 18 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -8557,6 +8557,7 @@ dependencies = [
|
|||
"glow",
|
||||
"half",
|
||||
"ipc-channel",
|
||||
"itertools 0.14.0",
|
||||
"log",
|
||||
"pixels",
|
||||
"snapshot",
|
||||
|
|
|
@ -26,6 +26,7 @@ fnv = { workspace = true }
|
|||
glow = { workspace = true }
|
||||
half = "2"
|
||||
ipc-channel = { workspace = true }
|
||||
itertools = { workspace = true }
|
||||
log = { workspace = true }
|
||||
pixels = { path = "../pixels" }
|
||||
snapshot = { workspace = true }
|
||||
|
|
|
@ -32,6 +32,7 @@ use glow::{
|
|||
};
|
||||
use half::f16;
|
||||
use ipc_channel::ipc::IpcSharedMemory;
|
||||
use itertools::Itertools;
|
||||
use log::{debug, error, trace, warn};
|
||||
use pixels::{self, PixelFormat, unmultiply_inplace};
|
||||
use surfman::chains::{PreserveBuffer, SwapChains, SwapChainsAPI};
|
||||
|
@ -2570,24 +2571,10 @@ impl WebGLImpl {
|
|||
chan.send((range_min, range_max, precision)).unwrap();
|
||||
}
|
||||
|
||||
fn get_extensions(gl: &Gl, chan: &WebGLSender<String>) {
|
||||
let mut ext_count = [0];
|
||||
unsafe {
|
||||
gl.get_parameter_i32_slice(gl::NUM_EXTENSIONS, &mut ext_count);
|
||||
}
|
||||
// Fall back to the depricated extensions API if that fails
|
||||
if unsafe { gl.get_error() } != gl::NO_ERROR {
|
||||
chan.send(unsafe { gl.get_parameter_string(gl::EXTENSIONS) })
|
||||
.unwrap();
|
||||
return;
|
||||
}
|
||||
let ext_count = ext_count[0] as usize;
|
||||
let mut extensions = Vec::with_capacity(ext_count);
|
||||
for idx in 0..ext_count {
|
||||
extensions.push(unsafe { gl.get_parameter_indexed_string(gl::EXTENSIONS, idx as u32) })
|
||||
}
|
||||
let extensions = extensions.join(" ");
|
||||
chan.send(extensions).unwrap();
|
||||
/// This is an implementation of `getSupportedExtensions()` from
|
||||
/// <https://registry.khronos.org/webgl/specs/latest/1.0/#5.14>
|
||||
fn get_extensions(gl: &Gl, result_sender: &WebGLSender<String>) {
|
||||
let _ = result_sender.send(gl.supported_extensions().iter().join(" "));
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.6
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue