main
noah metz 2024-10-29 13:21:57 -06:00
parent edf2e4b3c9
commit e2ffed91e2
2 changed files with 34 additions and 35 deletions

@ -109,41 +109,40 @@ VkResult draw_frame(
frame->transfer_count = 0;
frame->transfer_written = 0;
VkCommandBuffer compute_commands = frame->compute_commands;
VK_RESULT(vkResetCommandBuffer(compute_commands, 0));
VK_RESULT(vkBeginCommandBuffer(compute_commands, &begin_info));
VkMemoryBarrier compute_barrier = {
.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
};
vkCmdPipelineBarrier(compute_commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 1, &compute_barrier, 0, NULL, 0, NULL);
record_ui_compute(compute_commands, ui, context->current_frame);
VK_RESULT(vkEndCommandBuffer(compute_commands));
frame->compute_index += 1;
VkPipelineStageFlags compute_wait_stages[] = {VK_PIPELINE_STAGE_ALL_COMMANDS_BIT};
VkTimelineSemaphoreSubmitInfo compute_timeline = {
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
.waitSemaphoreValueCount = 1,
.pWaitSemaphoreValues = &frame->transfer_index,
.signalSemaphoreValueCount = 1,
.pSignalSemaphoreValues = &frame->compute_index,
};
VkSubmitInfo compute_submit = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.commandBufferCount = 1,
.pCommandBuffers = &compute_commands,
.pSignalSemaphores = &frame->compute,
.signalSemaphoreCount = 1,
.pWaitSemaphores = &frame->transfer,
.pWaitDstStageMask = compute_wait_stages,
.waitSemaphoreCount = 1,
.pNext = &compute_timeline,
};
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &compute_submit, VK_NULL_HANDLE));
}
VkCommandBuffer compute_commands = frame->compute_commands;
VK_RESULT(vkResetCommandBuffer(compute_commands, 0));
VK_RESULT(vkBeginCommandBuffer(compute_commands, &begin_info));
VkMemoryBarrier compute_barrier = {
.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER,
.srcAccessMask = VK_ACCESS_TRANSFER_WRITE_BIT,
.dstAccessMask = VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_TRANSFER_READ_BIT | VK_ACCESS_TRANSFER_WRITE_BIT,
};
vkCmdPipelineBarrier(compute_commands, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, 0, 1, &compute_barrier, 0, NULL, 0, NULL);
record_ui_compute(compute_commands, ui, context->current_frame);
VK_RESULT(vkEndCommandBuffer(compute_commands));
frame->compute_index += 1;
VkPipelineStageFlags compute_wait_stages[] = {VK_PIPELINE_STAGE_ALL_COMMANDS_BIT};
VkTimelineSemaphoreSubmitInfo compute_timeline = {
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
.waitSemaphoreValueCount = 1,
.pWaitSemaphoreValues = &frame->transfer_index,
.signalSemaphoreValueCount = 1,
.pSignalSemaphoreValues = &frame->compute_index,
};
VkSubmitInfo compute_submit = {
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
.commandBufferCount = 1,
.pCommandBuffers = &compute_commands,
.pSignalSemaphores = &frame->compute,
.signalSemaphoreCount = 1,
.pWaitSemaphores = &frame->transfer,
.pWaitDstStageMask = compute_wait_stages,
.waitSemaphoreCount = 1,
.pNext = &compute_timeline,
};
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &compute_submit, VK_NULL_HANDLE));
uint32_t image_index;
VK_RESULT(vkAcquireNextImageKHR(context->device, context->swapchain, UINT64_MAX, frame->image, VK_NULL_HANDLE, &image_index));

@ -189,7 +189,7 @@ VkResult main_thread(ClientContext* context) {
//
double last_draw = 0;
double draw_interval = 0.5;
double draw_interval = 0.1;
double frame_count = 0;
uint32_t* mapped_codes = context->ui.containers[0].layers[0].codes_buffer;
GPUString* mapped_string = context->ui.containers[0].layers[0].strings_buffer;
@ -204,7 +204,7 @@ VkResult main_thread(ClientContext* context) {
double frame_time = glfwGetTime();
//
if(frame_time - last_draw > draw_interval) {
if(frame_time - last_draw > draw_interval && context->render.current_frame == 1) {
test = (test + 1) % 7;
mapped_string->length = test;