You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
The Vulkan API accepts a lot of
const
pointers to input structure trees, many of which have variable content due to the use of opaquepNext
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 toconst_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.
The text was updated successfully, but these errors were encountered: