// Copyright 2018-2021 The Khronos Group, Inc.
//
// SPDX-License-Identifier: CC-BY-4.0

=== Alternate Methods to Signal Fences

Besides submitting a fence to a queue as part of a
<<devsandqueues-submission, queue submission>> command, a fence may: also be
signaled when a particular event occurs on a device or display.

[open,refpage='vkRegisterDeviceEventEXT',desc='Signal a fence when a device event occurs',type='protos']
--
To create a fence that will be signaled when an event occurs on a device,
call:

include::{generated}/api/protos/vkRegisterDeviceEventEXT.txt[]

  * pname:device is a logical device on which the event may: occur.
  * pname:pDeviceEventInfo is a pointer to a slink:VkDeviceEventInfoEXT
    structure describing the event of interest to the application.
  * pname:pAllocator controls host memory allocation as described in the
    <<memory-allocation, Memory Allocation>> chapter.
  * pname:pFence is a pointer to a handle in which the resulting fence
    object is returned.

include::{generated}/validity/protos/vkRegisterDeviceEventEXT.txt[]
--

[open,refpage='VkDeviceEventInfoEXT',desc='Describe a device event to create',type='structs']
--
The sname:VkDeviceEventInfoEXT structure is defined as:

include::{generated}/api/structs/VkDeviceEventInfoEXT.txt[]

  * pname:sType is the type of this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:device is a elink:VkDeviceEventTypeEXT value specifying when the
    fence will be signaled.

include::{generated}/validity/structs/VkDeviceEventInfoEXT.txt[]
--

[open,refpage='VkDeviceEventTypeEXT',desc='Events that can occur on a device object',type='enums']
--
Possible values of slink:VkDeviceEventInfoEXT::pname:device, specifying when
a fence will be signaled, are:

include::{generated}/api/enums/VkDeviceEventTypeEXT.txt[]

  * ename:VK_DEVICE_EVENT_TYPE_DISPLAY_HOTPLUG_EXT specifies that the fence
    is signaled when a display is plugged into or unplugged from the
    specified device.
    Applications can: use this notification to determine when they need to
    re-enumerate the available displays on a device.
--

[open,refpage='vkRegisterDisplayEventEXT',desc='Signal a fence when a display event occurs',type='protos']
--
To create a fence that will be signaled when an event occurs on a
slink:VkDisplayKHR object, call:

include::{generated}/api/protos/vkRegisterDisplayEventEXT.txt[]

  * pname:device is a logical device associated with pname:display
  * pname:display is the display on which the event may: occur.
  * pname:pDisplayEventInfo is a pointer to a slink:VkDisplayEventInfoEXT
    structure describing the event of interest to the application.
  * pname:pAllocator controls host memory allocation as described in the
    <<memory-allocation, Memory Allocation>> chapter.
  * pname:pFence is a pointer to a handle in which the resulting fence
    object is returned.

include::{generated}/validity/protos/vkRegisterDisplayEventEXT.txt[]
--

[open,refpage='VkDisplayEventInfoEXT',desc='Describe a display event to create',type='structs']
--
The sname:VkDisplayEventInfoEXT structure is defined as:

include::{generated}/api/structs/VkDisplayEventInfoEXT.txt[]

  * pname:sType is the type of this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:displayEvent is a elink:VkDisplayEventTypeEXT specifying when the
    fence will be signaled.

include::{generated}/validity/structs/VkDisplayEventInfoEXT.txt[]
--

[open,refpage='VkDisplayEventTypeEXT',desc='Events that can occur on a display object',type='enums']
--
Possible values of slink:VkDisplayEventInfoEXT::pname:displayEvent,
specifying when a fence will be signaled, are:

include::{generated}/api/enums/VkDisplayEventTypeEXT.txt[]

  * ename:VK_DISPLAY_EVENT_TYPE_FIRST_PIXEL_OUT_EXT specifies that the fence
    is signaled when the first pixel of the next display refresh cycle
    leaves the display engine for the display.
--
