-
Notifications
You must be signed in to change notification settings - Fork 45
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
gen: extended headers #270
Conversation
Here's a sample with yaml and corresponding generated header. |
EDIT: Moved this comment to #273 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. let me copy that comment to a new issue.
#ifdef __cplusplus | ||
#define __WGPU_EXTEND_ENUM(E, N, V) static const E N = E(V) | ||
#else | ||
#define __WGPU_EXTEND_ENUM(E, N, V) static const E N = (E)(V) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we need a WGPU_ENUM_EXTENDED_VALUE_ATTRIBUTE
here. I'm not really clear on when Swift needs NS_REFINED_FOR_SWIFT
exactly, but it seems like it probably would need one here in order to refine our enums into Swift enums?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know syntactically where the NS_REFINED_FOR_SWIFT would need to go.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(This does not block landing the PR. I don't think #179 is fully resolved right now anyway.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's just defer this to when someone asks for it.
Namespace indicatorsThe extension yaml parameter types can use re: SuffixesNow generator has a flag wgpu-native will now use this generator to generate it's |
I think it would be better to put the suffix in the yaml file, otherwise I think we wouldn't be able to split webgpu.yml into multiple files for example? Also generally I find it confusing to figure out where the suffix came from when it's implicit from the filename. (Took me a minute to figure this out even though you wrote it down.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good, I think you can land this whenever you want
Generator doesn't do anything implicit for extended bitflags yet, it expects custom values specified in yaml to be distinct. @kainino0x added #214 back on agenda to specify the format of extended bitflags. |
Merging, will make another PR for extended |
This PR finalizes the generations of implementation specific headers from custom yaml specifications aside from
webgpu.yml
.Apart from the general struct extensions, the PR now allows extending
enums
,bitflags
andobjects
with extra entires and functions across multiple yaml specifications.Enums
Because C/C++ can't allow extending enums, we need to use casts, the downside being we loose exhaustive switches in C++ over new entries.
Bitflags
Currently extended bitflag entries are similar to enums, but I think we should change generation of all bitflag entries to be
static const T N = V
instead of enum, because we need to make them 64bit anyway. Vulkan does the same for 64bit bitflagswebgpu_ext.h
Though not needed, but with this PR we can now create a separate common extension header
webgpu_ext.h
andwebgpu_core.h
for core API. So that we can move any native-specific extensions (SPIRV shader) that we currently have inwebgpu.h
towebgpu_ext.h
andwebgpu_core.h
would try to contain only JS spec API.Suffixes
Generator currently doesn't implicitly add any suffixes (
_DAWN
,_WGPU
) to non-extended identifiers in extension headers, those will need to be added in the corresponding yaml specification explicitly, which I think is what we want because it's flexible that way.