@@ -145,17 +145,18 @@ static std::optional<vk::Queue> ChoosePresentQueue(
145145std::shared_ptr<SwapchainImplVK> SwapchainImplVK::Create (
146146 const std::shared_ptr<Context>& context,
147147 vk::UniqueSurfaceKHR surface,
148- vk::SwapchainKHR old_swapchain,
149- vk::SurfaceTransformFlagBitsKHR last_transform) {
148+ const ISize& size,
149+ bool enable_msaa,
150+ vk::SwapchainKHR old_swapchain) {
150151 return std::shared_ptr<SwapchainImplVK>(new SwapchainImplVK (
151- context, std::move (surface), old_swapchain, last_transform ));
152+ context, std::move (surface), size, enable_msaa, old_swapchain ));
152153}
153154
154- SwapchainImplVK::SwapchainImplVK (
155- const std::shared_ptr<Context>& context ,
156- vk::UniqueSurfaceKHR surface ,
157- vk::SwapchainKHR old_swapchain ,
158- vk::SurfaceTransformFlagBitsKHR last_transform ) {
155+ SwapchainImplVK::SwapchainImplVK (const std::shared_ptr<Context>& context,
156+ vk::UniqueSurfaceKHR surface ,
157+ const ISize& size ,
158+ bool enable_msaa ,
159+ vk::SwapchainKHR old_swapchain ) {
159160 if (!context) {
160161 VALIDATION_LOG << " Cannot create a swapchain without a context." ;
161162 return ;
@@ -209,10 +210,10 @@ SwapchainImplVK::SwapchainImplVK(
209210 swapchain_info.imageColorSpace = format.value ().colorSpace ;
210211 swapchain_info.presentMode = vk::PresentModeKHR::eFifo;
211212 swapchain_info.imageExtent = vk::Extent2D{
212- std::clamp (surface_caps. currentExtent . width ,
213+ std::clamp (static_cast < uint32_t >(size. width ) ,
213214 surface_caps.minImageExtent .width ,
214215 surface_caps.maxImageExtent .width ),
215- std::clamp (surface_caps. currentExtent . height ,
216+ std::clamp (static_cast < uint32_t >(size. height ) ,
216217 surface_caps.minImageExtent .height ,
217218 surface_caps.maxImageExtent .height ),
218219 };
@@ -304,14 +305,19 @@ SwapchainImplVK::SwapchainImplVK(
304305 images_ = std::move (swapchain_images);
305306 synchronizers_ = std::move (synchronizers);
306307 current_frame_ = synchronizers_.size () - 1u ;
308+ size_ = size;
309+ enable_msaa_ = enable_msaa;
307310 is_valid_ = true ;
308- transform_if_changed_discard_swapchain_ = last_transform;
309311}
310312
311313SwapchainImplVK::~SwapchainImplVK () {
312314 DestroySwapchain ();
313315}
314316
317+ const ISize& SwapchainImplVK::GetSize () const {
318+ return size_;
319+ }
320+
315321bool SwapchainImplVK::IsValid () const {
316322 return is_valid_;
317323}
@@ -337,10 +343,6 @@ vk::Format SwapchainImplVK::GetSurfaceFormat() const {
337343 return surface_format_;
338344}
339345
340- vk::SurfaceTransformFlagBitsKHR SwapchainImplVK::GetLastTransform () const {
341- return transform_if_changed_discard_swapchain_;
342- }
343-
344346std::shared_ptr<Context> SwapchainImplVK::GetContext () const {
345347 return context_.lock ();
346348}
@@ -365,26 +367,6 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() {
365367 return SwapchainImplVK::AcquireResult{};
366368 }
367369
368- // ----------------------------------------------------------------------------
369- // / Poll to see if the orientation has changed.
370- // /
371- // / https://developer.android.com/games/optimize/vulkan-prerotation#using_polling
372- current_transform_poll_count_++;
373- if (current_transform_poll_count_ >= kPollFramesForOrientation ) {
374- current_transform_poll_count_ = 0u ;
375- auto [caps_result, caps] =
376- context.GetPhysicalDevice ().getSurfaceCapabilitiesKHR (*surface_);
377- if (caps_result != vk::Result::eSuccess) {
378- VALIDATION_LOG << " Could not get surface capabilities: "
379- << vk::to_string (caps_result);
380- return SwapchainImplVK::AcquireResult{};
381- }
382- if (caps.currentTransform != transform_if_changed_discard_swapchain_) {
383- transform_if_changed_discard_swapchain_ = caps.currentTransform ;
384- return AcquireResult{true /* out of date */ };
385- }
386- }
387-
388370 // ----------------------------------------------------------------------------
389371 // / Get the next image index.
390372 // /
@@ -430,7 +412,8 @@ SwapchainImplVK::AcquireResult SwapchainImplVK::AcquireNextDrawable() {
430412 return false ;
431413 }
432414 return swapchain->Present (image, image_index);
433- } // swap callback
415+ }, // swap callback
416+ enable_msaa_ //
434417 )};
435418}
436419
0 commit comments