Skip to content
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

mantle/wsi: fix minImageCount #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/mantle/mantle_wsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,21 @@ static void recreateSwapchain(
GetClientRect(hwnd, &clientRect);
const VkExtent2D imageExtent = { clientRect.right, clientRect.bottom };

VkSurfaceCapabilitiesKHR surfaceCapabilities;
res = vki.vkGetPhysicalDeviceSurfaceCapabilitiesKHR(grDevice->physicalDevice, mSurface,
&surfaceCapabilities);
if (res != VK_SUCCESS) {
LOGE("vkGetPhysicalDeviceSurfaceCapabilitiesKHR failed (%d)\n", res);
return;
}

// Recreate swapchain
const VkSwapchainCreateInfoKHR swapchainCreateInfo = {
.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
.pNext = NULL,
.flags = 0,
.surface = mSurface,
.minImageCount = 3,
.minImageCount = MAX(3, surfaceCapabilities.minImageCount),

This comment was marked as outdated.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to the spec maxImageCount may be 0, and then we would need additional logic to account for that, I think minImage is better

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Thanks for the heads-up!

Perhaps your original patch was right, then?

Suggested change
.minImageCount = MAX(3, surfaceCapabilities.minImageCount),
.minImageCount = MAX(2, surfaceCapabilities.minImageCount),

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think 2 vs 3 images is gonna make a big difference, but I might be wrong on that

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can just do: .minImageCount = surfaceCapabilities.minImageCount

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sometimes the minImageCount can be 1 and idk if apps will like that

.imageFormat = VK_FORMAT_B8G8R8A8_UNORM,
.imageColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR,
.imageExtent = imageExtent,
Expand Down
Loading