• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// Copyright 2020-2021 The Khronos Group, Inc.
2//
3// SPDX-License-Identifier: CC-BY-4.0
4
5[[acceleration-structure]]
6= Acceleration Structures
7
8
9[[acceleration-structure-def]]
10== Acceleration Structures
11
12_Acceleration structures_ are data structures used by the implementation to
13efficiently manage scene geometry as it is <<ray-traversal, traversed during
14a ray tracing query>>.
15The application is responsible for managing acceleration structure objects
16(see <<resources-acceleration-structures,Acceleration Structures>>),
17including allocation, destruction, executing builds or updates, and
18synchronizing resources used during ray tracing queries.
19
20There are two types of acceleration structures, _top level acceleration
21structures_ and _bottom level acceleration structures_.
22
23An acceleration structure is considered to be constructed if an
24<<acceleration-structure-building,acceleration structure build command>> or
25<<acceleration-structure-copying,copy command>> has been executed with the
26given acceleration structure as the destination.
27
28[[fig-accelstruct]]
29image::{images}/accelstruct.svg[align="center",title="Acceleration Structure",opts="{imageopts}"]
30
31.Caption
32****
33The diagram shows the relationship between top and bottom level acceleration
34structures.
35****
36
37
38[[acceleration-structure-geometry]]
39=== Geometry
40
41_Geometries_ refer to a triangle or axis-aligned bounding box.
42
43
44[[acceleration-structure-top-level]]
45=== Top Level Acceleration Structures
46
47Opaque acceleration structure for an array of instances.
48The descriptor or device address referencing this is the starting point for
49traversal.
50
51The top level acceleration structure takes a reference to any bottom level
52acceleration structure referenced by its instances.
53Those bottom level acceleration structure objects must: be valid when the
54top level acceleration structure is accessed.
55
56
57[[acceleration-structure-bottom-level]]
58=== Bottom Level Acceleration Structures
59
60Opaque acceleration structure for an array of geometries.
61
62
63[[acceleration-structure-update]]
64=== Acceleration Structure Update Rules
65
66The API defines two types of operations to produce acceleration structures
67from geometry:
68
69  * A _build_ operation is used to construct an acceleration structure.
70  * An _update_ operation is used to modify an existing acceleration
71    structure.
72
73An update operation imposes certain constraints on the input, in exchange
74for considerably faster execution.
75When performing an update, the application is required to provide a full
76description of the acceleration structure, but is prohibited from changing
77anything other than instance definitions, transform matrices, and vertex or
78AABB positions.
79All other aspects of the description must: exactly match the one from the
80original build.
81
82More precisely, the application must: not use an update operation to do any
83of the following:
84
85  * Change primitives or instances from _active_ to _inactive_ (as defined
86    in <<acceleration-structure-inactive-prims>>).
87  * Change the index or vertex formats of triangle geometry.
88  * Change triangle geometry transform pointers from null to non-null or
89    vice versa.
90  * Change the number of geometries or instances in the structure.
91  * Change the geometry flags for any geometry in the structure.
92  * Change the number of vertices or primitives for any geometry in the
93    structure.
94
95
96[[acceleration-structure-inactive-prims]]
97=== Inactive Primitives and Instances
98
99Acceleration structures allow the use of particular input values to signal
100_inactive_ primitives or instances.
101
102An _inactive_ triangle is one for which the first (X) component of each
103vertex is NaN.
104If any other vertex component is NaN, and the first is not, the behavior is
105undefined:.
106If the vertex format does not have a NaN representation, then all triangles
107are considered active.
108
109An _inactive_ instance is one whose acceleration structure handle is
110dlink:VK_NULL_HANDLE.
111
112An _inactive_ AABB is one for which the minimum X coordinate is NaN.
113If any other component is NaN, and the first is not, the behavior is
114undefined:.
115
116In the above definitions, "NaN" refers to any type of NaN.
117Signaling, non-signaling, quiet, loud, or otherwise.
118
119An inactive object is considered invisible to all rays, and should: not be
120represented in the acceleration structure.
121Implementations should: ensure that the presence of inactive objects does
122not seriously degrade traversal performance.
123
124Inactive objects are counted in the auto-generated index sequences which are
125provided to shaders via code:InstanceId and code:PrimitiveId SPIR-V
126decorations.
127This allows objects in the scene to change freely between the active and
128inactive states, without affecting the layout of any arrays which are being
129indexed using the ID values.
130
131Any transition between the active and inactive states requires a full
132acceleration structure rebuild.
133Applications must: not perform an acceleration structure update where an
134object is active in the source acceleration structure but would be inactive
135in the destination, or vice versa.
136
137
138[[acceleration-structure-building]]
139=== Building Acceleration Structures
140
141ifdef::VK_NV_ray_tracing[]
142[open,refpage='vkCmdBuildAccelerationStructureNV',desc='Build an acceleration structure',type='protos']
143--
144:refpage: vkCmdBuildAccelerationStructureNV
145
146To build an acceleration structure call:
147
148include::{generated}/api/protos/vkCmdBuildAccelerationStructureNV.txt[]
149
150  * pname:commandBuffer is the command buffer into which the command will be
151    recorded.
152  * pname:pInfo contains the shared information for the acceleration
153    structure's structure.
154  * pname:instanceData is the buffer containing an array of
155    slink:VkAccelerationStructureInstanceKHR structures defining
156    acceleration structures.
157    This parameter must: be `NULL` for bottom level acceleration structures.
158  * pname:instanceOffset is the offset in bytes (relative to the start of
159    pname:instanceData) at which the instance data is located.
160  * pname:update specifies whether to update the pname:dst acceleration
161    structure with the data in pname:src.
162  * pname:dst is a pointer to the target acceleration structure for the
163    build.
164  * pname:src is a pointer to an existing acceleration structure that is to
165    be used to update the pname:dst acceleration structure.
166  * pname:scratch is the slink:VkBuffer that will be used as scratch memory
167    for the build.
168  * pname:scratchOffset is the offset in bytes relative to the start of
169    pname:scratch that will be used as a scratch memory.
170
171Accesses to pname:dst, pname:src, and pname:scratch must: be
172<<synchronization-dependencies,synchronized>> with the
173ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
174<<synchronization-pipeline-stages, pipeline stage>> and an
175<<synchronization-access-types, access type>> of
176ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR or
177ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR.
178
179.Valid Usage
180****
181  * [[VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241]]
182    pname:geometryCount must: be less than or equal to
183    slink:VkPhysicalDeviceRayTracingPropertiesNV::pname:maxGeometryCount
184  * [[VUID-vkCmdBuildAccelerationStructureNV-dst-02488]]
185    pname:dst must: have been created with compatible
186    slink:VkAccelerationStructureInfoNV where
187    slink:VkAccelerationStructureInfoNV::pname:type and
188    slink:VkAccelerationStructureInfoNV::pname:flags are identical,
189    slink:VkAccelerationStructureInfoNV::pname:instanceCount and
190    slink:VkAccelerationStructureInfoNV::pname:geometryCount for pname:dst
191    are greater than or equal to the build size and each geometry in
192    slink:VkAccelerationStructureInfoNV::pname:pGeometries for pname:dst has
193    greater than or equal to the number of vertices, indices, and AABBs
194  * [[VUID-vkCmdBuildAccelerationStructureNV-update-02489]]
195    If pname:update is ename:VK_TRUE, pname:src must: not be
196    dlink:VK_NULL_HANDLE
197  * [[VUID-vkCmdBuildAccelerationStructureNV-update-02490]]
198    If pname:update is ename:VK_TRUE, pname:src must: have previously been
199    constructed with
200    ename:VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV set in
201    slink:VkAccelerationStructureInfoNV::pname:flags in the original build
202  * [[VUID-vkCmdBuildAccelerationStructureNV-update-02491]]
203    If pname:update is ename:VK_FALSE, the pname:size member of the
204    slink:VkMemoryRequirements structure returned from a call to
205    flink:vkGetAccelerationStructureMemoryRequirementsNV with
206    slink:VkAccelerationStructureMemoryRequirementsInfoNV::pname:accelerationStructure
207    set to pname:dst and
208    slink:VkAccelerationStructureMemoryRequirementsInfoNV::pname:type set to
209    ename:VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV
210    must: be less than or equal to the size of pname:scratch minus
211    pname:scratchOffset
212  * [[VUID-vkCmdBuildAccelerationStructureNV-update-02492]]
213    If pname:update is ename:VK_TRUE, the pname:size member of the
214    slink:VkMemoryRequirements structure returned from a call to
215    flink:vkGetAccelerationStructureMemoryRequirementsNV with
216    slink:VkAccelerationStructureMemoryRequirementsInfoNV::pname:accelerationStructure
217    set to pname:dst and
218    slink:VkAccelerationStructureMemoryRequirementsInfoNV::pname:type set to
219    ename:VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV
220    must: be less than or equal to the size of pname:scratch minus
221    pname:scratchOffset
222  * [[VUID-vkCmdBuildAccelerationStructureNV-scratch-03522]]
223    pname:scratch must: have been created with
224    ename:VK_BUFFER_USAGE_RAY_TRACING_BIT_NV usage flag
225  * [[VUID-vkCmdBuildAccelerationStructureNV-instanceData-03523]]
226    If pname:instanceData is not dlink:VK_NULL_HANDLE, pname:instanceData
227    must: have been created with ename:VK_BUFFER_USAGE_RAY_TRACING_BIT_NV
228    usage flag
229  * [[VUID-vkCmdBuildAccelerationStructureNV-accelerationStructureReference-03786]]
230    Each
231    slink:VkAccelerationStructureInstanceKHR::pname:accelerationStructureReference
232    value in pname:instanceData must: be a valid device address containing a
233    value obtained from flink:vkGetAccelerationStructureHandleNV
234  * [[VUID-vkCmdBuildAccelerationStructureNV-update-03524]]
235    If pname:update is ename:VK_TRUE, then objects that were previously
236    active must: not be made inactive as per
237    <<acceleration-structure-inactive-prims>>
238  * [[VUID-vkCmdBuildAccelerationStructureNV-update-03525]]
239    If pname:update is ename:VK_TRUE, then objects that were previously
240    inactive must: not be made active as per
241    <<acceleration-structure-inactive-prims>>
242  * [[VUID-vkCmdBuildAccelerationStructureNV-update-03526]]
243    If pname:update is ename:VK_TRUE, the pname:src and pname:dst objects
244    must: either be the same object or not have any
245    <<resources-memory-aliasing, memory aliasing>>
246
247****
248
249include::{generated}/validity/protos/vkCmdBuildAccelerationStructureNV.txt[]
250--
251endif::VK_NV_ray_tracing[]
252
253ifdef::VK_KHR_acceleration_structure[]
254[open,refpage='vkCmdBuildAccelerationStructuresKHR',desc='Build an acceleration structure',type='protos']
255--
256:refpage: vkCmdBuildAccelerationStructuresKHR
257:maxinstancecheck: pname:ppBuildRangeInfos[i][j].pname:primitiveCount
258
259To build acceleration structures call:
260
261include::{generated}/api/protos/vkCmdBuildAccelerationStructuresKHR.txt[]
262
263  * pname:commandBuffer is the command buffer into which the command will be
264    recorded.
265  * pname:infoCount is the number of acceleration structures to build.
266    It specifies the number of the pname:pInfos structures and
267    pname:ppBuildRangeInfos pointers that must: be provided.
268  * pname:pInfos is a pointer to an array of pname:infoCount
269    slink:VkAccelerationStructureBuildGeometryInfoKHR structures defining
270    the geometry used to build each acceleration structure.
271  * pname:ppBuildRangeInfos is a pointer to an array of pname:infoCount
272    pointers to arrays of slink:VkAccelerationStructureBuildRangeInfoKHR
273    structures.
274    Each pname:ppBuildRangeInfos[i] is a pointer to an array of
275    pname:pInfos[i].pname:geometryCount
276    slink:VkAccelerationStructureBuildRangeInfoKHR structures defining
277    dynamic offsets to the addresses where geometry data is stored, as
278    defined by pname:pInfos[i].
279
280The fname:vkCmdBuildAccelerationStructuresKHR command provides the ability
281to initiate multiple acceleration structures builds, however there is no
282ordering or synchronization implied between any of the individual
283acceleration structure builds.
284
285[NOTE]
286.Note
287====
288This means that an application cannot: build a top-level acceleration
289structure in the same flink:vkCmdBuildAccelerationStructuresKHR call as the
290associated bottom-level or instance acceleration structures are being built.
291There also cannot: be any memory aliasing between any acceleration structure
292memories or scratch memories being used by any of the builds.
293====
294
295[[acceleration-structure-scratch]]
296Accesses to the acceleration structure scratch buffers as identified by the
297slink:VkAccelerationStructureBuildGeometryInfoKHR::pname:scratchData buffer
298device addresses must: be <<synchronization-dependencies,synchronized>> with
299the ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
300<<synchronization-pipeline-stages, pipeline stage>> and an
301<<synchronization-access-types, access type>> of
302ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR or
303ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR.
304Similarly for accesses to each
305slink:VkAccelerationStructureBuildGeometryInfoKHR::pname:srcAccelerationStructure
306and
307slink:VkAccelerationStructureBuildGeometryInfoKHR::pname:dstAccelerationStructure.
308
309Accesses to other input buffers as identified by any used values of
310ifdef::VK_NV_ray_tracing_motion_blur[]
311slink:VkAccelerationStructureGeometryMotionTrianglesDataNV::pname:vertexData,
312endif::VK_NV_ray_tracing_motion_blur[]
313slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:vertexData,
314slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:indexData,
315slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:transformData,
316slink:VkAccelerationStructureGeometryAabbsDataKHR::pname:data, and
317slink:VkAccelerationStructureGeometryInstancesDataKHR::pname:data must: be
318<<synchronization-dependencies,synchronized>> with the
319ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
320<<synchronization-pipeline-stages, pipeline stage>> and an
321<<synchronization-access-types, access type>> of
322ename:VK_ACCESS_SHADER_READ_BIT.
323
324
325.Valid Usage
326****
327include::{chapters}/commonvalidity/build_acceleration_structure_common.txt[]
328include::{chapters}/commonvalidity/build_acceleration_structure_device_common.txt[]
329include::{chapters}/commonvalidity/build_acceleration_structure_nonindirect_common.txt[]
330****
331
332include::{generated}/validity/protos/vkCmdBuildAccelerationStructuresKHR.txt[]
333--
334
335[open,refpage='vkCmdBuildAccelerationStructuresIndirectKHR',desc='Build an acceleration structure with some parameters provided on the device',type='protos']
336--
337:refpage: vkCmdBuildAccelerationStructuresIndirectKHR
338:maxinstancecheck: pname:ppMaxPrimitiveCounts[i][j]
339
340To build acceleration structures with some parameters sourced on the device
341call:
342
343include::{generated}/api/protos/vkCmdBuildAccelerationStructuresIndirectKHR.txt[]
344
345  * pname:commandBuffer is the command buffer into which the command will be
346    recorded.
347  * pname:infoCount is the number of acceleration structures to build.
348  * pname:pInfos is a pointer to an array of pname:infoCount
349    slink:VkAccelerationStructureBuildGeometryInfoKHR structures defining
350    the geometry used to build each acceleration structure.
351  * pname:pIndirectDeviceAddresses is a pointer to an array of
352    pname:infoCount buffer device addresses which point to
353    pname:pInfos[i].pname:geometryCount
354    slink:VkAccelerationStructureBuildRangeInfoKHR structures defining
355    dynamic offsets to the addresses where geometry data is stored, as
356    defined by pname:pInfos[i].
357  * pname:pIndirectStrides is a pointer to an array of pname:infoCount byte
358    strides between elements of pname:pIndirectDeviceAddresses.
359  * pname:ppMaxPrimitiveCounts is a pointer to an array of pname:infoCount
360    pointers to arrays of pname:pInfos[i].pname:geometryCount values
361    indicating the maximum number of primitives that will be built by this
362    command for each geometry.
363
364Accesses to acceleration structures, scratch buffers, vertex buffers, index
365buffers, and instance buffers must be synchronized as with
366<<acceleration-structure-scratch,vkCmdBuildAccelerationStructuresKHR>>.
367
368Accesses to any element of pname:pIndirectDeviceAddresses must: be
369<<synchronization-dependencies,synchronized>> with the
370ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
371<<synchronization-pipeline-stages, pipeline stage>> and an
372<<synchronization-access-types, access type>> of
373ename:VK_ACCESS_INDIRECT_COMMAND_READ_BIT.
374
375
376.Valid Usage
377****
378include::{chapters}/commonvalidity/build_acceleration_structure_common.txt[]
379include::{chapters}/commonvalidity/build_acceleration_structure_device_common.txt[]
380  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectDeviceAddresses-03645]]
381    For any element of pname:pIndirectDeviceAddresses, if the buffer from
382    which it was queried is non-sparse then it must: be bound completely and
383    contiguously to a single slink:VkDeviceMemory object
384  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectDeviceAddresses-03646]]
385    For any element of pname:pIndirectDeviceAddresses[i], all device
386    addresses between pname:pIndirectDeviceAddresses[i] and
387    [eq]#pname:pIndirectDeviceAddresses[i] {plus}
388    (pname:pInfos[i].pname:geometryCount {times} pname:pIndirectStrides[i]) -
389    1# must: be in the buffer device address range of the same buffer
390  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectDeviceAddresses-03647]]
391    For any element of pname:pIndirectDeviceAddresses, the buffer from which
392    it was queried must: have been created with the
393    ename:VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT bit set
394  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectDeviceAddresses-03648]]
395    Each element of pname:pIndirectDeviceAddresses must: be a multiple of
396    `4`
397  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectStrides-03787]]
398    Each element of pname:pIndirectStrides must: be a multiple of `4`
399  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-commandBuffer-03649]]
400    pname:commandBuffer must: not be a protected command buffer
401  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650]]
402    The <<features-accelerationStructureIndirectBuild,
403    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureIndirectBuild>>
404    feature must: be enabled
405  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pIndirectDeviceAddresses-03651]]
406    Each slink:VkAccelerationStructureBuildRangeInfoKHR structure referenced
407    by any element of pname:pIndirectDeviceAddresses must: be a valid
408    slink:VkAccelerationStructureBuildRangeInfoKHR structure
409  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03652]]
410    pname:pInfos[i].pname:dstAccelerationStructure must: have been created
411    with a value of slink:VkAccelerationStructureCreateInfoKHR::pname:size
412    greater than or equal to the memory size required by the build
413    operation, as returned by flink:vkGetAccelerationStructureBuildSizesKHR
414    with [eq]#pname:pBuildInfo = pname:pInfos[i]# and
415    [eq]#pname:pMaxPrimitiveCounts = pname:ppMaxPrimitiveCounts[i]#
416  * [[VUID-vkCmdBuildAccelerationStructuresIndirectKHR-ppMaxPrimitiveCounts-03653]]
417    Each pname:ppMaxPrimitiveCounts[i][j] must: be greater than or equal to
418    the the pname:primitiveCount value specified by the
419    slink:VkAccelerationStructureBuildRangeInfoKHR structure located at
420    [eq]#pname:pIndirectDeviceAddresses[i] {plus} (code:j {times}
421    pname:pIndirectStrides[i])#
422****
423
424include::{generated}/validity/protos/vkCmdBuildAccelerationStructuresIndirectKHR.txt[]
425--
426
427
428[open,refpage='VkAccelerationStructureBuildGeometryInfoKHR',desc='Structure specifying the geometry data used to build an acceleration structure',type='structs']
429--
430:refpage: VkAccelerationStructureBuildGeometryInfoKHR
431
432The sname:VkAccelerationStructureBuildGeometryInfoKHR structure is defined
433as:
434
435include::{generated}/api/structs/VkAccelerationStructureBuildGeometryInfoKHR.txt[]
436
437  * pname:sType is the type of this structure.
438  * pname:pNext is `NULL` or a pointer to a structure extending this
439    structure.
440  * pname:type is a elink:VkAccelerationStructureTypeKHR value specifying
441    the type of acceleration structure being built.
442  * pname:flags is a bitmask of
443    elink:VkBuildAccelerationStructureFlagBitsKHR specifying additional
444    parameters of the acceleration structure.
445  * pname:mode is a elink:VkBuildAccelerationStructureModeKHR value
446    specifying the type of operation to perform.
447  * pname:srcAccelerationStructure is a pointer to an existing acceleration
448    structure that is to be used to update the pname:dst acceleration
449    structure when pname:mode is
450    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR.
451  * pname:dstAccelerationStructure is a pointer to the target acceleration
452    structure for the build.
453  * pname:geometryCount specifies the number of geometries that will be
454    built into pname:dstAccelerationStructure.
455  * pname:pGeometries is a pointer to an array of
456    slink:VkAccelerationStructureGeometryKHR structures.
457  * pname:ppGeometries is a pointer to an array of pointers to
458    slink:VkAccelerationStructureGeometryKHR structures.
459  * pname:scratchData is the device or host address to memory that will be
460    used as scratch memory for the build.
461
462Only one of pname:pGeometries or pname:ppGeometries can: be a valid pointer,
463the other must: be `NULL`.
464Each element of the non-`NULL` array describes the data used to build each
465acceleration structure geometry.
466
467ifdef::VK_KHR_ray_tracing_pipeline,VK_KHR_ray_query[]
468[[acceleration-structure-geometry-index]]
469The index of each element of the pname:pGeometries or pname:ppGeometries
470members of slink:VkAccelerationStructureBuildGeometryInfoKHR is used as the
471_geometry index_ during ray traversal.
472ifdef::VK_KHR_ray_tracing_pipeline[]
473The geometry index is available in ray shaders via the
474<<interfaces-builtin-variables-raygeometryindex,code:RayGeometryIndexKHR
475built-in>>, and is <<shader-binding-table-hit-shader-indexing, used to
476determine hit and intersection shaders executed during traversal>>.
477endif::VK_KHR_ray_tracing_pipeline[]
478ifdef::VK_KHR_ray_query[]
479The geometry index is available to ray queries via the
480code:OpRayQueryGetIntersectionGeometryIndexKHR instruction.
481endif::VK_KHR_ray_query[]
482endif::VK_KHR_ray_tracing_pipeline,VK_KHR_ray_query[]
483
484ifdef::VK_NV_ray_tracing_motion_blur[]
485[[acceleration-structure-motion-instances]]
486Setting ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV in pname:flags
487indicates that this build is a motion top level acceleration structure.
488A motion top level uses instances of format
489slink:VkAccelerationStructureMotionInstanceNV if
490slink:VkAccelerationStructureGeometryInstancesDataKHR::pname:arrayOfPointers
491is ename:VK_FALSE.
492
493If
494slink:VkAccelerationStructureGeometryInstancesDataKHR::pname:arrayOfPointers
495is ename:VK_TRUE, the pointer for any given element of the array of instance
496pointers consists of 4 bits of
497ename:VkAccelerationStructureMotionInstanceTypeNV in the low 4 bits of the
498pointer identifying the type of structure at the pointer.
499The device address accessed is the value in the array with the low 4 bits
500set to zero.
501The structure at the pointer is one of
502slink:VkAccelerationStructureInstanceKHR,
503slink:VkAccelerationStructureMatrixMotionInstanceNV or
504slink:VkAccelerationStructureSRTMotionInstanceNV, depending on the type
505value encoded in the low 4 bits.
506
507A top level acceleration structure with either motion instances or vertex
508motion in its instances must: set
509ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV in pname:flags.
510endif::VK_NV_ray_tracing_motion_blur[]
511
512Members pname:srcAccelerationStructure and pname:dstAccelerationStructure
513may: be the same or different for an update operation (when pname:mode is
514ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR).
515If they are the same, the update happens in-place.
516Otherwise, the target acceleration structure is updated and the source is
517not modified.
518
519.Valid Usage
520****
521  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654]]
522    pname:type must: not be ename:VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
523  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788]]
524    Only one of pname:pGeometries or pname:ppGeometries can: be a valid
525    pointer, the other must: be `NULL`
526  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789]]
527    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the
528    pname:geometryType member of elements of either pname:pGeometries or
529    pname:ppGeometries must: be ename:VK_GEOMETRY_TYPE_INSTANCES_KHR
530  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790]]
531    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR,
532    pname:geometryCount must: be `1`
533  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791]]
534    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
535    the pname:geometryType member of elements of either pname:pGeometries or
536    pname:ppGeometries must: not be ename:VK_GEOMETRY_TYPE_INSTANCES_KHR
537  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792]]
538    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
539    then the pname:geometryType member of each geometry in either
540    pname:pGeometries or pname:ppGeometries must: be the same
541  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793]]
542    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
543    then pname:geometryCount must: be less than or equal to
544    slink:VkPhysicalDeviceAccelerationStructurePropertiesKHR::pname:maxGeometryCount
545  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03794]]
546    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
547    and the pname:geometryType member of either pname:pGeometries or
548    pname:ppGeometries is ename:VK_GEOMETRY_TYPE_AABBS_KHR, the total number
549    of AABBs in all geometries must: be less than or equal to
550    slink:VkPhysicalDeviceAccelerationStructurePropertiesKHR::pname:maxPrimitiveCount
551  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03795]]
552    If pname:type is ename:VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR
553    and the pname:geometryType member of either pname:pGeometries or
554    pname:ppGeometries is ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, the total
555    number of triangles in all geometries must: be less than or equal to
556    slink:VkPhysicalDeviceAccelerationStructurePropertiesKHR::pname:maxPrimitiveCount
557  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796]]
558    If pname:flags has the
559    ename:VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,
560    then it must: not have the
561    ename:VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set
562ifdef::VK_NV_ray_tracing_motion_blur[]
563  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-dstAccelerationStructure-04927]]
564    If pname:dstAccelerationStructure was created with
565    ename:VK_ACCELERATION_STRUCTURE_CREATE_MOTION_BIT_NV set in
566    slink:VkAccelerationStructureCreateInfoKHR::pname:flags,
567    ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV must: be set in
568    pname:flags
569  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-04928]]
570    If ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV is set in
571    pname:flags, pname:dstAccelerationStructure must: have been created with
572    ename:VK_ACCELERATION_STRUCTURE_CREATE_MOTION_BIT_NV set in
573    slink:VkAccelerationStructureCreateInfoKHR::pname:flags
574  * [[VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-04929]]
575    If ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV is set in
576    pname:flags, pname:type must: not be
577    ename:VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR
578endif::VK_NV_ray_tracing_motion_blur[]
579****
580include::{generated}/validity/structs/VkAccelerationStructureBuildGeometryInfoKHR.txt[]
581--
582
583[open,refpage='VkBuildAccelerationStructureModeKHR',desc='Enum specifying the type of build operation to perform',type='enums']
584--
585:refpage: VkBuildAccelerationStructureModeKHR
586
587The ename:VkBuildAccelerationStructureModeKHR enumeration is defined as:
588
589include::{generated}/api/enums/VkBuildAccelerationStructureModeKHR.txt[]
590
591  * ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR specifies that the
592    destination acceleration structure will be built using the specified
593    geometries.
594  * ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR specifies that the
595    destination acceleration structure will be built using data in a source
596    acceleration structure, updated by the specified geometries.
597--
598
599[open,refpage='VkDeviceOrHostAddressKHR',desc='Union specifying a device or host address',type='structs']
600--
601:refpage: VkDeviceOrHostAddressKHR
602
603The sname:VkDeviceOrHostAddressKHR union is defined as:
604
605include::{generated}/api/structs/VkDeviceOrHostAddressKHR.txt[]
606
607  * pname:deviceAddress is a buffer device address as returned by the
608    flink:vkGetBufferDeviceAddressKHR command.
609  * pname:hostAddress is a host memory address.
610
611include::{generated}/validity/structs/VkDeviceOrHostAddressKHR.txt[]
612--
613
614[open,refpage='VkDeviceOrHostAddressConstKHR',desc='Union specifying a const device or host address',type='structs']
615--
616:refpage: VkDeviceOrHostAddressConstKHR
617
618The sname:VkDeviceOrHostAddressConstKHR union is defined as:
619
620include::{generated}/api/structs/VkDeviceOrHostAddressConstKHR.txt[]
621
622  * pname:deviceAddress is a buffer device address as returned by the
623    flink:vkGetBufferDeviceAddressKHR command.
624  * pname:hostAddress is a const host memory address.
625
626include::{generated}/validity/structs/VkDeviceOrHostAddressConstKHR.txt[]
627--
628
629[open,refpage='VkAccelerationStructureGeometryKHR',desc='Structure specifying geometries to be built into an acceleration structure',type='structs']
630--
631:refpage: VkAccelerationStructureGeometryKHR
632
633The sname:VkAccelerationStructureGeometryKHR structure is defined as:
634
635include::{generated}/api/structs/VkAccelerationStructureGeometryKHR.txt[]
636
637  * pname:sType is the type of this structure.
638  * pname:pNext is `NULL` or a pointer to a structure extending this
639    structure.
640  * pname:geometryType describes which type of geometry this
641    sname:VkAccelerationStructureGeometryKHR refers to.
642  * pname:geometry is a slink:VkAccelerationStructureGeometryDataKHR union
643    describing the geometry data for the relevant geometry type.
644  * pname:flags is a bitmask of elink:VkGeometryFlagBitsKHR values
645    describing additional properties of how the geometry should be built.
646
647include::{generated}/validity/structs/VkAccelerationStructureGeometryKHR.txt[]
648--
649
650[open,refpage='VkAccelerationStructureGeometryDataKHR',desc='Union specifying acceleration structure geometry data',type='structs']
651--
652:refpage: VkAccelerationStructureGeometryDataKHR
653
654The sname:VkAccelerationStructureGeometryDataKHR union is defined as:
655
656include::{generated}/api/structs/VkAccelerationStructureGeometryDataKHR.txt[]
657
658  * pname:triangles is a
659    slink:VkAccelerationStructureGeometryTrianglesDataKHR structure.
660  * pname:aabbs is a slink:VkAccelerationStructureGeometryAabbsDataKHR
661    struture.
662  * pname:instances is a
663    slink:VkAccelerationStructureGeometryInstancesDataKHR structure.
664
665include::{generated}/validity/structs/VkAccelerationStructureGeometryDataKHR.txt[]
666--
667
668[open,refpage='VkAccelerationStructureGeometryTrianglesDataKHR',desc='Structure specifying a triangle geometry in a bottom-level acceleration structure',type='structs']
669--
670:refpage: VkAccelerationStructureGeometryTrianglesDataKHR
671
672The sname:VkAccelerationStructureGeometryTrianglesDataKHR structure is
673defined as:
674
675include::{generated}/api/structs/VkAccelerationStructureGeometryTrianglesDataKHR.txt[]
676
677  * pname:sType is the type of this structure.
678  * pname:pNext is `NULL` or a pointer to a structure extending this
679    structure.
680  * pname:vertexFormat is the elink:VkFormat of each vertex element.
681  * pname:vertexData is a device or host address to memory containing vertex
682    data for this geometry.
683  * pname:maxVertex is the highest index of a vertex that will be addressed
684    by a build command using this structure.
685  * pname:vertexStride is the stride in bytes between each vertex.
686  * pname:indexType is the elink:VkIndexType of each index element.
687  * pname:indexData is a device or host address to memory containing index
688    data for this geometry.
689  * pname:transformData is a device or host address to memory containing an
690    optional reference to a slink:VkTransformMatrixKHR structure describing
691    a transformation from the space in which the vertices in this geometry
692    are described to the space in which the acceleration structure is
693    defined.
694
695[NOTE]
696.Note
697====
698Unlike the stride for vertex buffers in
699slink:VkVertexInputBindingDescription for graphics pipelines which must not
700exceed pname:maxVertexInputBindingStride, pname:vertexStride for
701acceleration structure geometry is instead restricted to being a 32-bit
702value.
703====
704
705.Valid Usage
706****
707  * [[VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03735]]
708    pname:vertexStride must: be a multiple of the size in bytes of the
709    smallest component of pname:vertexFormat
710  * [[VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819]]
711    pname:vertexStride must: be less than or equal to [eq]#2^32^-1#
712  * [[VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-03797]]
713    pname:vertexFormat must: support the
714    ename:VK_FORMAT_FEATURE_ACCELERATION_STRUCTURE_VERTEX_BUFFER_BIT_KHR in
715    slink:VkFormatProperties::pname:bufferFeatures as returned by
716    flink:vkGetPhysicalDeviceFormatProperties2
717  * [[VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798]]
718    pname:indexType must: be ename:VK_INDEX_TYPE_UINT16,
719    ename:VK_INDEX_TYPE_UINT32, or ename:VK_INDEX_TYPE_NONE_KHR
720****
721
722include::{generated}/validity/structs/VkAccelerationStructureGeometryTrianglesDataKHR.txt[]
723--
724
725ifdef::VK_NV_ray_tracing_motion_blur[]
726[open,refpage='VkAccelerationStructureGeometryMotionTrianglesDataNV',desc='Structure specifying vertex motion in a bottom-level acceleration structure',type='structs']
727--
728:refpage: VkAccelerationStructureGeometryMotionTrianglesDataNV
729
730The sname:VkAccelerationStructureGeometryMotionTrianglesDataNV structure is
731defined as:
732
733include::{generated}/api/structs/VkAccelerationStructureGeometryMotionTrianglesDataNV.txt[]
734
735  * pname:sType is the type of this structure.
736  * pname:pNext is `NULL` or a pointer to a structure extending this
737    structure.
738  * pname:vertexData is a pointer to vertex data for this geometry at time
739    1.0
740
741If sname:VkAccelerationStructureGeometryMotionTrianglesDataNV is included in
742the pname:pNext chain of a
743slink:VkAccelerationStructureGeometryTrianglesDataKHR structure, the basic
744vertex positions are used for the position of the triangles in the geometry
745at time 0.0 and the pname:vertexData in
746sname:VkAccelerationStructureGeometryMotionTrianglesDataNV is used for the
747vertex positions at time 1.0, with positions linearly interpolated at
748intermediate times.
749
750Indexing for sname:VkAccelerationStructureGeometryMotionTrianglesDataNV
751pname:vertexData is equivalent to the basic vertex position data.
752
753include::{generated}/validity/structs/VkAccelerationStructureGeometryMotionTrianglesDataNV.txt[]
754--
755endif::VK_NV_ray_tracing_motion_blur[]
756endif::VK_KHR_acceleration_structure[]
757
758[open,refpage='VkTransformMatrixKHR',desc='Structure specifying a 3x4 affine transformation matrix',type='structs',alias='VkTransformMatrixNV']
759--
760:refpage: VkTransformMatrixKHR
761
762The sname:VkTransformMatrixKHR structure is defined as:
763
764include::{generated}/api/structs/VkTransformMatrixKHR.txt[]
765
766ifdef::VK_NV_ray_tracing[]
767or the equivalent
768
769include::{generated}/api/structs/VkTransformMatrixNV.txt[]
770endif::VK_NV_ray_tracing[]
771
772  * pname:matrix is a 3x4 row-major affine transformation matrix.
773
774include::{generated}/validity/structs/VkTransformMatrixKHR.txt[]
775
776.Valid Usage
777****
778  * [[VUID-VkTransformMatrixKHR-matrix-03799]]
779    The first three columns of pname:matrix must: define an invertible 3x3
780    matrix
781****
782--
783
784ifdef::VK_KHR_acceleration_structure[]
785[open,refpage='VkAccelerationStructureGeometryAabbsDataKHR',desc='Structure specifying axis-aligned bounding box geometry in a bottom-level acceleration structure',type='structs']
786--
787:refpage: VkAccelerationStructureGeometryAabbsDataKHR
788
789The sname:VkAccelerationStructureGeometryAabbsDataKHR structure is defined
790as:
791
792include::{generated}/api/structs/VkAccelerationStructureGeometryAabbsDataKHR.txt[]
793
794  * pname:sType is the type of this structure.
795  * pname:pNext is `NULL` or a pointer to a structure extending this
796    structure.
797  * pname:data is a device or host address to memory containing
798    slink:VkAabbPositionsKHR structures containing position data for each
799    axis-aligned bounding box in the geometry.
800  * pname:stride is the stride in bytes between each entry in pname:data.
801    The stride must: be a multiple of `8`.
802
803.Valid Usage
804****
805  * [[VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03545]]
806    pname:stride must: be a multiple of `8`
807  * [[VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820]]
808    pname:stride must: be less than or equal to [eq]#2^32^-1#
809****
810
811include::{generated}/validity/structs/VkAccelerationStructureGeometryAabbsDataKHR.txt[]
812--
813endif::VK_KHR_acceleration_structure[]
814
815[open,refpage='VkAabbPositionsKHR',desc='Structure specifying two opposing corners of an axis-aligned bounding box',type='structs',alias='VkAabbPositionsNV']
816--
817:refpage: VkAabbPositionsKHR
818
819The sname:VkAabbPositionsKHR structure is defined as:
820
821include::{generated}/api/structs/VkAabbPositionsKHR.txt[]
822
823ifdef::VK_NV_ray_tracing[]
824or the equivalent
825
826include::{generated}/api/structs/VkAabbPositionsNV.txt[]
827endif::VK_NV_ray_tracing[]
828
829
830  * pname:minX is the x position of one opposing corner of a bounding box.
831  * pname:minY is the y position of one opposing corner of a bounding box.
832  * pname:minZ is the z position of one opposing corner of a bounding box.
833  * pname:maxX is the x position of the other opposing corner of a bounding
834    box.
835  * pname:maxY is the y position of the other opposing corner of a bounding
836    box.
837  * pname:maxZ is the z position of the other opposing corner of a bounding
838    box.
839
840.Valid Usage
841****
842  * [[VUID-VkAabbPositionsKHR-minX-03546]]
843    pname:minX must: be less than or equal to pname:maxX
844  * [[VUID-VkAabbPositionsKHR-minY-03547]]
845    pname:minY must: be less than or equal to pname:maxY
846  * [[VUID-VkAabbPositionsKHR-minZ-03548]]
847    pname:minZ must: be less than or equal to pname:maxZ
848****
849
850include::{generated}/validity/structs/VkAabbPositionsKHR.txt[]
851--
852
853ifdef::VK_KHR_acceleration_structure[]
854[open,refpage='VkAccelerationStructureGeometryInstancesDataKHR',desc='Structure specifying a geometry consisting of instances of other acceleration structures',type='structs']
855--
856:refpage: VkAccelerationStructureGeometryInstancesDataKHR
857
858The sname:VkAccelerationStructureGeometryInstancesDataKHR structure is
859defined as:
860
861include::{generated}/api/structs/VkAccelerationStructureGeometryInstancesDataKHR.txt[]
862
863  * pname:sType is the type of this structure.
864  * pname:pNext is `NULL` or a pointer to a structure extending this
865    structure.
866  * pname:arrayOfPointers specifies whether pname:data is used as an array
867    of addresses or just an array.
868  * pname:data is either the address of an array of device or host addresses
869    referencing individual slink:VkAccelerationStructureInstanceKHR
870    structures
871ifdef::VK_NV_ray_tracing_motion_blur[]
872    or packed motion instance information as described in
873    <<acceleration-structure-motion-instances, motion instances>>
874endif::VK_NV_ray_tracing_motion_blur[]
875    if pname:arrayOfPointers is ename:VK_TRUE, or the address of an array of
876    slink:VkAccelerationStructureInstanceKHR
877ifdef::VK_NV_ray_tracing_motion_blur[]
878    or slink:VkAccelerationStructureMotionInstanceNV
879endif::VK_NV_ray_tracing_motion_blur[]
880    structures.
881    Addresses and slink:VkAccelerationStructureInstanceKHR structures are
882    tightly packed.
883ifdef::VK_NV_ray_tracing_motion_blur[]
884    slink:VkAccelerationStructureMotionInstanceNV structures have a stride
885    of 160 bytes.
886endif::VK_NV_ray_tracing_motion_blur[]
887
888include::{generated}/validity/structs/VkAccelerationStructureGeometryInstancesDataKHR.txt[]
889--
890endif::VK_KHR_acceleration_structure[]
891
892[open,refpage='VkAccelerationStructureInstanceKHR',desc='Structure specifying a single acceleration structure instance for building into an acceleration structure geometry',type='structs',alias='VkAccelerationStructureInstanceNV']
893--
894:refpage: VkAccelerationStructureInstanceKHR
895
896_Acceleration structure instances_ can: be built into top-level acceleration
897structures.
898Each acceleration structure instance is a separate entry in the top-level
899acceleration structure which includes all the geometry of a bottom-level
900acceleration structure at a transformed location.
901Multiple instances can: point to the same bottom level acceleration
902structure.
903
904An acceleration structure instance is defined by the structure:
905
906include::{generated}/api/structs/VkAccelerationStructureInstanceKHR.txt[]
907
908ifdef::VK_NV_ray_tracing[]
909or the equivalent
910
911include::{generated}/api/structs/VkAccelerationStructureInstanceNV.txt[]
912endif::VK_NV_ray_tracing[]
913
914  * pname:transform is a slink:VkTransformMatrixKHR structure describing a
915    transformation to be applied to the acceleration structure.
916  * pname:instanceCustomIndex is a 24-bit user-specified index value
917    accessible to ray shaders in the code:InstanceCustomIndexKHR built-in.
918  * pname:mask is an 8-bit visibility mask for the geometry.
919    The instance may: only be hit if `Cull Mask & instance.mask != 0`
920  * pname:instanceShaderBindingTableRecordOffset is a 24-bit offset used in
921    calculating the hit shader binding table index.
922  * pname:flags is an 8-bit mask of elink:VkGeometryInstanceFlagBitsKHR
923    values to apply to this instance.
924  * pname:accelerationStructureReference is either:
925  ** a device address containing the value obtained from
926ifdef::VK_KHR_acceleration_structure[flink:vkGetAccelerationStructureDeviceAddressKHR]
927ifdef::VK_KHR_acceleration_structure+VK_NV_ray_tracing[or]
928ifdef::VK_NV_ray_tracing[flink:vkGetAccelerationStructureHandleNV]
929     (used by device operations which reference acceleration structures) or,
930  ** a slink:VkAccelerationStructureKHR object (used by host operations
931     which reference acceleration structures).
932
933The C language specification does not define the ordering of bit-fields, but
934in practice, this struct produces the correct layout with existing
935compilers.
936The intended bit pattern is for the following:
937
938  * pname:instanceCustomIndex and pname:mask occupy the same memory as if a
939    single code:uint32_t was specified in their place
940  ** pname:instanceCustomIndex occupies the 24 least significant bits of
941     that memory
942  ** pname:mask occupies the 8 most significant bits of that memory
943  * pname:instanceShaderBindingTableRecordOffset and pname:flags occupy the
944    same memory as if a single code:uint32_t was specified in their place
945  ** pname:instanceShaderBindingTableRecordOffset occupies the 24 least
946     significant bits of that memory
947  ** pname:flags occupies the 8 most significant bits of that memory
948
949If a compiler produces code that diverges from that pattern, applications
950must: employ another method to set values according to the correct bit
951pattern.
952
953include::{generated}/validity/structs/VkAccelerationStructureInstanceKHR.txt[]
954--
955
956[open,refpage='VkGeometryInstanceFlagBitsKHR',desc='Instance flag bits',type='enums',alias='VkGeometryInstanceFlagBitsNV']
957--
958:refpage: VkGeometryInstanceFlagBitsKHR
959
960Possible values of pname:flags in the instance modifying the behavior of
961that instance are:
962
963include::{generated}/api/enums/VkGeometryInstanceFlagBitsKHR.txt[]
964
965ifdef::VK_NV_ray_tracing[]
966or the equivalent
967
968include::{generated}/api/enums/VkGeometryInstanceFlagBitsNV.txt[]
969endif::VK_NV_ray_tracing[]
970
971  * ename:VK_GEOMETRY_INSTANCE_TRIANGLE_FACING_CULL_DISABLE_BIT_KHR disables
972    face culling for this instance.
973  * ename:VK_GEOMETRY_INSTANCE_TRIANGLE_FLIP_FACING_BIT_KHR indicates that
974    the <<ray-traversal-culling-face, facing determination>> for geometry in
975    this instance is inverted.
976    Because the facing is determined in object space, an instance transform
977    does not change the winding, but a geometry transform does.
978  * ename:VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR causes this instance to
979    act as though ename:VK_GEOMETRY_OPAQUE_BIT_KHR were specified on all
980    geometries referenced by this instance.
981    This behavior can: be overridden by the SPIR-V code:NoOpaqueKHR ray
982    flag.
983  * ename:VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR causes this instance
984    to act as though ename:VK_GEOMETRY_OPAQUE_BIT_KHR were not specified on
985    all geometries referenced by this instance.
986    This behavior can: be overridden by the SPIR-V code:OpaqueKHR ray flag.
987
988ename:VK_GEOMETRY_INSTANCE_FORCE_NO_OPAQUE_BIT_KHR and
989ename:VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_KHR must: not be used in the
990same flag.
991--
992
993[open,refpage='VkGeometryInstanceFlagsKHR',desc='Bitmask of VkGeometryInstanceFlagBitsKHR',type='flags',alias='VkGeometryInstanceFlagsNV']
994--
995:refpage: VkGeometryInstanceFlagsKHR
996
997include::{generated}/api/flags/VkGeometryInstanceFlagsKHR.txt[]
998
999ifdef::VK_NV_ray_tracing[]
1000or the equivalent
1001
1002include::{generated}/api/flags/VkGeometryInstanceFlagsNV.txt[]
1003endif::VK_NV_ray_tracing[]
1004
1005tname:VkGeometryInstanceFlagsKHR is a bitmask type for setting a mask of
1006zero or more elink:VkGeometryInstanceFlagBitsKHR.
1007--
1008
1009ifdef::VK_NV_ray_tracing_motion_blur[]
1010[open,refpage='VkAccelerationStructureMotionInstanceNV',desc='Structure specifying a single acceleration structure motion instance for building into an acceleration structure geometry',type='structs']
1011--
1012:refpage: VkAccelerationStructureMotionInstanceNV
1013
1014_Acceleration structure motion instances_ can: be built into top-level
1015acceleration structures.
1016Each acceleration structure instance is a separate entry in the top-level
1017acceleration structure which includes all the geometry of a bottom-level
1018acceleration structure at a transformed location including a type of motion
1019and parameters to determine the motion of the instance over time.
1020
1021An acceleration structure motion instance is defined by the structure:
1022
1023include::{generated}/api/structs/VkAccelerationStructureMotionInstanceNV.txt[]
1024
1025  * pname:type is a elink:VkAccelerationStructureMotionInstanceTypeNV
1026    enumerant identifying which type of motion instance this is and which
1027    type of the union is valid.
1028  * pname:flags is currently unused, but is required to keep natural
1029    alignment of pname:data.
1030  * pname:data is a slink:VkAccelerationStructureMotionInstanceDataNV
1031    containing motion instance data for this instance.
1032
1033[NOTE]
1034.Note
1035====
1036If writing this other than with a standard C compiler, note that the final
1037structure should be 152 bytes in size.
1038====
1039
1040include::{generated}/validity/structs/VkAccelerationStructureMotionInstanceNV.txt[]
1041--
1042
1043[open,refpage='VkAccelerationStructureMotionInstanceDataNV',desc='Union specifying a acceleration structure motion instance data for building into an acceleration structure geometry',type='structs']
1044--
1045:refpage: VkAccelerationStructureMotionInstanceDataNV
1046
1047Acceleration structure motion instance is defined by the union:
1048
1049include::{generated}/api/structs/VkAccelerationStructureMotionInstanceDataNV.txt[]
1050
1051  * pname:staticInstance is a slink:VkAccelerationStructureInstanceKHR
1052    structure containing data for a static instance.
1053  * pname:matrixMotionInstance is a
1054    slink:VkAccelerationStructureMatrixMotionInstanceNV structure containing
1055    data for a matrix motion instance.
1056  * pname:srtMotionInstance is a
1057    slink:VkAccelerationStructureSRTMotionInstanceNV structure containing
1058    data for an SRT motion instance.
1059
1060include::{generated}/validity/structs/VkAccelerationStructureMotionInstanceDataNV.txt[]
1061--
1062
1063[open,refpage='VkAccelerationStructureMotionInstanceFlagsNV',desc='Reserved for future use',type='flags']
1064--
1065include::{generated}/api/flags/VkAccelerationStructureMotionInstanceFlagsNV.txt[]
1066
1067tname:VkAccelerationStructureMotionInstanceFlagsNV is a bitmask type for
1068setting a mask, but is currently reserved for future use.
1069--
1070
1071[open,refpage='VkAccelerationStructureMotionInstanceTypeNV',desc='Enum specifying a type of acceleration structure motion instance data for building into an acceleration structure geometry',type='enums']
1072--
1073:refpage: VkAccelerationStructureMotionInstanceTypeNV
1074
1075The ename:VkAccelerationStructureMotionInstanceTypeNV enumeration is defined
1076as:
1077
1078include::{generated}/api/enums/VkAccelerationStructureMotionInstanceTypeNV.txt[]
1079
1080  * ename:VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_STATIC_NV specifies
1081    that the instance is a static instance with no instance motion.
1082  * ename:VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_MATRIX_MOTION_NV
1083    specifies that the instance is a motion instance with motion specified
1084    by interpolation between two matrices.
1085  * ename:VK_ACCELERATION_STRUCTURE_MOTION_INSTANCE_TYPE_SRT_MOTION_NV
1086    specifies that the instance is a motion instance with motion specified
1087    by interpolation in the SRT decomposition.
1088--
1089
1090[open,refpage='VkAccelerationStructureMatrixMotionInstanceNV',desc='Structure specifying a single acceleration structure matrix motion instance for building into an acceleration structure geometry',type='structs']
1091--
1092:refpage: VkAccelerationStructureMatrixMotionInstanceNV
1093
1094An acceleration structure matrix motion instance is defined by the
1095structure:
1096
1097include::{generated}/api/structs/VkAccelerationStructureMatrixMotionInstanceNV.txt[]
1098
1099  * pname:transformT0 is a slink:VkTransformMatrixKHR structure describing a
1100    transformation to be applied to the acceleration structure at time 0.
1101  * pname:transformT1 is a slink:VkTransformMatrixKHR structure describing a
1102    transformation to be applied to the acceleration structure at time 1.
1103  * pname:instanceCustomIndex is a 24-bit user-specified index value
1104    accessible to ray shaders in the code:InstanceCustomIndexKHR built-in.
1105  * pname:mask is an 8-bit visibility mask for the geometry.
1106    The instance may: only be hit if `Cull Mask & instance.mask != 0`
1107  * pname:instanceShaderBindingTableRecordOffset is a 24-bit offset used in
1108    calculating the hit shader binding table index.
1109  * pname:flags is an 8-bit mask of elink:VkGeometryInstanceFlagBitsKHR
1110    values to apply to this instance.
1111  * pname:accelerationStructureReference is either:
1112  ** a device address containing the value obtained from
1113ifdef::VK_KHR_acceleration_structure[flink:vkGetAccelerationStructureDeviceAddressKHR]
1114ifdef::VK_KHR_acceleration_structure+VK_NV_ray_tracing[or]
1115ifdef::VK_NV_ray_tracing[flink:vkGetAccelerationStructureHandleNV]
1116     (used by device operations which reference acceleration structures) or,
1117  ** a slink:VkAccelerationStructureKHR object (used by host operations
1118     which reference acceleration structures).
1119
1120The C language specification does not define the ordering of bit-fields, but
1121in practice, this struct produces the correct layout with existing
1122compilers.
1123The intended bit pattern is for the following:
1124
1125  * pname:instanceCustomIndex and pname:mask occupy the same memory as if a
1126    single code:uint32_t was specified in their place
1127  ** pname:instanceCustomIndex occupies the 24 least significant bits of
1128     that memory
1129  ** pname:mask occupies the 8 most significant bits of that memory
1130  * pname:instanceShaderBindingTableRecordOffset and pname:flags occupy the
1131    same memory as if a single code:uint32_t was specified in their place
1132  ** pname:instanceShaderBindingTableRecordOffset occupies the 24 least
1133     significant bits of that memory
1134  ** pname:flags occupies the 8 most significant bits of that memory
1135
1136If a compiler produces code that diverges from that pattern, applications
1137must: employ another method to set values according to the correct bit
1138pattern.
1139
1140The transform for a matrix motion instance at a point in time is derived by
1141component-wise linear interpolation of the two transforms.
1142That is, for a code:time in [0,1] the resulting transform is
1143
1144  {empty}:: [eq]#pname:transformT0 {times} (1 - code:time) {plus}
1145            pname:transformT1 {times} code:time#
1146
1147include::{generated}/validity/structs/VkAccelerationStructureMatrixMotionInstanceNV.txt[]
1148--
1149
1150[open,refpage='VkAccelerationStructureSRTMotionInstanceNV',desc='Structure specifying a single acceleration structure SRT motion instance for building into an acceleration structure geometry',type='structs']
1151--
1152:refpage: VkAccelerationStructureSRTMotionInstanceNV
1153
1154An acceleration structure SRT motion instance is defined by the structure:
1155
1156include::{generated}/api/structs/VkAccelerationStructureSRTMotionInstanceNV.txt[]
1157
1158  * pname:transformT0 is a slink:VkSRTDataNV structure describing a
1159    transformation to be applied to the acceleration structure at time 0.
1160  * pname:transformT1 is a slink:VkSRTDataNV structure describing a
1161    transformation to be applied to the acceleration structure at time 1.
1162  * pname:instanceCustomIndex is a 24-bit user-specified index value
1163    accessible to ray shaders in the code:InstanceCustomIndexKHR built-in.
1164  * pname:mask is an 8-bit visibility mask for the geometry.
1165    The instance may: only be hit if `Cull Mask & instance.mask != 0`
1166  * pname:instanceShaderBindingTableRecordOffset is a 24-bit offset used in
1167    calculating the hit shader binding table index.
1168  * pname:flags is an 8-bit mask of elink:VkGeometryInstanceFlagBitsKHR
1169    values to apply to this instance.
1170  * pname:accelerationStructureReference is either:
1171  ** a device address containing the value obtained from
1172ifdef::VK_KHR_acceleration_structure[flink:vkGetAccelerationStructureDeviceAddressKHR]
1173ifdef::VK_KHR_acceleration_structure+VK_NV_ray_tracing[or]
1174ifdef::VK_NV_ray_tracing[flink:vkGetAccelerationStructureHandleNV]
1175     (used by device operations which reference acceleration structures) or,
1176  ** a slink:VkAccelerationStructureKHR object (used by host operations
1177     which reference acceleration structures).
1178
1179The C language specification does not define the ordering of bit-fields, but
1180in practice, this struct produces the correct layout with existing
1181compilers.
1182The intended bit pattern is for the following:
1183
1184  * pname:instanceCustomIndex and pname:mask occupy the same memory as if a
1185    single code:uint32_t was specified in their place
1186  ** pname:instanceCustomIndex occupies the 24 least significant bits of
1187     that memory
1188  ** pname:mask occupies the 8 most significant bits of that memory
1189  * pname:instanceShaderBindingTableRecordOffset and pname:flags occupy the
1190    same memory as if a single code:uint32_t was specified in their place
1191  ** pname:instanceShaderBindingTableRecordOffset occupies the 24 least
1192     significant bits of that memory
1193  ** pname:flags occupies the 8 most significant bits of that memory
1194
1195If a compiler produces code that diverges from that pattern, applications
1196must: employ another method to set values according to the correct bit
1197pattern.
1198
1199The transform for a SRT motion instance at a point in time is derived from
1200component-wise linear interpolation of the two SRT transforms.
1201That is, for a code:time in [0,1] the resulting transform is
1202
1203  {empty}:: [eq]#pname:transformT0 {times} (1 - code:time) {plus}
1204            pname:transformT1 {times} code:time#
1205
1206include::{generated}/validity/structs/VkAccelerationStructureSRTMotionInstanceNV.txt[]
1207--
1208
1209[open,refpage='VkSRTDataNV',desc='Structure specifying a transform in SRT decomposition',type='structs']
1210--
1211:refpage: VkSRTDataNV
1212
1213An acceleration structure SRT transform is defined by the structure:
1214
1215include::{generated}/api/structs/VkSRTDataNV.txt[]
1216
1217  * pname:sx is the x component of the scale of the transform
1218  * pname:a is one component of the shear for the transform
1219  * pname:b is one component of the shear for the transform
1220  * pname:pvx is the x component of the pivot point of the transform
1221  * pname:sy is the y component of the scale of the transform
1222  * pname:c is one component of the shear for the transform
1223  * pname:pvy is the y component of the pivot point of the transform
1224  * pname:sz is the z component of the scale of the transform
1225  * pname:pvz is the z component of the pivot point of the transform
1226  * pname:qx is the x component of the rotation quaternion
1227  * pname:qy is the y component of the rotation quaternion
1228  * pname:qz is the z component of the rotation quaternion
1229  * pname:qw is the w component of the rotation quaternion
1230  * pname:tx is the x component of the post-rotation translation
1231  * pname:ty is the y component of the post-rotation translation
1232  * pname:tz is the z component of the post-rotation translation
1233
1234This transform decomposition consists of three elements.
1235The first is a matrix S, consisting of a scale, shear, and translation,
1236usually used to define the pivot point of the following rotation.
1237This matrix is constructed from the parameters above by:
1238
1239[latexmath]
1240++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1241S =
1242\left(
1243    \begin{matrix}
1244        sx & a  & b  & pvx \\
1245        0  & sy & c  & pvy \\
1246        0  & 0  & sz & pvz
1247    \end{matrix}
1248\right)
1249++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1250
1251The rotation quaternion is defined as:
1252
1253  {empty}:: [eq]#code:R = [ pname:qx, pname:qy, pname:qz, pname:qw ]#
1254
1255This is a rotation around a conceptual normalized axis [eq]#[ ax, ay, az ]#
1256of amount code:theta such that:
1257
1258  {empty}:: [eq]#[ pname:qx, pname:qy, pname:qz ] = sin(code:theta/2)
1259            {times} [ code:ax, code:ay, code:az ]#
1260
1261and
1262
1263  {empty}:: [eq]#pname:qw = cos(code:theta/2)#
1264
1265Finally, the transform has a translation T constructed from the parameters
1266above by:
1267
1268[latexmath]
1269++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1270T =
1271\left(
1272    \begin{matrix}
1273        1 & 0 & 0 & tx \\
1274        0 & 1 & 0 & ty \\
1275        0 & 0 & 1 & tz
1276    \end{matrix}
1277\right)
1278++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1279
1280The effective derived transform is then given by
1281
1282  {empty}:: [eq]#code:T {times} code:R {times} code:S#
1283
1284include::{generated}/validity/structs/VkSRTDataNV.txt[]
1285--
1286endif::VK_NV_ray_tracing_motion_blur[]
1287
1288ifdef::VK_KHR_acceleration_structure[]
1289[open,refpage='VkAccelerationStructureBuildRangeInfoKHR',desc='Structure specifying build offsets and counts for acceleration structure builds',type='structs']
1290--
1291:refpage: VkAccelerationStructureBuildOffsetInfoKHR
1292
1293sname:VkAccelerationStructureBuildRangeInfoKHR is defined as:
1294
1295include::{generated}/api/structs/VkAccelerationStructureBuildRangeInfoKHR.txt[]
1296
1297  * pname:primitiveCount defines the number of primitives for a
1298    corresponding acceleration structure geometry.
1299  * pname:primitiveOffset defines an offset in bytes into the memory where
1300    primitive data is defined.
1301  * pname:firstVertex is the index of the first vertex to build from for
1302    triangle geometry.
1303  * pname:transformOffset defines an offset in bytes into the memory where a
1304    transform matrix is defined.
1305
1306The primitive count and primitive offset are interpreted differently
1307depending on the elink:VkGeometryTypeKHR used:
1308
1309  * For geometries of type ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR,
1310    pname:primitiveCount is the number of triangles to be built, where each
1311    triangle is treated as 3 vertices.
1312  ** If the geometry uses indices, [eq]#pname:primitiveCount {times} 3#
1313     indices are consumed from
1314     slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:indexData,
1315     starting at an offset of pname:primitiveOffset.
1316     The value of pname:firstVertex is added to the index values before
1317     fetching vertices.
1318  ** If the geometry does not use indices, [eq]#pname:primitiveCount {times}
1319     3# vertices are consumed from
1320     slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:vertexData,
1321     starting at an offset of [eq]#pname:primitiveOffset {plus}
1322     slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:vertexStride
1323     {times} pname:firstVertex#.
1324  ** If
1325     slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:transformData
1326     is not `NULL`, a single slink:VkTransformMatrixKHR structure is
1327     consumed from
1328     slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:transformData,
1329     at an offset of pname:transformOffset.
1330     This matrix describes a transformation from the space in which the
1331     vertices for all triangles in this geometry are described to the space
1332     in which the acceleration structure is defined.
1333  * For geometries of type ename:VK_GEOMETRY_TYPE_AABBS_KHR,
1334    pname:primitiveCount is the number of axis-aligned bounding boxes.
1335    pname:primitiveCount slink:VkAabbPositionsKHR structures are consumed
1336    from slink:VkAccelerationStructureGeometryAabbsDataKHR::pname:data,
1337    starting at an offset of pname:primitiveOffset.
1338  * For geometries of type ename:VK_GEOMETRY_TYPE_INSTANCES_KHR,
1339    pname:primitiveCount is the number of acceleration structures.
1340    pname:primitiveCount slink:VkAccelerationStructureInstanceKHR
1341ifdef::VK_NV_ray_tracing_motion_blur[]
1342    or slink:VkAccelerationStructureMotionInstanceNV
1343endif::VK_NV_ray_tracing_motion_blur[]
1344    structures are consumed from
1345    slink:VkAccelerationStructureGeometryInstancesDataKHR::pname:data,
1346    starting at an offset of pname:primitiveOffset.
1347
1348.Valid Usage
1349****
1350  * [[VUID-VkAccelerationStructureBuildRangeInfoKHR-primitiveOffset-03656]]
1351    For geometries of type ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if the
1352    geometry uses indices, the offset pname:primitiveOffset from
1353    slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:indexData
1354    must: be a multiple of the element size of
1355    slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:indexType
1356  * [[VUID-VkAccelerationStructureBuildRangeInfoKHR-primitiveOffset-03657]]
1357    For geometries of type ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if the
1358    geometry does not use indices, the offset pname:primitiveOffset from
1359    slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:vertexData
1360    must: be a multiple of the component size of
1361    slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:vertexFormat
1362  * [[VUID-VkAccelerationStructureBuildRangeInfoKHR-transformOffset-03658]]
1363    For geometries of type ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, the offset
1364    pname:transformOffset from
1365    slink:VkAccelerationStructureGeometryTrianglesDataKHR::pname:transformData
1366    must: be a multiple of 16
1367  * [[VUID-VkAccelerationStructureBuildRangeInfoKHR-primitiveOffset-03659]]
1368    For geometries of type ename:VK_GEOMETRY_TYPE_AABBS_KHR, the offset
1369    pname:primitiveOffset from
1370    slink:VkAccelerationStructureGeometryAabbsDataKHR::pname:data must: be a
1371    multiple of 8
1372  * [[VUID-VkAccelerationStructureBuildRangeInfoKHR-primitiveOffset-03660]]
1373    For geometries of type ename:VK_GEOMETRY_TYPE_INSTANCES_KHR, the offset
1374    pname:primitiveOffset from
1375    slink:VkAccelerationStructureGeometryInstancesDataKHR::pname:data must:
1376    be a multiple of 16
1377****
1378
1379include::{generated}/validity/structs/VkAccelerationStructureBuildRangeInfoKHR.txt[]
1380--
1381endif::VK_KHR_acceleration_structure[]
1382
1383
1384[[acceleration-structure-copying]]
1385=== Copying Acceleration Structures
1386
1387An additional command exists for copying acceleration structures without
1388updating their contents.
1389The acceleration structure object can: be compacted in order to improve
1390performance.
1391Before copying, an application must: query the size of the resulting
1392acceleration structure.
1393
1394[open,refpage='vkCmdWriteAccelerationStructuresPropertiesKHR',desc='Write acceleration structure result parameters to query results.',type='protos']
1395--
1396:refpage: vkCmdWriteAccelerationStructuresPropertiesKHR
1397
1398To query acceleration structure size parameters call:
1399
1400ifdef::VK_KHR_acceleration_structure[]
1401include::{generated}/api/protos/vkCmdWriteAccelerationStructuresPropertiesKHR.txt[]
1402endif::VK_KHR_acceleration_structure[]
1403
1404  * pname:commandBuffer is the command buffer into which the command will be
1405    recorded.
1406  * pname:accelerationStructureCount is the count of acceleration structures
1407    for which to query the property.
1408  * pname:pAccelerationStructures is a pointer to an array of existing
1409    previously built acceleration structures.
1410  * pname:queryType is a elink:VkQueryType value specifying the type of
1411    queries managed by the pool.
1412  * pname:queryPool is the query pool that will manage the results of the
1413    query.
1414  * pname:firstQuery is the first query index within the query pool that
1415    will contain the pname:accelerationStructureCount number of results.
1416
1417Accesses to any of the acceleration structures listed in
1418pname:pAccelerationStructures must: be <<synchronization-dependencies,
1419synchronized>> with the
1420ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1421<<synchronization-pipeline-stages, pipeline stage>> and an
1422<<synchronization-access-types, access type>> of
1423ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR.
1424
1425  * If pname:queryType is
1426    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR, then the
1427    value written out is the number of bytes required by a compacted
1428    acceleration structure.
1429  * If pname:queryType is
1430    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR, then
1431    the value written out is the number of bytes required by a serialized
1432    acceleration structure.
1433
1434.Valid Usage
1435****
1436  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryPool-02493]]
1437    pname:queryPool must: have been created with a pname:queryType matching
1438    pname:queryType
1439  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryPool-02494]]
1440    The queries identified by pname:queryPool and pname:firstQuery must: be
1441    _unavailable_
1442  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-buffer-03736]]
1443    The pname:buffer used to create each acceleration structure in
1444    pname:pAccelerationStructures must: be bound to device memory
1445  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-query-04880]]
1446    The sum of pname:query plus pname:accelerationStructureCount must: be
1447    less than or equal to the number of queries in pname:queryPool
1448include::{chapters}/commonvalidity/write_acceleration_structure_properties_common.txt[]
1449****
1450
1451include::{generated}/validity/protos/vkCmdWriteAccelerationStructuresPropertiesKHR.txt[]
1452--
1453
1454ifdef::VK_NV_ray_tracing[]
1455[open,refpage='vkCmdWriteAccelerationStructuresPropertiesNV',desc='Write acceleration structure result parameters to query results.',type='protos']
1456--
1457:refpage: vkCmdWriteAccelerationStructuresPropertiesNV
1458
1459To query acceleration structure size parameters call:
1460
1461include::{generated}/api/protos/vkCmdWriteAccelerationStructuresPropertiesNV.txt[]
1462
1463
1464  * pname:commandBuffer is the command buffer into which the command will be
1465    recorded.
1466  * pname:accelerationStructureCount is the count of acceleration structures
1467    for which to query the property.
1468  * pname:pAccelerationStructures is a pointer to an array of existing
1469    previously built acceleration structures.
1470  * pname:queryType is a elink:VkQueryType value specifying the type of
1471    queries managed by the pool.
1472  * pname:queryPool is the query pool that will manage the results of the
1473    query.
1474  * pname:firstQuery is the first query index within the query pool that
1475    will contain the pname:accelerationStructureCount number of results.
1476
1477Accesses to any of the acceleration structures listed in
1478pname:pAccelerationStructures must: be <<synchronization-dependencies,
1479synchronized>> with the
1480ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1481<<synchronization-pipeline-stages, pipeline stage>> and an
1482<<synchronization-access-types, access type>> of
1483ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR.
1484
1485.Valid Usage
1486****
1487  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryPool-03755]]
1488    pname:queryPool must: have been created with a pname:queryType matching
1489    pname:queryType
1490  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryPool-03756]]
1491    The queries identified by pname:queryPool and pname:firstQuery must: be
1492    _unavailable_
1493  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-accelerationStructure-03757]]
1494    pname:accelerationStructure must: be bound completely and contiguously
1495    to a single sname:VkDeviceMemory object via
1496    flink:vkBindAccelerationStructureMemoryNV
1497  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-pAccelerationStructures-04958]]
1498    All acceleration structures in pname:pAccelerationStructures must: have
1499    been built prior to the execution of this command
1500  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-pAccelerationStructures-06215]]
1501    All acceleration structures in pname:pAccelerationStructures must: have
1502    been built with
1503    ename:VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_KHR if
1504    pname:queryType is
1505    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV
1506  * [[VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-06216]]
1507    pname:queryType must: be
1508    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_NV
1509****
1510
1511include::{generated}/validity/protos/vkCmdWriteAccelerationStructuresPropertiesNV.txt[]
1512--
1513
1514[open,refpage='vkCmdCopyAccelerationStructureNV',desc='Copy an acceleration structure',type='protos']
1515--
1516:refpage: vkCmdCopyAccelerationStructureNV
1517
1518To copy an acceleration structure call:
1519
1520include::{generated}/api/protos/vkCmdCopyAccelerationStructureNV.txt[]
1521
1522  * pname:commandBuffer is the command buffer into which the command will be
1523    recorded.
1524  * pname:dst is the target acceleration structure for the copy.
1525  * pname:src is the source acceleration structure for the copy.
1526  * pname:mode is a elink:VkCopyAccelerationStructureModeKHR value
1527    specifying additional operations to perform during the copy.
1528
1529Accesses to pname:src and pname:dst must: be <<synchronization-dependencies,
1530synchronized>> with the
1531ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1532<<synchronization-pipeline-stages, pipeline stage>> and an
1533<<synchronization-access-types, access type>> of
1534ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR or
1535ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR as appropriate.
1536
1537.Valid Usage
1538****
1539include::{chapters}/commonvalidity/copy_acceleration_structure_common.txt[]
1540****
1541
1542include::{generated}/validity/protos/vkCmdCopyAccelerationStructureNV.txt[]
1543--
1544endif::VK_NV_ray_tracing[]
1545
1546ifdef::VK_KHR_acceleration_structure[]
1547[open,refpage='vkCmdCopyAccelerationStructureKHR',desc='Copy an acceleration structure',type='protos']
1548--
1549:refpage: vkCmdCopyAccelerationStructureKHR
1550
1551To copy an acceleration structure call:
1552
1553include::{generated}/api/protos/vkCmdCopyAccelerationStructureKHR.txt[]
1554
1555  * pname:commandBuffer is the command buffer into which the command will be
1556    recorded.
1557  * pname:pInfo is a pointer to a slink:VkCopyAccelerationStructureInfoKHR
1558    structure defining the copy operation.
1559
1560This command copies the pname:pInfo->src acceleration structure to the
1561pname:pInfo->dst acceleration structure in the manner specified by
1562pname:pInfo->mode.
1563
1564Accesses to pname:pInfo->src and pname:pInfo->dst must: be
1565<<synchronization-dependencies, synchronized>> with the
1566ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1567<<synchronization-pipeline-stages, pipeline stage>> and an
1568<<synchronization-access-types, access type>> of
1569ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR or
1570ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR as appropriate.
1571
1572.Valid Usage
1573****
1574  * [[VUID-vkCmdCopyAccelerationStructureKHR-buffer-03737]]
1575    The pname:buffer used to create pname:pInfo->src must: be bound to
1576    device memory
1577  * [[VUID-vkCmdCopyAccelerationStructureKHR-buffer-03738]]
1578    The pname:buffer used to create pname:pInfo->dst must: be bound to
1579    device memory
1580****
1581
1582include::{generated}/validity/protos/vkCmdCopyAccelerationStructureKHR.txt[]
1583--
1584
1585[open,refpage='VkCopyAccelerationStructureInfoKHR',desc='Parameters for copying an acceleration structure',type='structs']
1586--
1587:refpage: VkCopyAccelerationStructureInfoKHR
1588
1589The sname:VkCopyAccelerationStructureInfoKHR structure is defined as:
1590
1591include::{generated}/api/structs/VkCopyAccelerationStructureInfoKHR.txt[]
1592
1593  * pname:sType is the type of this structure.
1594  * pname:pNext is `NULL` or a pointer to a structure extending this
1595    structure.
1596  * pname:src is the source acceleration structure for the copy.
1597  * pname:dst is the target acceleration structure for the copy.
1598  * pname:mode is a elink:VkCopyAccelerationStructureModeKHR value
1599    specifying additional operations to perform during the copy.
1600
1601.Valid Usage
1602****
1603include::{chapters}/commonvalidity/copy_acceleration_structure_common.txt[]
1604****
1605
1606include::{generated}/validity/structs/VkCopyAccelerationStructureInfoKHR.txt[]
1607--
1608endif::VK_KHR_acceleration_structure[]
1609
1610[open,refpage='VkCopyAccelerationStructureModeKHR',desc='Acceleration structure copy mode',type='enums',alias='VkCopyAccelerationStructureModeNV']
1611--
1612:refpage: VkCopyAccelerationStructureModeKHR
1613
1614Possible values of pname:mode specifying additional operations to perform
1615during the copy, are:
1616
1617include::{generated}/api/enums/VkCopyAccelerationStructureModeKHR.txt[]
1618
1619ifdef::VK_NV_ray_tracing[]
1620or the equivalent
1621
1622include::{generated}/api/enums/VkCopyAccelerationStructureModeNV.txt[]
1623endif::VK_NV_ray_tracing[]
1624
1625  * ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR creates a direct
1626    copy of the acceleration structure specified in pname:src into the one
1627    specified by pname:dst.
1628    The pname:dst acceleration structure must: have been created with the
1629    same parameters as pname:src.
1630    If pname:src contains references to other acceleration structures,
1631    pname:dst will reference the same acceleration structures.
1632  * ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR creates a more
1633    compact version of an acceleration structure pname:src into pname:dst.
1634    The acceleration structure pname:dst must: have been created with a size
1635    at least as large as that returned by
1636    flink:vkCmdWriteAccelerationStructuresPropertiesKHR
1637ifdef::VK_KHR_acceleration_structure[]
1638    or flink:vkWriteAccelerationStructuresPropertiesKHR
1639endif::VK_KHR_acceleration_structure[]
1640    after the build of the acceleration structure specified by pname:src.
1641    If pname:src contains references to other acceleration structures,
1642    pname:dst will reference the same acceleration structures.
1643  * ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR serializes the
1644    acceleration structure to a semi-opaque format which can be reloaded on
1645    a compatible implementation.
1646  * ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR deserializes
1647    the semi-opaque serialization format in the buffer to the acceleration
1648    structure.
1649--
1650
1651[open,refpage='vkCmdCopyAccelerationStructureToMemoryKHR',desc='Copy an acceleration structure to device memory',type='protos']
1652--
1653:refpage: vkCmdCopyAccelerationStructureToMemoryKHR
1654
1655To copy an acceleration structure to device memory call:
1656
1657include::{generated}/api/protos/vkCmdCopyAccelerationStructureToMemoryKHR.txt[]
1658
1659  * pname:commandBuffer is the command buffer into which the command will be
1660    recorded.
1661  * pname:pInfo is an a pointer to a
1662    slink:VkCopyAccelerationStructureToMemoryInfoKHR structure defining the
1663    copy operation.
1664
1665Accesses to pname:pInfo->src must: be <<synchronization-dependencies,
1666synchronized>> with the
1667ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1668<<synchronization-pipeline-stages, pipeline stage>> and an
1669<<synchronization-access-types, access type>> of
1670ename:VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR.
1671Accesses to the buffer indicated by pname:pInfo->dst.deviceAddress must: be
1672synchronized with the
1673ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline stage
1674and an access type of ename:VK_ACCESS_TRANSFER_WRITE_BIT.
1675
1676This command produces the same results as
1677flink:vkCopyAccelerationStructureToMemoryKHR, but writes its result to a
1678device address, and is executed on the device rather than the host.
1679The output may: not necessarily be bit-for-bit identical, but it can be
1680equally used by either flink:vkCmdCopyMemoryToAccelerationStructureKHR or
1681flink:vkCopyMemoryToAccelerationStructureKHR.
1682
1683The defined header structure for the serialized data consists of:
1684
1685  * ename:VK_UUID_SIZE bytes of data matching
1686    sname:VkPhysicalDeviceIDProperties::pname:driverUUID
1687  * ename:VK_UUID_SIZE bytes of data identifying the compatibility for
1688    comparison using flink:vkGetDeviceAccelerationStructureCompatibilityKHR
1689  * A 64-bit integer of the total size matching the value queried using
1690    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR
1691  * A 64-bit integer of the deserialized size to be passed in to
1692    sname:VkAccelerationStructureCreateInfoKHR::pname:size
1693  * A 64-bit integer of the count of the number of acceleration structure
1694    handles following.
1695    This will be zero for a bottom-level acceleration structure.
1696    For top-level acceleration structures this number is
1697    implementation-dependent; the number of and ordering of the handles may
1698    not match the instance descriptions which were used to build the
1699    acceleration structure.
1700
1701The corresponding handles matching the values returned by
1702ifdef::VK_KHR_acceleration_structure[flink:vkGetAccelerationStructureDeviceAddressKHR]
1703ifdef::VK_KHR_acceleration_structure+VK_NV_ray_tracing[or]
1704ifdef::VK_NV_ray_tracing[flink:vkGetAccelerationStructureHandleNV]
1705are tightly packed in the buffer following the count.
1706The application is expected to store a mapping between those handles and the
1707original application-generated bottom-level acceleration structures to
1708provide when deserializing.
1709The serialized data is written to the buffer (or read from the buffer)
1710according to the host endianness.
1711
1712.Valid Usage
1713****
1714  * [[VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03739]]
1715    pname:pInfo->dst.deviceAddress must: be a valid device address for a
1716    buffer bound to device memory
1717  * [[VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740]]
1718    pname:pInfo->dst.deviceAddress must: be aligned to `256` bytes
1719  * [[VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03741]]
1720    If the buffer pointed to by pname:pInfo->dst.deviceAddress is non-sparse
1721    then it must: be bound completely and contiguously to a single
1722    slink:VkDeviceMemory object
1723  * [[VUID-vkCmdCopyAccelerationStructureToMemoryKHR-None-03559]]
1724    The pname:buffer used to create pname:pInfo->src must: be bound to
1725    device memory
1726****
1727
1728include::{generated}/validity/protos/vkCmdCopyAccelerationStructureToMemoryKHR.txt[]
1729--
1730
1731[open,refpage='VkCopyAccelerationStructureToMemoryInfoKHR',desc='Parameters for serializing an acceleration structure',type='structs']
1732--
1733:refpage: VkCopyAccelerationStructureToMemoryInfoKHR
1734
1735include::{generated}/api/structs/VkCopyAccelerationStructureToMemoryInfoKHR.txt[]
1736
1737  * pname:sType is the type of this structure.
1738  * pname:pNext is `NULL` or a pointer to a structure extending this
1739    structure.
1740  * pname:src is the source acceleration structure for the copy
1741  * pname:dst is the device or host address to memory which is the target
1742    for the copy
1743  * pname:mode is a elink:VkCopyAccelerationStructureModeKHR value
1744    specifying additional operations to perform during the copy.
1745
1746.Valid Usage
1747****
1748  * [[VUID-VkCopyAccelerationStructureToMemoryInfoKHR-src-04959]]
1749    The source acceleration structure pname:src must: have been constructed
1750    prior to the execution of this command
1751  * [[VUID-VkCopyAccelerationStructureToMemoryInfoKHR-dst-03561]]
1752    The memory pointed to by pname:dst must: be at least as large as the
1753    serialization size of pname:src, as reported by
1754    flink:vkWriteAccelerationStructuresPropertiesKHR or
1755    flink:vkCmdWriteAccelerationStructuresPropertiesKHR with a query type of
1756    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR
1757  * [[VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412]]
1758    pname:mode must: be
1759    ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR
1760****
1761
1762include::{generated}/validity/structs/VkCopyAccelerationStructureToMemoryInfoKHR.txt[]
1763--
1764
1765[open,refpage='vkCmdCopyMemoryToAccelerationStructureKHR',desc='Copy device memory to an acceleration structure',type='protos']
1766--
1767:refpage: vkCmdCopyMemoryToAccelerationStructureKHR
1768
1769To copy device memory to an acceleration structure call:
1770
1771include::{generated}/api/protos/vkCmdCopyMemoryToAccelerationStructureKHR.txt[]
1772
1773  * pname:commandBuffer is the command buffer into which the command will be
1774    recorded.
1775  * pname:pInfo is a pointer to a
1776    slink:VkCopyMemoryToAccelerationStructureInfoKHR structure defining the
1777    copy operation.
1778
1779Accesses to pname:pInfo->dst must: be <<synchronization-dependencies,
1780synchronized>> with the
1781ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR
1782<<synchronization-pipeline-stages, pipeline stage>> and an
1783<<synchronization-access-types, access type>> of
1784ename:VK_ACCESS_ACCELERATION_STRUCTURE_WRITE_BIT_KHR.
1785Accesses to the buffer indicated by pname:pInfo->src.deviceAddress must: be
1786synchronized with the
1787ename:VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR pipeline stage
1788and an access type of ename:VK_ACCESS_TRANSFER_READ_BIT.
1789
1790This command can accept acceleration structures produced by either
1791flink:vkCmdCopyAccelerationStructureToMemoryKHR or
1792flink:vkCopyAccelerationStructureToMemoryKHR.
1793
1794The structure provided as input to deserialize is as described in
1795flink:vkCmdCopyAccelerationStructureToMemoryKHR, with any acceleration
1796structure handles filled in with the newly-queried handles to bottom level
1797acceleration structures created before deserialization.
1798These do not need to be built at deserialize time, but must: be created.
1799
1800.Valid Usage
1801****
1802  * [[VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03742]]
1803    pname:pInfo->src.deviceAddress must: be a valid device address for a
1804    buffer bound to device memory
1805  * [[VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743]]
1806    pname:pInfo->src.deviceAddress must: be aligned to `256` bytes
1807  * [[VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03744]]
1808    If the buffer pointed to by pname:pInfo->src.deviceAddress is non-sparse
1809    then it must: be bound completely and contiguously to a single
1810    slink:VkDeviceMemory object
1811  * [[VUID-vkCmdCopyMemoryToAccelerationStructureKHR-buffer-03745]]
1812    The pname:buffer used to create pname:pInfo->dst must: be bound to
1813    device memory
1814****
1815
1816include::{generated}/validity/protos/vkCmdCopyMemoryToAccelerationStructureKHR.txt[]
1817--
1818
1819[open,refpage='VkCopyMemoryToAccelerationStructureInfoKHR',desc='Parameters for deserializing an acceleration structure',type='structs']
1820--
1821:refpage: VkCopyMemoryToAccelerationStructureInfoKHR
1822
1823The sname:VkCopyMemoryToAccelerationStructureInfoKHR structure is defined
1824as:
1825
1826include::{generated}/api/structs/VkCopyMemoryToAccelerationStructureInfoKHR.txt[]
1827
1828  * pname:sType is the type of this structure.
1829  * pname:pNext is `NULL` or a pointer to a structure extending this
1830    structure.
1831  * pname:src is the device or host address to memory containing the source
1832    data for the copy.
1833  * pname:dst is the target acceleration structure for the copy.
1834  * pname:mode is a elink:VkCopyAccelerationStructureModeKHR value
1835    specifying additional operations to perform during the copy.
1836
1837.Valid Usage
1838****
1839  * [[VUID-VkCopyMemoryToAccelerationStructureInfoKHR-src-04960]]
1840    The source memory pointed to by pname:src must: contain data previously
1841    serialized using flink:vkCmdCopyAccelerationStructureToMemoryKHR,
1842    potentially modified to relocate acceleration structure references as
1843    described in that command
1844  * [[VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413]]
1845    pname:mode must: be
1846    ename:VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR
1847  * [[VUID-VkCopyMemoryToAccelerationStructureInfoKHR-pInfo-03414]]
1848    The data in pname:src must: have a format compatible with the
1849    destination physical device as returned by
1850    flink:vkGetDeviceAccelerationStructureCompatibilityKHR
1851  * [[VUID-VkCopyMemoryToAccelerationStructureInfoKHR-dst-03746]]
1852    pname:dst must: have been created with a pname:size greater than or
1853    equal to that used to serialize the data in pname:src
1854****
1855
1856include::{generated}/validity/structs/VkCopyMemoryToAccelerationStructureInfoKHR.txt[]
1857--
1858
1859[open,refpage='vkGetDeviceAccelerationStructureCompatibilityKHR',desc='Check if a serialized acceleration structure is compatible with the current device',type='protos']
1860--
1861:refpage: vkGetDeviceAccelerationStructureCompatibilityKHR
1862
1863To check if a serialized acceleration structure is compatible with the
1864current device call:
1865
1866include::{generated}/api/protos/vkGetDeviceAccelerationStructureCompatibilityKHR.txt[]
1867
1868  * pname:device is the device to check the version against.
1869  * pname:pVersionInfo is a pointer to a
1870    slink:VkAccelerationStructureVersionInfoKHR structure specifying version
1871    information to check against the device.
1872  * pname:pCompatibility is a pointer to a
1873    elink:VkAccelerationStructureCompatibilityKHR value in which
1874    compatibility information is returned.
1875
1876.Valid Usage
1877****
1878// TBD
1879  * [[VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661]]
1880    The <<features-rayTracingPipeline, pname:rayTracingPipeline>> or
1881    <<features-rayQuery, pname:rayQuery>> feature must: be enabled
1882****
1883
1884include::{generated}/validity/protos/vkGetDeviceAccelerationStructureCompatibilityKHR.txt[]
1885--
1886
1887[open,refpage='VkAccelerationStructureVersionInfoKHR',desc='Acceleration structure version information',type='structs']
1888--
1889:refpage: VkAccelerationStructureVersionKHR
1890
1891The sname:VkAccelerationStructureVersionInfoKHR structure is defined as:
1892
1893include::{generated}/api/structs/VkAccelerationStructureVersionInfoKHR.txt[]
1894
1895  * pname:sType is the type of this structure.
1896  * pname:pNext is `NULL` or a pointer to a structure extending this
1897    structure.
1898  * pname:pVersionData is a pointer to the version header of an acceleration
1899    structure as defined in flink:vkCmdCopyAccelerationStructureToMemoryKHR
1900
1901[NOTE]
1902.Note
1903====
1904pname:pVersionData is a _pointer_ to an array of 2*ename:VK_UUID_SIZE
1905code:uint8_t values instead of two ename:VK_UUID_SIZE arrays as the expected
1906use case for this member is to be pointed at the header of an previously
1907serialized acceleration structure (via
1908flink:vkCmdCopyAccelerationStructureToMemoryKHR or
1909flink:vkCopyAccelerationStructureToMemoryKHR) that is loaded in memory.
1910Using arrays would necessitate extra memory copies of the UUIDs.
1911====
1912
1913include::{generated}/validity/structs/VkAccelerationStructureVersionInfoKHR.txt[]
1914--
1915
1916[open,refpage='VkAccelerationStructureCompatibilityKHR',desc='Acceleration structure compatibility',type='enums']
1917--
1918Possible values of pname:pCompatibility returned by
1919flink:vkGetDeviceAccelerationStructureCompatibilityKHR are:
1920
1921include::{generated}/api/enums/VkAccelerationStructureCompatibilityKHR.txt[]
1922
1923  * ename:VK_ACCELERATION_STRUCTURE_COMPATIBILITY_COMPATIBLE_KHR if the
1924    pname:pVersionData version acceleration structure is compatible with
1925    pname:device.
1926  * ename:VK_ACCELERATION_STRUCTURE_COMPATIBILITY_INCOMPATIBLE_KHR if the
1927    pname:pVersionData version acceleration structure is not compatible with
1928    pname:device.
1929--
1930
1931
1932[[host-acceleration-structure]]
1933== Host Acceleration Structure Operations
1934
1935Implementations are also required to provide host implementations of the
1936acceleration structure operations if the
1937<<features-accelerationStructureHostCommands,pname:accelerationStructureHostCommands>>
1938feature is enabled:
1939
1940  * flink:vkBuildAccelerationStructuresKHR corresponding to
1941    flink:vkCmdBuildAccelerationStructuresKHR
1942  * flink:vkCopyAccelerationStructureKHR corresponding to
1943    flink:vkCmdCopyAccelerationStructureKHR
1944  * flink:vkCopyAccelerationStructureToMemoryKHR corresponding to
1945    flink:vkCmdCopyAccelerationStructureToMemoryKHR
1946  * flink:vkCopyMemoryToAccelerationStructureKHR corresponding to
1947    flink:vkCmdCopyMemoryToAccelerationStructureKHR
1948  * flink:vkWriteAccelerationStructuresPropertiesKHR corresponding to
1949    flink:vkCmdWriteAccelerationStructuresPropertiesKHR
1950
1951These commands are functionally equivalent to their device counterparts,
1952except that they are executed on the host timeline, rather than being
1953enqueued into command buffers.
1954
1955All acceleration structures used by the host commands must: be bound to
1956host-visible memory, and all input data for acceleration structure builds
1957must: be referenced using host addresses instead of device addresses.
1958Applications are not required to map acceleration structure memory when
1959using the host commands.
1960
1961
1962[NOTE]
1963.Note
1964====
1965The flink:vkBuildAccelerationStructuresKHR and
1966flink:vkCmdBuildAccelerationStructuresKHR may: use different algorithms, and
1967thus are not required to produce identical structures.
1968The structures produced by these two commands may: exhibit different memory
1969footprints or traversal performance, but should strive to be similar where
1970possible.
1971
1972Apart from these details, the host and device operations are interchangable.
1973For example, an application can: use flink:vkBuildAccelerationStructuresKHR
1974to build a structure, compact it on the device using
1975flink:vkCmdCopyAccelerationStructureKHR, and serialize the result using
1976flink:vkCopyAccelerationStructureToMemoryKHR.
1977====
1978
1979[NOTE]
1980.Note
1981====
1982For efficient execution, acceleration structures manipulated using these
1983commands should always be bound to host cached memory, as the implementation
1984may need to repeatedly read and write this memory during the execution of
1985the command.
1986====
1987
1988[open,refpage='vkBuildAccelerationStructuresKHR',desc='Build an acceleration structure on the host',type='protos']
1989--
1990:refpage: vkBuildAccelerationStructuresKHR
1991:maxinstancecheck: pname:ppBuildRangeInfos[i][j].pname:primitiveCount
1992
1993To build acceleration structures on the host, call:
1994
1995include::{generated}/api/protos/vkBuildAccelerationStructuresKHR.txt[]
1996
1997  * pname:device is the sname:VkDevice for which the acceleration structures
1998    are being built.
1999  * pname:deferredOperation is an optional slink:VkDeferredOperationKHR to
2000    <<deferred-host-operations-requesting, request deferral>> for this
2001    command.
2002  * pname:infoCount is the number of acceleration structures to build.
2003    It specifies the number of the pname:pInfos structures and
2004    pname:ppBuildRangeInfos pointers that must: be provided.
2005  * pname:pInfos is a pointer to an array of pname:infoCount
2006    slink:VkAccelerationStructureBuildGeometryInfoKHR structures defining
2007    the geometry used to build each acceleration structure.
2008  * pname:ppBuildRangeInfos is a pointer to an array of pname:infoCount
2009    pointers to arrays of slink:VkAccelerationStructureBuildRangeInfoKHR
2010    structures.
2011    Each pname:ppBuildRangeInfos[i] is a pointer to an array of
2012    pname:pInfos[i].pname:geometryCount
2013    slink:VkAccelerationStructureBuildRangeInfoKHR structures defining
2014    dynamic offsets to the addresses where geometry data is stored, as
2015    defined by pname:pInfos[i].
2016
2017This command fulfills the same task as
2018flink:vkCmdBuildAccelerationStructuresKHR but is executed by the host.
2019
2020The fname:vkBuildAccelerationStructuresKHR command provides the ability to
2021initiate multiple acceleration structures builds, however there is no
2022ordering or synchronization implied between any of the individual
2023acceleration structure builds.
2024
2025[NOTE]
2026.Note
2027====
2028This means that an application cannot: build a top-level acceleration
2029structure in the same flink:vkBuildAccelerationStructuresKHR call as the
2030associated bottom-level or instance acceleration structures are being built.
2031There also cannot: be any memory aliasing between any acceleration structure
2032memories or scratch memories being used by any of the builds.
2033====
2034
2035.Valid Usage
2036****
2037include::{chapters}/commonvalidity/build_acceleration_structure_common.txt[]
2038include::{chapters}/commonvalidity/build_acceleration_structure_nonindirect_common.txt[]
2039include::{chapters}/commonvalidity/deferred_operations_common.txt[]
2040  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03722]]
2041    For each element of pname:pInfos, the pname:buffer used to create its
2042    pname:dstAccelerationStructure member must: be bound to host-visible
2043    device memory
2044  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03723]]
2045    For each element of pname:pInfos, if its pname:mode member is
2046    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR the pname:buffer
2047    used to create its pname:srcAccelerationStructure member must: be bound
2048    to host-visible device memory
2049  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03724]]
2050    For each element of pname:pInfos, the pname:buffer used to create each
2051    acceleration structure referenced by the pname:geometry.instances.data
2052    member of any element of pname:pGeometries or pname:ppGeometries with a
2053    pname:geometryType of ename:VK_GEOMETRY_TYPE_INSTANCES_KHR must: be
2054    bound to host-visible device memory
2055  * [[VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581]]
2056    The <<features-accelerationStructureHostCommands,
2057    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureHostCommands>>
2058    feature must: be enabled
2059  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03725]]
2060    If pname:pInfos[i].pname:mode is
2061    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR, all addresses
2062    between pname:pInfos[i].pname:scratchData.hostAddress and
2063    pname:pInfos[i].pname:scratchData.hostAddress + N - 1 must: be valid
2064    host memory, where N is given by the pname:buildScratchSize member of
2065    the slink:VkAccelerationStructureBuildSizesInfoKHR structure returned
2066    from a call to flink:vkGetAccelerationStructureBuildSizesKHR with an
2067    identical slink:VkAccelerationStructureBuildGeometryInfoKHR structure
2068    and primitive count
2069  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03726]]
2070    If pname:pInfos[i].pname:mode is
2071    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, all addresses
2072    between pname:pInfos[i].pname:scratchData.hostAddress and
2073    pname:pInfos[i].pname:scratchData.hostAddress + N - 1 must: be valid
2074    host memory, where N is given by the pname:updateScratchSize member of
2075    the slink:VkAccelerationStructureBuildSizesInfoKHR structure returned
2076    from a call to flink:vkGetAccelerationStructureBuildSizesKHR with an
2077    identical slink:VkAccelerationStructureBuildGeometryInfoKHR structure
2078    and primitive count
2079  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03771]]
2080    For any element of pname:pInfos[i].pname:pGeometries or
2081    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2082    ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR,
2083    pname:geometry.triangles.vertexData.hostAddress must: be a valid host
2084    address
2085  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03772]]
2086    For any element of pname:pInfos[i].pname:pGeometries or
2087    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2088    ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if
2089    pname:geometry.triangles.indexType is not ename:VK_INDEX_TYPE_NONE_KHR,
2090    pname:geometry.triangles.indexData.hostAddress must: be a valid host
2091    address
2092  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03773]]
2093    For any element of pname:pInfos[i].pname:pGeometries or
2094    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2095    ename:VK_GEOMETRY_TYPE_TRIANGLES_KHR, if
2096    pname:geometry.triangles.transformData.hostAddress is not `0`, it must:
2097    be a valid host address
2098  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03774]]
2099    For any element of pname:pInfos[i].pname:pGeometries or
2100    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2101    ename:VK_GEOMETRY_TYPE_AABBS_KHR, pname:geometry.aabbs.data.hostAddress
2102    must: be a valid host address
2103ifdef::VK_KHR_device_group,VK_VERSION_1_1[]
2104  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03775]]
2105    For each element of pname:pInfos, the pname:buffer used to create its
2106    pname:dstAccelerationStructure member must: be bound to memory that was
2107    not allocated with multiple instances
2108  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03776]]
2109    For each element of pname:pInfos, if its pname:mode member is
2110    ename:VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR the pname:buffer
2111    used to create its pname:srcAccelerationStructure member must: be bound
2112    to memory that was not allocated with multiple instances
2113  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03777]]
2114    For each element of pname:pInfos, the pname:buffer used to create each
2115    acceleration structure referenced by the pname:geometry.instances.data
2116    member of any element of pname:pGeometries or pname:ppGeometries with a
2117    pname:geometryType of ename:VK_GEOMETRY_TYPE_INSTANCES_KHR must: be
2118    bound to memory that was not allocated with multiple instances
2119endif::VK_KHR_device_group,VK_VERSION_1_1[]
2120  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03778]]
2121    For any element of pname:pInfos[i].pname:pGeometries or
2122    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2123    ename:VK_GEOMETRY_TYPE_INSTANCES_KHR,
2124    pname:geometry.instances.data.hostAddress must: be a valid host address
2125  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-03779]]
2126    For any element of pname:pInfos[i].pname:pGeometries or
2127    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2128    ename:VK_GEOMETRY_TYPE_INSTANCES_KHR, each
2129    slink:VkAccelerationStructureInstanceKHR::pname:accelerationStructureReference
2130    value in pname:geometry.instances.data.hostAddress must be a valid
2131    slink:VkAccelerationStructureKHR object
2132ifdef::VK_NV_ray_tracing_motion_blur[]
2133  * [[VUID-vkBuildAccelerationStructuresKHR-pInfos-04930]]
2134    For any element of pname:pInfos[i].pname:pGeometries or
2135    pname:pInfos[i].pname:ppGeometries with a pname:geometryType of
2136    ename:VK_GEOMETRY_TYPE_INSTANCES_KHR with
2137    ename:VK_BUILD_ACCELERATION_STRUCTURE_MOTION_BIT_NV set, each
2138    pname:accelerationStructureReference in any structure in
2139    slink:VkAccelerationStructureMotionInstanceNV value in
2140    pname:geometry.instances.data.hostAddress must be a valid
2141    slink:VkAccelerationStructureKHR object
2142endif::VK_NV_ray_tracing_motion_blur[]
2143****
2144
2145include::{generated}/validity/protos/vkBuildAccelerationStructuresKHR.txt[]
2146--
2147
2148[open,refpage='vkCopyAccelerationStructureKHR',desc='Copy an acceleration structure on the host',type='protos']
2149--
2150:refpage: vkCopyAccelerationStructureKHR
2151
2152To copy or compact an acceleration structure on the host, call:
2153
2154include::{generated}/api/protos/vkCopyAccelerationStructureKHR.txt[]
2155
2156  * pname:device is the device which owns the acceleration structures.
2157  * pname:deferredOperation is an optional slink:VkDeferredOperationKHR to
2158    <<deferred-host-operations-requesting, request deferral>> for this
2159    command.
2160  * pname:pInfo is a pointer to a slink:VkCopyAccelerationStructureInfoKHR
2161    structure defining the copy operation.
2162
2163This command fulfills the same task as
2164flink:vkCmdCopyAccelerationStructureKHR but is executed by the host.
2165
2166.Valid Usage
2167****
2168include::{chapters}/commonvalidity/deferred_operations_common.txt[]
2169  * [[VUID-vkCopyAccelerationStructureKHR-buffer-03727]]
2170    The pname:buffer used to create pname:pInfo->src must: be bound to
2171    host-visible device memory
2172  * [[VUID-vkCopyAccelerationStructureKHR-buffer-03728]]
2173    The pname:buffer used to create pname:pInfo->dst must: be bound to
2174    host-visible device memory
2175  * [[VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582]]
2176    The <<features-accelerationStructureHostCommands,
2177    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureHostCommands>>
2178    feature must: be enabled
2179ifdef::VK_KHR_device_group,VK_VERSION_1_1[]
2180  * [[VUID-vkCopyAccelerationStructureKHR-buffer-03780]]
2181    The pname:buffer used to create pname:pInfo->src must: be bound to
2182    memory that was not allocated with multiple instances
2183  * [[VUID-vkCopyAccelerationStructureKHR-buffer-03781]]
2184    The pname:buffer used to create pname:pInfo->dst must: be bound to
2185    memory that was not allocated with multiple instances
2186endif::VK_KHR_device_group,VK_VERSION_1_1[]
2187****
2188
2189include::{generated}/validity/protos/vkCopyAccelerationStructureKHR.txt[]
2190--
2191
2192[open,refpage='vkCopyMemoryToAccelerationStructureKHR',desc='Deserialize an acceleration structure on the host',type='protos']
2193--
2194:refpage: vkCopyMemoryToAccelerationStructureKHR
2195
2196To copy host accessible memory to an acceleration structure, call:
2197
2198include::{generated}/api/protos/vkCopyMemoryToAccelerationStructureKHR.txt[]
2199
2200  * pname:device is the device which owns pname:pInfo->dst.
2201  * pname:deferredOperation is an optional slink:VkDeferredOperationKHR to
2202    <<deferred-host-operations-requesting, request deferral>> for this
2203    command.
2204  * pname:pInfo is a pointer to a
2205    slink:VkCopyMemoryToAccelerationStructureInfoKHR structure defining the
2206    copy operation.
2207
2208This command fulfills the same task as
2209flink:vkCmdCopyMemoryToAccelerationStructureKHR but is executed by the host.
2210
2211This command can accept acceleration structures produced by either
2212flink:vkCmdCopyAccelerationStructureToMemoryKHR or
2213flink:vkCopyAccelerationStructureToMemoryKHR.
2214
2215.Valid Usage
2216****
2217include::{chapters}/commonvalidity/deferred_operations_common.txt[]
2218  * [[VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729]]
2219    pname:pInfo->src.hostAddress must: be a valid host pointer
2220  * [[VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03750]]
2221    pname:pInfo->src.hostAddress must: be aligned to 16 bytes
2222  * [[VUID-vkCopyMemoryToAccelerationStructureKHR-buffer-03730]]
2223    The pname:buffer used to create pname:pInfo->dst must: be bound to
2224    host-visible device memory
2225  * [[VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583]]
2226    The <<features-accelerationStructureHostCommands,
2227    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureHostCommands>>
2228    feature must: be enabled
2229ifdef::VK_KHR_device_group,VK_VERSION_1_1[]
2230  * [[VUID-vkCopyMemoryToAccelerationStructureKHR-buffer-03782]]
2231    The pname:buffer used to create pname:pInfo->dst must: be bound to
2232    memory that was not allocated with multiple instances
2233endif::VK_KHR_device_group,VK_VERSION_1_1[]
2234****
2235
2236include::{generated}/validity/protos/vkCopyMemoryToAccelerationStructureKHR.txt[]
2237--
2238
2239[open,refpage='vkCopyAccelerationStructureToMemoryKHR',desc='Serialize an acceleration structure on the host',type='protos']
2240--
2241:refpage: vkCopyAccelerationStructureToMemoryKHR
2242
2243To copy an acceleration structure to host accessible memory, call:
2244
2245include::{generated}/api/protos/vkCopyAccelerationStructureToMemoryKHR.txt[]
2246
2247  * pname:device is the device which owns pname:pInfo->src.
2248  * pname:deferredOperation is an optional slink:VkDeferredOperationKHR to
2249    <<deferred-host-operations-requesting, request deferral>> for this
2250    command.
2251  * pname:pInfo is a pointer to a
2252    slink:VkCopyAccelerationStructureToMemoryInfoKHR structure defining the
2253    copy operation.
2254
2255This command fulfills the same task as
2256flink:vkCmdCopyAccelerationStructureToMemoryKHR but is executed by the host.
2257
2258This command produces the same results as
2259flink:vkCmdCopyAccelerationStructureToMemoryKHR, but writes its result
2260directly to a host pointer, and is executed on the host rather than the
2261device.
2262The output may: not necessarily be bit-for-bit identical, but it can be
2263equally used by either flink:vkCmdCopyMemoryToAccelerationStructureKHR or
2264flink:vkCopyMemoryToAccelerationStructureKHR.
2265
2266.Valid Usage
2267****
2268include::{chapters}/commonvalidity/deferred_operations_common.txt[]
2269  * [[VUID-vkCopyAccelerationStructureToMemoryKHR-buffer-03731]]
2270    The pname:buffer used to create pname:pInfo->src must: be bound to
2271    host-visible device memory
2272  * [[VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732]]
2273    pname:pInfo->dst.hostAddress must: be a valid host pointer
2274  * [[VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751]]
2275    pname:pInfo->dst.hostAddress must: be aligned to 16 bytes
2276  * [[VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584]]
2277    The <<features-accelerationStructureHostCommands,
2278    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureHostCommands>>
2279    feature must: be enabled
2280ifdef::VK_KHR_device_group,VK_VERSION_1_1[]
2281  * [[VUID-vkCopyAccelerationStructureToMemoryKHR-buffer-03783]]
2282    The pname:buffer used to create pname:pInfo->src must: be bound to
2283    memory that was not allocated with multiple instances
2284endif::VK_KHR_device_group,VK_VERSION_1_1[]
2285****
2286
2287include::{generated}/validity/protos/vkCopyAccelerationStructureToMemoryKHR.txt[]
2288--
2289
2290[open,refpage='vkWriteAccelerationStructuresPropertiesKHR',desc='Query acceleration structure meta-data on the host',type='protos']
2291--
2292:refpage: vkWriteAccelerationStructuresPropertiesKHR
2293
2294To query acceleration structure size parameters on the host, call:
2295
2296include::{generated}/api/protos/vkWriteAccelerationStructuresPropertiesKHR.txt[]
2297
2298  * pname:device is the device which owns the acceleration structures in
2299    pname:pAccelerationStructures.
2300  * pname:accelerationStructureCount is the count of acceleration structures
2301    for which to query the property.
2302  * pname:pAccelerationStructures is a pointer to an array of existing
2303    previously built acceleration structures.
2304  * pname:queryType is a elink:VkQueryType value specifying the property to
2305    be queried.
2306  * pname:dataSize is the size in bytes of the buffer pointed to by
2307    pname:pData.
2308  * pname:pData is a pointer to a user-allocated buffer where the results
2309    will be written.
2310  * pname:stride is the stride in bytes between results for individual
2311    queries within pname:pData.
2312
2313This command fulfills the same task as
2314flink:vkCmdWriteAccelerationStructuresPropertiesKHR but is executed by the
2315host.
2316
2317.Valid Usage
2318****
2319include::{chapters}/commonvalidity/write_acceleration_structure_properties_common.txt[]
2320  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448]]
2321    If pname:queryType is
2322    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR, then
2323    pname:stride must: be a multiple of the size of basetype:VkDeviceSize
2324  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03449]]
2325    If pname:queryType is
2326    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR, then
2327    pname:data must: point to a basetype:VkDeviceSize
2328  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450]]
2329    If pname:queryType is
2330    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR, then
2331    pname:stride must: be a multiple of the size of basetype:VkDeviceSize
2332  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03451]]
2333    If pname:queryType is
2334    ename:VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR, then
2335    pname:data must: point to a basetype:VkDeviceSize
2336  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452]]
2337    pname:dataSize must: be greater than or equal to
2338    [eq]#pname:accelerationStructureCount*pname:stride#
2339  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-buffer-03733]]
2340    The pname:buffer used to create each acceleration structure in
2341    pname:pAccelerationStructures must: be bound to host-visible device
2342    memory
2343  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585]]
2344    The <<features-accelerationStructureHostCommands,
2345    sname:VkPhysicalDeviceAccelerationStructureFeaturesKHR::pname:accelerationStructureHostCommands>>
2346    feature must: be enabled
2347ifdef::VK_KHR_device_group,VK_VERSION_1_1[]
2348  * [[VUID-vkWriteAccelerationStructuresPropertiesKHR-buffer-03784]]
2349    The pname:buffer used to create each acceleration structure in
2350    pname:pAccelerationStructures must: be bound to memory that was not
2351    allocated with multiple instances
2352endif::VK_KHR_device_group,VK_VERSION_1_1[]
2353****
2354
2355include::{generated}/validity/protos/vkWriteAccelerationStructuresPropertiesKHR.txt[]
2356--
2357