diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-28 22:33:58 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-28 22:33:58 -0500 |
| commit | 37347bf7811a5fa42c98e2a19adfee15252ee479 (patch) | |
| tree | 70fe178ad777f52404f51b90c06b8d14ef101276 | |
| parent | 85bbecbdebf4f096418aea1cd4f9616f9d97e451 (diff) | |
pke: checkpoint: vk renames + first-pass ui
Renamed pipeline and descriptor names to be more
self-descriptive.
UI work is not done, and will not record.
Needs vulkan items created (buffers).
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | assets/shaders/glyph.vert | 2 | ||||
| -rw-r--r-- | assets/shaders/ui-base.frag | 23 | ||||
| -rw-r--r-- | assets/shaders/ui-base.vert | 30 | ||||
| -rw-r--r-- | src/asset-manager.cpp | 4 | ||||
| -rw-r--r-- | src/asset-manager.hpp | 2 | ||||
| -rw-r--r-- | src/components-vk.hpp | 13 | ||||
| -rw-r--r-- | src/components.hpp | 7 | ||||
| -rw-r--r-- | src/entities.cpp | 6 | ||||
| -rw-r--r-- | src/font.cpp | 2 | ||||
| -rw-r--r-- | src/static-ui.cpp | 200 | ||||
| -rw-r--r-- | src/static-ui.hpp | 62 | ||||
| -rw-r--r-- | src/window.cpp | 230 | ||||
| -rw-r--r-- | src/window.hpp | 20 |
14 files changed, 541 insertions, 63 deletions
@@ -50,6 +50,7 @@ SRC = \ src/project-settings.cpp \ src/static-cube.cpp \ src/static-plane.cpp \ + src/static-ui.cpp \ src/thread-pool.cpp \ src/vendor-cgltf-include.cpp \ src/vendor-stb-image-include.c \ @@ -63,6 +64,8 @@ DST_SHADERS = \ $(DIR_OBJ)/shaders/present.frag.spv \ $(DIR_OBJ)/shaders/glyph.vert.spv \ $(DIR_OBJ)/shaders/glyph.frag.spv \ + $(DIR_OBJ)/shaders/ui-base.vert.spv \ + $(DIR_OBJ)/shaders/ui-base.frag.spv \ SRC_C = $(filter %.c,$(SRC)) SRC_CXX = $(filter %.cpp,$(SRC)) diff --git a/assets/shaders/glyph.vert b/assets/shaders/glyph.vert index a2c7de3..3f4b28a 100644 --- a/assets/shaders/glyph.vert +++ b/assets/shaders/glyph.vert @@ -23,7 +23,7 @@ out gl_PerVertex vec4 gl_Position; }; -void main() +void main() { vec4 transformed_position = pos_scale * vec4(in_position, 0.0, 1.0); gl_Position = vec4(transformed_position.xy, 0.0, 1.0); diff --git a/assets/shaders/ui-base.frag b/assets/shaders/ui-base.frag new file mode 100644 index 0000000..d6a9882 --- /dev/null +++ b/assets/shaders/ui-base.frag @@ -0,0 +1,23 @@ +# version 450 + +layout(location = 0) in vec4 in_border_color; +layout(location = 1) in vec4 in_background_color; +layout(location = 2) in vec2 in_px_scale; +layout(location = 3) in vec2 in_uv; + +layout(location = 0) out vec4 out_color; + +bool is_in_border() { + return in_uv.x <= in_px_scale.x + || in_uv.x >= 1.0-in_px_scale.x + || in_uv.y <= in_px_scale.x + || in_uv.y >= 1.0-in_px_scale.x; +} + +void main() { + if (is_in_border()) { + out_color = in_border_color; + } else { + out_color = in_background_color; + } +} diff --git a/assets/shaders/ui-base.vert b/assets/shaders/ui-base.vert new file mode 100644 index 0000000..458d599 --- /dev/null +++ b/assets/shaders/ui-base.vert @@ -0,0 +1,30 @@ +#version 450 + +// vertex +layout(location = 0) in vec2 in_position; +layout(location = 1) in vec2 in_uv; + +// instance +layout(location = 2) in mat4 pos_scale; +layout(location = 6) in vec2 px_scale; +layout(location = 7) in float depth; + +layout(location = 0) out vec4 out_border_color; +layout(location = 1) out vec4 out_background_color; +layout(location = 2) out vec2 out_px_scale; +layout(location = 3) out vec2 out_uv; + +out gl_PerVertex +{ + vec4 gl_Position; +}; + +void main() +{ + vec4 transformed_position = pos_scale * vec4(in_position, 0.0, 1.0); + gl_Position = vec4(transformed_position.xy, depth, 1.0); + out_border_color = vec4(0.8, 0.8, 0.8, 1.0); + out_background_color = vec4(0.2, 0.3, 0.2, 1.0); + out_px_scale = px_scale; + out_uv = in_uv; +} diff --git a/src/asset-manager.cpp b/src/asset-manager.cpp index f127024..2976643 100644 --- a/src/asset-manager.cpp +++ b/src/asset-manager.cpp @@ -22,6 +22,8 @@ AssetKey EngineDefinedAssets[EngineDefinedAssetCount] = { "pke_txtr_frg\0\0\0", "pke_glyph_vrt\0\0", "pke_glyph_frg\0\0", + "pke_ui_bs_vrt\0\0", + "pke_ui_bs_frg\0\0", }; void AM_Init() { @@ -33,6 +35,8 @@ void AM_Init() { AM_Register(EngineDefinedAssets[3], PKE_ASSET_TYPE_SHADER, "assets/shaders/texture.frag.spv"); AM_Register(EngineDefinedAssets[4], PKE_ASSET_TYPE_SHADER, "assets/shaders/glyph.vert.spv"); AM_Register(EngineDefinedAssets[5], PKE_ASSET_TYPE_SHADER, "assets/shaders/glyph.frag.spv"); + AM_Register(EngineDefinedAssets[6], PKE_ASSET_TYPE_SHADER, "assets/shaders/ui-base.vert.spv"); + AM_Register(EngineDefinedAssets[7], PKE_ASSET_TYPE_SHADER, "assets/shaders/ui-base.frag.spv"); } void AM_Load_Task(Asset &asset) { diff --git a/src/asset-manager.hpp b/src/asset-manager.hpp index 42cf423..ec98d08 100644 --- a/src/asset-manager.hpp +++ b/src/asset-manager.hpp @@ -29,7 +29,7 @@ const AssetType PKE_ASSET_TYPE_AUDIO = AssetType {0x08}; const AssetType PKE_ASSET_TYPE_FONT = AssetType {0x10}; const AssetType PKE_ASSET_TYPE_ALL = AssetType {0xFF}; -constexpr int64_t EngineDefinedAssetCount = 6; +constexpr int64_t EngineDefinedAssetCount = 8; extern AssetKey EngineDefinedAssets[EngineDefinedAssetCount]; struct Asset { diff --git a/src/components-vk.hpp b/src/components-vk.hpp new file mode 100644 index 0000000..f81462a --- /dev/null +++ b/src/components-vk.hpp @@ -0,0 +1,13 @@ +#ifndef PKE_COMPONENTS_VK_HPP +#define PKE_COMPONENTS_VK_HPP + +#include <vulkan/vulkan_core.h> + +struct BufferBindingDetails { + VkBuffer buffer = VK_NULL_HANDLE; + uint32_t firstBinding = 0; + uint32_t bindingCount = 0; + VkDeviceSize offsets[1] = {0}; +}; + +#endif /* PKE_COMPONENTS_VK_HPP */ diff --git a/src/components.hpp b/src/components.hpp index cf86099..b587fcc 100644 --- a/src/components.hpp +++ b/src/components.hpp @@ -1,6 +1,7 @@ #ifndef PKE_COMPONENTS_HPP #define PKE_COMPONENTS_HPP +#include "components-vk.hpp" #include "pk.h" #include "physics.hpp" #include "plugin-types.hpp" @@ -26,12 +27,6 @@ struct Entity_Base { bool isMarkedForRemoval = false; }; -struct BufferBindingDetails { - VkBuffer buffer = VK_NULL_HANDLE; - uint32_t firstBinding = 0; - uint32_t bindingCount = 0; - VkDeviceSize offsets[1] = {0}; -}; struct CompGrBinds { EntityHandle entHandle = EntityHandle_MAX; GrBindsHandle grBindsHandle = GrBindsHandle_MAX; diff --git a/src/entities.cpp b/src/entities.cpp index 10a1168..10974f8 100644 --- a/src/entities.cpp +++ b/src/entities.cpp @@ -198,7 +198,7 @@ void EntityType_Inner_UpdateDescriptorSets(EntityType *et) { VkDescriptorSetLayout *descriptorSets = pk_new<VkDescriptorSetLayout>(swapchainLength, pkeSettings.mem.bkt); for (long i = 0; i < swapchainLength; ++i) { - descriptorSets[i] = pkePipelines.descr_layouts.named.texture; + descriptorSets[i] = pkePipelines.descr_layouts.named.ubo_txtr; } VkDescriptorSetAllocateInfo vkDescriptorSetAllocateInfo; @@ -1096,8 +1096,8 @@ void EntityType_Load(EntityType &et) { * I don't like that we're just copying this. * This should be moved to window.cpp. */ - etdHelper.etd->grBinds->vkPipelineLayout = pkePipelines.pipe_layouts.named.texture; - etdHelper.etd->grBinds->graphicsPipeline = pkePipelines.pipelines.named.texture; + etdHelper.etd->grBinds->vkPipelineLayout = pkePipelines.pipe_layouts.named.ubo_txtr; + etdHelper.etd->grBinds->graphicsPipeline = pkePipelines.pipelines.named.entity_standard; // handle texture EntityType_LoadTexture(helper, i); diff --git a/src/font.cpp b/src/font.cpp index ba3008a..6a94d03 100644 --- a/src/font.cpp +++ b/src/font.cpp @@ -958,7 +958,7 @@ FontTypeIndex FontType_RegisterFont(pk_cstr title, AssetHandle fontTextureHandle vkDescriptorSetAllocateInfo.pNext = nullptr; vkDescriptorSetAllocateInfo.descriptorPool = ft->gr.vkDescriptorPool; vkDescriptorSetAllocateInfo.descriptorSetCount = (uint32_t)1; - vkDescriptorSetAllocateInfo.pSetLayouts = &pkePipelines.descr_layouts.named.glyph; + vkDescriptorSetAllocateInfo.pSetLayouts = &pkePipelines.descr_layouts.named.txtr; vkResult = vkAllocateDescriptorSets(vkDevice, &vkDescriptorSetAllocateInfo, &ft->gr.vkDescriptorSet); assert(vkResult == VK_SUCCESS); diff --git a/src/static-ui.cpp b/src/static-ui.cpp new file mode 100644 index 0000000..0c5d124 --- /dev/null +++ b/src/static-ui.cpp @@ -0,0 +1,200 @@ + +#include "static-ui.hpp" + +#include "pk.h" +#include "vendor-glm-include.hpp" +#include "window.hpp" + +#include <cassert> +#include <cstdio> +#include <cstring> + +struct pke_ui_box_instance_buffer_item { + glm::mat4 pos_scale; + glm::vec2 px_scale; + float depth; + float padding[1]; +}; + +struct pke_ui_master { + pk_membucket *bkt; + pke_ui_box **root_boxes; + pke_ui_box_count_T h_root_boxes; + pke_ui_box_count_T r_root_boxes; + pke_ui_graphics_bindings bindings; + bool should_recalc_ui = false; + glm::vec2 px_scale; +} pke_ui_master; + +void pke_ui_init() { + pke_ui_master.bkt = pk_bucket_create("pke ui", PK_DEFAULT_BUCKET_SIZE, false); + pke_ui_master.root_boxes = pk_new<pke_ui_box*>(1, pke_ui_master.bkt); + pke_ui_master.h_root_boxes = 0; + pke_ui_master.r_root_boxes = 1; + pke_ui_master.bindings = {}; +} + +void pke_ui_init_bindings() { + // TODO vulkan +} + +/* UI layout notes +Some restrictions: +- children cannot change the size of a parent, parents must be sized manually + - e.g.: exact font width + - consider writing a method to calculate text +*/ + +void pke_ui_calc_px(pke_ui_box *box) { + assert(box != nullptr); + glm::vec2 size; + glm::vec2 parent_pos_and_offset; + + assert(box->pos_top_left_x >= 0.0); + assert(box->pos_top_left_y >= 0.0); + assert(box->max_width >= 0.0); + assert(box->max_height >= 0.0); + + if (box->internal.parent != nullptr) { + parent_pos_and_offset.x = box->internal.parent->internal.px_corner_x + box->internal.parent->internal.px_offset_x; + parent_pos_and_offset.y = box->internal.parent->internal.px_corner_y + box->internal.parent->internal.px_offset_y; + size.x = box->internal.parent->internal.px_width - box->internal.parent->internal.px_offset_x; + size.y = box->internal.parent->internal.px_height - box->internal.parent->internal.px_offset_y; + // built-in padding + size -= glm::vec2(2); + } else { + parent_pos_and_offset = glm::vec2(0); + size = glm::vec2(Extent.width, Extent.height); + } + + if (PK_HAS_FLAG(box->flags, PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC)) { + size.x -= box->pos_top_left_x; + size.y -= box->pos_top_left_y; + box->internal.px_corner_x = 0 + + parent_pos_and_offset.x + + box->pos_top_left_x; + box->internal.px_corner_y = 0 + + parent_pos_and_offset.y + + box->pos_top_left_y; + } else { + assert(box->pos_top_left_x < 1.0); + assert(box->pos_top_left_y < 1.0); + box->internal.px_corner_x = parent_pos_and_offset.x; + box->internal.px_corner_y = parent_pos_and_offset.y; + float px_left = size.x * box->pos_top_left_x; + float px_top = size.y * box->pos_top_left_y; + box->internal.px_corner_x += px_left; + box->internal.px_corner_y += px_top; + size -= px_left; + size -= px_top; + } + size.x = PK_MIN(size.x, box->max_width); + size.y = PK_MIN(size.y, box->max_height); + if (box->internal.parent != nullptr) { + box->internal.parent->internal.px_offset_y += size.y; + } + // built-in padding + box->internal.px_offset_x = 1; + box->internal.px_offset_y = 1; + box->internal.px_width = size.x; + box->internal.px_height = size.y; +} + +void pke_ui_recalc_sizes_recursive(pke_ui_box *box, uint8_t depth = 0) { + uint64_t flags_masked; + + for (pke_ui_box_count_T i = 0; i < box->internal.h_children; ++i) { + flags_masked = box->flags & (PKE_UI_BOX_FLAG_POSITION_TYPE_BOTH); + if (flags_masked == 0 || flags_masked == PKE_UI_BOX_FLAG_POSITION_TYPE_BOTH) { + fprintf(stderr, "[%s] ui box invalid flags: position", __FILE__); + return; + } + } + + for (pke_ui_box_count_T i = 0; i < box->internal.h_children; ++i) { + pke_ui_calc_px(box->internal.children[i]); + pke_ui_recalc_sizes_recursive(box->internal.children[i], depth + 1); + } +} + +void pke_ui_tick(double delta) { + (void)delta; + if (pke_ui_master.should_recalc_ui == true) { + pke_ui_master.should_recalc_ui = false; + pke_ui_master.px_scale = glm::vec2( + 2.0 / (float)Extent.width, + 2.0 / (float)Extent.height + ); + for (pke_ui_box_count_T i = 0; i < pke_ui_master.h_root_boxes; ++i) { + pke_ui_box *box = pke_ui_master.root_boxes[i]; + pke_ui_calc_px(box); + pke_ui_recalc_sizes_recursive(box, 0); + } + } +} + +void pke_ui_teardown_box_recursive(pke_ui_box *box) { + for (pke_ui_box_count_T i = 0; i < box->internal.h_children; ++i) { + pke_ui_teardown_box_recursive(box->internal.children[i]); + } + if (box->internal.children != nullptr) { + pk_delete<pke_ui_box *>(box->internal.children, box->internal.r_children); + } +} + +void pke_ui_teardown() { + for (pke_ui_box_count_T i = 0; i < pke_ui_master.h_root_boxes; ++i) { + pke_ui_teardown_box_recursive(pke_ui_master.root_boxes[i]); + } + pk_delete<pke_ui_box *>(pke_ui_master.root_boxes, pke_ui_master.r_root_boxes); + pk_bucket_destroy(pke_ui_master.bkt); + pke_ui_master.bkt = nullptr; + pke_ui_master.root_boxes = nullptr; + pke_ui_master.h_root_boxes = 0; + pke_ui_master.r_root_boxes = 0; + // TODO vulkan +} + +pke_ui_box *pke_ui_box_new_root() { + if (pke_ui_master.h_root_boxes == pke_ui_master.r_root_boxes) { + pke_ui_box_count_T prev_r_root_boxes = pke_ui_master.r_root_boxes; + pke_ui_master.r_root_boxes *= 1.5; + pke_ui_box **boxes = pk_new<pke_ui_box*>(pke_ui_master.r_root_boxes); + for (pke_ui_box_count_T i = 0; i < pke_ui_master.h_root_boxes; ++i) { + boxes[i] = pke_ui_master.root_boxes[i]; + } + pk_delete<pke_ui_box*>(pke_ui_master.root_boxes, prev_r_root_boxes); + pke_ui_master.root_boxes = boxes; + } + pke_ui_box *box = pk_new<pke_ui_box>(pke_ui_master.bkt); + memset(box, 0, sizeof(pke_ui_box)); + pke_ui_master.root_boxes[pke_ui_master.h_root_boxes] = box; + pke_ui_master.h_root_boxes += 1; + return box; +} + +pke_ui_box *pke_ui_box_new_child(pke_ui_box *parent) { + assert(parent != nullptr); + if (parent->internal.h_children == parent->internal.r_children) { + pke_ui_box_count_T prev_r_children = parent->internal.r_children; + parent->internal.r_children *= PK_MIN(1.5, 2); + pke_ui_box **boxes = pk_new<pke_ui_box*>(parent->internal.r_children); + for (pke_ui_box_count_T i = 0; i < parent->internal.h_children; ++i) { + boxes[i] = parent->internal.children[i]; + } + if (parent->internal.children != nullptr) { + pk_delete<pke_ui_box*>(parent->internal.children, prev_r_children); + } + parent->internal.children = boxes; + } + pke_ui_box *box = pk_new<pke_ui_box>(pke_ui_master.bkt); + memset(box, 0, sizeof(pke_ui_box)); + parent->internal.children[parent->internal.h_children] = box; + parent->internal.h_children += 1; + box->internal.parent = parent; + return box; +} + +pke_ui_graphics_bindings *pke_ui_get_graphics_bindings() { + return &pke_ui_master.bindings; +} diff --git a/src/static-ui.hpp b/src/static-ui.hpp index b0bf98c..185b218 100644 --- a/src/static-ui.hpp +++ b/src/static-ui.hpp @@ -1,6 +1,9 @@ #ifndef PKE_STATIC_UI_HPP #define PKE_STATIC_UI_HPP +#include "components-vk.hpp" +#include <cstdint> + struct MSDFGlyphSettings { float width; float height; @@ -9,4 +12,63 @@ struct MSDFGlyphSettings { float range_em; }; +enum PKE_UI_BOX_FLAGS : uint64_t { + PKE_UI_BOX_FLAG_NONE = 0, + // position type [0-1] + // exact screen coordinates + PKE_UI_BOX_FLAG_POSITION_TYPE_STATIC = (1 << 0), + PKE_UI_BOX_FLAG_POSITION_TYPE_DYNAMIC = (1 << 1), + PKE_UI_BOX_FLAG_POSITION_TYPE_BOTH = (1 << 0) | (1 << 1), + // grow [2-3] + PKE_UI_BOX_FLAG_GROW_HORIZONTAL = (1 << 2), + PKE_UI_BOX_FLAG_GROW_VERTICAL = (1 << 3), + PKE_UI_BOX_FLAG_GROW_BOTH = (1 << 2) | (1 << 3), + // center [4-5] + PKE_UI_BOX_FLAG_CENTER_HORIZONTAL = (1 << 4), + PKE_UI_BOX_FLAG_CENTER_VERTICAL = (1 << 5), + PKE_UI_BOX_FLAG_CENTER_BOTH = (1 << 4) | (1 << 5), +}; + +typedef uint16_t pke_ui_box_count_T; + +struct pke_ui_box; + +struct pke_ui_box { + PKE_UI_BOX_FLAGS flags; + float pos_top_left_x, pos_top_left_y; + float max_width, max_height; + uint8_t layer; + struct pke_ui_box_internals { + float px_corner_x, px_corner_y; + float px_width, px_height; + float px_offset_x, px_offset_y; + pke_ui_box *parent; + pke_ui_box **children; + pke_ui_box_count_T h_children; + pke_ui_box_count_T r_children; + } internal; +}; + +struct pke_ui_graphics_bindings { + VkDeviceMemory deviceMemoryVert = VK_NULL_HANDLE; + VkDeviceMemory deviceMemoryInst = VK_NULL_HANDLE; + BufferBindingDetails bd_vertex; + BufferBindingDetails bd_uv; + BufferBindingDetails bd_index; + BufferBindingDetails bd_instance; + uint32_t index_count; + uint32_t instance_counter; + uint32_t instance_buffer_max_count; +}; + +void pke_ui_init(); +void pke_ui_init_bindings(); +void pke_ui_tick(double delta); +void pke_ui_teardown(); + +pke_ui_box *pke_ui_box_new_root(); +pke_ui_box *pke_ui_box_new_child(pke_ui_box *parent); + +pke_ui_graphics_bindings *pke_ui_get_graphics_bindings(); + #endif /* PKE_STATIC_UI_HPP */ diff --git a/src/window.cpp b/src/window.cpp index 6a71fe1..5f04275 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -16,6 +16,7 @@ #include "plugins.hpp" #include "static-cube.hpp" #include "static-missing-texture.hpp" +#include "static-ui.hpp" #include "window-types.hpp" #include "glm/ext/matrix_transform.hpp" @@ -1655,33 +1656,50 @@ void CreateGraphicsPipelines() { .bindingCount = 2, .pBindings = vkDescriptorSetLayoutBindings, }; - vkResult = vkCreateDescriptorSetLayout(vkDevice, &vkDescriptorSetLayoutCreateInfo, vkAllocator, &pkePipelines.descr_layouts.named.texture); + vkResult = vkCreateDescriptorSetLayout(vkDevice, &vkDescriptorSetLayoutCreateInfo, vkAllocator, &pkePipelines.descr_layouts.named.ubo_txtr); assert(vkResult == VK_SUCCESS); - assert(pkePipelines.descr_layouts.named.texture != VK_NULL_HANDLE); + assert(pkePipelines.descr_layouts.named.ubo_txtr != VK_NULL_HANDLE); // no UBO on glyph vkDescriptorSetLayoutBindings[0] = vkDescriptorSetLayoutBindings[1]; vkDescriptorSetLayoutBindings[0].binding = 0; vkDescriptorSetLayoutCreateInfo.bindingCount = 1; - vkResult = vkCreateDescriptorSetLayout(vkDevice, &vkDescriptorSetLayoutCreateInfo, vkAllocator, &pkePipelines.descr_layouts.named.glyph); + vkResult = vkCreateDescriptorSetLayout(vkDevice, &vkDescriptorSetLayoutCreateInfo, vkAllocator, &pkePipelines.descr_layouts.named.txtr); assert(vkResult == VK_SUCCESS); - assert(pkePipelines.descr_layouts.named.glyph != VK_NULL_HANDLE); + assert(pkePipelines.descr_layouts.named.txtr != VK_NULL_HANDLE); + + // no UBO or txtr + // 2025-02-28 JCB + // I'm calling this "base" for now, meaning no bindings. + // There's a good chance this will be toggled on and off as needed. + // At the current moment, I'm using this to start the UI render work. + // There's a good chance the UI shaders will get *a* UBO (for color?). + vkDescriptorSetLayoutCreateInfo.bindingCount = 0; + vkDescriptorSetLayoutCreateInfo.pBindings = VK_NULL_HANDLE; + vkResult = vkCreateDescriptorSetLayout(vkDevice, &vkDescriptorSetLayoutCreateInfo, vkAllocator, &pkePipelines.descr_layouts.named.base); + assert(vkResult == VK_SUCCESS); + assert(pkePipelines.descr_layouts.named.txtr != VK_NULL_HANDLE); + VkPipelineLayoutCreateInfo vkPipelineLayoutCreateInfo { .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .pNext = nullptr, .flags = 0, .setLayoutCount = 1, - .pSetLayouts = &pkePipelines.descr_layouts.named.texture, + .pSetLayouts = &pkePipelines.descr_layouts.named.ubo_txtr, .pushConstantRangeCount = 0, .pPushConstantRanges = nullptr, }; - vkCreatePipelineLayout(vkDevice, &vkPipelineLayoutCreateInfo, vkAllocator, &pkePipelines.pipe_layouts.named.texture); - assert(pkePipelines.pipe_layouts.named.texture != VK_NULL_HANDLE); + vkCreatePipelineLayout(vkDevice, &vkPipelineLayoutCreateInfo, vkAllocator, &pkePipelines.pipe_layouts.named.ubo_txtr); + assert(pkePipelines.pipe_layouts.named.ubo_txtr != VK_NULL_HANDLE); + + vkPipelineLayoutCreateInfo.pSetLayouts = &pkePipelines.descr_layouts.named.txtr; + vkCreatePipelineLayout(vkDevice, &vkPipelineLayoutCreateInfo, vkAllocator, &pkePipelines.pipe_layouts.named.txtr); + assert(pkePipelines.pipe_layouts.named.txtr != VK_NULL_HANDLE); - vkPipelineLayoutCreateInfo.pSetLayouts = &pkePipelines.descr_layouts.named.glyph; - vkCreatePipelineLayout(vkDevice, &vkPipelineLayoutCreateInfo, vkAllocator, &pkePipelines.pipe_layouts.named.glyph); - assert(pkePipelines.pipe_layouts.named.glyph != VK_NULL_HANDLE); + vkPipelineLayoutCreateInfo.pSetLayouts = &pkePipelines.descr_layouts.named.base; + vkCreatePipelineLayout(vkDevice, &vkPipelineLayoutCreateInfo, vkAllocator, &pkePipelines.pipe_layouts.named.base); + assert(pkePipelines.pipe_layouts.named.base != VK_NULL_HANDLE); } // pipelines @@ -1691,6 +1709,8 @@ void CreateGraphicsPipelines() { AssetHandle textureFragShaderAssetHandle { AM_GetHandle(AssetKey{"pke_txtr_frg\0\0\0"})}; AssetHandle vertGlyphAssetHandle{AM_GetHandle(AssetKey{"pke_glyph_vrt\0\0"})}; AssetHandle fragGlyphAssetHandle { AM_GetHandle(AssetKey{"pke_glyph_frg\0\0"})}; + AssetHandle asset_handle_vert_ui_base { AM_GetHandle(AssetKey{"pke_ui_bs_vrt\0\0"})}; + AssetHandle asset_handle_frag_ui_base { AM_GetHandle(AssetKey{"pke_ui_bs_frg\0\0"})}; const long vertexBindingCount = 4; long index = 0; @@ -1873,6 +1893,83 @@ void CreateGraphicsPipelines() { vkPipelineVertexInputStateCreateInfo_glyph.pVertexAttributeDescriptions = vertAttrDesc_glyph; } + index = 0; + offset = 0; + const long vertexBindingCount_ui_base = 3; + VkVertexInputBindingDescription vertInputBD_ui_base[vertexBindingCount_ui_base]; + const long vertexAttrDescCount_ui_base = 8; + VkVertexInputAttributeDescription vertAttrDesc_ui_base[vertexAttrDescCount_ui_base]; + VkPipelineVertexInputStateCreateInfo vkPipelineVertexInputStateCreateInfo_ui_base{vkPipelineVertexInputStateCreateInfo_txtr}; + { + // vertex - vertex + vertInputBD_ui_base[index].binding = index; + vertInputBD_ui_base[index].stride = sizeof(glm::vec2); + vertInputBD_ui_base[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + index += 1; + + // vertex - UV + vertInputBD_ui_base[index].binding = index; + vertInputBD_ui_base[index].stride = sizeof(glm::vec2); + vertInputBD_ui_base[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + index += 1; + + // instance - total + vertInputBD_ui_base[index].binding = index; + vertInputBD_ui_base[index].stride = 0 + + sizeof(glm::mat4) // pos_scale + + sizeof(glm::vec2) // px_scale + + sizeof(float) // depth + + (sizeof(float) * 1) // padding + + 0; + vertInputBD_ui_base[index].inputRate = VK_VERTEX_INPUT_RATE_INSTANCE; + // index += 1; + + index = 0; + for (long i = 0; i < vertexAttrDescCount_ui_base; ++i) { + vertAttrDesc_ui_base[i].location = i; + } + + // vertex - vertex + vertAttrDesc_ui_base[index].binding = 0; + vertAttrDesc_ui_base[index].format = VK_FORMAT_R32G32_SFLOAT; + vertAttrDesc_ui_base[index].offset = 0; + index += 1; + + // vertex - UV + vertAttrDesc_ui_base[index].binding = 1; + vertAttrDesc_ui_base[index].format = VK_FORMAT_R32G32_SFLOAT; + vertAttrDesc_ui_base[index].offset = 0; + index += 1; + + // instance - pos_scale + for (long i = 0; i < 4; ++i) { + vertAttrDesc_ui_base[index].binding = 2; + vertAttrDesc_ui_base[index].format = VK_FORMAT_R32G32B32A32_SFLOAT; + vertAttrDesc_ui_base[index].offset = offset; + offset += sizeof(glm::vec4); + index += 1; + } + + // instance - in_sprite_region_min + vertAttrDesc_ui_base[index].binding = 2; + vertAttrDesc_ui_base[index].format = VK_FORMAT_R32G32_SFLOAT; + vertAttrDesc_ui_base[index].offset = offset; + offset += sizeof(glm::vec2); + index += 1; + + // instance - in_sprite_region_min + vertAttrDesc_ui_base[index].binding = 2; + vertAttrDesc_ui_base[index].format = VK_FORMAT_R32_SFLOAT; + vertAttrDesc_ui_base[index].offset = offset; + // offset += sizeof(glm::vec2); + // index += 1; + + vkPipelineVertexInputStateCreateInfo_ui_base.vertexBindingDescriptionCount = vertexBindingCount_ui_base; + vkPipelineVertexInputStateCreateInfo_ui_base.pVertexBindingDescriptions = vertInputBD_ui_base; + vkPipelineVertexInputStateCreateInfo_ui_base.vertexAttributeDescriptionCount = vertexAttrDescCount_ui_base; + vkPipelineVertexInputStateCreateInfo_ui_base.pVertexAttributeDescriptions = vertAttrDesc_ui_base; + } + VkPipelineInputAssemblyStateCreateInfo vkPipelineInputAssemblyStateCreateInfo; vkPipelineInputAssemblyStateCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; vkPipelineInputAssemblyStateCreateInfo.pNext = nullptr; @@ -1976,10 +2073,14 @@ void CreateGraphicsPipelines() { const Asset *textureFragShaderAsset = AM_Get(textureFragShaderAssetHandle); const Asset *glyphVertShaderAsset = AM_Get(vertGlyphAssetHandle); const Asset *glyphFragShaderAsset = AM_Get(fragGlyphAssetHandle); + const Asset *vert_shader_asset_ui_base = AM_Get(asset_handle_vert_ui_base); + const Asset *frag_shader_asset_ui_base = AM_Get(asset_handle_frag_ui_base); assert(textureVertShaderAsset != nullptr && textureVertShaderAsset->state == PKE_ASSET_LOADING_STATE_LOADED); assert(textureFragShaderAsset != nullptr && textureFragShaderAsset->state == PKE_ASSET_LOADING_STATE_LOADED); assert(glyphVertShaderAsset != nullptr && glyphVertShaderAsset->state == PKE_ASSET_LOADING_STATE_LOADED); assert(glyphFragShaderAsset != nullptr && glyphFragShaderAsset->state == PKE_ASSET_LOADING_STATE_LOADED); + assert(vert_shader_asset_ui_base != nullptr && vert_shader_asset_ui_base->state == PKE_ASSET_LOADING_STATE_LOADED); + assert(frag_shader_asset_ui_base != nullptr && frag_shader_asset_ui_base->state == PKE_ASSET_LOADING_STATE_LOADED); VkPipelineShaderStageCreateInfo vkPipelineShaderStageCreateInfo_txtr[2]; for (long i = 0; i < 2; ++i) { @@ -2001,9 +2102,19 @@ void CreateGraphicsPipelines() { } vkPipelineShaderStageCreateInfo_glyph[0].stage = VK_SHADER_STAGE_VERTEX_BIT; vkPipelineShaderStageCreateInfo_glyph[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; + VkPipelineShaderStageCreateInfo vkPipelineShaderStageCreateInfo_ui_base[2]; + for (long i = 0; i < 2; ++i) { + vkPipelineShaderStageCreateInfo_ui_base[i].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO; + vkPipelineShaderStageCreateInfo_ui_base[i].pNext = nullptr; + vkPipelineShaderStageCreateInfo_ui_base[i].flags = {}; + vkPipelineShaderStageCreateInfo_ui_base[i].pName = "main"; + vkPipelineShaderStageCreateInfo_ui_base[i].pSpecializationInfo = nullptr; + } + vkPipelineShaderStageCreateInfo_ui_base[0].stage = VK_SHADER_STAGE_VERTEX_BIT; + vkPipelineShaderStageCreateInfo_ui_base[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; - VkGraphicsPipelineCreateInfo vkGraphicsPipelineCreateInfo[3]; - for (long i = 0; i < 3; ++i) { + VkGraphicsPipelineCreateInfo vkGraphicsPipelineCreateInfo[4]; + for (long i = 0; i < 4; ++i) { vkGraphicsPipelineCreateInfo[i].sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; vkGraphicsPipelineCreateInfo[i].pNext = nullptr; vkGraphicsPipelineCreateInfo[i].flags = {}; @@ -2020,48 +2131,61 @@ void CreateGraphicsPipelines() { vkGraphicsPipelineCreateInfo[i].basePipelineIndex = {}; } - vkGraphicsPipelineCreateInfo[0].layout = pkePipelines.pipe_layouts.named.texture; - vkGraphicsPipelineCreateInfo[1].layout = pkePipelines.pipe_layouts.named.texture; - vkGraphicsPipelineCreateInfo[2].layout = pkePipelines.pipe_layouts.named.glyph; + vkGraphicsPipelineCreateInfo[0].layout = pkePipelines.pipe_layouts.named.ubo_txtr; + vkGraphicsPipelineCreateInfo[1].layout = pkePipelines.pipe_layouts.named.ubo_txtr; + vkGraphicsPipelineCreateInfo[2].layout = pkePipelines.pipe_layouts.named.txtr; + vkGraphicsPipelineCreateInfo[3].layout = pkePipelines.pipe_layouts.named.base; vkGraphicsPipelineCreateInfo[0].renderPass = pkvk_3d.render_pass; vkGraphicsPipelineCreateInfo[1].renderPass = pkvk_3d.render_pass; vkGraphicsPipelineCreateInfo[2].renderPass = pkvk_2d.render_pass; + vkGraphicsPipelineCreateInfo[3].renderPass = pkvk_2d.render_pass; vkGraphicsPipelineCreateInfo[0].pVertexInputState = &vkPipelineVertexInputStateCreateInfo_txtr; vkGraphicsPipelineCreateInfo[1].pVertexInputState = &vkPipelineVertexInputStateCreateInfo_txtr; vkGraphicsPipelineCreateInfo[2].pVertexInputState = &vkPipelineVertexInputStateCreateInfo_glyph; + vkGraphicsPipelineCreateInfo[3].pVertexInputState = &vkPipelineVertexInputStateCreateInfo_ui_base; vkGraphicsPipelineCreateInfo[0].pRasterizationState = &vkPipelineRasterizationStateCreateInfoFill; vkGraphicsPipelineCreateInfo[1].pRasterizationState = &vkPipelineRasterizationStateCreateInfoLine; vkGraphicsPipelineCreateInfo[2].pRasterizationState = &vkPipelineRasterizationStateCreateInfoFill; + vkGraphicsPipelineCreateInfo[3].pRasterizationState = &vkPipelineRasterizationStateCreateInfoFill; vkGraphicsPipelineCreateInfo[0].pStages = vkPipelineShaderStageCreateInfo_txtr; vkGraphicsPipelineCreateInfo[1].pStages = vkPipelineShaderStageCreateInfo_txtr; vkGraphicsPipelineCreateInfo[2].pStages = vkPipelineShaderStageCreateInfo_glyph; + vkGraphicsPipelineCreateInfo[3].pStages = vkPipelineShaderStageCreateInfo_ui_base; // deffered shader creation vkPipelineShaderStageCreateInfo_txtr[0].module = UploadShader(vertShaderAssetHandle); vkPipelineShaderStageCreateInfo_txtr[1].module = UploadShader(textureFragShaderAssetHandle); vkPipelineShaderStageCreateInfo_glyph[0].module = UploadShader(vertGlyphAssetHandle); vkPipelineShaderStageCreateInfo_glyph[1].module = UploadShader(fragGlyphAssetHandle); + vkPipelineShaderStageCreateInfo_ui_base[0].module = UploadShader(asset_handle_vert_ui_base); + vkPipelineShaderStageCreateInfo_ui_base[1].module = UploadShader(asset_handle_frag_ui_base); - vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[0], vkAllocator, &pkePipelines.pipelines.named.texture); + vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[0], vkAllocator, &pkePipelines.pipelines.named.entity_standard); + assert(vkResult == VK_SUCCESS); + vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[1], vkAllocator, &pkePipelines.pipelines.named.entity_wireframe); assert(vkResult == VK_SUCCESS); - vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[1], vkAllocator, &pkePipelines.pipelines.named.texture_wireframe); + vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[2], vkAllocator, &pkePipelines.pipelines.named.font_glyph); assert(vkResult == VK_SUCCESS); - vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[2], vkAllocator, &pkePipelines.pipelines.named.glyph); + vkResult = vkCreateGraphicsPipelines(vkDevice, VK_NULL_HANDLE, 1, &vkGraphicsPipelineCreateInfo[3], vkAllocator, &pkePipelines.pipelines.named.ui_base); assert(vkResult == VK_SUCCESS); - assert(pkePipelines.pipelines.named.texture != VK_NULL_HANDLE); - assert(pkePipelines.pipelines.named.texture_wireframe != VK_NULL_HANDLE); - assert(pkePipelines.pipelines.named.glyph != VK_NULL_HANDLE); + assert(pkePipelines.pipelines.named.entity_standard != VK_NULL_HANDLE); + assert(pkePipelines.pipelines.named.entity_wireframe != VK_NULL_HANDLE); + assert(pkePipelines.pipelines.named.font_glyph != VK_NULL_HANDLE); + assert(pkePipelines.pipelines.named.ui_base != VK_NULL_HANDLE); for (long i = 0; i < 2; ++i) { vkDestroyShaderModule(vkDevice, vkPipelineShaderStageCreateInfo_txtr[i].module, vkAllocator); vkDestroyShaderModule(vkDevice, vkPipelineShaderStageCreateInfo_glyph[i].module, vkAllocator); + vkDestroyShaderModule(vkDevice, vkPipelineShaderStageCreateInfo_ui_base[i].module, vkAllocator); } // reverse order + AM_Release(asset_handle_frag_ui_base); + AM_Release(asset_handle_vert_ui_base); AM_Release(fragGlyphAssetHandle); AM_Release(vertGlyphAssetHandle); AM_Release(vertShaderAssetHandle); @@ -2483,7 +2607,7 @@ void UpdateDebugGraphicsPipeline() { VkDescriptorSetLayout *descriptorSets = pk_new<VkDescriptorSetLayout>(swapchainLength); for (long i = 0; i < swapchainLength; ++i) { - descriptorSets[i] = pkePipelines.descr_layouts.named.texture; + descriptorSets[i] = pkePipelines.descr_layouts.named.ubo_txtr; } VkDescriptorSetAllocateInfo vkDescriptorSetAllocateInfo; vkDescriptorSetAllocateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; @@ -2706,8 +2830,8 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { vkCmdDrawIndexed(commandBuffer, binder->indexCount, binder->instanceCounter, 0, 0, 0); if (pkeSettings.isRenderingDebug) { - vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.texture_wireframe); - vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.texture, 0, 1, &pkeDebugHitbox.vkDescriptorSets[imageIndex], 0, {}); + vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.entity_wireframe); + vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.ubo_txtr, 0, 1, &pkeDebugHitbox.vkDescriptorSets[imageIndex], 0, {}); vkCmdBindVertexBuffers(commandBuffer, binder->physVertBD.firstBinding, 1, &binder->physVertBD.buffer, binder->physVertBD.offsets); vkCmdBindVertexBuffers(commandBuffer, binder->physNormBD.firstBinding, 1, &binder->physNormBD.buffer, binder->physVertBD.offsets); @@ -2720,8 +2844,8 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { } if (pkeDebugHitbox.instanceBuffer != VK_NULL_HANDLE) { - vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.texture_wireframe); - vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.texture, 0, 1, &pkeDebugHitbox.vkDescriptorSets[imageIndex], 0, {}); + vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.entity_wireframe); + vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.ubo_txtr, 0, 1, &pkeDebugHitbox.vkDescriptorSets[imageIndex], 0, {}); vkCmdBindVertexBuffers(commandBuffer, 0, 1, &UniformBuffers[imageIndex], offsets); // TODO don't hardcode firstBinding @@ -2747,6 +2871,18 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { vkCmdSetScissor(commandBuffer, 0, 1, &scissor); // 2d overlay grbinds + if (false) + { + pke_ui_graphics_bindings *ui_gr = pke_ui_get_graphics_bindings(); + vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.ui_base); + vkCmdBindIndexBuffer(commandBuffer, ui_gr->bd_index.buffer, ui_gr->bd_index.offsets[0], VK_INDEX_TYPE_UINT16); + vkCmdBindVertexBuffers(commandBuffer, ui_gr->bd_vertex.firstBinding, ui_gr->bd_vertex.bindingCount, &ui_gr->bd_vertex.buffer, ui_gr->bd_vertex.offsets); + vkCmdBindVertexBuffers(commandBuffer, ui_gr->bd_uv.firstBinding, ui_gr->bd_uv.bindingCount, &ui_gr->bd_uv.buffer, ui_gr->bd_uv.offsets); + vkCmdBindVertexBuffers(commandBuffer, ui_gr->bd_instance.firstBinding, ui_gr->bd_instance.bindingCount, &ui_gr->bd_instance.buffer, ui_gr->bd_instance.offsets); + vkCmdDrawIndexed(commandBuffer, ui_gr->index_count, ui_gr->instance_counter, 0, 0, 0); + } + + // 2d - font glyphs FontTypeIndex count; FontType *fts = FontType_GetFonts(count); for (FontTypeIndex i = FontTypeIndex{0}; i < count; ++i) @@ -2754,9 +2890,9 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { FontType *ft = &fts[(FontTypeIndex_T)i]; if (ft->bindings.instanceCounter == 0) continue; - vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.glyph); + vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.font_glyph); - vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.glyph, 0, 1, &ft->gr.vkDescriptorSet, 0, {}); + vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.txtr, 0, 1, &ft->gr.vkDescriptorSet, 0, {}); vkCmdBindIndexBuffer(commandBuffer, ft->bindings.indexBD.buffer, ft->bindings.indexBD.offsets[0], VK_INDEX_TYPE_UINT16); vkCmdBindVertexBuffers(commandBuffer, ft->bindings.vertexBD.firstBinding, ft->bindings.vertexBD.bindingCount, &ft->bindings.vertexBD.buffer, ft->bindings.vertexBD.offsets); @@ -3090,22 +3226,28 @@ void DestroyWindow() { vkDestroyImage(vkDevice, pkeDebugHitbox.vkImage, vkAllocator); vkFreeMemory(vkDevice, pkeDebugHitbox.textureMemory, vkAllocator); - if (pkePipelines.pipelines.named.texture != VK_NULL_HANDLE) - vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.texture, vkAllocator); - if (pkePipelines.pipelines.named.texture_wireframe != VK_NULL_HANDLE) - vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.texture_wireframe, vkAllocator); - if (pkePipelines.pipelines.named.glyph != VK_NULL_HANDLE) - vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.glyph, vkAllocator); - - if (pkePipelines.pipe_layouts.named.texture != VK_NULL_HANDLE) - vkDestroyPipelineLayout(vkDevice, pkePipelines.pipe_layouts.named.texture, vkAllocator); - if (pkePipelines.pipe_layouts.named.glyph != VK_NULL_HANDLE) - vkDestroyPipelineLayout(vkDevice, pkePipelines.pipe_layouts.named.glyph, vkAllocator); - - if (pkePipelines.descr_layouts.named.texture != VK_NULL_HANDLE) - vkDestroyDescriptorSetLayout(vkDevice, pkePipelines.descr_layouts.named.texture, vkAllocator); - if (pkePipelines.descr_layouts.named.glyph != VK_NULL_HANDLE) - vkDestroyDescriptorSetLayout(vkDevice, pkePipelines.descr_layouts.named.glyph, vkAllocator); + if (pkePipelines.pipelines.named.entity_standard != VK_NULL_HANDLE) + vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.entity_standard, vkAllocator); + if (pkePipelines.pipelines.named.entity_wireframe != VK_NULL_HANDLE) + vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.entity_wireframe, vkAllocator); + if (pkePipelines.pipelines.named.font_glyph != VK_NULL_HANDLE) + vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.font_glyph, vkAllocator); + if (pkePipelines.pipelines.named.ui_base != VK_NULL_HANDLE) + vkDestroyPipeline(vkDevice, pkePipelines.pipelines.named.ui_base, vkAllocator); + + if (pkePipelines.pipe_layouts.named.ubo_txtr != VK_NULL_HANDLE) + vkDestroyPipelineLayout(vkDevice, pkePipelines.pipe_layouts.named.ubo_txtr, vkAllocator); + if (pkePipelines.pipe_layouts.named.txtr != VK_NULL_HANDLE) + vkDestroyPipelineLayout(vkDevice, pkePipelines.pipe_layouts.named.txtr, vkAllocator); + if (pkePipelines.pipe_layouts.named.base != VK_NULL_HANDLE) + vkDestroyPipelineLayout(vkDevice, pkePipelines.pipe_layouts.named.base, vkAllocator); + + if (pkePipelines.descr_layouts.named.ubo_txtr != VK_NULL_HANDLE) + vkDestroyDescriptorSetLayout(vkDevice, pkePipelines.descr_layouts.named.ubo_txtr, vkAllocator); + if (pkePipelines.descr_layouts.named.txtr != VK_NULL_HANDLE) + vkDestroyDescriptorSetLayout(vkDevice, pkePipelines.descr_layouts.named.txtr, vkAllocator); + if (pkePipelines.descr_layouts.named.base != VK_NULL_HANDLE) + vkDestroyDescriptorSetLayout(vkDevice, pkePipelines.descr_layouts.named.base, vkAllocator); DestroySyncObjects(); diff --git a/src/window.hpp b/src/window.hpp index 48da3c9..de1a2ac 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -66,21 +66,27 @@ extern DebugHitbox pkeDebugHitbox; struct ImplementedPKVK { struct ImplementedDescrSetLayouts { struct ImplementedDescrSetLayoutsByName { - VkDescriptorSetLayout texture; - VkDescriptorSetLayout glyph; + // 0 bindings + VkDescriptorSetLayout base; + // 1 binding, texture sampler + VkDescriptorSetLayout txtr; + // 2 bindings, ubo + texture sampler + VkDescriptorSetLayout ubo_txtr; } named; } descr_layouts; struct ImplementedPipelineLayouts { struct ImplementedPipelineLayoutsByName { - VkPipelineLayout texture; - VkPipelineLayout glyph; + VkPipelineLayout base; + VkPipelineLayout txtr; + VkPipelineLayout ubo_txtr; } named; } pipe_layouts; struct ImplementedPipelines { struct ImplementedPipelinesByName { - VkPipeline texture; - VkPipeline texture_wireframe; - VkPipeline glyph; + VkPipeline entity_standard; + VkPipeline entity_wireframe; + VkPipeline font_glyph; + VkPipeline ui_base; } named; } pipelines; }; |
