2024-10-09 14:31:30 -06:00
|
|
|
#ifndef PIPELINE_H
|
|
|
|
#define PIPELINE_H
|
|
|
|
|
|
|
|
#include "vulkan/vulkan_core.h"
|
|
|
|
#include "cglm/types.h"
|
2024-10-09 20:00:56 -06:00
|
|
|
#include "vk_mem_alloc.h"
|
|
|
|
#include "command.h"
|
2024-10-09 14:31:30 -06:00
|
|
|
|
2024-10-16 20:29:19 -06:00
|
|
|
#include "ft2build.h"
|
|
|
|
#include FT_FREETYPE_H
|
|
|
|
|
2024-10-14 19:42:38 -06:00
|
|
|
typedef struct ComputePipelineStruct {
|
|
|
|
VkPipelineLayout layout;
|
|
|
|
VkPipeline pipeline;
|
|
|
|
} ComputePipeline;
|
|
|
|
|
2024-10-09 14:31:30 -06:00
|
|
|
typedef struct GraphicsPipelineStruct {
|
2024-10-09 20:00:56 -06:00
|
|
|
VkPipelineLayout layout;
|
|
|
|
VkPipeline pipeline;
|
2024-10-09 14:31:30 -06:00
|
|
|
} GraphicsPipeline;
|
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct ColoredRectStruct {
|
2024-10-18 10:02:39 -06:00
|
|
|
vec3 pos;
|
|
|
|
uint32_t padding0;
|
2024-10-09 20:00:56 -06:00
|
|
|
vec2 size;
|
|
|
|
vec4 color;
|
2024-10-13 15:44:33 -06:00
|
|
|
} ColoredRect;
|
2024-10-09 20:00:56 -06:00
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct UIUniformStruct {
|
2024-10-13 14:11:28 -06:00
|
|
|
mat4 screen;
|
2024-10-13 15:44:33 -06:00
|
|
|
} UIUniform;
|
|
|
|
|
2024-10-15 16:14:34 -06:00
|
|
|
typedef struct StringStruct {
|
2024-10-18 10:02:39 -06:00
|
|
|
vec3 pos;
|
|
|
|
uint32_t padding0;
|
2024-10-14 19:42:38 -06:00
|
|
|
vec4 color;
|
2024-10-15 16:14:34 -06:00
|
|
|
float size;
|
2024-10-14 19:42:38 -06:00
|
|
|
uint32_t offset;
|
2024-10-15 16:14:34 -06:00
|
|
|
uint32_t length;
|
|
|
|
} String;
|
2024-10-14 19:42:38 -06:00
|
|
|
|
2024-10-15 11:44:59 -06:00
|
|
|
typedef struct DrawCommandStruct {
|
2024-10-17 15:56:35 -06:00
|
|
|
uint32_t vertex_count;
|
2024-10-15 11:44:59 -06:00
|
|
|
uint32_t instance_count;
|
2024-10-17 15:56:35 -06:00
|
|
|
uint32_t first_vertex;
|
2024-10-15 11:44:59 -06:00
|
|
|
uint32_t first_instance;
|
|
|
|
} DrawCommand;
|
|
|
|
|
2024-10-15 16:14:34 -06:00
|
|
|
typedef struct StringPointersStruct {
|
2024-10-15 00:06:46 -06:00
|
|
|
VkDeviceAddress strings;
|
|
|
|
VkDeviceAddress codes;
|
|
|
|
VkDeviceAddress characters;
|
2024-10-15 11:44:59 -06:00
|
|
|
VkDeviceAddress draw;
|
2024-10-15 16:14:34 -06:00
|
|
|
} StringPointers;
|
2024-10-15 00:06:46 -06:00
|
|
|
|
2024-10-15 16:14:34 -06:00
|
|
|
typedef struct CharacterStruct {
|
2024-10-18 10:02:39 -06:00
|
|
|
vec3 pos;
|
|
|
|
uint32_t padding0;
|
2024-10-13 22:18:37 -06:00
|
|
|
vec4 color;
|
2024-10-14 22:10:14 -06:00
|
|
|
float size;
|
2024-10-13 22:18:37 -06:00
|
|
|
uint32_t code;
|
2024-10-15 16:14:34 -06:00
|
|
|
} Character;
|
2024-10-13 22:18:37 -06:00
|
|
|
|
|
|
|
typedef struct FontUniformStruct {
|
2024-10-14 13:33:14 -06:00
|
|
|
uint32_t num_symbols;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
2024-10-14 14:16:59 -06:00
|
|
|
VkDeviceAddress symbol_list;
|
2024-10-13 22:18:37 -06:00
|
|
|
} FontUniform;
|
|
|
|
|
2024-10-14 13:33:14 -06:00
|
|
|
typedef struct SymbolInfoStruct {
|
2024-10-16 20:29:19 -06:00
|
|
|
int32_t top;
|
|
|
|
uint32_t left;
|
2024-10-14 13:33:14 -06:00
|
|
|
uint32_t width;
|
2024-10-16 20:29:19 -06:00
|
|
|
uint32_t height;
|
|
|
|
uint32_t advance;
|
2024-10-14 13:33:14 -06:00
|
|
|
} SymbolInfo;
|
|
|
|
|
2024-10-18 10:14:12 -06:00
|
|
|
typedef struct FontStorageStruct {
|
2024-10-14 14:59:49 -06:00
|
|
|
VmaAllocation symbol_memory;
|
2024-10-14 01:00:10 -06:00
|
|
|
VmaAllocation uniform_memory;
|
|
|
|
VmaAllocation image_memory;
|
2024-10-14 14:59:49 -06:00
|
|
|
VkBuffer symbols;
|
2024-10-14 01:00:10 -06:00
|
|
|
VkBuffer uniform;
|
|
|
|
VkImage image;
|
|
|
|
VkImageView view;
|
|
|
|
VkSampler sampler;
|
2024-10-18 10:14:12 -06:00
|
|
|
} FontStorage;
|
2024-10-14 01:00:10 -06:00
|
|
|
|
2024-10-17 11:06:09 -06:00
|
|
|
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;
|
|
|
|
|
2024-10-13 15:44:33 -06:00
|
|
|
typedef struct UILayerStruct {
|
2024-10-17 17:31:13 -06:00
|
|
|
VkDeviceAddress colored_rects;
|
|
|
|
uint32_t colored_rect_count;
|
2024-10-13 16:04:12 -06:00
|
|
|
|
2024-10-18 10:14:12 -06:00
|
|
|
VkDeviceAddress textured_rects;
|
|
|
|
uint32_t textured_rect_count;
|
|
|
|
VkDescriptorSet texture_array;
|
|
|
|
|
2024-10-15 16:14:34 -06:00
|
|
|
VkBuffer string_draw;
|
|
|
|
VkBuffer chars;
|
|
|
|
VkDeviceAddress string_pointers;
|
|
|
|
uint32_t string_count;
|
2024-10-17 11:06:09 -06:00
|
|
|
uint32_t chars_count;
|
2024-10-18 10:14:12 -06:00
|
|
|
VkDescriptorSet font;
|
2024-10-13 15:44:33 -06:00
|
|
|
} UILayer;
|
|
|
|
|
2024-10-13 20:27:09 -06:00
|
|
|
typedef struct UIContextStruct {
|
|
|
|
VkBuffer ui_descriptor_buffer;
|
|
|
|
VmaAllocation ui_descriptor_memory;
|
|
|
|
VkDescriptorSetLayout ui_descriptor_layout;
|
|
|
|
VkDescriptorPool ui_descriptor_pool;
|
|
|
|
VkDescriptorSet ui_descriptor_set;
|
|
|
|
|
2024-10-13 22:18:37 -06:00
|
|
|
VkDescriptorPool font_pool;
|
|
|
|
VkDescriptorSetLayout font_layout;
|
2024-10-14 22:10:14 -06:00
|
|
|
|
2024-10-13 20:27:09 -06:00
|
|
|
GraphicsPipeline ui_pipeline_rect;
|
|
|
|
GraphicsPipeline ui_pipeline_text;
|
2024-10-14 19:42:38 -06:00
|
|
|
ComputePipeline ui_compute_text;
|
2024-10-13 20:27:09 -06:00
|
|
|
} UIContext;
|
|
|
|
|
2024-10-17 11:06:09 -06:00
|
|
|
VkResult init_pipelines(
|
|
|
|
VkDevice device,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
VkExtent2D swapchain_extent,
|
|
|
|
vec2 window_scale,
|
|
|
|
VkRenderPass render_pass,
|
|
|
|
UIContext* context);
|
|
|
|
|
|
|
|
VkResult load_font(
|
|
|
|
VkDevice device,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
VkDescriptorSetLayout layout,
|
|
|
|
VkDescriptorPool pool,
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
Queue transfer_queue,
|
|
|
|
FT_Library library,
|
|
|
|
const char* ttf_file,
|
|
|
|
uint32_t size,
|
|
|
|
VkBool32 antialias,
|
|
|
|
uint32_t** charmap,
|
2024-10-18 10:14:12 -06:00
|
|
|
FontStorage* memory,
|
|
|
|
VkDescriptorSet* font);
|
2024-10-17 11:06:09 -06:00
|
|
|
|
|
|
|
VkResult create_text_pointers(
|
|
|
|
uint32_t max_strings,
|
|
|
|
uint32_t max_characters,
|
|
|
|
VkDevice device,
|
|
|
|
VmaAllocator allocator,
|
|
|
|
VkCommandPool transfer_pool,
|
|
|
|
Queue transfer_queue,
|
|
|
|
TextPointersMemory* memory,
|
|
|
|
VkDeviceAddress* address);
|
2024-10-14 01:00:10 -06:00
|
|
|
|
2024-10-09 14:31:30 -06:00
|
|
|
#endif
|