diff options
| author | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-05 19:09:10 -0500 |
|---|---|---|
| committer | Jonathan Bradley <jcb@pikum.xyz> | 2025-02-05 19:09:10 -0500 |
| commit | a9fb380f9d0b53cde554b265d9c6b66d26183c38 (patch) | |
| tree | 8ea3648c497d4a3ac8ce2f6dafa2beca324e7249 /src/window.cpp | |
| parent | 61e179f9580c985cb5ca80ea732fc7572d31c489 (diff) | |
pke: mtsdf displays, bypass fg/bg not working
Diffstat (limited to 'src/window.cpp')
| -rw-r--r-- | src/window.cpp | 57 |
1 files changed, 40 insertions, 17 deletions
diff --git a/src/window.cpp b/src/window.cpp index da4062c..11ce080 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1,5 +1,3 @@ -#include "pk.h" -#include <vulkan/vulkan_core.h> #define GLFW_INCLUDE_NONE #define GLFW_INCLUDE_VULKAN @@ -14,6 +12,7 @@ #include "font.hpp" #include "game-settings.hpp" #include "math-helpers.hpp" +#include "pk.h" #include "plugins.hpp" #include "static-cube.hpp" #include "static-missing-texture.hpp" @@ -1752,19 +1751,25 @@ void CreateGraphicsPipelines() { index = 0; long offset = 0; - const long vertexBindingCount_glyph = 3; + const long vertexBindingCount_glyph = 4; VkVertexInputBindingDescription vertInputBD_glyph[vertexBindingCount_glyph]; - const long vertexAttrDescCount_glyph = 6; + const long vertexAttrDescCount_glyph = 8; VkVertexInputAttributeDescription vertAttrDesc_glyph[vertexAttrDescCount_glyph]; VkPipelineVertexInputStateCreateInfo vkPipelineVertexInputStateCreateInfo_glyph{vkPipelineVertexInputStateCreateInfo_txtr}; { - // model vertex + // vertex - vertex vertInputBD_glyph[index].binding = index; vertInputBD_glyph[index].stride = sizeof(glm::vec2); vertInputBD_glyph[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; index += 1; - // model UV + // vertex - UV + vertInputBD_glyph[index].binding = index; + vertInputBD_glyph[index].stride = sizeof(glm::vec2); + vertInputBD_glyph[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; + index += 1; + + // vertex - atlas_size vertInputBD_glyph[index].binding = index; vertInputBD_glyph[index].stride = sizeof(glm::vec2); vertInputBD_glyph[index].inputRate = VK_VERTEX_INPUT_RATE_VERTEX; @@ -1775,7 +1780,8 @@ void CreateGraphicsPipelines() { vertInputBD_glyph[index].stride = 0 + sizeof(glm::vec4) + sizeof(glm::vec4) - + sizeof(glm::ivec4) + + sizeof(glm::vec2) + + sizeof(glm::vec2) + sizeof(float); vertInputBD_glyph[index].inputRate = VK_VERTEX_INPUT_RATE_INSTANCE; // index += 1; @@ -1785,41 +1791,55 @@ void CreateGraphicsPipelines() { vertAttrDesc_glyph[i].location = i; } - // model vertex + // vertex - vertex vertAttrDesc_glyph[index].binding = 0; vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32_SFLOAT; vertAttrDesc_glyph[index].offset = 0; index += 1; - // model UV + // vertex - UV vertAttrDesc_glyph[index].binding = 1; vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32_SFLOAT; vertAttrDesc_glyph[index].offset = 0; index += 1; - // instance - in_fg_color + // vertex - in_atlas_size vertAttrDesc_glyph[index].binding = 2; + vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32_SFLOAT; + vertAttrDesc_glyph[index].offset = offset; + offset += sizeof(glm::vec2); + index += 1; + + // instance - in_fg_color + vertAttrDesc_glyph[index].binding = 3; vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32B32A32_SFLOAT; vertAttrDesc_glyph[index].offset = 0; offset += sizeof(glm::vec4); index += 1; // instance - in_bg_color - vertAttrDesc_glyph[index].binding = 2; + vertAttrDesc_glyph[index].binding = 3; vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32B32A32_SFLOAT; vertAttrDesc_glyph[index].offset = offset; offset += sizeof(glm::vec4); index += 1; - // instance - in_sprite_region - vertAttrDesc_glyph[index].binding = 2; - vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32B32A32_SINT; + // instance - in_sprite_region_min + vertAttrDesc_glyph[index].binding = 3; + vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32_SFLOAT; vertAttrDesc_glyph[index].offset = offset; - offset += sizeof(glm::ivec4); + offset += sizeof(glm::vec2); index += 1; - // instance - in_sprite_region - vertAttrDesc_glyph[index].binding = 2; + // instance - in_sprite_region_max + vertAttrDesc_glyph[index].binding = 3; + vertAttrDesc_glyph[index].format = VK_FORMAT_R32G32_SFLOAT; + vertAttrDesc_glyph[index].offset = offset; + offset += sizeof(glm::vec2); + index += 1; + + // instance - in_width + vertAttrDesc_glyph[index].binding = 3; vertAttrDesc_glyph[index].format = VK_FORMAT_R32_SFLOAT; vertAttrDesc_glyph[index].offset = offset; // offset += sizeof(float); @@ -2710,6 +2730,8 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { for (FontTypeIndex i = FontTypeIndex{0}; i < count; ++i) { FontType *ft = &fts[(FontTypeIndex_T)i]; + if (ft->bindings.instanceCounter == 0) + continue; vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipelines.named.glyph); vkCmdBindDescriptorSets(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, pkePipelines.pipe_layouts.named.glyph, 0, 1, &ft->vkDescriptorSets[imageIndex], 0, {}); @@ -2717,6 +2739,7 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) { vkCmdBindVertexBuffers(commandBuffer, ft->bindings.vertexBD.firstBinding, ft->bindings.vertexBD.bindingCount, &ft->bindings.vertexBD.buffer, ft->bindings.vertexBD.offsets); vkCmdBindVertexBuffers(commandBuffer, ft->bindings.uvBD.firstBinding, ft->bindings.uvBD.bindingCount, &ft->bindings.uvBD.buffer, ft->bindings.uvBD.offsets); + vkCmdBindVertexBuffers(commandBuffer, ft->bindings.atlasSizeBD.firstBinding, ft->bindings.atlasSizeBD.bindingCount, &ft->bindings.atlasSizeBD.buffer, ft->bindings.atlasSizeBD.offsets); vkCmdBindVertexBuffers(commandBuffer, ft->bindings.instanceBD.firstBinding, ft->bindings.instanceBD.bindingCount, &ft->bindings.instanceBD.buffer, ft->bindings.instanceBD.offsets); vkCmdDrawIndexed(commandBuffer, ft->bindings.indexCount, ft->bindings.instanceCounter, 0, 0, 0); |
