Skip to content

Add from_handle constructors for various Vulkan object types. #1935

Open
@Rua

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 be unsafe.
  • Whereas the normal new constructor usually takes a Device and some kind of Info struct, the from_handle constructor would take a Device, a raw handle of the appropriate Ash type, and the Info 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 given Info 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 the Info 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).

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions