vulkan
Safe HaskellNone
LanguageHaskell2010

Vulkan.Extensions.VK_KHR_present_wait2

Description

Name

VK_KHR_present_wait2 - device extension

VK_KHR_present_wait2

Name String
VK_KHR_present_wait2
Extension Type
Device extension
Registered Extension Number
481
Revision
1
Ratification Status
Ratified
Extension and Version Dependencies
VK_KHR_get_surface_capabilities2 and VK_KHR_surface and VK_KHR_swapchain and VK_KHR_present_id2
Contact
  • Daniel Stone
Extension Proposal
VK_KHR_present_wait2

Other Extension Metadata

Last Modified Date
2025-05-30
IP Status
No known IP claims.
Contributors
  • Hans-Kristian Arntzen, Valve
  • James Jones, NVIDIA
  • Daniel Stone, Collabora
  • Derek Foreman, Collabora
  • /contributors to `VK_KHR_present_wait`/

Description

This device extension allows an application that uses the VK_KHR_swapchain extension to wait for present operations to complete. An application can use this to monitor and control the pacing of the application by managing the number of outstanding images yet to be presented.

New Commands

New Structures

New Enum Constants

Issues

1) When does the wait finish?

RESOLVED. The wait request will complete when the timeout expires, or after the corresponding presentation request has either taken effect within the presentation engine or has been replaced without presentation. Additionally, a wait may complete immediately if the swapchain becomes out of date.

In circumstances outside the application’s control, this wait may be particularly long. For example, a user session may have the display locked and switched off for multiple days. During this time, the latest image presented through the WSI will never be presented to the user (because nothing is being presented), or replaced (because nothing newer has been queued by the application). Each operating system may have a separate mechanism to inform the application of states such as these, however it is out of scope of the Vulkan WSI.

There is no requirement for any precise timing relationship between the presentation of the image to the user and the end of the wait.

This extension is not intended for time-to-light estimation, which is better solved by a separate extension dedicated to present-timing feedback for audio/visual/input synchronization.

2) Should this use fences or other existing synchronization mechanism?

RESOLVED. VkFence is a legacy primitive. Building a new API around a legacy primitive is undesirable.

Other existing synchronization mechanisms may lack a platform-provided framework for sharing synchronization objects between display and render drivers.

For these reasons, this extension will provide a separate synchronization API.

3) Should this extension share present identification with other extensions?

RESOLVED. Yes. A new extension, VK_KHR_present_id2, should be created to provide a shared structure for presentation identifiers.

4) What happens when presentations complete out of order with respect to calls to vkQueuePresent? This could happen if the semaphores for the presentations were ready out of order.

OPTION A: Require that when a PresentId is set that the driver ensure that images are always presented in the order of calls to vkQueuePresent.

OPTION B: Finish both waits when the earliest present completes. This will complete the later present wait earlier than the actual presentation. This should be the easiest to implement as the driver need only track the largest present ID completed. This is also the 'natural' consequence of interpreting the existing vkWaitForPresentKHR specification.

OPTION C: Finish both waits when both have completed. This will complete the earlier presentation later than the actual presentation time. This is allowed by the current specification as there is no precise timing requirement for when the presentId value is updated. This requires slightly more complexity in the driver as it will need to track all outstanding presentId values.

OPTION D: The order of completion between outstanding waitForPresent2KHR calls is always undefined. However, a SUCCESS return value in PresentWait2InfoKHR::presentId implies that future calls to waitForPresent2KHR where PresentWait2InfoKHR::presentId is less than or equal to N will complete immediately.

RESOLVED. OPTION D: This option ensures implementations do not need to create complex internal queues to generate signals in the right order.

5) Should this extension deviate from VK_KHR_present_wait and require the presentation engine to provide the presentId values?

RESOLVED. No. This extension is intended to be a bugfix of VK_KHR_present_wait, and existing low-latency apis require an application provided id. At least on some platforms, a mapping mechanism would be required to translate between presentation engine and application ids. This exceeds the intended scope of this extension.

When needed in the future, we can introduce an independent presentation engine driven id and a mechanism for mapping presentation engine ids to application provided ids.

Version History

  • Revision 1, 2022-10-05 (Daniel Stone)

    • Repurposed from VK_KHR_present_wait to be based on surface capabilities
    • Reworded wait finish section to avoid time-to-light

See Also

No cross-references are available

Document Notes

For more information, see the Vulkan Specification.

This page is a generated document. Fixes and changes should be made to the generator scripts, not directly.

Synopsis

Documentation

waitForPresent2KHR Source #

Arguments

:: MonadIO io 
=> Device

device is the device associated with swapchain.

-> SwapchainKHR

swapchain is the non-retired swapchain on which an image was queued for presentation.

-> PresentWait2InfoKHR

pPresentWait2Info is a pointer to a PresentWait2InfoKHR structure specifying the parameters of the wait.

