summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2023-09-15 11:30:35 -0400
committerJonathan Bradley <jcb@pikum.xyz>2023-09-15 11:30:35 -0400
commitb99d942010ed0ee678fafb917a4afd14c8a88fbc (patch)
treeae0877f0a1fceb8ac2d9b1644cfa98b41ccbc6c1 /src/window.cpp
parent766271e601a614a0692366f4caa053b172c2210b (diff)
cleanup vulkan object setup
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp184
1 files changed, 120 insertions, 64 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 02249a5..8e91184 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -188,16 +188,19 @@ void InitVulkan() {
Pke_Delete<VkLayerProperties>(availableLayerProperties, layerCount);
}
- VkApplicationInfo appInfo{};
+ VkApplicationInfo appInfo;
appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO;
- appInfo.apiVersion = VK_API_VERSION_1_3;
+ appInfo.pNext = nullptr;
appInfo.pApplicationName = "pikul";
- appInfo.pEngineName = "pikul";
appInfo.applicationVersion = 1;
+ appInfo.pEngineName = "pikul";
appInfo.engineVersion = 1;
+ appInfo.apiVersion = VK_API_VERSION_1_3;
- VkInstanceCreateInfo createInfo{};
+ VkInstanceCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = {};
createInfo.pApplicationInfo = &appInfo;
createInfo.enabledLayerCount = 0;
@@ -207,8 +210,11 @@ void InitVulkan() {
for (const char *s : enabledLayerNames) {
printf("\t%s\n", s);
}
- VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo{};
+
+ VkDebugUtilsMessengerCreateInfoEXT debugCreateInfo;
debugCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_MESSENGER_CREATE_INFO_EXT;
+ debugCreateInfo.pNext = nullptr;
+ debugCreateInfo.flags = {};
if (ENABLE_VALIDATION_LAYERS) {
createInfo.enabledLayerCount = enabledLayerNames.size();
createInfo.ppEnabledLayerNames = enabledLayerNames.data();
@@ -223,7 +229,6 @@ void InitVulkan() {
VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT;
debugCreateInfo.pfnUserCallback = UserDebugCallback;
debugCreateInfo.pUserData = nullptr;
- debugCreateInfo.pNext = nullptr;
createInfo.pNext = &debugCreateInfo;
}
@@ -238,8 +243,8 @@ void InitVulkan() {
allGlfwExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
allGlfwExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
}
- createInfo.ppEnabledExtensionNames = allGlfwExtensions.data();
createInfo.enabledExtensionCount = allGlfwExtensions.size();
+ createInfo.ppEnabledExtensionNames = allGlfwExtensions.data();
}
printf("Required Extensions:\n");
for (const auto &ext : allGlfwExtensions) {
@@ -268,12 +273,13 @@ void InitVulkan() {
PFN_vkCreateDebugReportCallbackEXT func = (PFN_vkCreateDebugReportCallbackEXT)vkGetInstanceProcAddr(vkInstance, "vkCreateDebugReportCallbackEXT");
assert(func != nullptr && "vkCreateDebugReportCallbackEXT ProcAddr was nullptr");
- VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo{};
+ VkDebugReportCallbackCreateInfoEXT debugReportCallbackCreateInfo;
+ debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
+ debugReportCallbackCreateInfo.pNext = nullptr;
debugReportCallbackCreateInfo.flags =
VK_DEBUG_REPORT_ERROR_BIT_EXT |
VK_DEBUG_REPORT_WARNING_BIT_EXT |
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
- debugReportCallbackCreateInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
debugReportCallbackCreateInfo.pfnCallback = DebugReport;
debugReportCallbackCreateInfo.pUserData = nullptr;
@@ -385,7 +391,7 @@ void InitVulkan() {
deviceQueueCreateInfos[1].queueCount = 1l;
deviceQueueCreateInfos[1].pQueuePriorities = transferPriorities;
- VkPhysicalDeviceFeatures vkPhysicalDeviceFeatures{};
+ VkPhysicalDeviceFeatures vkPhysicalDeviceFeatures;
vkGetPhysicalDeviceFeatures(vkPhysicalDevice, &vkPhysicalDeviceFeatures);
VkPhysicalDeviceFeatures requestedFeatures{}; // {} to initialize everything to 0
@@ -393,19 +399,19 @@ void InitVulkan() {
requestedFeatures.sampleRateShading = VK_TRUE;
requestedFeatures.fillModeNonSolid = vkPhysicalDeviceFeatures.fillModeNonSolid;
- VkDeviceCreateInfo vkDeviceCreateInfo{};
+ VkDeviceCreateInfo vkDeviceCreateInfo;
vkDeviceCreateInfo.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO;
- vkDeviceCreateInfo.flags = 0;
vkDeviceCreateInfo.pNext = nullptr;
+ vkDeviceCreateInfo.flags = 0;
vkDeviceCreateInfo.queueCreateInfoCount = 2;
vkDeviceCreateInfo.pQueueCreateInfos = deviceQueueCreateInfos;
- vkDeviceCreateInfo.enabledExtensionCount = REQUIRED_EXTENSIONS.size();
- vkDeviceCreateInfo.ppEnabledExtensionNames = REQUIRED_EXTENSIONS.data();
- vkDeviceCreateInfo.pEnabledFeatures = &requestedFeatures;
if (ENABLE_VALIDATION_LAYERS) {
vkDeviceCreateInfo.enabledLayerCount = enabledLayerNames.size();
vkDeviceCreateInfo.ppEnabledLayerNames = enabledLayerNames.data();
}
+ vkDeviceCreateInfo.enabledExtensionCount = REQUIRED_EXTENSIONS.size();
+ vkDeviceCreateInfo.ppEnabledExtensionNames = REQUIRED_EXTENSIONS.data();
+ vkDeviceCreateInfo.pEnabledFeatures = &requestedFeatures;
result = vkCreateDevice(vkPhysicalDevice, &vkDeviceCreateInfo, vkAllocator, &vkDevice);
if (result != VK_SUCCESS) {
@@ -422,8 +428,9 @@ void InitVulkan() {
}
// generic present sampler
- VkSamplerCreateInfo samplerCreateInfo{};
+ VkSamplerCreateInfo samplerCreateInfo;
samplerCreateInfo.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO;
+ samplerCreateInfo.pNext = nullptr;
samplerCreateInfo.flags = 0U;
samplerCreateInfo.magFilter = VK_FILTER_NEAREST;
samplerCreateInfo.minFilter = VK_FILTER_NEAREST;
@@ -498,22 +505,26 @@ void CreateSwapchain() {
Pke_Delete<VkPresentModeKHR>(presentModes, presentModeCount);
}
- VkSwapchainCreateInfoKHR vkSwapchainCreateInfo{};
+ VkSwapchainCreateInfoKHR vkSwapchainCreateInfo;
vkSwapchainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR;
+ vkSwapchainCreateInfo.pNext = nullptr;
vkSwapchainCreateInfo.flags = 0;
+ vkSwapchainCreateInfo.surface = vkSurfaceKHR;
vkSwapchainCreateInfo.minImageCount = MAX_FRAMES_IN_FLIGHT;
vkSwapchainCreateInfo.imageFormat = vkSurfaceFormatKHR.format;
vkSwapchainCreateInfo.imageColorSpace = vkSurfaceFormatKHR.colorSpace;
vkSwapchainCreateInfo.imageExtent = extent;
vkSwapchainCreateInfo.imageArrayLayers = 1;
vkSwapchainCreateInfo.imageUsage = VkImageUsageFlagBits::VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
+ vkSwapchainCreateInfo.imageSharingMode = {};
+ vkSwapchainCreateInfo.queueFamilyIndexCount = 0;
+ vkSwapchainCreateInfo.pQueueFamilyIndices = nullptr;
vkSwapchainCreateInfo.preTransform = surfaceCapabilities.currentTransform;
vkSwapchainCreateInfo.compositeAlpha = VkCompositeAlphaFlagBitsKHR::VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR;
vkSwapchainCreateInfo.presentMode = vkPresentModeKHR;
vkSwapchainCreateInfo.clipped = VK_TRUE;
// vkSwapchainCreateInfo.oldSwapchain = vkSwapchainKHR;
vkSwapchainCreateInfo.oldSwapchain = VK_NULL_HANDLE;
- vkSwapchainCreateInfo.surface = vkSurfaceKHR;
unsigned int qfi[2] = { graphicsFamilyIndex, presentFamilyIndex };
if (graphicsFamilyIndex != presentFamilyIndex) {
@@ -534,8 +545,9 @@ void CreateSwapchain() {
vkImageSubresourceRange.baseArrayLayer = 0u;
vkImageSubresourceRange.layerCount = 1u;
- VkImageViewCreateInfo vkImageViewCreateInfo{};
+ VkImageViewCreateInfo vkImageViewCreateInfo;
vkImageViewCreateInfo.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO;
+ vkImageViewCreateInfo.pNext = nullptr;
vkImageViewCreateInfo.flags = 0;
vkImageViewCreateInfo.viewType = VkImageViewType::VK_IMAGE_VIEW_TYPE_2D;
vkImageViewCreateInfo.format = vkSurfaceFormatKHR.format;
@@ -558,7 +570,8 @@ void CreateSwapchain() {
}
void CreateRenderPass() {
- VkAttachmentDescription colorAttachment{};
+ VkAttachmentDescription colorAttachment;
+ colorAttachment.flags = {};
colorAttachment.format = vkSurfaceFormatKHR.format;
colorAttachment.samples = VkSampleCountFlagBits::VK_SAMPLE_COUNT_1_BIT;
colorAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_CLEAR;
@@ -568,14 +581,20 @@ void CreateRenderPass() {
colorAttachment.initialLayout = VK_IMAGE_LAYOUT_UNDEFINED;
colorAttachment.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
- VkAttachmentReference colorAttachmentRef{};
+ VkAttachmentReference colorAttachmentRef;
colorAttachmentRef.attachment = 0;
colorAttachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
- VkSubpassDescription subpass{};
+ VkSubpassDescription subpass;
+ subpass.flags = {};
subpass.pipelineBindPoint = VK_PIPELINE_BIND_POINT_GRAPHICS;
+ subpass.inputAttachmentCount = {};
subpass.colorAttachmentCount = 1;
subpass.pColorAttachments = &colorAttachmentRef;
+ subpass.pResolveAttachments = nullptr;
+ subpass.pDepthStencilAttachment = nullptr;
+ subpass.preserveAttachmentCount = {};
+ subpass.pPreserveAttachments = nullptr;
VkSubpassDependency subpassDependencies[2];
for (long i = 0; i < 2; ++i) {
@@ -596,8 +615,10 @@ void CreateRenderPass() {
subpassDependencies[1].srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_READ_BIT | VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT;
subpassDependencies[1].dstAccessMask = VK_ACCESS_MEMORY_READ_BIT;
- VkRenderPassCreateInfo renderPassInfo{};
+ VkRenderPassCreateInfo renderPassInfo;
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
+ renderPassInfo.pNext = nullptr;
+ renderPassInfo.flags = {};
renderPassInfo.attachmentCount = 1;
renderPassInfo.pAttachments = &colorAttachment;
renderPassInfo.subpassCount = 1;
@@ -619,10 +640,10 @@ void CreateGraphicsPipeline() {
VkPipelineShaderStageCreateInfo shaderStages[2];
for (long i = 0; i < 2; ++i) {
shaderStages[i].sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO;
+ shaderStages[i].pNext = nullptr;
shaderStages[i].flags = 0;
shaderStages[i].pName = "main";
shaderStages[i].pSpecializationInfo = nullptr;
- shaderStages[i].pNext = nullptr;
}
shaderStages[0].stage = VK_SHADER_STAGE_VERTEX_BIT;
shaderStages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT;
@@ -633,24 +654,31 @@ void CreateGraphicsPipeline() {
VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR
};
- VkPipelineDynamicStateCreateInfo dynamicState{};
+
+ VkPipelineDynamicStateCreateInfo dynamicState;
dynamicState.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO;
+ dynamicState.pNext = nullptr;
+ dynamicState.flags = {};
dynamicState.dynamicStateCount = 2;
dynamicState.pDynamicStates = dynamicStates;
- VkPipelineVertexInputStateCreateInfo vertexInputInfo{};
+ VkPipelineVertexInputStateCreateInfo vertexInputInfo;
vertexInputInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO;
+ vertexInputInfo.pNext = nullptr;
+ vertexInputInfo.flags = {};
vertexInputInfo.vertexBindingDescriptionCount = 0;
vertexInputInfo.pVertexBindingDescriptions = nullptr;
vertexInputInfo.vertexAttributeDescriptionCount = 0;
vertexInputInfo.pVertexAttributeDescriptions = nullptr;
- VkPipelineInputAssemblyStateCreateInfo inputAssembly{};
+ VkPipelineInputAssemblyStateCreateInfo inputAssembly;
inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO;
+ inputAssembly.pNext = nullptr;
+ inputAssembly.flags = {};
inputAssembly.topology = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST;
inputAssembly.primitiveRestartEnable = VK_FALSE;
- VkViewport viewport{};
+ VkViewport viewport;
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float) extent.width;
@@ -658,43 +686,49 @@ void CreateGraphicsPipeline() {
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
- VkRect2D scissor{};
+ VkRect2D scissor;
scissor.offset = {0, 0};
scissor.extent = extent;
- VkPipelineViewportStateCreateInfo viewportState{};
+ VkPipelineViewportStateCreateInfo viewportState;
viewportState.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO;
+ viewportState.pNext = nullptr;
+ viewportState.flags = {};
viewportState.viewportCount = 1;
viewportState.pViewports = &viewport;
viewportState.scissorCount = 1;
viewportState.pScissors = &scissor;
- VkPipelineRasterizationStateCreateInfo rasterizer{};
+ VkPipelineRasterizationStateCreateInfo rasterizer;
rasterizer.sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO;
+ rasterizer.pNext = nullptr;
+ rasterizer.flags = {};
rasterizer.depthClampEnable = VK_FALSE;
rasterizer.rasterizerDiscardEnable = VK_FALSE;
rasterizer.polygonMode = VK_POLYGON_MODE_FILL;
- rasterizer.lineWidth = 1.0f;
rasterizer.cullMode = VK_CULL_MODE_BACK_BIT;
rasterizer.frontFace = VK_FRONT_FACE_CLOCKWISE;
rasterizer.depthBiasEnable = VK_FALSE;
rasterizer.depthBiasConstantFactor = 0.0f;
rasterizer.depthBiasClamp = 0.0f;
rasterizer.depthBiasSlopeFactor = 0.0f;
+ rasterizer.lineWidth = 1.0f;
- VkPipelineMultisampleStateCreateInfo multisampling{};
+ VkPipelineMultisampleStateCreateInfo multisampling;
multisampling.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO;
- multisampling.sampleShadingEnable = VK_FALSE;
+ multisampling.pNext = nullptr;
+ multisampling.flags = {};
multisampling.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT;
+ multisampling.sampleShadingEnable = VK_FALSE;
multisampling.minSampleShading = 1.0f;
multisampling.pSampleMask = nullptr;
multisampling.alphaToCoverageEnable = VK_FALSE;
multisampling.alphaToOneEnable = VK_FALSE;
+ // TODO
VkPipelineDepthStencilStateCreateInfo *depthStencilInfo = nullptr;
- VkPipelineColorBlendAttachmentState colorBlendAttachment{};
- colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
+ VkPipelineColorBlendAttachmentState colorBlendAttachment;
colorBlendAttachment.blendEnable = VK_FALSE;
colorBlendAttachment.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
colorBlendAttachment.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
@@ -702,9 +736,12 @@ void CreateGraphicsPipeline() {
colorBlendAttachment.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
colorBlendAttachment.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
colorBlendAttachment.alphaBlendOp = VK_BLEND_OP_ADD;
+ colorBlendAttachment.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT | VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
- VkPipelineColorBlendStateCreateInfo colorBlending{};
+ VkPipelineColorBlendStateCreateInfo colorBlending;
colorBlending.sType = VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO;
+ colorBlending.pNext = nullptr;
+ colorBlending.flags = {};
colorBlending.logicOpEnable = VK_FALSE;
colorBlending.logicOp = VK_LOGIC_OP_COPY;
colorBlending.attachmentCount = 1;
@@ -719,7 +756,7 @@ void CreateGraphicsPipeline() {
*/
/*
- VkDescriptorSetLayoutBinding imageSamplerLayoutBinding{};
+ VkDescriptorSetLayoutBinding imageSamplerLayoutBinding;
imageSamplerLayoutBinding.binding = 0;
imageSamplerLayoutBinding.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
imageSamplerLayoutBinding.descriptorCount = 1;
@@ -727,8 +764,9 @@ void CreateGraphicsPipeline() {
imageSamplerLayoutBinding.pImmutableSamplers = nullptr;
*/
- VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo{};
+ VkDescriptorSetLayoutCreateInfo descriptorSetLayoutCreateInfo;
descriptorSetLayoutCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
+ descriptorSetLayoutCreateInfo.pNext = nullptr;
descriptorSetLayoutCreateInfo.flags = 0;
descriptorSetLayoutCreateInfo.bindingCount = 0;
descriptorSetLayoutCreateInfo.pBindings = nullptr;
@@ -743,32 +781,34 @@ void CreateGraphicsPipeline() {
}
/*
- VkDescriptorPoolSize vkDescriptorPoolSize{};
- vkDescriptorPoolSize.descriptorCount = swapchainLength;
+ VkDescriptorPoolSize vkDescriptorPoolSize;
vkDescriptorPoolSize.type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER;
+ vkDescriptorPoolSize.descriptorCount = swapchainLength;
- VkDescriptorPoolCreateInfo descriptorPoolCreateInfo{};
+ VkDescriptorPoolCreateInfo descriptorPoolCreateInfo;
descriptorPoolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ descriptorPoolCreateInfo.pNext = nullptr;
descriptorPoolCreateInfo.flags = 0;
descriptorPoolCreateInfo.maxSets = 1;
descriptorPoolCreateInfo.poolSizeCount = 1;
descriptorPoolCreateInfo.pPoolSizes = &vkDescriptorPoolSize;
- descriptorPoolCreateInfo.pNext = nullptr;
vkCreateDescriptorPool(vkDevice, &descriptorPoolCreateInfo, vkAllocator, &presentDescriptorPool);
- VkDescriptorSetAllocateInfo allocInfo{};
+ VkDescriptorSetAllocateInfo allocInfo;
allocInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO;
+ allocInfo.pNext = nullptr;
allocInfo.descriptorPool = presentDescriptorPool;
allocInfo.descriptorSetCount = 1;
allocInfo.pSetLayouts = &vkDescriptorSetLayout;
- allocInfo.pNext = nullptr;
vkAllocateDescriptorSets(vkDevice, &allocInfo, presentDescriptorSets);
*/
- VkPipelineLayoutCreateInfo pipelineLayoutInfo{};
+ VkPipelineLayoutCreateInfo pipelineLayoutInfo;
pipelineLayoutInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO;
+ pipelineLayoutInfo.pNext = nullptr;
+ pipelineLayoutInfo.flags = {};
pipelineLayoutInfo.setLayoutCount = 1;
pipelineLayoutInfo.pSetLayouts = &vkDescriptorSetLayout;
pipelineLayoutInfo.pushConstantRangeCount = 0;
@@ -779,8 +819,10 @@ void CreateGraphicsPipeline() {
throw "failed to create pipeline layout";
}
- VkGraphicsPipelineCreateInfo pipelineInfo{};
+ VkGraphicsPipelineCreateInfo pipelineInfo;
pipelineInfo.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO;
+ pipelineInfo.pNext = nullptr;
+ pipelineInfo.flags = {};
pipelineInfo.stageCount = 2;
pipelineInfo.pStages = shaderStages;
@@ -844,10 +886,13 @@ void CreateFramebuffers() {
assert(swapchainFramebuffers == nullptr || swapchainFramebuffers == CAFE_BABE(VkFramebuffer));
swapchainFramebuffers = Pke_New<VkFramebuffer>(swapchainLength);
- VkFramebufferCreateInfo framebufferInfo{};
+ VkFramebufferCreateInfo framebufferInfo;
framebufferInfo.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
+ framebufferInfo.pNext = nullptr;
+ framebufferInfo.flags = {};
framebufferInfo.renderPass = renderPass;
framebufferInfo.attachmentCount = 1;
+ framebufferInfo.pAttachments = nullptr;
framebufferInfo.width = extent.width;
framebufferInfo.height = extent.height;
framebufferInfo.layers = 1;
@@ -865,8 +910,9 @@ void CreateFramebuffers() {
}
void CreateCommandPool() {
- VkCommandPoolCreateInfo poolInfo{};
+ VkCommandPoolCreateInfo poolInfo;
poolInfo.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
+ poolInfo.pNext = nullptr;
poolInfo.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT;
poolInfo.queueFamilyIndex = graphicsFamilyIndex;
@@ -884,8 +930,9 @@ void CreateCommandPool() {
}
void CreateCommandBuffer() {
- VkCommandBufferAllocateInfo allocInfo{};
+ VkCommandBufferAllocateInfo allocInfo;
allocInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO;
+ allocInfo.pNext = nullptr;
allocInfo.commandPool = graphicsCommandPool;
allocInfo.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
allocInfo.commandBufferCount = MAX_FRAMES_IN_FLIGHT;
@@ -909,11 +956,14 @@ void CreateCommandBuffer() {
}
void CreateSyncObjects() {
- VkSemaphoreCreateInfo semaphoreInfo{};
+ VkSemaphoreCreateInfo semaphoreInfo;
semaphoreInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
+ semaphoreInfo.pNext = nullptr;
+ semaphoreInfo.flags = {};
- VkFenceCreateInfo fenceInfo{};
+ VkFenceCreateInfo fenceInfo;
fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO;
+ fenceInfo.pNext = nullptr;
fenceInfo.flags = VK_FENCE_CREATE_SIGNALED_BIT;
for (long i = 0; i < MAX_FRAMES_IN_FLIGHT; ++i) {
@@ -950,8 +1000,9 @@ void CreateImGui() {
{VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, 1000},
};
- VkDescriptorPoolCreateInfo descriptorPoolCreateInfo{};
+ VkDescriptorPoolCreateInfo descriptorPoolCreateInfo;
descriptorPoolCreateInfo.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO;
+ descriptorPoolCreateInfo.pNext = nullptr;
descriptorPoolCreateInfo.flags = VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT;
descriptorPoolCreateInfo.maxSets = 1000 * IM_ARRAYSIZE(poolSizes),
descriptorPoolCreateInfo.poolSizeCount = static_cast<uint32_t>(IM_ARRAYSIZE(poolSizes));
@@ -960,7 +1011,7 @@ void CreateImGui() {
vkCreateDescriptorPool(vkDevice, &descriptorPoolCreateInfo, vkAllocator, &imGuiDescriptorPool);
ImGui_ImplGlfw_InitForVulkan(window, true);
- ImGui_ImplVulkan_InitInfo initInfo{};
+ ImGui_ImplVulkan_InitInfo initInfo;
initInfo.Allocator = vkAllocator;
initInfo.CheckVkResultFn = ImGuiCheckVkResult;
initInfo.ColorAttachmentFormat = VkFormat::VK_FORMAT_B8G8R8A8_SRGB;
@@ -981,19 +1032,20 @@ void CreateImGui() {
// font
{
- VkCommandBufferBeginInfo begInfo{};
+ VkCommandBufferBeginInfo begInfo;
begInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
+ begInfo.pNext = nullptr;
begInfo.flags = VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT;
begInfo.pInheritanceInfo = {};
- begInfo.pNext = nullptr;
vkBeginCommandBuffer(presentCommandBuffers[0], &begInfo);
ImGui_ImplVulkan_CreateFontsTexture(presentCommandBuffers[0]);
vkEndCommandBuffer(presentCommandBuffers[0]);
- VkSubmitInfo submitInfo{};
+ VkSubmitInfo submitInfo;
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submitInfo.pNext = nullptr;
submitInfo.waitSemaphoreCount = 0;
submitInfo.pWaitSemaphores = nullptr;
submitInfo.pWaitDstStageMask = nullptr;
@@ -1010,7 +1062,7 @@ void CreateImGui() {
void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) {
vkResetCommandBuffer(commandBuffer, 0);
- VkCommandBufferBeginInfo beginInfo {};
+ VkCommandBufferBeginInfo beginInfo;
beginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
beginInfo.flags = 0;
beginInfo.pInheritanceInfo = nullptr;
@@ -1045,7 +1097,7 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) {
// present pass
VkClearValue clearColor = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
- VkRenderPassBeginInfo renderPassInfo{};
+ VkRenderPassBeginInfo renderPassInfo;
renderPassInfo.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO;
renderPassInfo.renderPass = renderPass;
renderPassInfo.framebuffer = swapchainFramebuffers[imageIndex];
@@ -1058,7 +1110,7 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) {
vkCmdBeginRenderPass(commandBuffer, &renderPassInfo, VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_GRAPHICS, graphicsPipeline);
- VkViewport viewport{};
+ VkViewport viewport;
viewport.x = 0.0f;
viewport.y = 0.0f;
viewport.width = (float)extent.width;
@@ -1066,7 +1118,7 @@ void RecordCommandBuffer(VkCommandBuffer commandBuffer, uint32_t imageIndex) {
viewport.minDepth = 0.0f;
viewport.maxDepth = 1.0f;
- VkRect2D scissor{};
+ VkRect2D scissor;
scissor.offset = {0, 0};
scissor.extent = extent;
@@ -1195,8 +1247,10 @@ void DestroyWindow() {
VkShaderModule UploadShader(AssetHandle handle) {
const Asset *asset = AM_Get(handle);
- VkShaderModuleCreateInfo createInfo{};
+ VkShaderModuleCreateInfo createInfo;
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
+ createInfo.pNext = nullptr;
+ createInfo.flags = {};
createInfo.codeSize = asset->size;
createInfo.pCode = static_cast<const uint32_t *>(asset->ptr);
@@ -1229,8 +1283,9 @@ void Render() {
VkSemaphore signalSemaphores[] = {presentRenderFinishedSemaphores[CURRENT_FRAME]};
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT};
- VkSubmitInfo submitInfo{};
+ VkSubmitInfo submitInfo;
submitInfo.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
+ submitInfo.pNext = nullptr;
submitInfo.waitSemaphoreCount = 1;
submitInfo.pWaitSemaphores = waitSemaphores;
submitInfo.pWaitDstStageMask = waitStages;
@@ -1246,8 +1301,9 @@ void Render() {
VkSwapchainKHR swapchains[] = {vkSwapchainKHR};
- VkPresentInfoKHR presentInfo{};
+ VkPresentInfoKHR presentInfo;
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
+ presentInfo.pNext = nullptr;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = signalSemaphores;
presentInfo.swapchainCount = 1;