|
|
@ -83,26 +83,23 @@ VkResult draw_frame(
|
|
|
|
frame->transfer_infos[tid].size);
|
|
|
|
frame->transfer_infos[tid].size);
|
|
|
|
src_offset += frame->transfer_infos[tid].size;
|
|
|
|
src_offset += frame->transfer_infos[tid].size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(vkEndCommandBuffer(transfer_commands));
|
|
|
|
VK_RESULT(vkEndCommandBuffer(transfer_commands));
|
|
|
|
|
|
|
|
|
|
|
|
VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_TRANSFER_BIT};
|
|
|
|
VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_TRANSFER_BIT};
|
|
|
|
VkSemaphore transfer_signals[] = {frame->transfer};
|
|
|
|
|
|
|
|
VkSemaphore transfer_waits[] = {frame->frame};
|
|
|
|
|
|
|
|
uint64_t transfer_wait_values[] = {frame->frame_index};
|
|
|
|
|
|
|
|
VkTimelineSemaphoreSubmitInfo timeline_info = {
|
|
|
|
VkTimelineSemaphoreSubmitInfo timeline_info = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
|
|
|
.waitSemaphoreValueCount = sizeof(transfer_wait_values)/sizeof(uint64_t),
|
|
|
|
.waitSemaphoreValueCount = 1,
|
|
|
|
.pWaitSemaphoreValues = transfer_wait_values,
|
|
|
|
.pWaitSemaphoreValues = &frame->frame_index,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
VkSubmitInfo submit_info = {
|
|
|
|
VkSubmitInfo submit_info = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
|
|
|
.commandBufferCount = 1,
|
|
|
|
.commandBufferCount = 1,
|
|
|
|
.pCommandBuffers = &transfer_commands,
|
|
|
|
.pCommandBuffers = &transfer_commands,
|
|
|
|
.pSignalSemaphores = transfer_signals,
|
|
|
|
.pSignalSemaphores = &frame->transfer,
|
|
|
|
.signalSemaphoreCount = sizeof(transfer_signals)/sizeof(VkSemaphore),
|
|
|
|
.signalSemaphoreCount = 1,
|
|
|
|
.pWaitSemaphores = transfer_waits,
|
|
|
|
.pWaitSemaphores = &frame->frame,
|
|
|
|
.pWaitDstStageMask = wait_stages,
|
|
|
|
.pWaitDstStageMask = wait_stages,
|
|
|
|
.waitSemaphoreCount = sizeof(transfer_waits)/sizeof(VkSemaphore),
|
|
|
|
.waitSemaphoreCount = 1,
|
|
|
|
.pNext = &timeline_info,
|
|
|
|
.pNext = &timeline_info,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &submit_info, VK_NULL_HANDLE));
|
|
|
|
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &submit_info, VK_NULL_HANDLE));
|
|
|
@ -115,35 +112,30 @@ VkResult draw_frame(
|
|
|
|
VK_RESULT(vkBeginCommandBuffer(compute_commands, &begin_info));
|
|
|
|
VK_RESULT(vkBeginCommandBuffer(compute_commands, &begin_info));
|
|
|
|
record_ui_compute(compute_commands, ui, context->current_frame);
|
|
|
|
record_ui_compute(compute_commands, ui, context->current_frame);
|
|
|
|
VK_RESULT(vkEndCommandBuffer(compute_commands));
|
|
|
|
VK_RESULT(vkEndCommandBuffer(compute_commands));
|
|
|
|
VkPipelineStageFlags compute_wait_stages[] = {VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT};
|
|
|
|
|
|
|
|
frame->compute_index += 1;
|
|
|
|
frame->compute_index += 1;
|
|
|
|
VkSemaphore compute_signals[] = {frame->compute};
|
|
|
|
VkPipelineStageFlags compute_wait_stages[] = {VK_PIPELINE_STAGE_TRANSFER_BIT | VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT};
|
|
|
|
uint64_t compute_signal_values[] = {frame->compute_index};
|
|
|
|
|
|
|
|
VkSemaphore compute_waits[] = {frame->transfer};
|
|
|
|
|
|
|
|
VkTimelineSemaphoreSubmitInfo compute_timeline = {
|
|
|
|
VkTimelineSemaphoreSubmitInfo compute_timeline = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_TIMELINE_SEMAPHORE_SUBMIT_INFO,
|
|
|
|
.signalSemaphoreValueCount = sizeof(compute_signal_values)/sizeof(uint64_t),
|
|
|
|
.signalSemaphoreValueCount = 1,
|
|
|
|
.pSignalSemaphoreValues = compute_signal_values,
|
|
|
|
.pSignalSemaphoreValues = &frame->compute_index,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
VkSubmitInfo compute_submit = {
|
|
|
|
VkSubmitInfo compute_submit = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
|
|
|
|
.commandBufferCount = 1,
|
|
|
|
.commandBufferCount = 1,
|
|
|
|
.pCommandBuffers = &compute_commands,
|
|
|
|
.pCommandBuffers = &compute_commands,
|
|
|
|
.pSignalSemaphores = compute_signals,
|
|
|
|
.pSignalSemaphores = &frame->compute,
|
|
|
|
.signalSemaphoreCount = sizeof(compute_signals)/sizeof(VkSemaphore),
|
|
|
|
.signalSemaphoreCount = 1,
|
|
|
|
.pWaitSemaphores = compute_waits,
|
|
|
|
.pWaitSemaphores = &frame->transfer,
|
|
|
|
.pWaitDstStageMask = compute_wait_stages,
|
|
|
|
.pWaitDstStageMask = compute_wait_stages,
|
|
|
|
.waitSemaphoreCount = sizeof(compute_waits)/sizeof(VkSemaphore),
|
|
|
|
.waitSemaphoreCount = 1,
|
|
|
|
.pNext = &compute_timeline,
|
|
|
|
.pNext = &compute_timeline,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &compute_submit, VK_NULL_HANDLE));
|
|
|
|
VK_RESULT(vkQueueSubmit(context->transfer_queue.handle, 1, &compute_submit, VK_NULL_HANDLE));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t image_index;
|
|
|
|
uint32_t image_index;
|
|
|
|
result = vkAcquireNextImageKHR(context->device, context->swapchain, UINT64_MAX, frame->image, VK_NULL_HANDLE, &image_index);
|
|
|
|
VK_RESULT(vkAcquireNextImageKHR(context->device, context->swapchain, UINT64_MAX, frame->image, VK_NULL_HANDLE, &image_index));
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkCommandBuffer command_buffer = context->swapchain_command_buffers[image_index];
|
|
|
|
VkCommandBuffer command_buffer = context->swapchain_command_buffers[image_index];
|
|
|
|
VK_RESULT(vkResetCommandBuffer(command_buffer, 0));
|
|
|
|
VK_RESULT(vkResetCommandBuffer(command_buffer, 0));
|
|
|
@ -178,13 +170,12 @@ VkResult draw_frame(
|
|
|
|
vkCmdNextSubpass(command_buffer, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
vkCmdNextSubpass(command_buffer, VK_SUBPASS_CONTENTS_INLINE);
|
|
|
|
record_ui_draw(command_buffer, ui, time, context->current_frame);
|
|
|
|
record_ui_draw(command_buffer, ui, time, context->current_frame);
|
|
|
|
vkCmdEndRenderPass(command_buffer);
|
|
|
|
vkCmdEndRenderPass(command_buffer);
|
|
|
|
|
|
|
|
|
|
|
|
VK_RESULT(vkEndCommandBuffer(command_buffer));
|
|
|
|
VK_RESULT(vkEndCommandBuffer(command_buffer));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
frame->frame_index += 1;
|
|
|
|
VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT};
|
|
|
|
VkPipelineStageFlags wait_stages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT, VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT};
|
|
|
|
VkSemaphore wait_semaphores[] = {frame->image, frame->compute};
|
|
|
|
VkSemaphore wait_semaphores[] = {frame->image, frame->compute};
|
|
|
|
VkSemaphore signal_semaphores[] = {frame->render, frame->frame};
|
|
|
|
VkSemaphore signal_semaphores[] = {frame->render, frame->frame};
|
|
|
|
frame->frame_index += 1;
|
|
|
|
|
|
|
|
uint64_t wait_values[] = {0, frame->compute_index};
|
|
|
|
uint64_t wait_values[] = {0, frame->compute_index};
|
|
|
|
uint64_t signal_values[] = {0, frame->frame_index};
|
|
|
|
uint64_t signal_values[] = {0, frame->frame_index};
|
|
|
|
VkTimelineSemaphoreSubmitInfo timeline_info = {
|
|
|
|
VkTimelineSemaphoreSubmitInfo timeline_info = {
|
|
|
@ -206,10 +197,7 @@ VkResult draw_frame(
|
|
|
|
.pNext = &timeline_info,
|
|
|
|
.pNext = &timeline_info,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
result = vkQueueSubmit(context->graphics_queue.handle, 1, &submit_info, frame->ready);
|
|
|
|
VK_RESULT(vkQueueSubmit(context->graphics_queue.handle, 1, &submit_info, frame->ready));
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VkPresentInfoKHR present_info = {
|
|
|
|
VkPresentInfoKHR present_info = {
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
|
|
|
.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
|
|
|
@ -221,10 +209,7 @@ VkResult draw_frame(
|
|
|
|
.pResults = 0,
|
|
|
|
.pResults = 0,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
result = vkQueuePresentKHR(context->present_queue.handle, &present_info);
|
|
|
|
VK_RESULT(vkQueuePresentKHR(context->present_queue.handle, &present_info));
|
|
|
|
if(result != VK_SUCCESS) {
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
context->current_frame = (context->current_frame + 1) % MAX_FRAMES_IN_FLIGHT;
|
|
|
|
context->current_frame = (context->current_frame + 1) % MAX_FRAMES_IN_FLIGHT;
|
|
|
|
|
|
|
|
|
|
|
|