diff --git a/Common/Vulkan/VulkanContext.cpp b/Common/Vulkan/VulkanContext.cpp index 4c387df779..917193b596 100644 --- a/Common/Vulkan/VulkanContext.cpp +++ b/Common/Vulkan/VulkanContext.cpp @@ -88,9 +88,7 @@ VulkanContext::VulkanContext(const char *app_name, int app_ver, uint32_t flags) instance_extension_names.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); } - VkApplicationInfo app_info = {}; - app_info.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; - app_info.pNext = NULL; + VkApplicationInfo app_info = { VK_STRUCTURE_TYPE_APPLICATION_INFO }; app_info.pApplicationName = app_name; app_info.applicationVersion = app_ver; app_info.pEngineName = app_name; @@ -99,9 +97,7 @@ VulkanContext::VulkanContext(const char *app_name, int app_ver, uint32_t flags) // Don't specify the API patch version. app_info.apiVersion = VK_MAKE_VERSION(1, 0, 0); - VkInstanceCreateInfo inst_info = {}; - inst_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; - inst_info.pNext = NULL; + VkInstanceCreateInfo inst_info = { VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO }; inst_info.flags = 0; inst_info.pApplicationInfo = &app_info; inst_info.enabledLayerCount = (uint32_t)instance_layer_names.size(); @@ -165,9 +161,7 @@ VulkanContext::~VulkanContext() { } void TransitionToPresent(VkCommandBuffer cmd, VkImage image) { - VkImageMemoryBarrier prePresentBarrier = {}; - prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - prePresentBarrier.pNext = NULL; + VkImageMemoryBarrier prePresentBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; prePresentBarrier.srcAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; prePresentBarrier.dstAccessMask = 0; prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; @@ -185,9 +179,7 @@ void TransitionToPresent(VkCommandBuffer cmd, VkImage image) { } void TransitionFromPresent(VkCommandBuffer cmd, VkImage image) { - VkImageMemoryBarrier prePresentBarrier = {}; - prePresentBarrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - prePresentBarrier.pNext = NULL; + VkImageMemoryBarrier prePresentBarrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; prePresentBarrier.srcAccessMask = 0; prePresentBarrier.dstAccessMask = VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT; prePresentBarrier.oldLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR; @@ -234,18 +226,14 @@ VkCommandBuffer VulkanContext::BeginSurfaceRenderPass(VkClearValue clear_values[ // Process pending deletes. frame->deleteList.PerformDeletes(device_); - VkCommandBufferBeginInfo begin; - begin.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - begin.pNext = NULL; + VkCommandBufferBeginInfo begin = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; begin.flags = 0; begin.pInheritanceInfo = nullptr; res = vkBeginCommandBuffer(frame->cmdBuf, &begin); TransitionFromPresent(frame->cmdBuf, swapChainBuffers[current_buffer].image); - VkRenderPassBeginInfo rp_begin; - rp_begin.sType = VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO; - rp_begin.pNext = NULL; + VkRenderPassBeginInfo rp_begin = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; rp_begin.renderPass = surface_render_pass_; rp_begin.framebuffer = framebuffers_[current_buffer]; rp_begin.renderArea.offset.x = 0; @@ -288,23 +276,19 @@ void VulkanContext::EndSurfaceRenderPass() { cmdQueue_.clear(); cmdBufs.push_back(frame->cmdBuf); - VkSubmitInfo submit_info[1] = {}; - submit_info[0].pNext = NULL; - submit_info[0].sType = VK_STRUCTURE_TYPE_SUBMIT_INFO; - submit_info[0].waitSemaphoreCount = 1; - submit_info[0].pWaitSemaphores = &acquireSemaphore; + VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO }; + submit_info.waitSemaphoreCount = 1; + submit_info.pWaitSemaphores = &acquireSemaphore; VkPipelineStageFlags waitStage[1] = { VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT }; - submit_info[0].pWaitDstStageMask = waitStage; - submit_info[0].commandBufferCount = (uint32_t)cmdBufs.size(); - submit_info[0].pCommandBuffers = cmdBufs.data(); - submit_info[0].signalSemaphoreCount = 0; - submit_info[0].pSignalSemaphores = NULL; - res = vkQueueSubmit(gfx_queue_, 1, submit_info, frame->fence); + submit_info.pWaitDstStageMask = waitStage; + submit_info.commandBufferCount = (uint32_t)cmdBufs.size(); + submit_info.pCommandBuffers = cmdBufs.data(); + submit_info.signalSemaphoreCount = 0; + submit_info.pSignalSemaphores = NULL; + res = vkQueueSubmit(gfx_queue_, 1, &submit_info, frame->fence); assert(res == VK_SUCCESS); - VkPresentInfoKHR present; - present.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; - present.pNext = NULL; + VkPresentInfoKHR present = { VK_STRUCTURE_TYPE_PRESENT_INFO_KHR }; present.swapchainCount = 1; present.pSwapchains = &swap_chain_; present.pImageIndices = ¤t_buffer; @@ -344,9 +328,7 @@ bool VulkanContext::MemoryTypeFromProperties(uint32_t typeBits, VkFlags requirem void VulkanBeginCommandBuffer(VkCommandBuffer cmd) { VkResult U_ASSERT_ONLY res; - VkCommandBufferBeginInfo cmd_buf_info = {}; - cmd_buf_info.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO; - cmd_buf_info.pNext = NULL; + VkCommandBufferBeginInfo cmd_buf_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; cmd_buf_info.pInheritanceInfo = nullptr; cmd_buf_info.flags = 0; res = vkBeginCommandBuffer(cmd, &cmd_buf_info); @@ -359,9 +341,7 @@ void VulkanContext::InitObjects(bool depthPresent) { // Create frame data - VkCommandBufferAllocateInfo cmd_alloc = {}; - cmd_alloc.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO; - cmd_alloc.pNext = NULL; + VkCommandBufferAllocateInfo cmd_alloc = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; cmd_alloc.commandPool = cmd_pool_; cmd_alloc.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY; cmd_alloc.commandBufferCount = 4; @@ -607,7 +587,6 @@ static VkBool32 CheckLayers(const std::vector &layer_props, co VkResult VulkanContext::CreateDevice(int physical_device) { VkResult res; - VkDeviceQueueCreateInfo queue_info = {}; if (!init_error_.empty()) { ELOG("Vulkan init failed: %s", init_error_.c_str()); @@ -621,6 +600,10 @@ VkResult VulkanContext::CreateDevice(int physical_device) { vkGetPhysicalDeviceQueueFamilyProperties(physical_devices_[0], &queue_count, queue_props.data()); assert(queue_count >= 1); + VkDeviceQueueCreateInfo queue_info = { VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO }; + float queue_priorities[1] = { 0.0 }; + queue_info.queueCount = 1; + queue_info.pQueuePriorities = queue_priorities; bool found = false; for (int i = 0; i < (int)queue_count; i++) { if (queue_props[i].queueFlags & VK_QUEUE_GRAPHICS_BIT) { @@ -632,6 +615,7 @@ VkResult VulkanContext::CreateDevice(int physical_device) { assert(found); assert(queue_count >= 1); + // Detect preferred formats, in this order. static const VkFormat depthStencilFormats[] = { VK_FORMAT_D24_UNORM_S8_UINT, @@ -652,12 +636,6 @@ VkResult VulkanContext::CreateDevice(int physical_device) { vkGetPhysicalDeviceMemoryProperties(physical_devices_[0], &memory_properties); vkGetPhysicalDeviceProperties(physical_devices_[0], &gpu_props); - float queue_priorities[1] = { 0.0 }; - queue_info.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; - queue_info.pNext = nullptr; - queue_info.queueCount = 1; - queue_info.pQueuePriorities = queue_priorities; - // Optional features vkGetPhysicalDeviceFeatures(physical_devices_[0], &featuresAvailable_); memset(&featuresEnabled_, 0, sizeof(featuresEnabled_)); @@ -688,9 +666,7 @@ VkResult VulkanContext::CreateDevice(int physical_device) { featuresEnabled_.samplerAnisotropy = true; } - VkDeviceCreateInfo device_info = {}; - device_info.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; - device_info.pNext = NULL; + VkDeviceCreateInfo device_info = { VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO }; device_info.queueCreateInfoCount = 1; device_info.pQueueCreateInfos = &queue_info; device_info.enabledLayerCount = (uint32_t)device_layer_names.size(); @@ -751,12 +727,10 @@ void VulkanContext::DestroyDebugMsgCallback() { void VulkanContext::InitDepthStencilBuffer(VkCommandBuffer cmd) { VkResult U_ASSERT_ONLY res; bool U_ASSERT_ONLY pass; - VkImageCreateInfo image_info = {}; const VkFormat depth_format = deviceInfo_.preferredDepthStencilFormat; int aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT; - image_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - image_info.pNext = NULL; + VkImageCreateInfo image_info = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; image_info.imageType = VK_IMAGE_TYPE_2D; image_info.format = depth_format; image_info.extent.width = width_; @@ -771,9 +745,7 @@ void VulkanContext::InitDepthStencilBuffer(VkCommandBuffer cmd) { image_info.usage = VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT; image_info.flags = 0; - VkMemoryAllocateInfo mem_alloc = {}; - mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - mem_alloc.pNext = NULL; + VkMemoryAllocateInfo mem_alloc = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO }; mem_alloc.allocationSize = 0; mem_alloc.memoryTypeIndex = 0; @@ -804,9 +776,7 @@ void VulkanContext::InitDepthStencilBuffer(VkCommandBuffer cmd) { VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL); - VkImageViewCreateInfo depth_view_info = {}; - depth_view_info.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - depth_view_info.pNext = NULL; + VkImageViewCreateInfo depth_view_info = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; depth_view_info.image = depth.image; depth_view_info.format = depth_format; depth_view_info.components.r = VK_COMPONENT_SWIZZLE_R; @@ -949,9 +919,7 @@ void VulkanContext::InitQueue() { vkGetDeviceQueue(device_, graphics_queue_family_index_, 0, &gfx_queue_); ILOG("gfx_queue_: %p", gfx_queue_); - VkSemaphoreCreateInfo acquireSemaphoreCreateInfo; - acquireSemaphoreCreateInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO; - acquireSemaphoreCreateInfo.pNext = NULL; + VkSemaphoreCreateInfo acquireSemaphoreCreateInfo = { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; acquireSemaphoreCreateInfo.flags = 0; res = vkCreateSemaphore(device_, @@ -1038,9 +1006,7 @@ void VulkanContext::InitSwapchain(VkCommandBuffer cmd) { preTransform = surfCapabilities.currentTransform; } - VkSwapchainCreateInfoKHR swap_chain_info = {}; - swap_chain_info.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; - swap_chain_info.pNext = NULL; + VkSwapchainCreateInfoKHR swap_chain_info = { VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; swap_chain_info.surface = surface_; swap_chain_info.minImageCount = desiredNumberOfSwapChainImages; swap_chain_info.imageFormat = swapchain_format; @@ -1073,9 +1039,7 @@ void VulkanContext::InitSwapchain(VkCommandBuffer cmd) { for (uint32_t i = 0; i < swapchainImageCount; i++) { swap_chain_buffer sc_buffer; - VkImageViewCreateInfo color_image_view = {}; - color_image_view.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; - color_image_view.pNext = NULL; + VkImageViewCreateInfo color_image_view = { VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO }; color_image_view.format = swapchain_format; color_image_view.components.r = VK_COMPONENT_SWIZZLE_R; color_image_view.components.g = VK_COMPONENT_SWIZZLE_G; @@ -1156,8 +1120,7 @@ void VulkanContext::InitSurfaceRenderPass(bool include_depth, bool clear) { subpass.preserveAttachmentCount = 0; subpass.pPreserveAttachments = NULL; - VkRenderPassCreateInfo rp_info = {}; - rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO; + VkRenderPassCreateInfo rp_info = { VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; rp_info.pNext = NULL; rp_info.attachmentCount = include_depth ? 2 : 1; rp_info.pAttachments = attachments; @@ -1196,9 +1159,7 @@ void VulkanContext::InitFramebuffers(bool include_depth) { void VulkanContext::InitCommandPool() { VkResult U_ASSERT_ONLY res; - VkCommandPoolCreateInfo cmd_pool_info = {}; - cmd_pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - cmd_pool_info.pNext = NULL; + VkCommandPoolCreateInfo cmd_pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; cmd_pool_info.queueFamilyIndex = graphics_queue_family_index_; cmd_pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT | VK_COMMAND_POOL_CREATE_TRANSIENT_BIT; @@ -1208,9 +1169,7 @@ void VulkanContext::InitCommandPool() { VkFence VulkanContext::CreateFence(bool presignalled) { VkFence fence; - VkFenceCreateInfo fenceInfo; - fenceInfo.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO; - fenceInfo.pNext = NULL; + VkFenceCreateInfo fenceInfo = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; fenceInfo.flags = presignalled ? VK_FENCE_CREATE_SIGNALED_BIT : 0; vkCreateFence(device_, &fenceInfo, NULL, &fence); return fence; @@ -1230,6 +1189,7 @@ void VulkanContext::DestroyDepthStencilBuffer() { vkDestroyImageView(device_, depth.view, NULL); vkDestroyImage(device_, depth.image, NULL); vkFreeMemory(device_, depth.mem, NULL); + depth.view = VK_NULL_HANDLE; depth.image = VK_NULL_HANDLE; depth.mem = VK_NULL_HANDLE; @@ -1274,9 +1234,7 @@ VkPipelineCache VulkanContext::CreatePipelineCache() { } bool VulkanContext::CreateShaderModule(const std::vector &spirv, VkShaderModule *shaderModule) { - VkShaderModuleCreateInfo sm; - sm.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO; - sm.pNext = nullptr; + VkShaderModuleCreateInfo sm = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO }; sm.pCode = spirv.data(); sm.codeSize = spirv.size() * sizeof(uint32_t); sm.flags = 0; @@ -1289,9 +1247,7 @@ bool VulkanContext::CreateShaderModule(const std::vector &spirv, VkSha } void TransitionImageLayout(VkCommandBuffer cmd, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout old_image_layout, VkImageLayout new_image_layout) { - VkImageMemoryBarrier image_memory_barrier = {}; - image_memory_barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER; - image_memory_barrier.pNext = NULL; + VkImageMemoryBarrier image_memory_barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; image_memory_barrier.srcAccessMask = 0; image_memory_barrier.dstAccessMask = 0; image_memory_barrier.oldLayout = old_image_layout; diff --git a/Common/Vulkan/VulkanImage.cpp b/Common/Vulkan/VulkanImage.cpp index 5bbd680698..876da2cad3 100644 --- a/Common/Vulkan/VulkanImage.cpp +++ b/Common/Vulkan/VulkanImage.cpp @@ -31,9 +31,7 @@ void VulkanTexture::CreateMappableImage() { bool U_ASSERT_ONLY pass; - VkImageCreateInfo image_create_info = {}; - image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - image_create_info.pNext = NULL; + VkImageCreateInfo image_create_info = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; image_create_info.imageType = VK_IMAGE_TYPE_2D; image_create_info.format = format_; image_create_info.extent.width = tex_width; @@ -50,9 +48,7 @@ void VulkanTexture::CreateMappableImage() { image_create_info.flags = 0; image_create_info.initialLayout = VK_IMAGE_LAYOUT_PREINITIALIZED; - VkMemoryAllocateInfo mem_alloc = {}; - mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - mem_alloc.pNext = NULL; + VkMemoryAllocateInfo mem_alloc = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO }; mem_alloc.allocationSize = 0; mem_alloc.memoryTypeIndex = 0; @@ -113,9 +109,7 @@ void VulkanTexture::Unlock() { mappableImage = VK_NULL_HANDLE; mappableMemory = VK_NULL_HANDLE; } else { - VkImageCreateInfo image_create_info = {}; - image_create_info.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO; - image_create_info.pNext = NULL; + VkImageCreateInfo image_create_info = { VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO }; image_create_info.imageType = VK_IMAGE_TYPE_2D; image_create_info.format = format_; image_create_info.extent.width = tex_width; @@ -138,9 +132,7 @@ void VulkanTexture::Unlock() { vkGetImageMemoryRequirements(vulkan_->GetDevice(), image, &mem_reqs); - VkMemoryAllocateInfo mem_alloc = {}; - mem_alloc.sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO; - mem_alloc.pNext = NULL; + VkMemoryAllocateInfo mem_alloc = { VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO }; mem_alloc.memoryTypeIndex = 0; mem_alloc.allocationSize = mem_reqs.size; diff --git a/GPU/Vulkan/DrawEngineVulkan.cpp b/GPU/Vulkan/DrawEngineVulkan.cpp index c0e6806e75..3ca11821ed 100644 --- a/GPU/Vulkan/DrawEngineVulkan.cpp +++ b/GPU/Vulkan/DrawEngineVulkan.cpp @@ -129,9 +129,7 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan) VkDevice device = vulkan_->GetDevice(); - VkDescriptorSetLayoutCreateInfo dsl; - dsl.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - dsl.pNext = nullptr; + VkDescriptorSetLayoutCreateInfo dsl = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; dsl.bindingCount = 5; dsl.pBindings = bindings; VkResult res = vkCreateDescriptorSetLayout(device, &dsl, nullptr, &descriptorSetLayout_); @@ -143,8 +141,7 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan) dpTypes[1].descriptorCount = 200; dpTypes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - VkDescriptorPoolCreateInfo dp; - dp.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; + VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; dp.pNext = nullptr; dp.flags = 0; // Don't want to mess around with individually freeing these, let's go fixed each frame and zap the whole array. Might try the dynamic approach later. dp.maxSets = 1000; @@ -161,9 +158,7 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan) frame_[i].pushIndex = new VulkanPushBuffer(vulkan_, 1 * 1024 * 1024); } - VkPipelineLayoutCreateInfo pl; - pl.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - pl.pNext = nullptr; + VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; pl.pushConstantRangeCount = 0; pl.setLayoutCount = 1; @@ -172,9 +167,7 @@ DrawEngineVulkan::DrawEngineVulkan(VulkanContext *vulkan) res = vkCreatePipelineLayout(device, &pl, nullptr, &pipelineLayout_); assert(VK_SUCCESS == res); - VkSamplerCreateInfo samp = {}; - samp.sType = VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO; - samp.pNext = nullptr; + VkSamplerCreateInfo samp = { VK_STRUCTURE_TYPE_SAMPLER_CREATE_INFO }; samp.addressModeU = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; samp.addressModeV = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; samp.addressModeW = VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; @@ -500,9 +493,7 @@ VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSamp // We wipe the cache on every frame. VkDescriptorSet desc; - VkDescriptorSetAllocateInfo descAlloc; - VkDescriptorImageInfo tex; - descAlloc.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO; + VkDescriptorSetAllocateInfo descAlloc = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; descAlloc.pNext = nullptr; descAlloc.pSetLayouts = &descriptorSetLayout_; descAlloc.descriptorPool = frame->descPool; @@ -515,6 +506,7 @@ VkDescriptorSet DrawEngineVulkan::GetDescriptorSet(VkImageView imageView, VkSamp memset(writes, 0, sizeof(writes)); // Main texture int n = 0; + VkDescriptorImageInfo tex; if (imageView) { // TODO: Also support LAYOUT_GENERAL to be able to texture from framebuffers without transitioning them? tex.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL; diff --git a/GPU/Vulkan/VulkanUtil.cpp b/GPU/Vulkan/VulkanUtil.cpp index f8f70f4c37..91de80234b 100644 --- a/GPU/Vulkan/VulkanUtil.cpp +++ b/GPU/Vulkan/VulkanUtil.cpp @@ -152,7 +152,6 @@ VkDescriptorSet Vulkan2D::GetDescriptorSet(VkImageView tex1, VkSampler sampler1, image1.imageView = tex1; image1.sampler = sampler1; writes[n].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writes[n].pNext = nullptr; writes[n].dstBinding = 0; writes[n].pImageInfo = &image1; writes[n].descriptorCount = 1; @@ -166,7 +165,6 @@ VkDescriptorSet Vulkan2D::GetDescriptorSet(VkImageView tex1, VkSampler sampler1, image2.imageView = tex2; image2.sampler = sampler2; writes[n].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET; - writes[n].pNext = nullptr; writes[n].dstBinding = 1; writes[n].pImageInfo = &image2; writes[n].descriptorCount = 1; diff --git a/ext/native/thin3d/thin3d_vulkan.cpp b/ext/native/thin3d/thin3d_vulkan.cpp index f00bf86c7f..f2e6a7fb1c 100644 --- a/ext/native/thin3d/thin3d_vulkan.cpp +++ b/ext/native/thin3d/thin3d_vulkan.cpp @@ -603,9 +603,7 @@ Thin3DVKContext::Thin3DVKContext(VulkanContext *vulkan) memset(boundTextures_, 0, sizeof(boundTextures_)); CreatePresets(); - VkCommandPoolCreateInfo p; - p.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO; - p.pNext = nullptr; + VkCommandPoolCreateInfo p = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; p.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; p.queueFamilyIndex = vulkan->GetGraphicsQueueFamilyIndex(); VkResult res = vkCreateCommandPool(device_, &p, nullptr, &cmdPool_); @@ -617,9 +615,7 @@ Thin3DVKContext::Thin3DVKContext(VulkanContext *vulkan) dpTypes[1].descriptorCount = 200; dpTypes[1].type = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - VkDescriptorPoolCreateInfo dp; - dp.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO; - dp.pNext = nullptr; + VkDescriptorPoolCreateInfo dp = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; dp.flags = 0; // Don't want to mess around with individually freeing these, let's go dynamic each frame. dp.maxSets = 200; // 200 textures per frame should be enough for the UI... dp.pPoolSizes = dpTypes; @@ -646,17 +642,13 @@ Thin3DVKContext::Thin3DVKContext(VulkanContext *vulkan) bindings[1].stageFlags = VK_SHADER_STAGE_FRAGMENT_BIT; bindings[1].binding = 1; - VkDescriptorSetLayoutCreateInfo dsl; - dsl.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; - dsl.pNext = nullptr; + VkDescriptorSetLayoutCreateInfo dsl = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; dsl.bindingCount = 2; dsl.pBindings = bindings; res = vkCreateDescriptorSetLayout(device_, &dsl, nullptr, &descriptorSetLayout_); assert(VK_SUCCESS == res); - VkPipelineLayoutCreateInfo pl; - pl.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO; - pl.pNext = nullptr; + VkPipelineLayoutCreateInfo pl = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; pl.pPushConstantRanges = nullptr; pl.pushConstantRangeCount = 0; pl.setLayoutCount = 1; @@ -827,16 +819,12 @@ VkPipeline Thin3DVKContext::GetOrCreatePipeline() { VkVertexInputBindingDescription bindDescs[1]; curVertexFormat_->ToVulkan(&vertex, attrDescs, bindDescs); - VkPipelineInputAssemblyStateCreateInfo inputAssembly; - inputAssembly.sType = VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO; - inputAssembly.pNext = nullptr; + VkPipelineInputAssemblyStateCreateInfo inputAssembly = { VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; inputAssembly.topology = curPrim_; inputAssembly.primitiveRestartEnable = false; VkDynamicState dynamics[] = { VK_DYNAMIC_STATE_VIEWPORT, VK_DYNAMIC_STATE_SCISSOR }; - VkPipelineDynamicStateCreateInfo dynamicInfo; - dynamicInfo.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO; - dynamicInfo.pNext = nullptr; + VkPipelineDynamicStateCreateInfo dynamicInfo = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO }; dynamicInfo.dynamicStateCount = ARRAY_SIZE(dynamics); dynamicInfo.pDynamicStates = dynamics; @@ -858,23 +846,19 @@ VkPipeline Thin3DVKContext::GetOrCreatePipeline() { raster.depthClampEnable = false; raster.depthBiasSlopeFactor = 0.0; - VkPipelineMultisampleStateCreateInfo ms; - memset(&ms, 0, sizeof(ms)); - ms.sType = VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO; + VkPipelineMultisampleStateCreateInfo ms = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO }; ms.pNext = nullptr; ms.pSampleMask = nullptr; ms.rasterizationSamples = VK_SAMPLE_COUNT_1_BIT; - VkPipelineViewportStateCreateInfo vs; - vs.sType = VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO; + VkPipelineViewportStateCreateInfo vs = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; vs.pNext = nullptr; vs.viewportCount = 1; vs.scissorCount = 1; vs.pViewports = nullptr; // dynamic vs.pScissors = nullptr; // dynamic - VkGraphicsPipelineCreateInfo info = {}; - info.sType = VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO; + VkGraphicsPipelineCreateInfo info = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; info.pNext = nullptr; info.flags = 0; info.stageCount = 2;