-> io Result 

vkWaitForPresent2KHR - Wait for presentation

Description

waitForPresent2KHR waits for the presentation engine to have begun presentation of the presentation request associated with the PresentWait2InfoKHR::presentId on swapchain, or for PresentWait2InfoKHR::timeout to have expired.

The wait request will complete when the timeout expires, or after the corresponding presentation request has either taken effect within the presentation engine or has been replaced without presentation.

The timing relationship between the presentation of the image to the user and the wait request completing is implementation-dependent due to variations in window system implementations.

If the swapchain becomes ERROR_OUT_OF_DATE_KHR either before or during this call, the call may either return SUCCESS (if the image was delivered to the presentation engine and may have been presented to the user) or return early with status ERROR_OUT_OF_DATE_KHR (if the image could not be presented to the user).

As an exception to the normal rules for objects which are externally synchronized, the swapchain passed to waitForPresent2KHR may be simultaneously used by other threads in calls to functions other than destroySwapchainKHR. Access to the swapchain data associated with this extension must be atomic within the implementation.

Valid Usage

Valid Usage (Implicit)

  • device must be a valid Device handle
  • swapchain must be a valid SwapchainKHR handle
  • pPresentWait2Info must be a valid pointer to a valid PresentWait2InfoKHR structure
  • swapchain must have been created, allocated, or retrieved from device

Host Synchronization

  • Host access to swapchain must be externally synchronized

Return Codes

Success
Failure

See Also

VK_KHR_present_wait2, Device, PresentWait2InfoKHR, SwapchainKHR

waitForPresent2KHRSafe Source #

Arguments

:: MonadIO io 
=> Device

device is the device associated with swapchain.

-> SwapchainKHR

swapchain is the non-retired swapchain on which an image was queued for presentation.

-> PresentWait2InfoKHR

pPresentWait2Info is a pointer to a PresentWait2InfoKHR structure specifying the parameters of the wait.

-> io Result 

A variant of waitForPresent2KHR which makes a *safe* FFI call

data PresentWait2InfoKHR Source #

VkPresentWait2InfoKHR - Structure describing parameters of a presentation wait

Valid Usage (Implicit)

See Also

VK_KHR_present_wait2, StructureType, waitForPresent2KHR

Constructors

PresentWait2InfoKHR 

Fields

  • presentId :: Word64

    presentId is the presentation presentId to wait for.

  • timeout :: Word64

    timeout is the timeout period in units of nanoseconds. timeout is adjusted to the closest value allowed by the implementation-dependent timeout accuracy, which may be substantially longer than one nanosecond, and may be longer than the requested period.

Instances

Instances details
Eq PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Storable PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Show PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

FromCStruct PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

ToCStruct PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Zero PresentWait2InfoKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

data PhysicalDevicePresentWait2FeaturesKHR Source #

VkPhysicalDevicePresentWait2FeaturesKHR - Structure indicating support for present wait 2

Members

This structure describes the following feature:

Description

If the PhysicalDevicePresentWait2FeaturesKHR structure is included in the pNext chain of the PhysicalDeviceFeatures2 structure passed to getPhysicalDeviceFeatures2, it is filled in to indicate whether each corresponding feature is supported. If the application wishes to use a Device with any features described by PhysicalDevicePresentWait2FeaturesKHR, it must add an instance of the structure, with the desired feature members set to TRUE, to the pNext chain of DeviceCreateInfo when creating the Device.

Valid Usage (Implicit)

See Also

VK_KHR_present_wait2, Bool32, StructureType

Constructors

PhysicalDevicePresentWait2FeaturesKHR 

Fields

Instances

Instances details
Eq PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Storable PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Show PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

FromCStruct PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

ToCStruct PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Zero PhysicalDevicePresentWait2FeaturesKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

data SurfaceCapabilitiesPresentWait2KHR Source #

VkSurfaceCapabilitiesPresentWait2KHR - Structure describing presentation-wait capabilities of a surface

Description

This structure can be included in the pNext chain of SurfaceCapabilities2KHR to determine support for present-wait. If presentWait2Supported is FALSE, it indicates that waiting for presentation is not possible for this surface.

Applications must not attempt to call waitForPresent2KHR on a swapchain if presentWait2Supported is FALSE.

Valid Usage (Implicit)

See Also

VK_KHR_present_wait2, Bool32, StructureType

Constructors

SurfaceCapabilitiesPresentWait2KHR 

Fields

  • presentWait2Supported :: Bool

    presentWait2Supported is a boolean describing whether the surface is able to support the present-wait extension

Instances

Instances details
Eq SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Storable SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Show SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

FromCStruct SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

ToCStruct SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

Zero SurfaceCapabilitiesPresentWait2KHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_present_wait2

type KHR_PRESENT_WAIT_2_EXTENSION_NAME = "VK_KHR_present_wait2" Source #

