Struct ImageBuilder

Inheritance Relationships

Base Type

Struct Documentation

struct ImageBuilder : public portal::renderer::vulkan::BuilderBase<ImageBuilder, vk::ImageCreateInfo>

Builder for creating VMA-allocated Vulkan images.

Inherits common VMA options from BuilderBase. Extent is required at construction. Supports 1D, 2D, and 3D images with configurable format, mip levels, array layers, etc.

Usage:

auto image = ImageBuilder(vk::Extent2D{1024, 1024})
    .with_format(vk::Format::eR8G8B8A8Unorm)
    .with_usage(vk::ImageUsageFlagBits::eSampled | vk::ImageUsageFlagBits::eTransferDst)
    .with_mips_levels(mip_count)
    .build(device);

Public Functions

explicit ImageBuilder(const vk::Extent3D &extent)

Constructs image builder with 3D extent.

Parameters:

extentImage extent (width, height, depth)

explicit ImageBuilder(const vk::Extent2D &extent)

Constructs image builder with 2D extent.

Parameters:

extentImage extent (width, height)

explicit ImageBuilder(size_t width, size_t height = 1, size_t depth = 1)

Constructs image builder with dimensions.

Parameters:
  • widthImage width

  • heightImage height (default 1)

  • depthImage depth (default 1)

ImageBuilder &with_format(vk::Format format)

Sets image format.

Parameters:

formatImage format (eR8G8B8A8Unorm, eD32Sfloat, etc.)

Returns:

Reference to this builder

ImageBuilder &with_image_type(vk::ImageType type)

Sets image type.

Parameters:

typeImage type (e1D, e2D, e3D)

Returns:

Reference to this builder

ImageBuilder &with_array_layers(size_t layers)

Sets array layer count.

Parameters:

layers – Number of array layers

Returns:

Reference to this builder

ImageBuilder &with_mips_levels(size_t levels)

Sets mip level count.

Parameters:

levels – Number of mip levels

Returns:

Reference to this builder

ImageBuilder &with_sample_count(vk::SampleCountFlagBits sample_count)

Sets sample count (for MSAA)

Parameters:

sample_count – Sample count (e1, e2, e4, e8, etc.)

Returns:

Reference to this builder

ImageBuilder &with_tiling(vk::ImageTiling tiling)

Sets image tiling mode.

Parameters:

tiling – Tiling mode (eOptimal or eLinear)

Returns:

Reference to this builder

ImageBuilder &with_usage(vk::ImageUsageFlags usage)

Sets image usage flags.

Parameters:

usage – Usage flags (eSampled, eStorage, eColorAttachment, etc.)

Returns:

Reference to this builder

ImageBuilder &with_flags(vk::ImageCreateFlags flags)

Sets image create flags.

Parameters:

flags – Create flags (eCubeCompatible, eMutableFormat, etc.)

Returns:

Reference to this builder

ImageAllocation build(const VulkanDevice &device) const

Creates ImageAllocation.

Parameters:

device – The Vulkan device

Returns:

ImageAllocation with VMA-allocated memory