Skip to content

Commit b917923

Browse files
committed
Use designated initializers where possible
1 parent 116a68c commit b917923

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

base/vulkanexamplebase.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ std::string VulkanExampleBase::getWindowTitle() const
192192

193193
void VulkanExampleBase::createCommandBuffers()
194194
{
195-
VkCommandBufferAllocateInfo cmdBufAllocateInfo = vks::initializers::commandBufferAllocateInfo(cmdPool, VK_COMMAND_BUFFER_LEVEL_PRIMARY, static_cast<uint32_t>(drawCmdBuffers.size()));
195+
VkCommandBufferAllocateInfo cmdBufAllocateInfo{
196+
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
197+
.commandPool = cmdPool,
198+
.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY,
199+
.commandBufferCount = static_cast<uint32_t>(drawCmdBuffers.size()),
200+
};
196201
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufAllocateInfo, drawCmdBuffers.data()));
197202
}
198203

@@ -208,8 +213,7 @@ std::string VulkanExampleBase::getShadersPath() const
208213

209214
void VulkanExampleBase::createPipelineCache()
210215
{
211-
VkPipelineCacheCreateInfo pipelineCacheCreateInfo = {};
212-
pipelineCacheCreateInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO;
216+
VkPipelineCacheCreateInfo pipelineCacheCreateInfo { .sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO };
213217
VK_CHECK_RESULT(vkCreatePipelineCache(device, &pipelineCacheCreateInfo, nullptr, &pipelineCache));
214218
}
215219

@@ -679,8 +683,8 @@ void VulkanExampleBase::updateOverlay()
679683
void VulkanExampleBase::drawUI(const VkCommandBuffer commandBuffer)
680684
{
681685
if (settings.overlay && ui.visible) {
682-
const VkViewport viewport = vks::initializers::viewport((float)width, (float)height, 0.0f, 1.0f);
683-
const VkRect2D scissor = vks::initializers::rect2D(width, height, 0, 0);
686+
const VkViewport viewport{ .width = (float)width, .height = (float)height, .minDepth = 0.0f, .maxDepth = 1.0f};
687+
const VkRect2D scissor{ .extent = {.width = width, .height = height } };
684688
vkCmdSetViewport(commandBuffer, 0, 1, &viewport);
685689
vkCmdSetScissor(commandBuffer, 0, 1, &scissor);
686690
ui.draw(commandBuffer, currentBuffer);
@@ -2921,19 +2925,19 @@ void VulkanExampleBase::mouseMoved(double x, double y, bool & handled) {}
29212925
void VulkanExampleBase::createSynchronizationPrimitives()
29222926
{
29232927
// Wait fences to sync command buffer access
2924-
VkFenceCreateInfo fenceCreateInfo = vks::initializers::fenceCreateInfo(VK_FENCE_CREATE_SIGNALED_BIT);
2928+
VkFenceCreateInfo fenceCreateInfo{ .sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO, .flags = VK_FENCE_CREATE_SIGNALED_BIT };
29252929
for (auto& fence : waitFences) {
29262930
VK_CHECK_RESULT(vkCreateFence(device, &fenceCreateInfo, nullptr, &fence));
29272931
}
29282932
// Used to ensure that image presentation is complete before starting to submit again
29292933
for (auto& semaphore : presentCompleteSemaphores) {
2930-
VkSemaphoreCreateInfo semaphoreCI{ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
2934+
VkSemaphoreCreateInfo semaphoreCI{ .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
29312935
VK_CHECK_RESULT(vkCreateSemaphore(device, &semaphoreCI, nullptr, &semaphore));
29322936
}
29332937
// Semaphore used to ensure that all commands submitted have been finished before submitting the image to the queue
29342938
renderCompleteSemaphores.resize(swapChain.images.size());
29352939
for (auto& semaphore : renderCompleteSemaphores) {
2936-
VkSemaphoreCreateInfo semaphoreCI{ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
2940+
VkSemaphoreCreateInfo semaphoreCI{ .sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO };
29372941
VK_CHECK_RESULT(vkCreateSemaphore(device, &semaphoreCI, nullptr, &semaphore));
29382942
}
29392943
}

0 commit comments

Comments
 (0)