newtype SwapchainKHR Source #

VkSwapchainKHR - Opaque handle to a swapchain object

Description

A swapchain is an abstraction for an array of presentable images that are associated with a surface. The presentable images are represented by Image objects created by the platform. One image (which can be an array image for multiview/stereoscopic-3D surfaces) is displayed at a time, but multiple images can be queued for presentation. An application renders to the image, and then queues the image for presentation to the surface.

A native window cannot be associated with more than one non-retired swapchain at a time. Further, swapchains cannot be created for native windows that have a non-Vulkan graphics API surface associated with them.

The presentation engine is an abstraction for the platform’s compositor or display engine.

The presentation engine may be synchronous or asynchronous with respect to the application and/or logical device.

Some implementations may use the device’s graphics queue or dedicated presentation hardware to perform presentation.

The presentable images of a swapchain are owned by the presentation engine. An application can acquire use of a presentable image from the presentation engine. Use of a presentable image must occur only after the image is returned by acquireNextImageKHR, and before it is released by queuePresentKHR. This includes transitioning the image layout and rendering commands.

An application can acquire use of a presentable image with acquireNextImageKHR. After acquiring a presentable image and before modifying it, the application must use a synchronization primitive to ensure that the presentation engine has finished reading from the image. The application can then transition the image’s layout, queue rendering commands to it, etc. Finally, the application presents the image with queuePresentKHR, which releases the acquisition of the image. The application can also release the acquisition of the image through releaseSwapchainImagesKHR, if the image is not in use by the device, and skip the present operation.

The presentation engine controls the order in which presentable images are acquired for use by the application.

This allows the platform to handle situations which require out-of-order return of images after presentation. At the same time, it allows the application to generate command buffers referencing all of the images in the swapchain at initialization time, rather than in its main loop.

See Also

VK_DEFINE_NON_DISPATCHABLE_HANDLE, VK_KHR_swapchain, AcquireNextImageInfoKHR, BindImageMemorySwapchainInfoKHR, ImageSwapchainCreateInfoKHR, PastPresentationTimingInfoEXT, PresentInfoKHR, ReleaseSwapchainImagesInfoKHR, SwapchainCalibratedTimestampInfoEXT, SwapchainCreateInfoKHR, acquireFullScreenExclusiveModeEXT, acquireNextImageKHR, createSharedSwapchainsKHR, createSwapchainKHR, destroySwapchainKHR, getLatencyTimingsNV, getPastPresentationTimingGOOGLE, getRefreshCycleDurationGOOGLE, getSwapchainCounterEXT, getSwapchainImagesKHR, getSwapchainStatusKHR, getSwapchainTimeDomainPropertiesEXT, getSwapchainTimingPropertiesEXT, latencySleepNV, queuePresentKHR, releaseFullScreenExclusiveModeEXT, setHdrMetadataEXT, setLatencyMarkerNV, setLatencySleepModeNV, setLocalDimmingAMD, setSwapchainPresentTimingQueueSizeEXT, waitForPresent2KHR, waitForPresentKHR

Constructors

SwapchainKHR Word64 

Instances

Instances details
Eq SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

Ord SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

Storable SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

Show SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

HasObjectType SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

IsHandle SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

Zero SwapchainKHR Source # 
Instance details

Defined in Vulkan.Extensions.Handles

newtype SwapchainCreateFlagBitsKHR Source #

VkSwapchainCreateFlagBitsKHR - Bitmask controlling swapchain creation

Description

See Also

VK_KHR_swapchain, SwapchainCreateFlagsKHR

Instances

Instances details
Bits SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Methods

(.&.) :: SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR #

(.|.) :: SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR #

xor :: SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR #

complement :: SwapchainCreateFlagBitsKHR -> SwapchainCreateFlagBitsKHR #

shift :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

rotate :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

zeroBits :: SwapchainCreateFlagBitsKHR #

bit :: Int -> SwapchainCreateFlagBitsKHR #

setBit :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

clearBit :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

complementBit :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

testBit :: SwapchainCreateFlagBitsKHR -> Int -> Bool #

bitSizeMaybe :: SwapchainCreateFlagBitsKHR -> Maybe Int #

bitSize :: SwapchainCreateFlagBitsKHR -> Int #

isSigned :: SwapchainCreateFlagBitsKHR -> Bool #

shiftL :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

unsafeShiftL :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

shiftR :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

unsafeShiftR :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

rotateL :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

rotateR :: SwapchainCreateFlagBitsKHR -> Int -> SwapchainCreateFlagBitsKHR #

popCount :: SwapchainCreateFlagBitsKHR -> Int #

FiniteBits SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Eq SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Ord SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Storable SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Read SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Show SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain

Zero SwapchainCreateFlagBitsKHR Source # 
Instance details

Defined in Vulkan.Extensions.VK_KHR_swapchain