7#include "pipeline_SDF_texture_map.hpp"
8#include "pipeline_SDF_specialization_constants.hpp"
9#include "../text/glyph_ids.hpp"
10#include "../text/glyph_atlas_info.hpp"
13#include "../vector_span.hpp"
14#include "../geometry/rectangle.hpp"
15#include "../geometry/scale.hpp"
16#include "../geometry/transform.hpp"
17#include "../color/quad_color.hpp"
18#include <vma/vk_mem_alloc.h>
19#include <vulkan/vulkan.hpp>
21#include <unordered_map>
23namespace hi::inline
v1 {
27class gfx_device_vulkan;
28struct attributed_glyph;
30namespace pipeline_SDF {
41 static constexpr int atlasImageWidth = 256;
42 static constexpr int atlasImageHeight = 256;
43 static_assert(atlasImageWidth == atlasImageHeight,
"needed for fwidth(textureCoord)");
45 static constexpr int atlasMaximumNrImages = 128;
46 static constexpr int stagingImageWidth = 64;
47 static constexpr int stagingImageHeight = 64;
49 static constexpr float atlasTextureCoordinateMultiplier = 1.0f / atlasImageWidth;
50 static constexpr float drawfontSize = 28.0f;
51 static constexpr float drawBorder = sdf_r8::max_distance;
52 static constexpr float scaledDrawBorder = drawBorder / drawfontSize;
56 vk::ShaderModule vertexShaderModule;
57 vk::ShaderModule fragmentShaderModule;
61 vk::SpecializationInfo fragmentShaderSpecializationInfo;
68 vk::Sampler atlasSampler;
69 vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo;
71 point3 atlas_allocation_position = {};
73 int atlasAllocationMaxHeight = 0;
94 void drawInCommandBuffer(vk::CommandBuffer &commandBuffer);
125 aarectangle
const &clipping_rectangle,
133 void addAtlasImage();
143 auto &info = glyph.atlas_info();
145 if (info) [[likely]] {
146 return {&info,
false};
149 add_glyph_to_atlas(glyph, info);
150 return {&info,
true};
Utilities used by the HikoGUI library itself.
DOXYGEN BUG.
Definition algorithm.hpp:15
Definition quad_color.hpp:12
Definition gfx_device_vulkan.hpp:21
Definition pipeline_SDF_device_shared.hpp:34
void destroy(gfx_device_vulkan *vulkanDevice)
void prepareStagingPixmapForDrawing()
This will transition the staging texture to 'general' for writing by the CPU.
glyph_atlas_info allocate_rect(extent2 draw_extent, scale2 draw_scale) noexcept
Allocate an glyph in the atlas.
aarectangle get_bounding_box(glyph_ids const &glyphs) const noexcept
Get the bounding box, including draw border of a glyph.
bool place_vertices(vector_span< vertex > &vertices, aarectangle const &clipping_rectangle, quad const &box, glyph_ids const &glyphs, quad_color colors) noexcept
Place vertices for a single glyph.
void uploadStagingPixmapToAtlas(glyph_atlas_info const &location)
Once drawing in the staging pixmap is completed, you can upload it to the atlas.
void prepare_atlas_for_rendering()
This will transition the atlas to 'shader-read'.
Definition pipeline_SDF_specialization_constants.hpp:12
Definition pipeline_SDF_texture_map.hpp:17
Definition glyph_atlas_info.hpp:15
A set of glyph-ids of a font which composites into a single glyph.
Definition glyph_ids.hpp:135
Definition vector_span.hpp:134