diff --git a/client/include/pipeline.h b/client/include/pipeline.h index 9bc48bc..cbbabbc 100644 --- a/client/include/pipeline.h +++ b/client/include/pipeline.h @@ -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; diff --git a/client/src/main.c b/client/src/main.c index fdd4412..72d3e50 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -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) { diff --git a/client/src/pipeline.c b/client/src/pipeline.c index dc0f3a5..9e624b5 100644 --- a/client/src/pipeline.c +++ b/client/src/pipeline.c @@ -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), }, };