@@ -63,7 +63,7 @@ static std::unordered_map<VkFormat, int, VkFormatHasher> surfaceFormatPriorities
6363};
6464
6565static VkSurfaceFormat2KHR SelectSurfaceFormat ( DynamicArray<VkSurfaceFormat2KHR>& formats ) {
66- VkFormat bestFormat = VK_FORMAT_UNDEFINED;
66+ VkFormat bestFormat = VK_FORMAT_UNDEFINED;
6767 VkSurfaceFormat2KHR* bestFmt = &formats[0 ];
6868
6969 for ( VkSurfaceFormat2KHR& format : formats ) {
@@ -79,7 +79,7 @@ static VkSurfaceFormat2KHR SelectSurfaceFormat( DynamicArray<VkSurfaceFormat2KHR
7979
8080 if ( surfaceFormatPriorities[surfaceFormat] > surfaceFormatPriorities[bestFormat] ) {
8181 bestFormat = surfaceFormat;
82- bestFmt = &format;
82+ bestFmt = &format;
8383 }
8484 }
8585
@@ -106,6 +106,7 @@ static std::unordered_map<VkPresentModeKHR, uint32, VkPresentModeKHRHasher> pres
106106
107107static VkPresentModeKHR SelectPresentMode ( DynamicArray<VkPresentModeKHR>& presentModes ) {
108108 VkPresentModeKHR bestMode = presentModes[0 ];
109+
109110 for ( VkPresentModeKHR mode : presentModes ) {
110111 if ( mode == r_vkPresentMode.Get () ) {
111112 return mode;
@@ -127,7 +128,7 @@ void SwapChain::Init( const VkInstance instance ) {
127128
128129 #ifdef _MSC_VER
129130 VkSurfaceFullScreenExclusiveInfoEXT fullscreenInfo {
130- .fullScreenExclusive = VK_FULL_SCREEN_EXCLUSIVE_ALLOWED_EXT
131+ .fullScreenExclusive = VK_FULL_SCREEN_EXCLUSIVE_APPLICATION_CONTROLLED_EXT
131132 };
132133
133134 surfaceInfo.pNext = &fullscreenInfo;
@@ -164,24 +165,36 @@ void SwapChain::Init( const VkInstance instance ) {
164165 }
165166
166167 VkSurfaceCapabilitiesKHR& capabilities = capabilities2.surfaceCapabilities ;
167- imageCount =
168+ const uint32 minImageCount =
168169 capabilities.minImageCount > 2
169- ? capabilities.minImageCount
170+ ? capabilities.minImageCount
170171 : ( 2 <= capabilities.maxImageCount ? 2 : capabilities.maxImageCount );
171172
172173 minImages = capabilities.minImageCount ;
173174 maxImages = capabilities.maxImageCount ;
174175
176+ VkExtent2D swapChainSize;
177+
178+ switch ( r_mode.Get () ) {
179+ case -2 :
180+ default :
181+ swapChainSize = capabilities.minImageExtent ;
182+ break ;
183+ case -1 :
184+ swapChainSize = { ( uint32 ) r_customWidth.Get (), ( uint32 ) r_customHeight.Get () };
185+ break ;
186+ }
187+
175188 VkSwapchainCreateInfoKHR swapChainInfo {
176- .flags = 0 ,
189+ .flags = 0 ,
177190
178- .surface = surface,
191+ .surface = surface,
179192
180- .minImageCount = imageCount ,
193+ .minImageCount = minImageCount ,
181194 .imageFormat = format.surfaceFormat .format ,
182195 .imageColorSpace = format.surfaceFormat .colorSpace ,
183196
184- .imageExtent = capabilities. minImageExtent ,
197+ .imageExtent = swapChainSize ,
185198 .imageArrayLayers = 1 ,
186199 .imageUsage = capabilities.supportedUsageFlags ,
187200 .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
@@ -193,10 +206,24 @@ void SwapChain::Init( const VkInstance instance ) {
193206
194207 .clipped = VK_TRUE,
195208
196- .oldSwapchain = nullptr
209+ .oldSwapchain = nullptr
197210 };
198211
199212 vkCreateSwapchainKHR ( device, &swapChainInfo, nullptr , &swapChain );
213+
214+ #ifdef _MSC_VER
215+ /* VkResult res = vkAcquireFullScreenExclusiveModeEXT( device, swapChain );
216+
217+ if ( res == VK_SUCCESS ) {
218+ Log::Notice( "SwapChain: acquired exclusive fullscreen" );
219+ } */
220+ #endif
221+
222+ vkGetSwapchainImagesKHR ( device, swapChain, &imageCount, nullptr );
223+
224+ images.Resize ( mainSwapChain.imageCount );
225+
226+ vkGetSwapchainImagesKHR ( device, swapChain, &imageCount, images.memory );
200227}
201228
202229void SwapChain::Free () {
0 commit comments