-
-
Notifications
You must be signed in to change notification settings - Fork 152
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
gpu: build idiomatic Zig interface to WebGPU, abstract away native+browser support #21
Comments
For what its worth, I've brought up an easily reproducible dawn build here: https://github.com/meshula/LabSlang (it assumes you have jinja2 installed). I've been looking for a way to zigify the sample program: https://github.com/meshula/LabSlang/blob/main/example/ManualSwapChainTest.cpp and stumbled across your glfw binding which could be a nice first step, from my perspective. |
@meshula Oh, a few thoughts:
You can read a bit about it here: https://devlog.hexops.com/2021/mach-engine-the-future-of-graphics-with-zig#whats-next-webgpu I'll try to get a branch up that you can look at / play with / help out with, if you're interested, sometime this week |
Sent a PR to fix the Obj-C++ compilation issue in Zig, so we can compile Dawn using a |
Sorry I missed your reply, if you post a branch, I'm definitely interested. |
I got all the way to the compiling .mm issue, as you might expect. I haven't been building zig myself, so does it make sense to wait for that to land? or is there an artifact I can download from CI somewhere? I have a fairly large contraption right now where I am writing zig bindings over my LabSlang project, which I need for a current zig project that currently is CLI only. I'd be happy to shift my attention to mach in the short term to see if we are both pushing in the same direction. Due to the mm compilation issue, I can do other things in the meanwhile and wait a little for "relatively easy", and therefore put off learning to build zig :) As you probably already know:
|
The only part of the build that required a bit of research was the installation of git-subtree. I downloaded the git sources, and did an install from the contrib/subtree folder, with |
@meshula can you clarify why you needed to install Git from source? AFAIK, only I myself should ever need to use I'd wait until I can get the |
Here's what I did.
I was making it up as I went along since I wasn't sure what the intended build process actually is, and I haven't used git in a monorepo context in this way before. Maybe I missed an obvious (to one practiced in the monorepo arts ;) ) workflow step. |
I'd love more details on this part, what error did you get? GLFW is committed to the repository the same as any other file, so you really shouldn't have ever needed to touch |
hmm, I think i have another mac without git subtree installed. standby. |
ok, all of my macs except that one have subtree installed, so (1) there is likely something wrong with git on that machine, probably I've hacked it too much with aliases and helper things. (2) all my other machines function as you describe; I can clone and zig build in the root directory, and in the dawn branch, in the webgpu directory, with the same .mm issue. All right, sorry for the noise, but glad to have worked through this. |
Perfect! Glad to hear it. |
* add support for compiling Objective-C++ code Prior to this change, calling `step.addCSourceFiles` with Obj-C++ file extensions (`.mm`) would result in an error due to Zig not being aware of that extension. Clang supports an `-ObjC++` compilation mode flag, but it was only possible to use if you violated standards and renamed your `.mm` Obj-C++ files to `.m` (Obj-C) to workaround Zig being unaware of the extension. This change makes Zig aware of `.mm` files so they can be compiled, enabling compilation of projects such as [Google's Dawn WebGPU](https://dawn.googlesource.com/dawn/) using a `build.zig` file only. Helps hexops/mach#21 Signed-off-by: Stephen Gutekanst <stephen@hexops.com> * test/standalone: add ObjC++ compilation/linking test Based on the existing objc example, just tweaked for ObjC++. Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
This would give us a truly nice, cross-platform, seamless graphics API across browsers, mobile and desktop via Vulkan, Metal, and OpenGL as fallback.
Use the same Zig API for:
This is also the only truly cross-platform graphics API being blessed by major vendors (e.g. Apple) which leads me to believe it has a real shot long-term at displacing the tried and true Vulkan+Metal+OpenGL combo. And even if it doesn't, there has been a massive undertaking to offer a unified API of that Vulkan+Metal+OpenGL combo in forming WebGPU that very few will be able to effectively beat in the general case (e.g. I think we can effectively beat Godot's, potentially Unity and Unreal's, graphics API abstractions using WebGPU.)
The text was updated successfully, but these errors were encountered: