VkSwapchainPresentFenceInfoKHR is overspecified

Aperta
#2,838 2 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@cubanismo ci sta già lavorando.

Dal 20/10/2026.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
45/100
Tipo di issue
Documentazione
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript
Ambito
documentation

Direzione di ricerca

Start by reading the VkSwapchainPresentFenceInfoKHR and vkQueuePresentKHR specification text, then compare the cited queue and semaphore guarantees in the Fundamentals, Devices and Queues, and Synchronization chapters. The issue proposes revising semaphore wording and adding explanatory text, with a related question about swapchain destruction; done means resolving those claims and updating the relevant specification text.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

System Integration

VkSwapchainPresentFenceInfoEXT makes the following statements:

The set of queue operations defined by queuing an image for presentation, as well as operations performed by the presentation engine, access the payloads of objects associated with the presentation operation. The associated objects include:

  • [...]

  • The wait semaphores specified when queuing the image for presentation.

The application can provide a fence that the implementation will signal after all such queue operations have completed, and after the presentation engine has taken a reference to the payloads of all objects provided in VkPresentInfoKHR that the presentation engine accesses as part of the present operation. The fence may not wait for the present operation to complete. For all binary wait semaphores imported by the presentation engine using the equivalent of reference transference, as described in Importing Semaphore Payloads, this fence must not signal until all such semaphore payloads have been reset by the presentation engine.

And AIUI allowing the application to destroy or reuse the semaphores was one of the motivating factor for this struct.

However, I believe in the current version of the spec, all of this already follows from much more general statements about how queues operate and this level of detail in VkSwapchainPresentFenceInfoKHR only creates confusion about vkQueuePresent maybe being a special case with different requirements.

The Fundamentals chapter says:

Before a fence or semaphore is signaled, it is guaranteed that any previously submitted queue operations have completed execution

The Devices and Queues chapter says:

Work is submitted to a queue via queue submission commands such as [...] vkQueuePresentKHR [...]. Queue submission commands define a set of queue operations

The vkQueuePresentKHR command says:

Queueing an image for presentation defines a set of queue operations, including waiting on the semaphores

The Synchronization and Cache Control chapter says:

[...] waiting for a binary semaphore also unsignals that semaphore when the wait completes

Therefore, it follows that the fence must not signal before the wait on the semaphores has completed and the semaphore has been unsignaled.

Furthermore, VkSwapchainPresentFenceInfoKHR is unnecessary for this purpose and is only useful for efficiency. Performing an empty vkQueueSubmit with only a fence attached would be equivalent since that fence must also wait for the previously submitted semaphore wait operations on the queue to complete.

Therefore, the notion of the presentation engine "taking a reference" to the semaphores is unnecessary from the perspective of applications. The semaphore wait -> fence pipeline is no different from the same pipeline in vkQueueSubmit.


There is a lot of confusion surrounding present semaphore reuse and destruction and I think it would be useful to

  1. remove the language I quoted above as far as it references semaphores
  2. add a note to the spec saying that the spec has evolved to make the semaphore handling in presentation requests identical to the handling in all other queue submission commands

I already created this issue a few days ago in a similar vein: https://github.com/KhronosGroup/Vulkan-ValidationLayers/issues/13434


The following is a bit of an afterthought since I originally wanted to open this issue only for the semaphore issue.

VkSwapchainPresentFenceInfoEXT also says that

The application [...] can destroy the swapchain when the fences associated with all past presentation requests referring to that swapchain have signaled.

It seems that VkSwapchainPresentFenceInfoEXT would still be useful for swapchain destruction even if it was not useful for semaphore destruction.

However, I believe it is unnecessary for that as well. As I already quoted above:

Before a fence or semaphore is signaled, it is guaranteed that any previously submitted queue operations have completed execution

The Devices and Queues chapter says

Work is submitted to a queue via queue submission commands such as vkQueueSubmit2 or vkQueuePresentKHR or vkQueueSubmit. Queue submission commands define a set of queue operations to be executed by the underlying physical device, including synchronization with semaphores and fences.

Therefore, signaling a fence is itself a queue operation and therefore all fences used with a queue must signal in order. Therefore, the fence used in an empty vkQueueSubmit must not signal before the fence in a previous vkQueuePresentKHR and both can therefore be used interchangeably for swapchain destruction.

There is an argument to be made that, if the application does not attach a fence to vkQueuePresentKHR itself, then this happens-before relationship does not hold. But it seems unlikely that there are implementations that use such a fast path.

Somewhat ironically, if the specification is compiled without maintenance1 support, it guarantees that every vkQueuePresentKHR command has such a fence operation attached:

Regarding interaction with vkQueueWaitIdle, vkQueuePresentKHR behaves as if it signals a fence payload that is managed by the implementation and that has no associated VkFence handle

Lingua principale
JavaScript
Stelle
3.4k
Fork
555
Merge medio
3g 10h
PR unite (30g)
5

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di KhronosGroup/Vulkan-Docs

Tutte le issue di KhronosGroup/Vulkan-Docs

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.