summaryrefslogtreecommitdiff
path: root/chapters/VK_NV_low_latency2/low_latency2.adoc
blob: 85cfeed975a4e6548098b636b02f6fe05d6597a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
// Copyright 2023 The Khronos Group Inc.
//
// SPDX-License-Identifier: CC-BY-4.0


[[low-latency2]]
= Low Latency 2

== Latency Reduction
[open,refpage='vkSetLatencySleepModeNV',desc='Enable or Disable low latency mode on a swapchain',type='protos']
--
To enable or disable low latency mode on a swapchain, call:

include::{generated}/api/protos/vkSetLatencySleepModeNV.adoc[]

  * pname:device is the device associated with pname:swapchain.
  * pname:swapchain is the swapchain to enable or disable low latency mode
    on.
  * pname:pSleepModeInfo is `NULL` or a pointer to a
    slink:VkLatencySleepModeInfoNV structure specifying the parameters of
    the latency sleep mode.

If pname:pSleepModeInfo is `NULL`, fname:vkSetLatencySleepModeNV will
disable low latency mode, low latency boost, and set the minimum present
interval previously specified by slink:VkLatencySleepModeInfoNV to zero on
pname:swapchain.
As an exception to the normal rules for objects which are externally
synchronized, the swapchain passed to fname:vkSetLatencySleepModeNV may: be
simultaneously used by other threads in calls to functions other than
flink:vkDestroySwapchainKHR.
Access to the swapchain data associated with this extension must: be atomic
within the implementation.

include::{generated}/validity/protos/vkSetLatencySleepModeNV.adoc[]
--

[open,refpage='VkLatencySleepModeInfoNV',desc='Structure to set low latency mode',type='structs']
--
The sname:VkLatencySleepModeInfoNV structure is defined as:

include::{generated}/api/structs/VkLatencySleepModeInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:lowLatencyMode is the toggle to enable or disable low latency
    mode.
  * pname:lowLatencyBoost allows an application to hint to the GPU to
    increase performance to provide additional latency savings at a cost of
    increased power consumption.
  * pname:minimumPresentIntervalUs is the microseconds between
    flink:vkQueuePresentKHR calls for a given swapchain that
    flink:vkLatencySleepNV will enforce.

If pname:lowLatencyMode is set to ename:VK_FALSE, pname:lowLatencyBoost will
still hint to the GPU to increase its power state and fname:vkLatencySleepNV
will still enforce pname:minimumIntervalUs between fname:vkQueuePresentKHR
calls.

include::{generated}/validity/structs/VkLatencySleepModeInfoNV.adoc[]
--

[open,refpage='vkLatencySleepNV',desc='Trigger low latency mode Sleep',type='protos']
--
To provide the synchronization primitive used to delay host CPU work for
lower latency rendering, call:

include::{generated}/api/protos/vkLatencySleepNV.adoc[]

  * pname:device is the device associated with pname:swapchain.
  * pname:swapchain is the swapchain to delay associated CPU work based on
    slink:VkLatencySubmissionPresentIdNV submissions.
  * pname:pSleepInfo is a pointer to a slink:VkLatencySleepInfoNV structure
    specifying the parameters of the latency sleep.

fname:vkLatencySleepNV returns immediately.
Applications should: use flink:vkWaitSemaphores with
pname:pSleepInfo::pname:signalSemaphore to delay host CPU work.
CPU work refers to application work done before presenting which includes
but is not limited to: input sampling, simulation, command buffer recording,
command buffer submission, and present submission.
It is recommended to call this function before input sampling.
When using this function, it should: be called exactly once between
presents.

include::{generated}/validity/protos/vkLatencySleepNV.adoc[]
--

[open,refpage='VkLatencySleepInfoNV',desc='Structure specifying the parameters of vkLatencySleepNV',type='structs']
--
The sname:VkLatencySleepInfoNV structure is defined as:

include::{generated}/api/structs/VkLatencySleepInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:signalSemaphore is a semaphore that is signaled to indicate that
    the application should: resume input sampling work.
  * pname:value is the value that pname:signalSemaphore is set to for
    resuming sampling work.

