Skip to main content

wrap_image

Function wrap_image 

Source
pub unsafe fn wrap_image(
    device: &Device,
    image: u64,
    width: u32,
    height: u32,
    format: TextureFormat,
) -> Result<Texture, String>
Expand description

The host’s VkImage (a non-dispatchable handle, as u64) as a render attachment of device. format is one format_from_vk accepts and the image’s own; the image was created with VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT at width x height.

Wrap the image again for every frame and drop the texture after submitting: a fresh wrapper makes wgpu assume an undefined layout and discard the old contents, so it never relies on a layout the host moved the image to in between.

§Safety

device comes from open_device; image is a valid image of that VkDevice matching the description above, alive until the work rendering into it has executed.