-
Notifications
You must be signed in to change notification settings - Fork 953
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
Validate bind group layouts by value instead of "by ID" #335
Comments
I'd like to tackle this. I'll post updates/questions in this thread. |
Okay, I think I've got a really rough version implemented. Since this relaxes the current constraints, I need to write some tests that to be more sure I didn't do something totally terrible - the current examples working doesn't prove anything. While implementing, I of course ran into things I'd like to understand a bit better: The Hub Access DAG I understand this is meant to prevent deadlocks by only allowing the programmer to access subsequent nodes in the graph, based on what was previously accessed, but I am unsure whether the current code enforces this. Because the registry methods don't consume the token and only take it by // This is not prevented currently
let (mut pass_guard, _) = hub.render_passes.write(&mut token);
// ... possibly somewhere else in code ...
let (mut pass_guard2, _) = hub.render_passes.write(&mut token); I this could be made more difficult to accidentally violate by always consuming the access token, modifying its drop impl, and providing a method for transitioning a general token into a more specific one. The token would probably need to store the count by which to decrement the Bind Group Layout Compatibility What does it mean for two Bind Group Layouts to be compatible? I currently assume they are compatible iff their I also do have a couple of more specific, implementation questions:
I will publish a draft PR soon. |
They borrow the token mutably, which means you can't have two storages accessed using the same token at the same time. In your example, either the first guard gets dropped before the second one is acquired, or the compiler will yell at you.
That's good for now. We can come back to this later.
Yes, it's ok and useful.
It sounds fine, we'll get to this when your PR is reviewed. |
I see your point and it indeed should prevent 2 borrows, but the current implementation doesn't. You can borrow two guards and deadlock with the current API, one doesn't even have to explicitly drop the tokens like I did in the above snippet. I think this is because the input lifetime of the token is not tied to the output lifetime of either the token or the lock guard. I experimented by modifying the However, even with my tweak, if you explicitly drop the tokens (but not the guards) returned from I think this could be possible to solve on the type level, but I realize this is all really academical and only concerns an internal API, so I understand if we don't want to spend more time on this 😄
Yeah, I just realized the |
400: Validate bind group layouts by value r=kvark a=yanchith This PR widens the comparisons done between two bind group layouts to also consider them equivalent if their vectors of `BindGroupLayoutBinding`s are equal. Tested on various modifications of the cube example from wgpu-rs. https://gist.github.com/yanchith/56e15fe35658b14587ff9bfcbd53116f Fixes #335 Co-authored-by: yanchith <yanchi.toth@gmail.com>
We had to disable that for now: wgpu/wgpu-core/src/device/mod.rs Line 882 in e39aaa9
|
753: Deduplicate BindGroupLayout by value r=cwfitzgerald a=kvark **Connections** Fixes #335 **Description** BGL now has distinct `MultiRefCount` type with a bit of a hacky logic to support deduplication. Good review is needed! **Testing** Ran wgpu-rs examples. The actual new logic is NOT tested enough! Co-authored-by: Dzmitry Malyshau <kvarkus@gmail.com>
* Enable X11 in Vulkan * Fix Cargo comments
The upstream WebGPU spec is written (currently in the discussion logs, not yet in the actual spec) in a way that makes two bind group layouts interchangeable as long as the content passed into their creation is exactly the same ("by value" semantics). This also matches all the low-level APIs behavior.
We need to change our validation rules to compare them by value instead of by ID.
The text was updated successfully, but these errors were encountered: