-
Notifications
You must be signed in to change notification settings - Fork 634
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Work-around macOS/iOS blank screen issues on swapchain recreation #1150
Conversation
…void blank screen on macOS/iOS
…wing VK_SUBOPTIMAL_KHR result
Creating the very same handle a second time seems a bit weird! Even as a workaround. |
@asuessenbach I understand your perspective. My approach here was to log the problem and ask for assistance from a few knowledgeable experts regarding macOS-specifics (see defect #1149). I spent some time tracing around in the debugger and it seems that swapchain old resource destruction and new resource creation can happen out-of-order. It seems to be the final destroy of old image resources (after creation of new ones) that causes the blank screen. While this is a possible clue, I don't know enough about MoltenVK internals to determine the root cause. I felt that putting this workaround up may provide additional information that could help diagnose the problem. Note that the second call does create a new handle instance, but with no memory of image resources from the previous configuration. |
…_ERROR_OUT_OF_DATE_KHR cases
…IMAL_KHR / VK_ERROR_OUT_OF_DATE_KHR
@asuessenbach - I'm following up here with some new information and a code update. It seems like MoltenVK behaves differently than native Vulkan implementations when rebuilding the swapchain for reasons other than resizing. On Windows and Linux, swapchain image count, image usage flags, and transform changes seem to be transparent to In my latest changes I have removed the awkward "double handle create" approach you rightly commented on, and instead added code to I also noticed a defect in the way |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks much, well, more logical. Thanks.
Just one remaining issue.
Merging - 3 approvals |
Description
This PR does
twothree things:image_count
,image_usage_flags
, ortransform
parameters are changing (i.e. without resizing). This workaround recreates the swapchain a second time within[HPP]RenderContext::begin_frame()
specifically in cases whenvkAcquireNextImageKHR()
returnsVK_SUBOPTIMAL_KHR
. This fixes the blank screen problem when options are selected in certain samples (afbc, msaa, swapchain_images, hpp_swapchain_images, and surface_rotation).VK_SUBOPTIMAL_KHR
return codes within[HPP]RenderContext::begin_frame()
. TheseVK_SUBOPTIMAL_KHR
return codes were due to swapchain recreation problems in item 1 above. With these now addressed, the code allowingVK_SUBOPTIMAL_KHR
is no longer needed.[HPP]RenderContext::begin_frame()
callsswapchain->acquire_next_image()
a second time using the same semaphore from the first call. This is not correct since that semaphore will already be signaled and cannot be used again until cleared by a queue wait operation. To address this, I added code to destroy the semaphore and recreate it in a non-signaled state.Fixes #1149
Tested on macOS Ventura 13.6.6, iOS 17.6.1, and Windows 10 using an AMD 6600XT GPU.
General Checklist:
Please ensure the following points are checked:
Note: The Samples CI runs a number of checks including:
If this PR contains framework changes:
batch
command line argument to make sure all samples still work properlySample Checklist
If your PR contains a new or modified sample, these further checks must be carried out in addition to the General Checklist: