1 changed files with 17 additions and 1 deletions
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>
commit
3e116e6e43
|
|
@ -1072,8 +1072,24 @@ void Window::CreateSwapchain()
|
||||||
swapchainCI.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
swapchainCI.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||||
swapchainCI.queueFamilyIndexCount = 0;
|
swapchainCI.queueFamilyIndexCount = 0;
|
||||||
// VK_PRESENT_MODE_FIFO_KHR ("v-sync") is guaranteed available per spec, so
|
// 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;
|
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
|
// 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;
|
swapchainCI.oldSwapchain = oldSwapchain;
|
||||||
// Setting clipped to VK_TRUE allows the implementation to discard rendering outside of the surface area
|
// Setting clipped to VK_TRUE allows the implementation to discard rendering outside of the surface area
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue