Closed kainino0x closed 9 months ago
For a file like this, would it be exclusively webgpu, or would it also have the ability to contain platform specific information (similar to how dawn.json has the dawn
and native
flags)?
I could see it either way, it's outside the realm of the common header so it doesn't fit, but on the flip side, there maybe common extensions we work on and sharing the definition would make them more portable.
I guess the takeaway is: this would be really nice, we should really do it someday, but it's hard to ever call it urgent. So I don't know when we should work on it actively.
I actually quite like the idea of writing this as a typescript program that outputs JSON. It would provide a lightweight schema though wouldn't be a formal schema for the output JSON, and I don't know how important that will be to tooling (guessing not critical? but there are clever things like https://www.npmjs.com/package/typescript-json-schema).
For a file like this, would it be exclusively webgpu, or would it also have the ability to contain platform specific information (similar to how dawn.json has the
dawn
andnative
flags)?
IMO we should maintain a file that doesn't have that, but it should be powerful enough to also define implementation-specific extensions using the same format.
Ok, I'll drop the branch I started (https://github.com/dj2/webgpu-headers/blob/gen/gen_webgpu.rb) where I did it in Ruby as there doesn't seem to be much desire on that front.
The vk.xml
file is hard to parse, but a chunk of that is due to the complexities of Vulkan and capabilities and extensions. XML itself is pretty easy to parse and procecess with XPath.
FTR, I wish we had something like this when I wrote my shallow C++ wrapper: https://github.com/eliemichel/WebGPU-Cpp
Instead I scrap the webgpu.h
header (and the spec's web page for default values...), which is an approach that has the merit to work with both Dawn's custom webgpu.h
and wgpu-native's combination of webgpu.h
+wgpu.h
(thanks for adding WGPU_NULL
and other such extra annotations btw).
But I am starting to seriously consider the idea of parsing wgpu-native's headers into a dawn.json
-like file, so that I can use Dawn's generator and thus use Dawn's C++ wrapper transparently on both implementations. In a way that'd make dawn.json
a de facto structured format.
That's what I did to generate the webgpu.xml
file that I was then generating the webgpu header from with gen_webgpu.rb
. You can see the script I was using to parse the dawn.json
file at https://gist.github.com/dj2/296828495dfd794d401656f2c6e238c8 if it's useful (although it's pretty rough as I didn't intend to commit it anywhere just to create the initial XML file).
Another reference that @rajveermalviya recommended taking ideas from: wayland.xml https://gitlab.freedesktop.org/wayland/wayland/-/tree/master/protocol
Meeting:
(Note that YAML is well known to look nice but have 1000 corner cases which make it awkward in practice)
Couldn't we have some form of IDL and corresponding parser that outputs various formats needed by the consumers of webgpu.h?
Previous meetings involved discussions on somehow adapting WebIDL, but the potential complexity of providing IDL for the third-party language bindings generators could be a problem. Unless we also generate a yaml/json/xml from our IDL-based-generator.
I'm not sure I understand the aversion to XML. Yes, it can be a bit more verbose, but is that really an issue here? It's know to handle what we're trying to do (given both vk.xml and wayland.xml exist and do this now). There are tools in every language to handle XML already.
It doesn't end up being too verbose from my prototype (https://github.com/dj2/webgpu-headers/blob/gen/webgpu.xml).
Dec 14 meeting:
To add some context from a conversation I had with Corentin shortly before the meeting:
I might go so far as to say - I'd like to author this in YAML, but downstream projects should consume the JSON instead, and if they add extensions as new files, they may choose to write the extension files as JSON instead of YAML.
We have most of this now so I think we can close this as fixed! With enhancements ongoing (like handling implementation-specific extensions)
There are many useful properties of the API that aren't expressible in C, but are still programmatically useful, especially for generating bindings to other languages. Vulkan has
vk.xml
, for example. It would make sense for us to have such a thing too.Dawn already generates
webgpu.h
andwebgpu_cpp.h
fromdawn.json
. If we do define a file like this here, we should generatewebgpu.h
from it too.See previous discussion on #169, where knowing "in" pointers from "out" pointers would be useful for C# bindings.