vk_scheduler: Make use of designated initializers where applicable

This commit is contained in:
Lioncash 2020-07-16 19:10:49 -04:00
parent fd7af52ec3
commit 97e7663004

View File

@ -100,16 +100,19 @@ void VKScheduler::RequestRenderpass(VkRenderPass renderpass, VkFramebuffer frame
state.framebuffer = framebuffer; state.framebuffer = framebuffer;
state.render_area = render_area; state.render_area = render_area;
VkRenderPassBeginInfo renderpass_bi; const VkRenderPassBeginInfo renderpass_bi{
renderpass_bi.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; .sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO,
renderpass_bi.pNext = nullptr; .pNext = nullptr,
renderpass_bi.renderPass = renderpass; .renderPass = renderpass,
renderpass_bi.framebuffer = framebuffer; .framebuffer = framebuffer,
renderpass_bi.renderArea.offset.x = 0; .renderArea =
renderpass_bi.renderArea.offset.y = 0; {
renderpass_bi.renderArea.extent = render_area; .offset = {.x = 0, .y = 0},
renderpass_bi.clearValueCount = 0; .extent = render_area,
renderpass_bi.pClearValues = nullptr; },
.clearValueCount = 0,
.pClearValues = nullptr,
};
Record([renderpass_bi, end_renderpass](vk::CommandBuffer cmdbuf) { Record([renderpass_bi, end_renderpass](vk::CommandBuffer cmdbuf) {
if (end_renderpass) { if (end_renderpass) {
@ -157,16 +160,17 @@ void VKScheduler::SubmitExecution(VkSemaphore semaphore) {
current_cmdbuf.End(); current_cmdbuf.End();
VkSubmitInfo submit_info; const VkSubmitInfo submit_info{
submit_info.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; .sType = VK_STRUCTURE_TYPE_SUBMIT_INFO,
submit_info.pNext = nullptr; .pNext = nullptr,
submit_info.waitSemaphoreCount = 0; .waitSemaphoreCount = 0,
submit_info.pWaitSemaphores = nullptr; .pWaitSemaphores = nullptr,
submit_info.pWaitDstStageMask = nullptr; .pWaitDstStageMask = nullptr,
submit_info.commandBufferCount = 1; .commandBufferCount = 1,
submit_info.pCommandBuffers = current_cmdbuf.address(); .pCommandBuffers = current_cmdbuf.address(),
submit_info.signalSemaphoreCount = semaphore ? 1 : 0; .signalSemaphoreCount = semaphore ? 1U : 0U,
submit_info.pSignalSemaphores = &semaphore; .pSignalSemaphores = &semaphore,
};
switch (const VkResult result = device.GetGraphicsQueue().Submit(submit_info, *current_fence)) { switch (const VkResult result = device.GetGraphicsQueue().Submit(submit_info, *current_fence)) {
case VK_SUCCESS: case VK_SUCCESS:
break; break;
@ -181,19 +185,18 @@ void VKScheduler::SubmitExecution(VkSemaphore semaphore) {
void VKScheduler::AllocateNewContext() { void VKScheduler::AllocateNewContext() {
++ticks; ++ticks;
VkCommandBufferBeginInfo cmdbuf_bi;
cmdbuf_bi.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
cmdbuf_bi.pNext = nullptr;
cmdbuf_bi.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
cmdbuf_bi.pInheritanceInfo = nullptr;
std::unique_lock lock{mutex}; std::unique_lock lock{mutex};
current_fence = next_fence; current_fence = next_fence;
next_fence = &resource_manager.CommitFence(); next_fence = &resource_manager.CommitFence();
current_cmdbuf = vk::CommandBuffer(resource_manager.CommitCommandBuffer(*current_fence), current_cmdbuf = vk::CommandBuffer(resource_manager.CommitCommandBuffer(*current_fence),
device.GetDispatchLoader()); device.GetDispatchLoader());
current_cmdbuf.Begin(cmdbuf_bi); current_cmdbuf.Begin({
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO,
.pNext = nullptr,
.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT,
.pInheritanceInfo = nullptr,
});
// Enable counters once again. These are disabled when a command buffer is finished. // Enable counters once again. These are disabled when a command buffer is finished.
if (query_cache) { if (query_cache) {