.Valid Usage
****
  * [[VUID-VkLatencySleepInfoNV-signalSemaphore-09361]]
    pname:signalSemaphore must: be a timeline semaphore
****

include::{generated}/validity/structs/VkLatencySleepInfoNV.adoc[]
--

[open,refpage='vkSetLatencyMarkerNV',desc='Pass in marker for timing info',type='protos']
--
An application can: provide timestamps at various stages of its frame
generation work by calling:

include::{generated}/api/protos/vkSetLatencyMarkerNV.adoc[]

  * pname:device is the device associated with pname:swapchain.
  * pname:swapchain is the swapchain to capture timestamps on.
  * pname:pSetLatencyMarkerInfo is a pointer to a
    slink:VkSetLatencyMarkerInfoNV structure specifying the parameters of
    the marker to set.

At the beginning and end of simulation and render threads and beginning and
end of flink:vkQueuePresentKHR calls, fname:vkSetLatencyMarkerNV can: be
called to provide timestamps for the application's reference.
These timestamps are returned with a call to flink:vkGetLatencyTimingsNV
alongside driver provided timestamps at various points of interest with
regards to latency within the application.
As an exception to the normal rules for objects which are externally
synchronized, the swapchain passed to fname:vkSetLatencyMarkerNV may: be
simultaneously used by other threads in calls to functions other than
flink:vkDestroySwapchainKHR.
Access to the swapchain data associated with this extension must: be atomic
within the implementation.

include::{generated}/validity/protos/vkSetLatencyMarkerNV.adoc[]
--

[open,refpage='VkSetLatencyMarkerInfoNV',desc='Structure specifying the parameters of vkSetLatencyMarkerNV',type='structs']
--
The sname:VkSetLatencyMarkerInfoNV structure is defined as:

include::{generated}/api/structs/VkSetLatencyMarkerInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:presentId is an application provided value that is used to
    associate the timestamp with a fname:vkQueuePresentKHR command using
    slink:VkPresentIdKHR::pname:pPresentIds for a given present.
  * pname:marker is the type of timestamp to be recorded.

include::{generated}/validity/structs/VkSetLatencyMarkerInfoNV.adoc[]
--

[open,refpage='VkLatencyMarkerNV',desc='Structure used to mark different points in latency',type='enums']
--
The elink:VkLatencyMarkerNV enum is defined as:

include::{generated}/api/enums/VkLatencyMarkerNV.adoc[]

The members of the elink:VkLatencyMarkerNV are used as arguments for
flink:vkSetLatencyMarkerNV in the use cases described below:

  * ename:VK_LATENCY_MARKER_SIMULATION_START_NV should: be called at the
    start of the simulation execution each frame, but after the call to
    fname:vkLatencySleepNV.
  * ename:VK_LATENCY_MARKER_SIMULATION_END_NV should: be called at the end
    of the simulation execution each frame.
  * ename:VK_LATENCY_MARKER_RENDERSUBMIT_START_NV should: be called at the
    beginning of the render submission execution each frame.
    This should: be wherever Vulkan API calls are made and must: not span
    into asynchronous rendering.
  * ename:VK_LATENCY_MARKER_RENDERSUBMIT_END_NV should: be called at the end
    of the render submission execution each frame.
  * ename:VK_LATENCY_MARKER_PRESENT_START_NV should: be called just before
    fname:vkQueuePresentKHR.
  * ename:VK_LATENCY_MARKER_PRESENT_END_NV should: be called when
    fname:vkQueuePresentKHR returns.
  * ename:VK_LATENCY_MARKER_INPUT_SAMPLE_NV should: be called just before
    the application gathers input data.
  * ename:VK_LATENCY_MARKER_TRIGGER_FLASH_NV should: be called anywhere
    between ename:VK_LATENCY_MARKER_SIMULATION_START_NV and
    ename:VK_LATENCY_MARKER_SIMULATION_END_NV whenever a left mouse click
    occurs.
--

[open,refpage='vkGetLatencyTimingsNV',desc='Get latency marker results',type='protos']
--
To get an array containing the newest collected latency data, call:

