Skip to content
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

Extension structs have lifetimes even when they don't need one #906

Open
Rua opened this issue Apr 14, 2024 · 3 comments
Open

Extension structs have lifetimes even when they don't need one #906

Rua opened this issue Apr 14, 2024 · 3 comments

Comments

@Rua
Copy link
Contributor

Rua commented Apr 14, 2024

Extension structs do contain pointers, but their lifetime cannot ever be used if the only pointer they contain is p_next. Structs like this don't actually borrow anything, all structures in a p_next chain are borrowed by the parent. They have no push_next method, and there are no other methods that return Self with a different lifetime than the input struct. Technically you can set the lifetime using the PhantomData member, but that seems a bit silly and pointless.

Take ExternalMemoryImageCreateInfo for example. It has no methods that borrow data.

@MarijnS95
Copy link
Collaborator

Cross-posting from #969 (comment): I don't think this issue is actionable if we don't want a breaking release any time such a struct starts being referenced in a new structextends. This is much less likely for ExternalMemoryImageCreateInfo given that it is already part of a chain defined by a parent struct, but very possible for "new" parent structs that are defined with pNext up-front with no extensions available right now, but possibility for extensions in future Vulkan releases.

@Ralith
Copy link
Collaborator

Ralith commented Dec 3, 2024

Could we classify structs into "always root" or "always extension" and omit lifetimes from the latter? Not sure Khronos would respect that...

@MarijnS95
Copy link
Collaborator

I doubt they would want to commit to that, but we could try.

I have no reason to pursue this (kept it out of the 0.39 milestone) as it's very easy to represent with 'static lifetime in user code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants