Skip to content Skip to sidebar Skip to footer

Phantom Images After Going From Split Screen To Full Screen

I am writing a game for Android using the NDK. My game uses vulkan if it is available and otherwise uses OpenGL. I have a problem where if you put the game in split screen mode wi

Solution 1:

The Vulkan part is pretty self explanatory; there's a imageUsage member. Let me just give you code:

VkSurfaceCapabilitiesKHR caps;
errco = vkGetPhysicalDeviceSurfaceCapabilitiesKHR( pdev, mySurface, &caps ); if(errco) panic();
if( !(caps.supportedUsageFlags & VK_IMAGE_USAGE_TRANSFER_DST_BIT) ) panic();

VkSwapchainCreateInfoKHR sci = {VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR};
sci.surface = mySurface;
sci.imageUsage = VK_IMAGE_USAGE_TRANSFER_DST_BIT; // !// etc

VkSwapchainKHR mySwapchain;
errco = vkCreateSwapchainKHR( dev, &sci, nullptr, &mySwapchain ); if(errco) panic();

Though you should probably not be doing it anyway. There is no reason to do vkCmdClearColorImage. Use render pass to clear color images before you intend to write them (VkAttachmentDescription::loadOp). It is more efficient and as a bonus it counts as a render and does not need TRANSFER usage.

It seems windowBackgroundFallback is supposed to be the general solution to this assuming your app cannot provide a new image in time.

The best solution to get rid of the phantom image is to tell android not to shutdown the app if a screen resize occurs. This way, the screen resize can be handled by recreating the swapchain and redrawing the game. This article talks setting android:configChanges in the manifests file. The following setting stops android from shutting down the app when a screen resize from split screen to full screen occurs:

android:configChanges="screenSize|orientation|screenLayout"

Post a Comment for "Phantom Images After Going From Split Screen To Full Screen"