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

Create generic structure tree cloner #56

Open
solidpixel opened this issue Jan 23, 2025 · 0 comments
Open

Create generic structure tree cloner #56

solidpixel opened this issue Jan 23, 2025 · 0 comments
Assignees

Comments

@solidpixel
Copy link
Contributor

solidpixel commented Jan 23, 2025

The Vulkan API accepts a lot of const pointers to input structure trees, many of which have variable content due to the use of opaque pNext pointers to support extensions. Layers often want to change input data before calling down the stack, and the quick and dirty way to do this quickly is just to const_cast the inputs and modify in place. This usually works, and has low overhead, but is obviously violating the API contract with the application and applications that reuse structures on the assumption that they are immutable will get unexpected behavior.

The right solution here is for the layer to clone the input structure tree that it wants to modify, so that it actually owns the memory that it is modifying and knows that it is writable. TO support this we should provide a common utility module that can clone an API structure tree, with managed memory lifetime of the clone. I suspect that this module will need to be hand-written because the needs of the clone are going to be structure dependent.

We should also provide a generic search utility that will return a correctly typed pointer to a structure in the pNext chain.

@solidpixel solidpixel self-assigned this Jan 23, 2025
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

1 participant