-
Notifications
You must be signed in to change notification settings - Fork 52
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
Store Vulkan device as a reference to avoid huge struct sizes #259
Conversation
Could you provide some context about why this change is required, and required to break backwards compatibility (for example: can't we just put the device in a Box and not have to have the lifetime on Allocator)? |
This change reduces the
It's not required, just a solution to #159.
Wrapping
Unfortunately I'm not sure if we can just wrap it in an
I think references are a good middle-ground between wrapping an Feel free to merge when ash-rs/ash#731 is resolved or even now |
A reference won't work in a self-referential struct. How would we denote the lifetime in this instance? struct Device {
device: ash::Device,
allocator: gpu_allocator::vulkan::Allocator<'self_device>,
} Here This is a very real scenario for implementations and abstractions around Vulkan. |
Hmm, I see. It's either |
If we really want to, we could use a |
Nothing works here. |
I don't think that "nothing works" here, just that whichever way we pick is going to be opinionated unless we allow the user to store any form of enum AshDevice<'a> {
Arc(Arc<ash::Device>),
Box(Box<ash::Device>),
// The below two effectively form a Cow:
Owned(ash::Device),
Borrowed(&'a ash::Device),
} But the caller still has to ensure they free all their allocations and drop their We could also decide to store just Neither do I think that At the same time that design doesn't work at all with the current design of Given your comment above that this is "just a solution to #159", does that mean you are not impacted by this but only wanted to address this because of seeing a "misleadingly trivial" open issue? I think we're all totally open to change our design and approach here to accommodate most usage patterns in an efficient way (also why #260 was opened), but need real-world usage examples to decide which of these many solutions is the right way forward. Thanks for bringing this to our attention once again! |
Unfortunately this change is not backwards compatible.