TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
vk_image.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <vulkan/vulkan.h>
6#include <vk_mem_alloc.h>
7
8#include <cstdint>
9#include <vector>
10
11namespace tachyon::vulkan
12{
15
17 {
18 public:
19 VkImage image;
20 VkImageView imageView;
21 VmaAllocation allocation;
22 VkExtent3D imageExtent;
23 VkFormat imageFormat;
24 VkSampler imageSampler;
25
28 struct Recipe
29 {
30 VkImageUsageFlags usage = 0;
32 bool mipmapped = false;
33 std::vector<uint8_t> pixels;
35 };
36
38 {
39 public:
41 static constexpr uint32_t kCapacity = 256;
42
43 std::vector<VkDescriptorImageInfo> textures;
44 std::vector<VulkanImage*> owners;
45
48
49 public:
50 void Clear() override;
52 void Remove(tachyon::ImageIndex index) override;
54 bool SetDescriptor(tachyon::ImageIndex index, const VkDescriptorImageInfo& descriptor);
56
57 private:
58 tachyon::ImageIndex Allocate(const VkDescriptorImageInfo& descriptor);
59 bool IsInRange(tachyon::ImageIndex index) const;
60
61 std::vector<tachyon::ImageIndex> m_freeIndices;
62 };
63
64}
The images the shaders can sample, each at an ImageIndex. Implemented by the backend.
Definition gui_image.h:44
An image made by GraphicsContext::CreateImage; the backend defines its contents.
Definition gui_image.h:40
Definition vk_image.h:38
tachyon::ImageIndex Add(tachyon::Image *image) override
Adds an image (not owned) and returns its index.
void RefreshDescriptors()
Points every index back at its image, after the images were made again.
tachyon::ImageIndex ReserveIndex()
bool SetImage(tachyon::ImageIndex index, VulkanImage *image)
bool SetDescriptor(tachyon::ImageIndex index, const VkDescriptorImageInfo &descriptor)
std::vector< VulkanImage * > owners
the image behind each index, or null
Definition vk_image.h:44
void Clear() override
Removes every image, freeing all indices.
void Remove(tachyon::ImageIndex index) override
Frees the index for reuse; the image itself stays.
static constexpr uint32_t kCapacity
Size of the shader's bindless texture array.
Definition vk_image.h:41
std::vector< VkDescriptorImageInfo > textures
Definition vk_image.h:43
Definition vk_image.h:17
VkSampler imageSampler
Definition vk_image.h:24
VkFormat imageFormat
Definition vk_image.h:23
VkExtent3D imageExtent
Definition vk_image.h:22
VkImage image
Definition vk_image.h:19
VkImageView imageView
Definition vk_image.h:20
struct tachyon::vulkan::VulkanImage::Recipe recipe
VmaAllocation allocation
Definition vk_image.h:21
Sampler
How an image is filtered and addressed when sampled.
Definition gui_image.h:27
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:37
@ UNDEFINED
Definition gui_image.h:28
Definition vk_defaults.h:4
How it was made, to make it again on a new device after the old one is lost; with its pixels when it ...
Definition vk_image.h:29
std::vector< uint8_t > pixels
Definition vk_image.h:33
VkImageUsageFlags usage
Definition vk_image.h:30
bool mipmapped
Definition vk_image.h:32
tachyon::Sampler sampler
Definition vk_image.h:31