-
Notifications
You must be signed in to change notification settings - Fork 101
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
Update library to latest webgpu-native headers #427
base: trunk
Are you sure you want to change the base?
Conversation
This goes up to webgpu-native/webgpu-headers@2b59747 Things I *didn't* do: * I didn't update the library to make sure "instance dropped" callback error codes are guaranteed to happen, like they seem to be in Dawn. List of changes (roughly in order of header commits): Various enum and struct renames Updated callbacks to use the new *CallbackInfo structs and 2-userdata system. Also updated functions to return WGPUFuture, though the WGPUFuture thing is just stubbed out at the moment as I don't think wgpu-core has the necessary functionality for it. wgpuInstanceWaitAny is unimplemented!() DepthClipControl merged into PrimitiveState, related code simplified. Updated depthWriteEnabled to use an optional bool, mostly matters due to added validation. Add TODOs for missing features (sliced 3D compressed textures) *Reference() became *AddRef() Added unorm10-10-10-2 vertex format Usage field in TextureViewDescriptor, just used for validation as wgpu-core doesn't allow specifying it anyways. Removed maxInterStageShaderComponents Added clang_macro_fallback to bindgen config, since the headers switched to using UINT32_MAX etc. UINT64_MAX still doesn't work so I had to manually define those. Renamed flags enums. Added a conversion helper function to convert them from u64 -> u32 for mapping. (means added direct dependency on bitflags crate) Removed device argument from (unimplemented) wgpuGetProcAddress Suboptimal surface texture acquisition moved to enum return value, was easy since wgpu-core already returns it like that. "Undefined" present mode added, it just selects FIFO.
1e19d06
to
0c60733
Compare
This enum was replaced with WGPUMapAsyncStatus, but I didn't quite notice. The error codes map different.
Remaining Windows CI failure is caused by webgpu-native/webgpu-headers#339 |
Replaces *EnumerateFeatures with *GetFeatures. Also fixes CI due to fix in headers.
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 but maybe @rajveermalviya can have a look at the Rust code.
Upstream removed the "Flags" suffix from flags types and moved them to no longer be C enums. This matches that change. WGPUInstanceFlag still has "Flag" in the name because, well, there'd be nothing left to distinguish it from WGPUInstance, and it makes sense for it.
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.
Nice job! I started looking at how to implement futures in wgpu
a couple of days ago, nothing obvious but I'll share if I figure sth out!
let present_mode = match config.presentMode { | ||
native::WGPUPresentMode_Undefined => wgt::PresentMode::Fifo, | ||
_ => map_present_mode(config.presentMode), | ||
}; |
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 believe this match
should be part of map_present_mode
rather than being added on top of it
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 did this here because I wasn't sure if I could cleanly add that to map_present_mode
, as it's defined with a map_enum!
macro.
@@ -1701,3 +1694,11 @@ pub fn map_adapter_type(device_type: wgt::DeviceType) -> native::WGPUAdapterType | |||
wgt::DeviceType::Cpu => native::WGPUAdapterType_CPU, | |||
} | |||
} | |||
|
|||
pub fn from_u64_bits<T: bitflags::Flags<Bits = u32>>(value: u64) -> Option<T> { |
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.
(Note: Ideally bitfields would switch to u64
in upstream wgpu
instead of needing a conversion here)
Cargo.toml
Outdated
@@ -157,6 +157,7 @@ log = "0.4" | |||
thiserror = "1" | |||
parking_lot = "0.12" | |||
smallvec = "1" | |||
bitflags = "2.6.0" |
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.
why is this needed?
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.
It's to be able to refer to bitflags
types for the from_u64_bits
helper.
Also updates wgpu.h to use WGPUStringView everywhere.
For WGPUFuture, we need to have access to submission index (and return that in the future's id). Here is the beginning of an attempt at adding this upstream: gfx-rs/wgpu#6360 |
_ => make_slice(string_view.data as *const u8, string_view.length), | ||
}; | ||
|
||
Some(std::str::from_utf8_unchecked(bytes)) |
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.
Important to note: this doesn't check whether strings passed into the library are valid UTF-8. I previously many locations did, but I figured this wasn't necessary.
ef739f1
to
fe965c8
Compare
This goes up to webgpu-native/webgpu-headers@a41b613
Things I didn't do:
List of changes (roughly in order of header commits):
*CallbackInfo
structs and 2-userdata system. Also updated functions to returnWGPUFuture
, though theWGPUFuture
thing is just stubbed out at the moment as I don't think wgpu-core has the necessary functionality for it.wgpuInstanceWaitAny
isunimplemented!()
DepthClipControl
merged intoPrimitiveState
, related code simplified.depthWriteEnabled
to use an optional bool, mostly matters due to added validation.*Reference()
became*AddRef()
unorm10-10-10-2
vertex formatTextureViewDescriptor
, just used for validation as wgpu-core doesn't allow specifying it anyways.maxInterStageShaderComponents
clang_macro_fallback()
to bindgen config, since the headers switched to usingUINT32_MAX
etc.UINT64_MAX
still doesn't work so I had to manually define those.wgpuGetProcAddress
*EnumerateFeatures()
has been replaced with*GetFeatures()
.WGPUStringView
.