7#include "pipeline_image_texture_map.hpp"
8#include "pipeline_image_page.hpp"
9#include "../required.hpp"
10#include "../color/sfloat_rgba16.hpp"
11#include <vma/vk_mem_alloc.h>
12#include <vulkan/vulkan.hpp>
16class gui_device_vulkan;
17template<
typename T>
class pixel_map;
20namespace tt::pipeline_image {
25 static constexpr int atlasNrHorizontalPages = 16;
26 static constexpr int atlasNrVerticalPages = 16;
27 static constexpr int atlasImageWidth = atlasNrHorizontalPages * Page::widthIncludingBorder;
28 static constexpr int atlasImageHeight = atlasNrVerticalPages * Page::heightIncludingBorder;
29 static constexpr int atlasNrPagesPerImage = atlasNrHorizontalPages * atlasNrVerticalPages;
30 static constexpr int atlasMaximumNrImages = 16;
31 static constexpr int stagingImageWidth = 1024;
32 static constexpr int stagingImageHeight = 1024;
36 vk::ShaderModule vertexShaderModule;
37 vk::ShaderModule fragmentShaderModule;
44 vk::Sampler atlasSampler;
45 vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo;
67 ttlet imageIndex = page.nr / atlasNrPagesPerImage;
68 ttlet pageNrInsideImage = page.nr % atlasNrPagesPerImage;
70 ttlet pageY = pageNrInsideImage / atlasNrVerticalPages;
71 ttlet pageX = pageNrInsideImage % atlasNrVerticalPages;
73 ttlet x = pageX * Page::widthIncludingBorder + Page::border;
74 ttlet y = pageY * Page::heightIncludingBorder + Page::border;
76 return i32x4{narrow_cast<int>(x), narrow_cast<int>(y), narrow_cast<int>(imageIndex), 1};
92 void drawInCommandBuffer(vk::CommandBuffer &commandBuffer);
96 void prepareAtlasForRendering();
100 return getStagingPixelMap().submap({
i32x4::point(0,0), extent});
103 void updateAtlasWithStagingPixelMap(Image
const &image);
107 void addAtlasImage();
A 2D canvas of pixels.
Definition pixel_map.hpp:99
Definition gui_device_vulkan.hpp:23
Definition pipeline_image_device_shared.hpp:24
void freePages(std::vector< Page > const &pages) noexcept
Deallocate pages back to the atlas.
static i32x4 getAtlasPositionFromPage(Page page) noexcept
Definition pipeline_image_device_shared.hpp:66
std::vector< Page > allocatePages(int const nrPages) noexcept
Allocate pages from the atlas.
Image makeImage(i32x4 extent) noexcept
Allocate an image in the atlas.
void destroy(gui_device_vulkan *vulkanDevice)
This is a image that is uploaded into the texture atlas.
Definition pipeline_image_image.hpp:30
Definition pipeline_image_page.hpp:12
Definition pipeline_image_texture_map.hpp:18
A 4D vector.
Definition ivec.hpp:38
static constexpr numeric_array point() noexcept
Get a point at the origin.
Definition numeric_array.hpp:90