Added call to compute shader in draw loop, fixed wrong subpass index in ui pipelines

main
noah metz 2024-10-15 00:18:29 -06:00
parent 28cd4efbaf
commit 6e778e7d22
3 changed files with 18 additions and 6 deletions

@ -38,11 +38,7 @@ layout(buffer_reference, std430) readonly buffer Strings{
String strings[]; String strings[];
}; };
layout(set = 0, binding = 0) uniform UIUniform { layout(set = 0, binding = 0) uniform Font {
mat4 screen;
} ubo;
layout(set = 1, binding = 0) uniform Font {
uint num_symbols; uint num_symbols;
uint width; uint width;
uint height; uint height;

@ -181,7 +181,7 @@ VkResult create_ui_pipeline(
.pMultisampleState = &multisample_info, .pMultisampleState = &multisample_info,
.layout = pipeline->layout, .layout = pipeline->layout,
.renderPass = render_pass, .renderPass = render_pass,
.subpass = 0, .subpass = 1,
.basePipelineHandle = VK_NULL_HANDLE, .basePipelineHandle = VK_NULL_HANDLE,
.basePipelineIndex = -1, .basePipelineIndex = -1,
}; };
@ -304,10 +304,14 @@ VkResult create_ui_text_pipeline(VkDevice device, VkRenderPass render_pass, VkDe
.size = 8, .size = 8,
}; };
VkDescriptorSetLayout compute_descriptors[] = {font_layout};
VkPipelineLayoutCreateInfo compute_layout_info = { VkPipelineLayoutCreateInfo compute_layout_info = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO, .sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
.pushConstantRangeCount = 1, .pushConstantRangeCount = 1,
.pPushConstantRanges = &push_constant, .pPushConstantRanges = &push_constant,
.setLayoutCount = sizeof(compute_descriptors)/sizeof(VkDescriptorSetLayout),
.pSetLayouts = compute_descriptors,
}; };
result = vkCreatePipelineLayout(device, &compute_layout_info, NULL, &compute->layout); result = vkCreatePipelineLayout(device, &compute_layout_info, NULL, &compute->layout);

@ -1026,6 +1026,18 @@ VkResult draw_frame(RenderContext* context, UIContext* ui_context, UILayer* ui_l
.clearValueCount = 2, .clearValueCount = 2,
.pClearValues = clear_values, .pClearValues = clear_values,
}; };
// UI strings compute pass
vkCmdBindPipeline(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, ui_context->ui_compute_text.pipeline);
for(uint32_t i = 0; i < ui_layer_count; i ++) {
if(ui_layers[i].text_count > 0) {
vkCmdBindDescriptorSets(command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, ui_context->ui_compute_text.layout, 0, 1, &ui_layers[i].font.set, 0, NULL);
vkCmdDispatch(command_buffer, 1, 1, 1);
}
}
vkCmdDispatch(command_buffer, 1, 1, 1);
// Render Pass
vkCmdBeginRenderPass(command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE); vkCmdBeginRenderPass(command_buffer, &render_pass_begin, VK_SUBPASS_CONTENTS_INLINE);
// World subpass // World subpass