-
Notifications
You must be signed in to change notification settings - Fork 977
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
Expose adapter specific formats features via Extension, support for storage read+write #1112
Conversation
TextureFormatFeatures is now a struct of two u32 flags. Query happens only at texture creation time
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 is an autogenerated code review.
Checker summary (by rust_clippy):
The tool has found 82 warnings, 0 errors.
@@ -132,7 +133,8 @@ impl<B: GfxBackend> Adapter<B> { | |||
|
|||
let mut features = wgt::Features::default() | |||
| wgt::Features::MAPPABLE_PRIMARY_BUFFERS | |||
| wgt::Features::PUSH_CONSTANTS; | |||
| wgt::Features::PUSH_CONSTANTS | |||
| wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES; |
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 actually need this feature. I.e. can we pretend it's always supported? On the Web, we can just return the statically known features (until WebGPU gets a proper extension).
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.
That thought crossed my mind as well but what kept me from it is
- (most important) one might develop a cross platform application (e.g. web + desktop) and unknowingly break its portability if this is not an explicit opt-in. Imho a huge selling point of wgpu(-rs) is that it formulates a feature set that will work on a very wide variety of devices
- other things in the limits struct need to be requested explicitly as well and default to the webgpu specification (e.g. how many storage bindings are supported)
- if and when WebGPU gets an extension this may fit more nicely as a "free-for-all tier"
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.
That's a very good point! Ideally I'd love to make it so you can't use a feature that you haven't either discovered or requested. This should apply to format features as well. So what you are saying makes total sense, and is much appreciated!
We can also go a slightly different route and consider the format features to be "basic" unless the user asks for them. This would make the same code portable across the web and non-web.
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.
consider the format features to be "basic" unless the user asks for them
You're thinking that the user can request particular texture features ahead of time? That would make sense in regard to how the limit struct works and keeps all the missing-feature surprises to the device selection rather than some random texture binding.
Or did you mean something else? :)
Otherwise, the way it's done here would already be a manual opt-in by the user, only that it's a bit vague what one ends up with :/
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.
No, I wasn't think about "ahead of time" kind of thing as we do for limits. I was thinking more simple: if the user didn't call get_texture_features
(or whatever it's called), then they can only assume the base guaranteed feature set for this format specifically (and we validate that).
flags |= wgt::TextureFormatFeatureFlags::STORAGE_ATOMICS; | ||
} | ||
// TODO: hal update | ||
//if texture_format_properties.contains(hal::format::ImageFeature::STORAGE_READ_WRITE) { |
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.
can now be implemented thanks to you!
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.
😊
once we managed to upgrade to newest gfx that is :)
+ some cleanup/fix indentations
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 is an autogenerated code review.
Checker summary (by rust_clippy):
The tool has found 82 warnings, 0 errors.
Support for read+write textures is all operational but will always fail validation right now (see commented out code with TODO note in |
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 is an autogenerated code review.
Checker summary (by rust_clippy):
The tool has found 82 warnings, 0 errors.
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.
Very nice, thank you!
bors r+
I was going back and forth on some pieces, thinking if they could be written better... but no, it's all really good 🕶️ . |
1140: Enable storage read/write format feature r=kvark a=Wumpf **Connections** #1112 **Description** Use `wgt::TextureFormatFeatureFlags::STORAGE_READ_WRITE` in `get_texture_format_features`. This has been waiting for a gfx update which was enabled by @elartista 's workaround in #1136 \o/ Co-authored-by: Andreas Reich <[email protected]>
713: Expose texture format feature query (and update to latest wgpu) r=kvark a=Wumpf Exposes texture format feature query from gfx-rs/wgpu#1112 Updating wgpu-core led to breaking change of moving get_swap_chain_preferred_format from device to adapter. Co-authored-by: Andreas Reich <[email protected]>
713: Expose texture format feature query (and update to latest wgpu) r=kvark a=Wumpf Exposes texture format feature query from gfx-rs#1112 Updating wgpu-core led to breaking change of moving get_swap_chain_preferred_format from device to adapter. Co-authored-by: Andreas Reich <[email protected]>
Connections
Draft until gfx-rs/gfx#3559 landed (then update and comment two lines in)
New & improved replacement for #1109
PR for wgpu-rs to be opened once there's some confidence that this is that it should look like. Preview
Description
Adapter exposes now per texture format specific features. Feature struct defined as allowed usages + flags. Flags describe only storage texture usage so far.
Query not used for validation unless
TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES
feature is enabled on a device. Otherwise uses hardcoded feature set guaranteed by webgpu.Storage read/write binding can then be used as a consequence (storage atomic has no effect yet).
Testing
Manual testing with my fluid sim project through wgpu-rs which covers storage r/w for a few different formats and storage in general for formats that don't support this usage by default at all.
Ran tests and a couple of samples to see if anything broke with the feature disabled.