Module vulkano::image

source ·
Expand description

Image storage (1D, 2D, 3D, arrays, etc.) and image views.

An image is a region of memory whose purpose is to store multi-dimensional data. Its most common use is to store a 2D array of color pixels (in other words an image in everyday language), but it can also be used to store arbitrary data.

The advantage of using an image compared to a buffer is that the memory layout is optimized for locality. When reading a specific pixel of an image, reading the nearby pixels is really fast. Most implementations have hardware dedicated to reading from images if you access them through a sampler.

Properties of an image

TODO

Images and image views

There is a distinction between images and image views. As its name suggests, an image view describes how the GPU must interpret the image.

Transfer and memory operations operate on images themselves, while reading/writing an image operates on image views. You can create multiple image views from the same image.

High-level wrappers

In the vulkano library, images that have memory bound to them are represented by Image. You can create an Image directly by providing a memory allocator and all the info for the image and allocation you want to create. This should satisify most use cases. The more low-level use cases such as importing memory for the image are described below.

You can create an ImageView from any Image.

Low-level information

RawImage is the low-level wrapper around a VkImage, which has no memory bound to it. You can create a RawImage similarly to Image except that you don’t provide any info about the allocation. That way, you can bind memory to it however you wish, including:

You can create a ResourceMemory from DeviceMemory if you want to bind its own block of memory to an image.

Re-exports

Modules

  • How to retrieve data from a sampled image within a shader.
  • Low-level implementation of images.
  • Image views.

Structs

Enums

Functions

  • Returns the maximum number of mipmap levels for the given image extent.
  • Returns the extent of the levelth mipmap level. If level is 0, then it returns extent back unchanged.