mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
enable debug extension on emscripten (#3519)
* enable debug extension on emscripten * update changelog * extract emscripten stuff into a separate module * use unmasked queries on w-u-u, and only enable extension on emscripten * fix docs
This commit is contained in:
parent
330d112843
commit
1208071e7f
@ -40,6 +40,13 @@ Bottom level categories:
|
||||
|
||||
## Unreleased
|
||||
|
||||
## wgpu-0.15.2 (2023-03-08)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
#### GLES
|
||||
- Enable `WEBGL_debug_renderer_info` before querying unmasked vendor/renderer to avoid crashing on emscripten in [#3519](https://github.com/gfx-rs/wgpu/pull/3519)
|
||||
|
||||
## wgpu-0.15.1 (2023-02-09)
|
||||
|
||||
### Changes
|
||||
|
@ -186,10 +186,21 @@ impl super::Adapter {
|
||||
let extensions = gl.supported_extensions();
|
||||
|
||||
let (vendor_const, renderer_const) = if extensions.contains("WEBGL_debug_renderer_info") {
|
||||
// emscripten doesn't enable "WEBGL_debug_renderer_info" extension by default. so, we do it manually.
|
||||
// See https://github.com/gfx-rs/wgpu/issues/3245 for context
|
||||
#[cfg(feature = "emscripten")]
|
||||
if unsafe { super::emscripten::enable_extension("WEBGL_debug_renderer_info\0") } {
|
||||
(GL_UNMASKED_VENDOR_WEBGL, GL_UNMASKED_RENDERER_WEBGL)
|
||||
} else {
|
||||
(glow::VENDOR, glow::RENDERER)
|
||||
}
|
||||
// glow already enables WEBGL_debug_renderer_info on wasm32-unknown-unknown target by default.
|
||||
#[cfg(not(feature = "emscripten"))]
|
||||
(GL_UNMASKED_VENDOR_WEBGL, GL_UNMASKED_RENDERER_WEBGL)
|
||||
} else {
|
||||
(glow::VENDOR, glow::RENDERER)
|
||||
};
|
||||
|
||||
let (vendor, renderer) = {
|
||||
let vendor = unsafe { gl.get_parameter_string(vendor_const) };
|
||||
let renderer = unsafe { gl.get_parameter_string(renderer_const) };
|
||||
|
26
wgpu-hal/src/gles/emscripten.rs
Normal file
26
wgpu-hal/src/gles/emscripten.rs
Normal file
@ -0,0 +1,26 @@
|
||||
extern "C" {
|
||||
/// returns 1 if success. 0 if failure. extension name must be null terminated
|
||||
fn emscripten_webgl_enable_extension(
|
||||
context: std::ffi::c_int,
|
||||
extension: *const std::ffi::c_char,
|
||||
) -> std::ffi::c_int;
|
||||
fn emscripten_webgl_get_current_context() -> std::ffi::c_int;
|
||||
}
|
||||
/// Webgl requires extensions to be enabled before using them.
|
||||
/// This function can be used to enable webgl extension on emscripten target.
|
||||
///
|
||||
/// returns true on success
|
||||
///
|
||||
/// # Safety:
|
||||
///
|
||||
/// - opengl context MUST BE current
|
||||
/// - extension_name_null_terminated argument must be a valid string with null terminator.
|
||||
/// - extension must be present. check `glow_context.supported_extensions()`
|
||||
pub unsafe fn enable_extension(extension_name_null_terminated: &str) -> bool {
|
||||
unsafe {
|
||||
emscripten_webgl_enable_extension(
|
||||
emscripten_webgl_get_current_context(),
|
||||
extension_name_null_terminated.as_ptr() as _,
|
||||
) == 1
|
||||
}
|
||||
}
|
@ -59,6 +59,8 @@ To address this, we invalidate the vertex buffers based on:
|
||||
///cbindgen:ignore
|
||||
#[cfg(any(not(target_arch = "wasm32"), feature = "emscripten"))]
|
||||
mod egl;
|
||||
#[cfg(feature = "emscripten")]
|
||||
mod emscripten;
|
||||
#[cfg(all(target_arch = "wasm32", not(feature = "emscripten")))]
|
||||
mod web;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user