test(bench): measure net perf gain from #40 to master in Sponza (#155) #156

Merged
catbot merged 2 commits from claude/issue-155 into master 2026-06-18 21:36:37 +02:00
Showing only changes of commit 3e116e6e43 - Show all commits

feat(window): env-gated uncapped present mode for benchmarking

CRAFTER_PRESENT_IMMEDIATE selects IMMEDIATE (then MAILBOX) when the
surface offers it, instead of the default FIFO. Needed to measure
steady-state frame throughput without the compositor's vblank cap; FIFO
remains the default when the variable is unset.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
catbot 2026-06-18 19:35:54 +00:00

View file

@ -1072,8 +1072,24 @@ void Window::CreateSwapchain()
swapchainCI.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapchainCI.queueFamilyIndexCount = 0;
// VK_PRESENT_MODE_FIFO_KHR ("v-sync") is guaranteed available per spec, so
// it is used unconditionally — no present-mode enumeration is needed.
// it is the default. For benchmarking we want frame pacing uncapped from
// the display refresh, so when CRAFTER_PRESENT_IMMEDIATE is set in the
// environment we enumerate the surface's present modes and prefer
// IMMEDIATE (then MAILBOX) when offered, falling back to FIFO otherwise.
swapchainCI.presentMode = VK_PRESENT_MODE_FIFO_KHR;
if (std::getenv("CRAFTER_PRESENT_IMMEDIATE")) {
std::uint32_t presentModeCount = 0;
vkGetPhysicalDeviceSurfacePresentModesKHR(Device::physDevice, vulkanSurface, &presentModeCount, nullptr);
std::vector<VkPresentModeKHR> presentModes(presentModeCount);
vkGetPhysicalDeviceSurfacePresentModesKHR(Device::physDevice, vulkanSurface, &presentModeCount, presentModes.data());
bool haveImmediate = false, haveMailbox = false;
for (VkPresentModeKHR m : presentModes) {
if (m == VK_PRESENT_MODE_IMMEDIATE_KHR) haveImmediate = true;
if (m == VK_PRESENT_MODE_MAILBOX_KHR) haveMailbox = true;
}
if (haveImmediate) swapchainCI.presentMode = VK_PRESENT_MODE_IMMEDIATE_KHR;
else if (haveMailbox) swapchainCI.presentMode = VK_PRESENT_MODE_MAILBOX_KHR;
}
// Setting oldSwapChain to the saved handle of the previous swapchain aids in resource reuse and makes sure that we can still present already acquired images
swapchainCI.oldSwapchain = oldSwapchain;
// Setting clipped to VK_TRUE allows the implementation to discard rendering outside of the surface area