Swapchain assumes exactly 3 images: minImageCount ignores surface caps, images[] can overflow #160
Labels
No labels
claude:blocked
claude:done
claude:failed
claude:in-progress
claude:ready
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
Catcrafts/Crafter.Graphics#160
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Swapchain creation assumes the driver returns exactly
Window::numFrames(3) images. It never compares that against the surface capabilities, and it reads the images into a fixed 3-element array. Line numbers refer to6aa0338.Details
implementations/Crafter.Graphics-Window.cpp:1061:swapchainCI.minImageCount = numFrames;. The capabilities queried at:1027are used for extent and transform only;minImageCount/maxImageCountare ignored.:1102-1105: the count returned by the firstvkGetSwapchainImagesKHRcall is passed straight to the second, which writes intoVkImage images[numFrames](interfaces/Crafter.Graphics-Window.cppm:261). Every other per-image array (command buffers, fences, image view infos, the per-frame heap copies) is sizednumFramesas well.Two consequences:
minImageCountasks for.minImageCountto be at least the surface's minimum (or the minimum for the chosen present mode, when that is queried and passed along).Concrete case
Mesa Turnip on phoc (Fairphone 6, Mesa 26.2.2) reports:
minImageCountFIFO(per present mode,VK_KHR_surface_maintenance1)MAILBOXPresent modes offered:
MAILBOX,FIFO(noIMMEDIATE).FIFOpath: 3 requested, Mesa creates 3, the UI renders. Verified on the device. The request is still below the general surface minimum; the phone has no validation layer, so I did not see whether it reports that.CRAFTER_PRESENT_IMMEDIATE(:1076-1087) falls back toMAILBOXthere, which needs 4 images. Not run; by the numbers above it overflowsimages[].The descriptor-set fallback change (pending) adds a guard that throws when the image count differs from
numFrames. That turns the overflow into a clear error; it does not lift the limitation.Suggested fix
VkSurfacePresentModeKHRchained intovkGetPhysicalDeviceSurfaceCapabilities2KHR) and requestmax(numFrames, thatMinimum), clamped tomaxImageCount.numFramesfor the per-frame resources only.