Add from_handle
constructors for various Vulkan object types. #1935
Open
Description
On Discord, a wish was expressed for the ability to create Vulkano types from raw Vulkan object handles (whose types are defined by Ash). Although there are many object types to implement this for, I think this would be relatively easy for new contributors to implement. Some implementation guidelines:
- The new constructor, I'm naming it
from_handle
for the moment, should beunsafe
. - Whereas the normal
new
constructor usually takes aDevice
and some kind ofInfo
struct, thefrom_handle
constructor would take aDevice
, a raw handle of the appropriate Ash type, and theInfo
struct. - The function must have a
# Safety
header explaining that the handle must be a valid Vulkan object handle, must be created from the given device, and that the parameters in the givenInfo
struct must match those that were previously used to create the handle. - Because the handle is assumed to be already valid, little to no validation will be needed inside
from_handle
. The data in theInfo
struct could probably just be moved into the Vulkano type without any checks.
If anyone wants to try implementing this, but is unsure about the number of changes required, you can start by implementing it only for a single, not too complex type (e.g. Sampler
, QueryPool
).