@@ -1914,9 +1914,9 @@ VK_IMPORT_DEVICE
19141914 m_textVideoMem.resize (false , _init.resolution .width , _init.resolution .height );
19151915 m_textVideoMem.clear ();
19161916
1917- for (uint8_t ii = 0 ; ii < BX_COUNTOF (m_swapchainFormats ); ++ii)
1917+ for (uint8_t ii = 0 ; ii < BX_COUNTOF (m_swapChainFormats ); ++ii)
19181918 {
1919- m_swapchainFormats [ii] = TextureFormat::Enum (ii);
1919+ m_swapChainFormats [ii] = TextureFormat::Enum (ii);
19201920 }
19211921
19221922 result = m_backBuffer.create (UINT16_MAX, g_platformData.nwh , m_resolution.width , m_resolution.height , m_resolution.format );
@@ -2763,12 +2763,14 @@ VK_IMPORT_DEVICE
27632763 | BGFX_RESET_DEPTH_CLAMP
27642764 );
27652765
2766- // Note: m_needToRefreshSwapchain is deliberately ignored when deciding whether to recreate the swapchain
2767- // because it can happen several frames before submit is called with the new resolution.
2768- // Instead, vkAcquireNextImageKHR and all draws to the backbuffer are skipped until the window size is updated.
2769- // That also fixes a related issue where VK_ERROR_OUT_OF_DATE_KHR is returned from
2770- // vkQueuePresentKHR when the window doesn't exist anymore, and vkGetPhysicalDeviceSurfaceCapabilitiesKHR
2771- // fails with VK_ERROR_SURFACE_LOST_KHR.
2766+ // Note: m_needToRefreshSwapchain is deliberately ignored when deciding whether to
2767+ // recreate the swapchain because it can happen several frames before submit is called
2768+ // with the new resolution.
2769+ //
2770+ // Instead, vkAcquireNextImageKHR and all draws to the backbuffer are skipped until
2771+ // the window size is updated. That also fixes a related issue where VK_ERROR_OUT_OF_DATE_KHR
2772+ // is returned from vkQueuePresentKHR when the window doesn't exist anymore, and
2773+ // vkGetPhysicalDeviceSurfaceCapabilitiesKHR fails with VK_ERROR_SURFACE_LOST_KHR.
27722774
27732775 if (false
27742776 || m_resolution.format != _resolution.format
@@ -4431,7 +4433,7 @@ VK_IMPORT_DEVICE
44314433 bool m_timerQuerySupport;
44324434
44334435 FrameBufferVK m_backBuffer;
4434- TextureFormat::Enum m_swapchainFormats [TextureFormat::Count];
4436+ TextureFormat::Enum m_swapChainFormats [TextureFormat::Count];
44354437
44364438 uint16_t m_numWindows;
44374439 FrameBufferHandle m_windows[BGFX_CONFIG_MAX_FRAME_BUFFERS];
@@ -6645,7 +6647,7 @@ VK_DESTROY
66456647
66466648 void SwapChainVK::destroy ()
66476649 {
6648- if (VK_NULL_HANDLE != m_swapchain )
6650+ if (VK_NULL_HANDLE != m_swapChain )
66496651 {
66506652 releaseFrameBuffer ();
66516653 releaseAttachments ();
@@ -7012,41 +7014,47 @@ VK_DESTROY
70127014 m_sci.presentMode = s_presentMode[presentModeIdx].mode ;
70137015 m_sci.clipped = VK_FALSE;
70147016
7015- result = vkCreateSwapchainKHR (device, &m_sci, allocatorCb, &m_swapchain );
7017+ result = vkCreateSwapchainKHR (device, &m_sci, allocatorCb, &m_swapChain );
70167018 if (VK_SUCCESS != result)
70177019 {
70187020 BX_TRACE (" Create swapchain error: vkCreateSwapchainKHR failed %d: %s." , result, getName (result) );
70197021 return result;
70207022 }
70217023
7022- m_sci.oldSwapchain = m_swapchain ;
7024+ m_sci.oldSwapchain = m_swapChain ;
70237025
7024- result = vkGetSwapchainImagesKHR (device, m_swapchain , &m_numSwapchainImages , NULL );
7026+ result = vkGetSwapchainImagesKHR (device, m_swapChain , &m_numSwapChainImages , NULL );
70257027 if (VK_SUCCESS != result)
70267028 {
70277029 BX_TRACE (" Create swapchain error: vkGetSwapchainImagesKHR failed %d: %s." , result, getName (result) );
70287030 return result;
70297031 }
70307032
7031- if (m_numSwapchainImages < m_sci.minImageCount )
7033+ BX_TRACE (" Create swapchain numSwapChainImages %d, minImageCount %d, BX_COUNTOF(m_backBufferColorImage) %d"
7034+ , m_numSwapChainImages
7035+ , m_sci.minImageCount
7036+ , BX_COUNTOF (m_backBufferColorImage)
7037+ );
7038+
7039+ if (m_numSwapChainImages < m_sci.minImageCount )
70327040 {
70337041 BX_TRACE (" Create swapchain error: vkGetSwapchainImagesKHR: numSwapchainImages %d < minImageCount %d."
7034- , m_numSwapchainImages
7042+ , m_numSwapChainImages
70357043 , m_sci.minImageCount
70367044 );
70377045 return VK_ERROR_INITIALIZATION_FAILED;
70387046 }
70397047
7040- if (m_numSwapchainImages > BX_COUNTOF (m_backBufferColorImage) )
7048+ if (m_numSwapChainImages > BX_COUNTOF (m_backBufferColorImage) )
70417049 {
70427050 BX_TRACE (" Create swapchain error: vkGetSwapchainImagesKHR: numSwapchainImages %d > countof(m_backBufferColorImage) %d."
7043- , m_numSwapchainImages
7051+ , m_numSwapChainImages
70447052 , BX_COUNTOF (m_backBufferColorImage)
70457053 );
70467054 return VK_ERROR_INITIALIZATION_FAILED;
70477055 }
70487056
7049- result = vkGetSwapchainImagesKHR (device, m_swapchain , &m_numSwapchainImages , &m_backBufferColorImage[0 ]);
7057+ result = vkGetSwapchainImagesKHR (device, m_swapChain , &m_numSwapChainImages , &m_backBufferColorImage[0 ]);
70507058 if (VK_SUCCESS != result && VK_INCOMPLETE != result)
70517059 {
70527060 BX_TRACE (" Create swapchain error: vkGetSwapchainImagesKHR failed %d: %s."
@@ -7072,7 +7080,7 @@ VK_DESTROY
70727080 ivci.subresourceRange .baseArrayLayer = 0 ;
70737081 ivci.subresourceRange .layerCount = 1 ;
70747082
7075- for (uint32_t ii = 0 ; ii < m_numSwapchainImages ; ++ii)
7083+ for (uint32_t ii = 0 ; ii < m_numSwapChainImages ; ++ii)
70767084 {
70777085 ivci.image = m_backBufferColorImage[ii];
70787086
@@ -7129,7 +7137,7 @@ VK_DESTROY
71297137 release (m_renderDoneSemaphore[ii]);
71307138 }
71317139
7132- release (m_swapchain );
7140+ release (m_swapChain );
71337141 }
71347142
71357143 VkResult SwapChainVK::createAttachments (VkCommandBuffer _commandBuffer)
@@ -7231,7 +7239,7 @@ VK_DESTROY
72317239 return result;
72327240 }
72337241
7234- for (uint32_t ii = 0 ; ii < m_numSwapchainImages ; ++ii)
7242+ for (uint32_t ii = 0 ; ii < m_numSwapChainImages ; ++ii)
72357243 {
72367244 uint32_t numAttachments = 2 ;
72377245 ::VkImageView attachments[3 ] =
@@ -7387,9 +7395,9 @@ VK_DESTROY
73877395 {
73887396 selectedFormat = requested;
73897397 if (0 != ii
7390- && s_renderVK->m_swapchainFormats [_format] != selectedFormat)
7398+ && s_renderVK->m_swapChainFormats [_format] != selectedFormat)
73917399 {
7392- s_renderVK->m_swapchainFormats [_format] = selectedFormat;
7400+ s_renderVK->m_swapChainFormats [_format] = selectedFormat;
73937401 BX_TRACE (
73947402 " findSurfaceFormat: Surface format %s not found! Defaulting to %s."
73957403 , bimg::getName (bimg::TextureFormat::Enum (_format) )
@@ -7413,7 +7421,7 @@ VK_DESTROY
74137421
74147422 bool SwapChainVK::acquire (VkCommandBuffer _commandBuffer)
74157423 {
7416- if (VK_NULL_HANDLE == m_swapchain
7424+ if (VK_NULL_HANDLE == m_swapChain
74177425 || m_needToRefreshSwapchain)
74187426 {
74197427 return false ;
@@ -7432,7 +7440,7 @@ VK_DESTROY
74327440 BGFX_PROFILER_SCOPE (" vkAcquireNextImageKHR" , kColorFrame );
74337441 result = vkAcquireNextImageKHR (
74347442 device
7435- , m_swapchain
7443+ , m_swapChain
74367444 , UINT64_MAX
74377445 , m_lastImageAcquiredSemaphore
74387446 , VK_NULL_HANDLE
@@ -7482,7 +7490,7 @@ VK_DESTROY
74827490 void SwapChainVK::present ()
74837491 {
74847492 BGFX_PROFILER_SCOPE (" SwapChainVk::present" , kColorFrame );
7485- if (VK_NULL_HANDLE != m_swapchain
7493+ if (VK_NULL_HANDLE != m_swapChain
74867494 && m_needPresent)
74877495 {
74887496 VkPresentInfoKHR pi;
@@ -7491,7 +7499,7 @@ VK_DESTROY
74917499 pi.waitSemaphoreCount = 1 ;
74927500 pi.pWaitSemaphores = &m_lastImageRenderedSemaphore;
74937501 pi.swapchainCount = 1 ;
7494- pi.pSwapchains = &m_swapchain ;
7502+ pi.pSwapchains = &m_swapChain ;
74957503 pi.pImageIndices = &m_backBufferColorIdx;
74967504 pi.pResults = NULL ;
74977505 VkResult result;
0 commit comments