1// Copyright 2017-2024 The Khronos Group Inc. 2// 3// SPDX-License-Identifier: CC-BY-4.0 4 5include::{generated}/meta/{refprefix}VK_KHR_ray_query.adoc[] 6 7=== Other Extension Metadata 8 9*Last Modified Date*:: 10 2020-11-12 11*Interactions and External Dependencies*:: 12 - This extension provides API support for 13 {GLSLregistry}/ext/GLSL_EXT_ray_query.txt[`GLSL_EXT_ray_query`] 14*Contributors*:: 15 - Matthäus Chajdas, AMD 16 - Greg Grebe, AMD 17 - Nicolai Hähnle, AMD 18 - Tobias Hector, AMD 19 - Dave Oldcorn, AMD 20 - Skyler Saleh, AMD 21 - Mathieu Robart, Arm 22 - Marius Bjorge, Arm 23 - Tom Olson, Arm 24 - Sebastian Tafuri, EA 25 - Henrik Rydgard, Embark 26 - Juan Cañada, Epic Games 27 - Patrick Kelly, Epic Games 28 - Yuriy O'Donnell, Epic Games 29 - Michael Doggett, Facebook/Oculus 30 - Andrew Garrard, Imagination 31 - Don Scorgie, Imagination 32 - Dae Kim, Imagination 33 - Joshua Barczak, Intel 34 - Slawek Grajewski, Intel 35 - Jeff Bolz, NVIDIA 36 - Pascal Gautron, NVIDIA 37 - Daniel Koch, NVIDIA 38 - Christoph Kubisch, NVIDIA 39 - Ashwin Lele, NVIDIA 40 - Robert Stepinski, NVIDIA 41 - Martin Stich, NVIDIA 42 - Nuno Subtil, NVIDIA 43 - Eric Werness, NVIDIA 44 - Jon Leech, Khronos 45 - Jeroen van Schijndel, OTOY 46 - Juul Joosten, OTOY 47 - Alex Bourd, Qualcomm 48 - Roman Larionov, Qualcomm 49 - David McAllister, Qualcomm 50 - Spencer Fricke, Samsung 51 - Lewis Gordon, Samsung 52 - Ralph Potter, Samsung 53 - Jasper Bekkers, Traverse Research 54 - Jesse Barker, Unity 55 - Baldur Karlsson, Valve 56 57=== Description 58 59Rasterization has been the dominant method to produce interactive graphics, 60but increasing performance of graphics hardware has made ray tracing a 61viable option for interactive rendering. 62Being able to integrate ray tracing with traditional rasterization makes it 63easier for applications to incrementally add ray traced effects to existing 64applications or to do hybrid approaches with rasterization for primary 65visibility and ray tracing for secondary queries. 66 67Ray queries are available to all shader types, including graphics, compute 68and ray tracing pipelines. 69Ray queries are not able to launch additional shaders, instead returning 70traversal results to the calling shader. 71 72This extension adds support for the following SPIR-V extension in Vulkan: 73 74 * `SPV_KHR_ray_query` 75 76include::{generated}/interfaces/VK_KHR_ray_query.adoc[] 77 78 79=== New SPIR-V Capabilities 80 81 * <<spirvenv-capabilities-table-RayQueryKHR, code:RayQueryKHR>> 82 * <<spirvenv-capabilities-table-RayTraversalPrimitiveCullingKHR, 83 code:RayTraversalPrimitiveCullingKHR>> 84 85 86=== Sample Code 87 88Example of ray query in a GLSL shader, illustrating how to use ray queries 89to determine whether a given position (at ray origin) is in shadow or not, 90by tracing a ray towards the light, and checking for any intersections with 91geometry occluding the light. 92 93[source,c] 94---- 95rayQueryEXT rq; 96 97rayQueryInitializeEXT(rq, accStruct, gl_RayFlagsTerminateOnFirstHitEXT, cullMask, origin, tMin, direction, tMax); 98 99// Traverse the acceleration structure and store information about the first intersection (if any) 100rayQueryProceedEXT(rq); 101 102if (rayQueryGetIntersectionTypeEXT(rq, true) == gl_RayQueryCommittedIntersectionNoneEXT) { 103 // Not in shadow 104} 105---- 106 107=== Issues 108 109(1) What are the changes between the public provisional (VK_KHR_ray_tracing 110v8) release and the final (VK_KHR_acceleration_structure v11 / 111VK_KHR_ray_query v1) release? 112-- 113 * refactor VK_KHR_ray_tracing into 3 extensions, enabling implementation 114 flexibility and decoupling ray query support from ray pipelines: 115 ** `apiext:VK_KHR_acceleration_structure` (for acceleration structure 116 operations) 117 ** `apiext:VK_KHR_ray_tracing_pipeline` (for ray tracing pipeline and 118 shader stages) 119 ** `apiext:VK_KHR_ray_query` (for ray queries in existing shader stages) 120 * Update SPIRV capabilities to use code:RayQueryKHR 121 * extension is no longer provisional 122-- 123 124 125=== Version History 126 127 * Revision 1, 2020-11-12 (Mathieu Robart, Daniel Koch, Andrew Garrard) 128 ** Decomposition of the specification, from VK_KHR_ray_tracing to 129 VK_KHR_ray_query (#1918,!3912) 130 ** update to use code:RayQueryKHR SPIR-V capability 131 ** add numerical limits for ray parameters (#2235,!3960) 132 ** relax formula for ray intersection candidate determination 133 (#2322,!4080) 134 ** restrict traces to TLAS (#2239,!4141) 135 ** require code:HitT to be in ray interval for 136 code:OpRayQueryGenerateIntersectionKHR (#2359,!4146) 137 ** add ray query shader stages for AS read bit (#2407,!4203) 138