include::{generated}/api/protos/vkGetLatencyTimingsNV.adoc[]

  * pname:device is the device associated with pname:swapchain.
  * pname:swapchain is the swapchain to return data from.
  * pname:pGetLatencyMarkerInfo is a pointer to a
    slink:VkGetLatencyMarkerInfoNV structure specifying the parameters for
    returning latency information.

The timings returned by fname:vkGetLatencyTimingsNV contain the timestamps
requested from flink:vkSetLatencyMarkerNV and additional
implementation-specific markers defined in
slink:VkLatencyTimingsFrameReportNV.

include::{generated}/validity/protos/vkGetLatencyTimingsNV.adoc[]
--

[open,refpage='VkGetLatencyMarkerInfoNV',desc='Structure specifying the parameters of vkGetLatencyTimingsNV',type='structs']
--
The sname:VkGetLatencyMarkerInfoNV structure is defined as:

include::{generated}/api/structs/VkGetLatencyMarkerInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is either `NULL` or a pointer to a structure extending this
    structure.
  * pname:timingCount is an integer related to the number of of previous
    frames of latency data available or queried, as described below.
  * pname:pTimings is either `NULL` or a pointer to an array of
    slink:VkLatencyTimingsFrameReportNV structures.

If pname:pTimings is `NULL` then the maximum number of queryable frame data
is returned in pname:timingCount.
Otherwise, pname:timingCount must: be set by the user to the number of
elements in the pname:pTimings array, and on return the variable is
overwritten with the number of values actually written to pname:pTimings.
The elements of pname:pTimings are arranged in the order they were requested
in, with the oldest data in the first entry.

include::{generated}/validity/structs/VkGetLatencyMarkerInfoNV.adoc[]
--

[open,refpage='VkLatencyTimingsFrameReportNV',desc='Structure containing latency data',type='structs']
--
The slink:VkLatencyTimingsFrameReportNV structure describes latency data
returned by flink:vkGetLatencyTimingsNV

include::{generated}/api/structs/VkLatencyTimingsFrameReportNV.adoc[]

The members of the slink:VkLatencyTimingsFrameReportNV structure describe
the following:

  * pname:presentId is the application provided value that is used to
    associate the timestamp with a fname:vkQueuePresentKHR command using
    slink:VkPresentIdKHR::pname:pPresentIds for a given present.
  * pname:simStartTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_SIMULATION_START_NV.
  * pname:simEndTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_SIMULATION_END_NV
  * pname:renderStartTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_RENDERSUBMIT_START_NV.
  * pname:renderEndTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_RENDERSUBMIT_END_NV.
  * pname:presentStartTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_PRESENT_START_NV.
  * pname:presentEndTimeUs is the timestamp written when
    fname:vkSetLatencyMarkerNV is called with the ename:VkLatencyMarkerNV
    enum ename:VK_LATENCY_MARKER_PRESENT_END_NV.
  * pname:driverStartTimeUs is the timestamp written when the first
    fname:vkQueueSubmit for the frame is called.
  * pname:driverEndTimeUs is the timestamp written when the final
    fname:vkQueueSubmit hands off from the Vulkan Driver.
  * pname:osRenderQueueStartTimeUs is the timestamp written when the final
    fname:vkQueueSubmit hands off from the Vulkan Driver.
  * pname:osRenderQueueEndTimeUs is the timestamp written when the first
    submission reaches the GPU.
  * pname:gpuRenderStartTimeUs is the timestamp written when the first
    submission reaches the GPU.
  * pname:gpuRenderEndTimeUs is the timestamp written when the final
    submission finishes on the GPU for the frame.

include::{generated}/validity/structs/VkLatencyTimingsFrameReportNV.adoc[]
--

[open,refpage='VkLatencySubmissionPresentIdNV',desc='Structure used to associate a queueSubmit with a presentId',type='structs']
--
The slink:VkLatencySubmissionPresentIdNV structure is defined as:

include::{generated}/api/structs/VkLatencySubmissionPresentIdNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:presentId is used to associate the fname:vkQueueSubmit with the
    presentId used for a given fname:vkQueuePresentKHR via
    slink:VkPresentIdKHR::pname:pPresentIds.

