TachyonUI 1.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:
42 uint32_t capacity = 4096;
43
44 std::vector<VkDescriptorImageInfo> textures;
45 std::vector<VulkanImage*> owners;
46
49
52 uint64_t Version() const { return m_version; }
53
54 public:
55 void Clear() override;
57 void Remove(tachyon::ImageIndex index) override;
59 bool SetDescriptor(tachyon::ImageIndex index, const VkDescriptorImageInfo& descriptor);
61
62 private:
63 tachyon::ImageIndex Allocate(const VkDescriptorImageInfo& descriptor);
64 bool IsInRange(tachyon::ImageIndex index) const;
65 static uint64_t NextVersion();
66
67 std::vector<tachyon::ImageIndex> m_freeIndices;
68 uint64_t m_version = NextVersion();
69 };
70
71}
The images the shaders can sample, each at an ImageIndex. Implemented by the backend.
Definition gui_image.h:106
An image made by GraphicsContext::CreateImage; the backend defines its contents.
Definition gui_image.h:102
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)
uint32_t capacity
Size of the shader's bindless texture array: the device context's imageSlots once the device is up.
Definition vk_image.h:42
std::vector< VulkanImage * > owners
the image behind each index, or null
Definition vk_image.h:45
void Clear() override
Removes every image, freeing all indices.
void Remove(tachyon::ImageIndex index) override
Frees the index for reuse; the image itself stays.
uint64_t Version() const
Moves on with every change to a slot, never back, and no two sets share one (0 is none): a window fra...
Definition vk_image.h:52
std::vector< VkDescriptorImageInfo > textures
Definition vk_image.h:44
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:89
ImageIndex
Index of an image in the graphics context's image set, as the shaders sample it.
Definition gui_image.h:99
@ UNDEFINED
Definition gui_image.h:90
Definition vk_defaults.h:6
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