-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Add support for creating WebGPU surfaces #2759
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
base: master
Are you sure you want to change the base?
Conversation
Note that this commit only adds support when running on Wayland.
This reverts commit cb0c289.
|
This seems similar to #2333 |
I use an extern function with the `weak` attribute and an assert to ensure that the function is available at runtime instead. I also started to add an example using WebGPU.
…ateSurface`." This reverts commit 8c2f255.
|
Note that the code to fetch the pre-compiled The CI pipeline on macOS needs access to both the x64 and arm64 implementation of WebGPU at the same time, which WebGPU-distribution can not provide at the moment, which is why I decided to inline fetching the library. |
|
Please note that I do not think we would accept a modification to the CMakelists which pulls code from the internet. |
I see. Given that the example needs WebGPU to compile (and I can't include either its source code or binaries in this repo), how should I structure the example? |
|
The usual way to do this is to use CMake to check for the existence of the module/header dependencies and then only set the define which builds WebGPU to |
|
Unfortunately using I could still use |
|
In addition to However disabling WebGPU is also a reasonable start. |
|
Note that I would favour merging the simpler PR #2333 over this. Whilst the OpenGL context creation code is somewhat mixed with the platform window code I do not think this should be the case for WebGPU, though I haven't had the time to speak with @elmindreda about their preference. EDIT: overall the PR looks like good programming work, but the modification of core GLFW files gives me pause. |
|
My rationale for the way I structured the code is that surface creation with WebGPU is very similar to surface creation with Vulkan, so I modeled my implementation for WebGPU on the way this was implemented for Vulkan. While it would have been possible to keep both the platform specific and platform agnostic code in For now I will disable building the WebGPU example by default and add an option to enable building it. I will also move the CMake code that fetches the pre-compiled |
The example is now not built by default. Move code to fetch pre-compiled `wgpu_native` library to `CMake/modules/FindWebGPU.cmake`.
This PR adds the option to create a WebGPU surface using GLFW by calling
glfwCreateWindowWGPUSurface.The address of
wgpuInstanceCreateSurfacemust be provided to the implementation viaglfwSetWGPUInstanceCreateSurfaceAddr.Including
<GLFW/glfw3.h>will also include<webgpu/webgpu.h>ifGLFW_INCLUDE_WEBGPUis defined before the include.Example: