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

Consider adding a function/helper for creating WebGPU surfaces #8912

Open
eliasdaler opened this issue Jan 23, 2024 · 5 comments
Open

Consider adding a function/helper for creating WebGPU surfaces #8912

eliasdaler opened this issue Jan 23, 2024 · 5 comments
Milestone

Comments

@eliasdaler
Copy link

Hello.

I've been playing with WebGPU and SDL recently and one of the problems was creating a surface you can render to with SDL.

I've found this implementation which works fine, but I feel like it would be nice to include something like this in SDL since creating OpenGL context is a lot easier than creating a WebGPU "context" (actually wgpu/Dawn manages that, but you still need to bring the code to "glue" WebGPU and SDL together).

Feel free to close the issue if it seems "out of scope" for SDL. :)

@slouken
Copy link
Collaborator

slouken commented Jan 23, 2024

This requires us to bring in a hard dependency on WebGPU, right?

If so, this is probably more a candidate for a README-webgpu.md than an API we’d add. There are lots of third party toolkits that we don’t directly support that are pretty easy to add glue for like this.

@icculus, thoughts?

@eliasdaler
Copy link
Author

This requires us to bring in a hard dependency on WebGPU, right?

Only a header part of it. It might look kind of like SDL_opengl.h. Seeing how OpenGL context creation is actually implemented is a bit scary, though (didn't know it was that complex).

For WebGPU it's much easier, and I think that you might require the user to bring in their own webgpu.h? But this probably might not be how SDL does things... but you probably wouldn't want to generate your own webgpu.h...

@icculus
Copy link
Collaborator

icculus commented Jan 23, 2024

@icculus, thoughts?

I have to read up on this more; eventually we're going to end up with WebGPU in the renderer and/or the GPU API, for Emscripten if not other platforms, so we might end up with a tiny helper API, like we did for Vulkan.

@slouken slouken added this to the 3.2.0 milestone Jan 23, 2024
@eliasdaler
Copy link
Author

Sounds good to me!

In Dawn, wgpu::glfw::CreateSurfaceForWindow(instance, window) helper exists (here is how it can be used) which makes getting into WebGPU with glfw easy. Having something like this in SDL would definitely be great. :)

@ryuukk
Copy link

ryuukk commented Aug 30, 2024

@icculus, thoughts?

I have to read up on this more; eventually we're going to end up with WebGPU in the renderer and/or the GPU API, for Emscripten if not other platforms, so we might end up with a tiny helper API, like we did for Vulkan.

Emscripten is not WASM, it's a toolchain, please consider making all WebGPU related work toolchain agnostic, so it's easier to use from languages other than C/C++

It's ok to expect users to manually write JS glue code, it's more portable this way

https://schellcode.github.io/webassembly-without-emscripten

https://surma.dev/things/c-to-webassembly/

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

No branches or pull requests

4 participants