Renamed Text to Char

main
noah metz 2024-10-14 01:09:05 -06:00
parent 74e1a05790
commit a06fbe8b1c
3 changed files with 13 additions and 9 deletions

@ -21,12 +21,12 @@ typedef struct UIUniformStruct {
mat4 screen;
} UIUniform;
typedef struct TextStruct {
typedef struct CharStruct {
vec3 pos;
vec2 size;
vec4 color;
uint32_t code;
} Text;
} Char;
typedef struct FontUniformStruct {
vec2 size;

@ -80,7 +80,7 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render_context) {
VkBufferCreateInfo text_buffer_info = {
.sType = VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO,
.usage = VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,
.size = 2*sizeof(Text),
.size = 2*sizeof(Char),
.sharingMode = VK_SHARING_MODE_EXCLUSIVE,
};
@ -93,7 +93,7 @@ VkResult render_thread(GLFWwindow* window, RenderContext* render_context) {
return result;
}
Text* text;
Char* text;
result = vmaMapMemory(render_context->allocator, text_memory, (void**)&text);
if(result != VK_SUCCESS) {

@ -294,6 +294,10 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
if(frag_shader == VK_NULL_HANDLE) {
return VK_ERROR_UNKNOWN;
}
// TODO: add a compute stage before the shader stages that sets up the draw buffer and commands for the characters based off of strings + positions
// 1. Reserve a buffer for array of draw command params + CharStruct on the GPU
// 2. Reserve a buffer for StringStruct
VkPipelineShaderStageCreateInfo shader_stages[] = {
{
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
@ -317,7 +321,7 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
},
{
.binding = 1,
.stride = sizeof(Text),
.stride = sizeof(Char),
.inputRate = VK_VERTEX_INPUT_RATE_INSTANCE,
}
};
@ -332,25 +336,25 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
.binding = 1,
.location = 1,
.format = VK_FORMAT_R32G32B32_SFLOAT,
.offset = offsetof(Text, pos),
.offset = offsetof(Char, pos),
},
{
.binding = 1,
.location = 2,
.format = VK_FORMAT_R32G32_SFLOAT,
.offset = offsetof(Text, size),
.offset = offsetof(Char, size),
},
{
.binding = 1,
.location = 3,
.format = VK_FORMAT_R32G32B32A32_SFLOAT,
.offset = offsetof(Text, color),
.offset = offsetof(Char, color),
},
{
.binding = 1,
.location = 4,
.format = VK_FORMAT_R32_UINT,
.offset = offsetof(Text, code),
.offset = offsetof(Char, code),
},
};