#ifndef PIPELINE_H #define PIPELINE_H #include "vulkan/vulkan_core.h" #include "cglm/types.h" #include "vk_mem_alloc.h" #include "command.h" #include "ft2build.h" #include FT_FREETYPE_H typedef struct ComputePipelineStruct { VkPipelineLayout layout; VkPipeline pipeline; } ComputePipeline; typedef struct GraphicsPipelineStruct { VkPipelineLayout layout; VkPipeline pipeline; } GraphicsPipeline; typedef struct UIRectStruct { vec3 pos; float pad0; vec2 size; vec4 color; } UIRect; typedef struct StringStruct { vec3 pos; float pad0; vec4 color; float size; uint32_t offset; uint32_t length; } String; typedef struct DrawCommandStruct { uint32_t vertex_count; uint32_t instance_count; uint32_t first_vertex; uint32_t first_instance; } DrawCommand; typedef struct DispatchCommandStruct { uint32_t x; uint32_t y; uint32_t z; } DispatchCommand; typedef struct CharacterStruct { vec3 pos; float pad0; vec4 color; float size; uint32_t code; } Character; typedef struct FontStruct { uint32_t num_symbols; uint32_t width; uint32_t height; VkDeviceAddress symbol_list; } Font; typedef struct SymbolInfoStruct { int32_t top; uint32_t left; uint32_t width; uint32_t height; uint32_t advance; } SymbolInfo; typedef struct FontStorageStruct { VmaAllocation symbol_memory; VmaAllocation image_memory; VkBuffer symbols; VkImage image; VkImageView view; VkSampler sampler; uint32_t index; } FontStorage; typedef struct TextPointersMemoryStruct { VmaAllocation pointers_memory; VmaAllocation draw_memory; VmaAllocation strings_memory; VmaAllocation codes_memory; VmaAllocation characters_memory; VkBuffer pointers_buffer; VkBuffer draw_buffer; VkBuffer strings_buffer; VkBuffer codes_buffer; VkBuffer characters_buffer; } TextPointersMemory; typedef struct UIlayerStorageStruct { VkBuffer strings; VkBuffer chars; VkBuffer codes; VkBuffer rects; VkBuffer layer; VmaAllocation strings_memory; VmaAllocation rects_memory; VmaAllocation chars_memory; VmaAllocation codes_memory; VmaAllocation layer_memory; VkDeviceAddress address; } UILayerStorage; typedef struct UILayerStruct { VkDeviceAddress rects; uint32_t rect_count; VkDeviceAddress strings; uint32_t font_index; DrawCommand draw_chars; DrawCommand draw_rects; DispatchCommand dispatch_strings; } UILayer; typedef struct UIContextStruct { mat4 screen; VkDeviceAddress font_infos; } UIContext; typedef struct UIContextStorageStruct { VkDeviceAddress address; VkBuffer context; VmaAllocation context_memory; VkBuffer font_infos; VmaAllocation font_infos_memory; VkDescriptorSet font_samplers; VkDescriptorSet font_textures; VkDescriptorSetLayout font_samplers_layout; VkDescriptorSetLayout font_textures_layout; VkDescriptorPool fonts_pool; GraphicsPipeline rect_pipeline; GraphicsPipeline char_pipeline; ComputePipeline string_pipeline; } UIContextStorage; VkResult create_ui_context( VkDevice device, VmaAllocator allocator, VkRenderPass render_pass, UIContextStorage* memory); VkResult load_font( VkDevice device, VmaAllocator allocator, VkBuffer font_infos, VkDescriptorSet font_samplers, VkDescriptorSet font_textures, uint32_t last_index, VkCommandPool transfer_pool, Queue transfer_queue, FT_Library library, const char* ttf_file, uint32_t size, VkBool32 antialias, uint32_t** charmap, FontStorage* memory); VkResult create_layer( uint32_t max_strings, uint32_t max_characters, uint32_t max_rects, VkDevice device, VmaAllocator allocator, VkCommandPool transfer_pool, Queue transfer_queue, UILayerStorage* memory, VkDeviceAddress* address); #endif