For any submission to be tracked with low latency mode pacing, it needs to
be associated with other submissions in a given present.
Applications :must include the VkLatencySubmissionPresentIdNV in the pNext
chain of flink:vkQueueSubmit to associate that submission with the
pname:presentId present for low latency mode.

include::{generated}/validity/structs/VkLatencySubmissionPresentIdNV.adoc[]
--

[open,refpage='vkQueueNotifyOutOfBandNV',desc='Notify out of band queue',type='protos']
--
An application can mark a queue as Out of Band to indicate that all
fname:vkQueueSubmit calls on this queue are ignored for latency evaluation
by calling:
include::{generated}/api/protos/vkQueueNotifyOutOfBandNV.adoc[]

  * pname:queue is the VkQueue to be marked as out of band.
  * pname:pQueueTypeInfo is a pointer to a slink:VkOutOfBandQueueTypeInfoNV
    structure specifying the queue type.

include::{generated}/validity/protos/vkQueueNotifyOutOfBandNV.adoc[]
--

[open,refpage='VkOutOfBandQueueTypeInfoNV',desc='Structure used to describe the queue that is being marked as Out of Band',type='structs']
--
The slink:VkOutOfBandQueueTypeInfoNV structure is defined as:

include::{generated}/api/structs/VkOutOfBandQueueTypeInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:queueType describes the usage of the queue to be marked as out of
    band.

include::{generated}/validity/structs/VkOutOfBandQueueTypeInfoNV.adoc[]
--

[open,refpage='VkOutOfBandQueueTypeNV',desc='Type of out of band queue',type='enums']
--
The elink:VkOutOfBandQueueTypeNV enum is defined as:

include::{generated}/api/enums/VkOutOfBandQueueTypeNV.adoc[]

The members of the elink:VkOutOfBandQueueTypeNV are used to describe the
queue type in slink:VkOutOfBandQueueTypeInfoNV as described below:

  * ename:VK_OUT_OF_BAND_QUEUE_TYPE_RENDER_NV indicates that work will be
    submitted to this queue.
  * ename:VK_OUT_OF_BAND_QUEUE_TYPE_PRESENT_NV indicates that this queue
    will be presented from.
--

[open,refpage='VkSwapchainLatencyCreateInfoNV',desc='Specify that a swapchain will use low latency mode',type='structs']
--
To allow low latency mode to be used by a swapchain, add a
sname:VkSwapchainLatencyCreateInfoNV structure to the pname:pNext chain of
slink:VkSwapchainCreateInfoKHR.

The sname:VkSwapchainLatencyCreateInfoNV structure is defined as:

include::{generated}/api/structs/VkSwapchainLatencyCreateInfoNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:lowLatencyModeEnable indicates if the swapchain created will
    utilize low latency mode.

include::{generated}/validity/structs/VkSwapchainLatencyCreateInfoNV.adoc[]
--

[open,refpage='VkLatencySurfaceCapabilitiesNV',desc='Structure describing surface optimized presentation modes for use with low latency mode',type='structs']
--
The sname:VkLatencySurfaceCapabilitiesNV structure is defined as:

include::{generated}/api/structs/VkLatencySurfaceCapabilitiesNV.adoc[]

  * pname:sType is a elink:VkStructureType value identifying this structure.
  * pname:pNext is `NULL` or a pointer to a structure extending this
    structure.
  * pname:presentModeCount is the number of presentation modes provided.
  * pname:pPresentModes is list of presentation modes optimized for use with
    low latency mode with pname:presentModeCount entries.

If pname:pPresentModes is `NULL`, then the number of present modes that are
optimized for use with low latency mode returned in pname:presentModeCount.
Otherwise, pname:presentModeCount must be set by the user to the number of
elements in the pname:pPresentModes array, and on return the variable is
overwritten with the number of values actually written to
pname:pPresentModes.
If the value of pname:presentModeCount is less than the number of optimized
present modes, at most pname:presentModeCount values will be written to
pname:pPresentModes.

include::{generated}/validity/structs/VkLatencySurfaceCapabilitiesNV.adoc[]
--