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

enable debug extension on emscripten #3519

Merged
merged 5 commits into from
Feb 22, 2023

Conversation

coderedart
Copy link
Contributor

@coderedart coderedart commented Feb 21, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
#3245

Description
we check if WEBGL_debug_renderer_info extension is available on emscripten and if it is, we query for unmasked vendor/renderer strings.
but on webgl, we need to enable the extension before using it. but emscripten avoids enabling this particular extension by default.
so, we use emscripten's extern functions defined in https://github.com/emscripten-core/emscripten/blob/4d864df0a57024d667e8db171aab2c3385d04c30/system/include/emscripten/html5_webgl.h#L61 to manually enable the extension if it is found on emscripten target. or fallback to vendor/renderer constants instead of the unmasked variants.

Testing
wgpu-hal's gles html example used for testing.

I believe the wiki needs to be updated https://github.com/gfx-rs/wgpu/wiki/Running-on-the-web-with-Emscripten

@cwfitzgerald cwfitzgerald added the PR: needs back-porting PR with a fix that needs to land on crates label Feb 22, 2023
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some notes

wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/adapter.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/emscripten.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/emscripten.rs Outdated Show resolved Hide resolved
wgpu-hal/src/gles/emscripten.rs Outdated Show resolved Hide resolved
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing!

@coderedart
Copy link
Contributor Author

nice. don't forget to update the wiki too 👍

@cwfitzgerald cwfitzgerald merged commit af5f4d2 into gfx-rs:master Feb 22, 2023
@cwfitzgerald
Copy link
Member

The wiki is publicly editable :)

cwfitzgerald pushed a commit to cwfitzgerald/wgpu that referenced this pull request Mar 9, 2023
* 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
cwfitzgerald pushed a commit that referenced this pull request Mar 9, 2023
* 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
@cwfitzgerald cwfitzgerald removed the PR: needs back-porting PR with a fix that needs to land on crates label Mar 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants