Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature = emscripten, compability fixes for wgpu-native #2450

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
feature = emscripten, compability fixes for wgpu-native
caiiiycuk committed Feb 6, 2022

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c1cfd05ae6c8a32032960290c4509e0dcce1a878
5 changes: 3 additions & 2 deletions wgpu-hal/examples/raw-gles.rs
Original file line number Diff line number Diff line change
@@ -4,8 +4,9 @@
//! Emscripten build:
//! 1. install emsdk
//! 2. build this example with cargo:
//! EMMAKEN_CFLAGS="-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry -s FULL_ES3=1" cargo build --example raw-gles --target wasm32-unknown-emscripten --features emscripten,webgl
//! 3. copy raw-gles.em.html into target/wasm32-unknown-emscripten/debug/examples/ and open it in browser
//! EMCC_CFLAGS="-g -s ERROR_ON_UNDEFINED_SYMBOLS=0 --no-entry -s FULL_ES3=1" cargo build --example raw-gles --target wasm32-unknown-emscripten --features emscripten,webgl
//! 3. copy raw-gles.em.html into target directory and open it in browser:
//! cp wgpu-hal/examples/raw-gles.em.html target/wasm32-unknown-emscripten/debug/examples

extern crate wgpu_hal as hal;

28 changes: 15 additions & 13 deletions wgpu-hal/src/gles/egl.rs
Original file line number Diff line number Diff line change
@@ -501,19 +501,21 @@ impl Inner {

// Testing if context can be binded without surface
// and creating dummy pbuffer surface if not.
let pbuffer =
if version >= (1, 5) || display_extensions.contains("EGL_KHR_surfaceless_context") {
log::info!("\tEGL context: +surfaceless");
None
} else {
let attributes = [egl::WIDTH, 1, egl::HEIGHT, 1, egl::NONE];
egl.create_pbuffer_surface(display, config, &attributes)
.map(Some)
.map_err(|e| {
log::warn!("Error in create_pbuffer_surface: {:?}", e);
crate::InstanceError
})?
};
let pbuffer = if version >= (1, 5)
|| display_extensions.contains("EGL_KHR_surfaceless_context")
|| cfg!(feature = "emscripten")
{
log::info!("\tEGL context: +surfaceless");
None
} else {
let attributes = [egl::WIDTH, 1, egl::HEIGHT, 1, egl::NONE];
egl.create_pbuffer_surface(display, config, &attributes)
.map(Some)
.map_err(|e| {
log::warn!("Error in create_pbuffer_surface: {:?}", e);
crate::InstanceError
})?
};

Ok(Self {
egl: EglContext {