Code cleanup

This commit is contained in:
Sascha Willems 2024-11-23 15:37:57 +01:00
parent 4d91720ccc
commit 0f56b8270d
5 changed files with 38 additions and 41 deletions

View file

@ -167,7 +167,7 @@ void VulkanExampleBase::renderFrame()
VulkanExampleBase::submitFrame();
}
std::string VulkanExampleBase::getWindowTitle()
std::string VulkanExampleBase::getWindowTitle() const
{
std::string windowTitle{ title + " - " + deviceProperties.deviceName };
if (!settings.overlay) {
@ -1160,7 +1160,7 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
{
this->windowInstance = hinstance;
WNDCLASSEX wndClass;
WNDCLASSEX wndClass{};
wndClass.cbSize = sizeof(WNDCLASSEX);
wndClass.style = CS_HREDRAW | CS_VREDRAW;
@ -3076,26 +3076,23 @@ void VulkanExampleBase::setupDepthStencil()
void VulkanExampleBase::setupFrameBuffer()
{
VkImageView attachments[2];
// Depth/Stencil attachment is the same for all frame buffers
attachments[1] = depthStencil.view;
VkFramebufferCreateInfo frameBufferCreateInfo = {};
frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
frameBufferCreateInfo.pNext = NULL;
frameBufferCreateInfo.renderPass = renderPass;
frameBufferCreateInfo.attachmentCount = 2;
frameBufferCreateInfo.pAttachments = attachments;
frameBufferCreateInfo.width = width;
frameBufferCreateInfo.height = height;
frameBufferCreateInfo.layers = 1;
// Create frame buffers for every swap chain image
frameBuffers.resize(swapChain.imageCount);
for (uint32_t i = 0; i < frameBuffers.size(); i++)
{
attachments[0] = swapChain.buffers[i].view;
const VkImageView attachments[2] = {
swapChain.buffers[i].view,
// Depth/Stencil attachment is the same for all frame buffers
depthStencil.view
};
VkFramebufferCreateInfo frameBufferCreateInfo{};
frameBufferCreateInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
frameBufferCreateInfo.renderPass = renderPass;
frameBufferCreateInfo.attachmentCount = 2;
frameBufferCreateInfo.pAttachments = attachments;
frameBufferCreateInfo.width = width;
frameBufferCreateInfo.height = height;
frameBufferCreateInfo.layers = 1;
VK_CHECK_RESULT(vkCreateFramebuffer(device, &frameBufferCreateInfo, nullptr, &frameBuffers[i]));
}
}
@ -3142,7 +3139,7 @@ void VulkanExampleBase::setupRenderPass()
subpassDescription.pResolveAttachments = nullptr;
// Subpass dependencies for layout transitions
std::array<VkSubpassDependency, 2> dependencies;
std::array<VkSubpassDependency, 2> dependencies{};
dependencies[0].srcSubpass = VK_SUBPASS_EXTERNAL;
dependencies[0].dstSubpass = 0;