UgTexture

2D texture loading and descriptor management

It

GPU texture with its image, memory, view, sampler, and descriptor set

struct It {
  VkImage image;
  VkDeviceMemory memory;
  VkImageView view;
  VkSampler sampler;
  VkDescriptorSetLayout setLayout;
  VkDescriptorSet descriptorSet;
};

create

Load a texture from a file and upload it to the GPU

UgTexture.It create(UgContext.It& ctx, const I8* path);

Parameters

  • ctx — Vulkan context
  • path — Path to the image file

Returns — Initialized texture object


createSetLayout

Create the descriptor set layout for a single combined image sampler

VkDescriptorSetLayout createSetLayout(UgContext.It& ctx);

Parameters

  • ctx — Vulkan context

Returns — Descriptor set layout handle


bind

Bind the texture's descriptor set to a pipeline slot

U0 bind(UgTexture.It& texture, UgCommandBuffer.It& cmd, VkPipelineLayout pipelineLayout, U32 slot);

Parameters

  • texture — Texture to bind
  • cmd — Active command buffer
  • pipelineLayout — Pipeline layout the descriptor set is compatible with
  • slot — Descriptor set index (texture slot)

destroy

Destroy the texture and free all GPU resources

U0 destroy(UgContext.It& ctx, UgTexture.It& texture);

Parameters

  • ctx — Vulkan context
  • texture — Texture to destroy