summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2020-07-16 19:27:02 -0400
committerGravatar Lioncash2020-07-16 19:27:02 -0400
commit08d36afd409dbe725802a79d66175aa7f4ecb141 (patch)
treee8381194d5e82c232a89a44e397cfc587b295a7a /src
parentvk_stream_buffer: Make use of designated initializers where applicable (diff)
downloadyuzu-08d36afd409dbe725802a79d66175aa7f4ecb141.tar.gz
yuzu-08d36afd409dbe725802a79d66175aa7f4ecb141.tar.xz
yuzu-08d36afd409dbe725802a79d66175aa7f4ecb141.zip
vk_swapchain: Make use of designated initializers where applicable
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_vulkan/vk_swapchain.cpp94
1 files changed, 51 insertions, 43 deletions
diff --git a/src/video_core/renderer_vulkan/vk_swapchain.cpp b/src/video_core/renderer_vulkan/vk_swapchain.cpp
index bffd8f32a..c25e312b6 100644
--- a/src/video_core/renderer_vulkan/vk_swapchain.cpp
+++ b/src/video_core/renderer_vulkan/vk_swapchain.cpp
@@ -95,15 +95,16 @@ bool VKSwapchain::Present(VkSemaphore render_semaphore, VKFence& fence) {
95 const auto present_queue{device.GetPresentQueue()}; 95 const auto present_queue{device.GetPresentQueue()};
96 bool recreated = false; 96 bool recreated = false;
97 97
98 VkPresentInfoKHR present_info; 98 const VkPresentInfoKHR present_info{
99 present_info.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR; 99 .sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR,
100 present_info.pNext = nullptr; 100 .pNext = nullptr,
101 present_info.waitSemaphoreCount = render_semaphore ? 2U : 1U; 101 .waitSemaphoreCount = render_semaphore ? 2U : 1U,
102 present_info.pWaitSemaphores = semaphores.data(); 102 .pWaitSemaphores = semaphores.data(),
103 present_info.swapchainCount = 1; 103 .swapchainCount = 1,
104 present_info.pSwapchains = swapchain.address(); 104 .pSwapchains = swapchain.address(),
105 present_info.pImageIndices = &image_index; 105 .pImageIndices = &image_index,
106 present_info.pResults = nullptr; 106 .pResults = nullptr,
107 };
107 108
108 switch (const VkResult result = present_queue.Present(present_info)) { 109 switch (const VkResult result = present_queue.Present(present_info)) {
109 case VK_SUCCESS: 110 case VK_SUCCESS:
@@ -147,24 +148,25 @@ void VKSwapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities,
147 requested_image_count = capabilities.maxImageCount; 148 requested_image_count = capabilities.maxImageCount;
148 } 149 }
149 150
150 VkSwapchainCreateInfoKHR swapchain_ci; 151 VkSwapchainCreateInfoKHR swapchain_ci{
151 swapchain_ci.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; 152 .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
152 swapchain_ci.pNext = nullptr; 153 .pNext = nullptr,
153 swapchain_ci.flags = 0; 154 .flags = 0,
154 swapchain_ci.surface = surface; 155 .surface = surface,
155 swapchain_ci.minImageCount = requested_image_count; 156 .minImageCount = requested_image_count,
156 swapchain_ci.imageFormat = surface_format.format; 157 .imageFormat = surface_format.format,
157 swapchain_ci.imageColorSpace = surface_format.colorSpace; 158 .imageColorSpace = surface_format.colorSpace,
158 swapchain_ci.imageArrayLayers = 1; 159 .imageArrayLayers = 1,
159 swapchain_ci.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; 160 .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
160 swapchain_ci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; 161 .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
161 swapchain_ci.queueFamilyIndexCount = 0; 162 .queueFamilyIndexCount = 0,
162 swapchain_ci.pQueueFamilyIndices = nullptr; 163 .pQueueFamilyIndices = nullptr,
163 swapchain_ci.preTransform = capabilities.currentTransform; 164 .preTransform = capabilities.currentTransform,
164 swapchain_ci.compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR; 165 .compositeAlpha = VK_COMPOSITE_ALPHA_OPAQUE_BIT_KHR,
165 swapchain_ci.presentMode = present_mode; 166 .presentMode = present_mode,
166 swapchain_ci.clipped = VK_FALSE; 167 .clipped = VK_FALSE,
167 swapchain_ci.oldSwapchain = nullptr; 168 .oldSwapchain = nullptr,
169 };
168 170
169 const u32 graphics_family{device.GetGraphicsFamily()}; 171 const u32 graphics_family{device.GetGraphicsFamily()};
170 const u32 present_family{device.GetPresentFamily()}; 172 const u32 present_family{device.GetPresentFamily()};
@@ -173,8 +175,6 @@ void VKSwapchain::CreateSwapchain(const VkSurfaceCapabilitiesKHR& capabilities,
173 swapchain_ci.imageSharingMode = VK_SHARING_MODE_CONCURRENT; 175 swapchain_ci.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
174 swapchain_ci.queueFamilyIndexCount = static_cast<u32>(queue_indices.size()); 176 swapchain_ci.queueFamilyIndexCount = static_cast<u32>(queue_indices.size());
175 swapchain_ci.pQueueFamilyIndices = queue_indices.data(); 177 swapchain_ci.pQueueFamilyIndices = queue_indices.data();
176 } else {
177 swapchain_ci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
178 } 178 }
179 179
180 // Request the size again to reduce the possibility of a TOCTOU race condition. 180 // Request the size again to reduce the possibility of a TOCTOU race condition.
@@ -200,20 +200,28 @@ void VKSwapchain::CreateSemaphores() {
200} 200}
201 201
202void VKSwapchain::CreateImageViews() { 202void VKSwapchain::CreateImageViews() {
203 VkImageViewCreateInfo ci; 203 VkImageViewCreateInfo ci{
204 ci.sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO; 204 .sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
205 ci.pNext = nullptr; 205 .pNext = nullptr,
206 ci.flags = 0; 206 .flags = 0,
207 // ci.image 207 .viewType = VK_IMAGE_VIEW_TYPE_2D,
208 ci.viewType = VK_IMAGE_VIEW_TYPE_2D; 208 .format = image_format,
209 ci.format = image_format; 209 .components =
210 ci.components = {VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY, 210 {
211 VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY}; 211 .r = VK_COMPONENT_SWIZZLE_IDENTITY,
212 ci.subresourceRange.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; 212 .g = VK_COMPONENT_SWIZZLE_IDENTITY,
213 ci.subresourceRange.baseMipLevel = 0; 213 .b = VK_COMPONENT_SWIZZLE_IDENTITY,
214 ci.subresourceRange.levelCount = 1; 214 .a = VK_COMPONENT_SWIZZLE_IDENTITY,
215 ci.subresourceRange.baseArrayLayer = 0; 215 },
216 ci.subresourceRange.layerCount = 1; 216 .subresourceRange =
217 {
218 .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
219 .baseMipLevel = 0,
220 .levelCount = 1,
221 .baseArrayLayer = 0,
222 .layerCount = 1,
223 },
224 };
217 225
218 image_views.resize(image_count); 226 image_views.resize(image_count);
219 for (std::size_t i = 0; i < image_count; i++) { 227 for (std::size_t i = 0; i < image_count; i++) {