HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Data Fields | Static Public Attributes
tt::PipelineSDF::DeviceShared Struct Referencefinal

Public Member Functions

 DeviceShared (GUIDevice const &device)
 
 DeviceShared (DeviceShared const &)=delete
 
DeviceSharedoperator= (DeviceShared const &)=delete
 
 DeviceShared (DeviceShared &&)=delete
 
DeviceSharedoperator= (DeviceShared &&)=delete
 
void destroy (GUIDevice *vulkanDevice)
 
AtlasRect allocateRect (vec drawExtent) noexcept
 Allocate an glyph in the atlas.
 
void drawInCommandBuffer (vk::CommandBuffer &commandBuffer)
 
void uploadStagingPixmapToAtlas (AtlasRect location)
 Once drawing in the staging pixmap is completed, you can upload it to the atlas.
 
void prepareStagingPixmapForDrawing ()
 This will transition the staging texture to 'general' for writing by the CPU.
 
void prepareAtlasForRendering ()
 This will transition the atlas to 'shader-read'.
 
void prepareAtlas (ShapedText const &text) noexcept
 Prepare the atlas for drawing a text.
 
void placeVertices (vspan< Vertex > &vertices, FontGlyphIDs const &glyphs, rect box, vec color, aarect clippingRectangle) noexcept
 Place vertices for a single glyph.
 
void placeVertices (vspan< Vertex > &vertices, ShapedText const &text, mat transform, aarect clippingRectangle) noexcept
 Draw the text on the screen.
 
void placeVertices (vspan< Vertex > &vertices, ShapedText const &text, mat transform, aarect clippingRectangle, vec color) noexcept
 Draw the text on the screen.
 

Static Public Member Functions

static aarect getBoundingBox (FontGlyphIDs const &glyphs) noexcept
 Get the bounding box, including draw border of a glyph.
 

Data Fields

GUIDevice const & device
 
vk::ShaderModule vertexShaderModule
 
vk::ShaderModule fragmentShaderModule
 
SpecializationConstants specializationConstants
 
std::vector< vk::SpecializationMapEntry > fragmentShaderSpecializationMapEntries
 
vk::SpecializationInfo fragmentShaderSpecializationInfo
 
std::vector< vk::PipelineShaderStageCreateInfo > shaderStages
 
std::unordered_map< FontGlyphIDs, AtlasRectglyphs_in_atlas
 
TextureMap stagingTexture
 
std::vector< TextureMapatlasTextures
 
std::array< vk::DescriptorImageInfo, atlasMaximumNrImages > atlasDescriptorImageInfos
 
vk::Sampler atlasSampler
 
vk::DescriptorImageInfo atlasSamplerDescriptorImageInfo
 
ivec atlasAllocationPosition = {}
 
int atlasAllocationMaxHeight = 0
 During allocation on a row, we keep track of the tallest glyph.
 

Static Public Attributes

static constexpr int atlasImageWidth = 1024
 
static constexpr int atlasImageHeight = 1024
 
static constexpr int atlasMaximumNrImages = 16
 
static constexpr int stagingImageWidth = 128
 
static constexpr int stagingImageHeight = 128
 
static constexpr float atlasTextureCoordinateMultiplier = 1.0f / atlasImageWidth
 
static constexpr float drawFontSize = 28.0f
 
static constexpr float drawBorder = SDF8::max_distance
 
static constexpr float scaledDrawBorder = drawBorder / drawFontSize
 

Member Function Documentation

◆ allocateRect()

AtlasRect tt::PipelineSDF::DeviceShared::allocateRect ( vec drawExtent)
noexcept

Allocate an glyph in the atlas.

This may allocate an atlas texture, up to atlasMaximumNrImages.

◆ destroy()

void tt::PipelineSDF::DeviceShared::destroy ( GUIDevice * vulkanDevice)

Deallocate vulkan resources. This is called in the destructor of GUIDevice_vulkan, therefor we can not use our std::weak_ptr<GUIDevice_vulkan> device.

◆ getBoundingBox()

static aarect tt::PipelineSDF::DeviceShared::getBoundingBox ( FontGlyphIDs const & glyphs)
staticnoexcept

Get the bounding box, including draw border of a glyph.

◆ placeVertices() [1/3]

void tt::PipelineSDF::DeviceShared::placeVertices ( vspan< Vertex > & vertices,
FontGlyphIDs const & glyphs,
rect box,
vec color,
aarect clippingRectangle )
noexcept

Place vertices for a single glyph.

Parameters
verticesThe list of vertices to add to.
glyphsThe font-id, composed-glyphs to render
boxThe rectangle of the glyph in window coordinates; including the draw border.
colorThe color of the glyph.
clippingRectangleThe rectangle to clip the glyph.

◆ placeVertices() [2/3]

void tt::PipelineSDF::DeviceShared::placeVertices ( vspan< Vertex > & vertices,
ShapedText const & text,
mat transform,
aarect clippingRectangle )
noexcept

Draw the text on the screen.

Parameters
textThe box of text to draw
transformThe 2D transformation to move and rotate the box to the correct position on screen.
clippingRectangleThe clipping rectangle in screen space where glyphs should be cut off.
verticesThe vertices to draw the glyphs to.

◆ placeVertices() [3/3]

void tt::PipelineSDF::DeviceShared::placeVertices ( vspan< Vertex > & vertices,
ShapedText const & text,
mat transform,
aarect clippingRectangle,
vec color )
noexcept

Draw the text on the screen.

Parameters
textThe box of text to draw
transformThe 2D transformation to move and rotate the box to the correct position on screen.
clippingRectangleThe clipping rectangle in screen space where glyphs should be cut off.
verticesThe vertices to draw the glyphs to.
colorOverride the color of the text to draw.

◆ prepareAtlas()

void tt::PipelineSDF::DeviceShared::prepareAtlas ( ShapedText const & text)
noexcept

Prepare the atlas for drawing a text.

◆ prepareAtlasForRendering()

void tt::PipelineSDF::DeviceShared::prepareAtlasForRendering ( )

This will transition the atlas to 'shader-read'.

◆ prepareStagingPixmapForDrawing()

void tt::PipelineSDF::DeviceShared::prepareStagingPixmapForDrawing ( )

This will transition the staging texture to 'general' for writing by the CPU.

◆ uploadStagingPixmapToAtlas()

void tt::PipelineSDF::DeviceShared::uploadStagingPixmapToAtlas ( AtlasRect location)

Once drawing in the staging pixmap is completed, you can upload it to the atlas.

This will transition the stating texture to 'source' and the atlas to 'destination'.

Field Documentation

◆ atlasAllocationMaxHeight

int tt::PipelineSDF::DeviceShared::atlasAllocationMaxHeight = 0

During allocation on a row, we keep track of the tallest glyph.


The documentation for this struct was generated from the following file: