136 lines
3.1 KiB
C
136 lines
3.1 KiB
C
#ifndef PIPELINE_H
|
|
#define PIPELINE_H
|
|
|
|
#include "vulkan/vulkan_core.h"
|
|
#include "cglm/types.h"
|
|
#include "vk_mem_alloc.h"
|
|
#include "command.h"
|
|
|
|
typedef struct ComputePipelineStruct {
|
|
VkPipelineLayout layout;
|
|
VkPipeline pipeline;
|
|
} ComputePipeline;
|
|
|
|
typedef struct GraphicsPipelineStruct {
|
|
VkPipelineLayout layout;
|
|
VkPipeline pipeline;
|
|
} GraphicsPipeline;
|
|
|
|
typedef struct ColoredRectStruct {
|
|
vec3 pos;
|
|
vec2 size;
|
|
vec4 color;
|
|
} ColoredRect;
|
|
|
|
typedef struct UIUniformStruct {
|
|
mat4 screen;
|
|
} UIUniform;
|
|
|
|
typedef struct StringStruct {
|
|
vec3 pos;
|
|
vec4 color;
|
|
float size;
|
|
uint32_t offset;
|
|
uint32_t length;
|
|
} String;
|
|
|
|
typedef struct DrawCommandStruct {
|
|
uint32_t index_count;
|
|
uint32_t instance_count;
|
|
uint32_t first_index;
|
|
int32_t vertex_offset;
|
|
uint32_t first_instance;
|
|
} DrawCommand;
|
|
|
|
typedef struct StringPointersStruct {
|
|
VkDeviceAddress strings;
|
|
VkDeviceAddress codes;
|
|
VkDeviceAddress characters;
|
|
VkDeviceAddress draw;
|
|
} StringPointers;
|
|
|
|
typedef struct CharacterStruct {
|
|
vec3 pos;
|
|
vec4 color;
|
|
float size;
|
|
uint32_t code;
|
|
} Character;
|
|
|
|
typedef struct FontUniformStruct {
|
|
uint32_t num_symbols;
|
|
uint32_t width;
|
|
uint32_t height;
|
|
uint32_t space_width;
|
|
VkDeviceAddress symbol_list;
|
|
} FontUniform;
|
|
|
|
typedef struct SymbolInfoStruct {
|
|
uint32_t x;
|
|
uint32_t top;
|
|
uint32_t width;
|
|
} SymbolInfo;
|
|
|
|
typedef struct FontDataStruct {
|
|
FontUniform info;
|
|
uint16_t* codes;
|
|
} FontData;
|
|
|
|
typedef struct FontDescriptorStruct {
|
|
VmaAllocation symbol_memory;
|
|
VmaAllocation uniform_memory;
|
|
VmaAllocation image_memory;
|
|
VkBuffer symbols;
|
|
VkBuffer uniform;
|
|
VkImage image;
|
|
VkImageView view;
|
|
VkSampler sampler;
|
|
VkDescriptorSet set;
|
|
} FontDescriptor;
|
|
|
|
typedef struct UILayerStruct {
|
|
VkBuffer colored_rects;
|
|
uint32_t colored_rect_count;
|
|
|
|
VkBuffer textured_rects;
|
|
uint32_t textured_rect_count;
|
|
VkDescriptorSet textured_rect_descriptor;
|
|
|
|
VkBuffer string_draw;
|
|
VkBuffer string_draw_clear;
|
|
uint32_t chars_size;
|
|
VkBuffer chars;
|
|
VkDeviceAddress string_pointers;
|
|
uint32_t string_count;
|
|
FontDescriptor font;
|
|
} UILayer;
|
|
|
|
struct RectBuffer {
|
|
VkBuffer vertex;
|
|
VkBuffer index;
|
|
|
|
VmaAllocation vertex_memory;
|
|
VmaAllocation index_memory;
|
|
};
|
|
|
|
typedef struct UIContextStruct {
|
|
VkBuffer ui_descriptor_buffer;
|
|
VmaAllocation ui_descriptor_memory;
|
|
VkDescriptorSetLayout ui_descriptor_layout;
|
|
VkDescriptorPool ui_descriptor_pool;
|
|
VkDescriptorSet ui_descriptor_set;
|
|
|
|
VkDescriptorPool font_pool;
|
|
VkDescriptorSetLayout font_layout;
|
|
|
|
struct RectBuffer ui_rect;
|
|
GraphicsPipeline ui_pipeline_rect;
|
|
GraphicsPipeline ui_pipeline_text;
|
|
ComputePipeline ui_compute_text;
|
|
} UIContext;
|
|
|
|
VkResult init_pipelines(VkDevice device, VmaAllocator allocator, VkExtent2D swapchain_extent, vec2 window_scale, VkRenderPass render_pass, Queue transfer_queue, VkCommandPool transfer_pool, UIContext* context);
|
|
|
|
VkResult create_text_descriptor(VkDevice device, VmaAllocator allocator, VkDescriptorSetLayout layout, VkDescriptorPool pool, FontData* font, SymbolInfo* symbols, uint32_t* atlas, VkCommandPool transfer_pool, Queue transfer_queue, FontDescriptor* descriptor);
|
|
|
|
#endif
|