Top Description Fields Constructors Methods
org.lwjgl.vulkan

public Class KHRRayTracingPipeline

extends Object
Class Inheritance
Imports
javax.annotation.*, java.nio.*, org.lwjgl.system.*

Rasterization has been the dominant method to produce interactive graphics, but increasing performance of graphics hardware has made ray tracing a viable option for interactive rendering. Being able to integrate ray tracing with traditional rasterization makes it easier for applications to incrementally add ray traced effects to existing applications or to do hybrid approaches with rasterization for primary visibility and ray tracing for secondary queries.

To enable ray tracing, this extension adds a few different categories of new functionality:

This extension adds support for the following SPIR-V extension in Vulkan:

Sample Code

Example ray generation GLSL shader


#version 450 core
#extension GL_EXT_ray_tracing : require
layout(set = 0, binding = 0, rgba8) uniform image2D image;
layout(set = 0, binding = 1) uniform accelerationStructureEXT as;
layout(location = 0) rayPayloadEXT float payload;

void main()
{
   vec4 col = vec4(0, 0, 0, 1);

   vec3 origin = vec3(float(gl_LaunchIDEXT.x)/float(gl_LaunchSizeEXT.x), float(gl_LaunchIDEXT.y)/float(gl_LaunchSizeEXT.y), 1.0);
   vec3 dir = vec3(0.0, 0.0, -1.0);

   traceRayEXT(as, 0, 0xff, 0, 1, 0, origin, 0.0, dir, 1000.0, 0);

   col.y = payload;

   imageStore(image, ivec2(gl_LaunchIDEXT.xy), col);
}
VK_KHR_ray_tracing_pipeline
Name String
VK_KHR_ray_tracing_pipeline
Extension Type
Device extension
Registered Extension Number
348
Revision
1
Extension and Version Dependencies
VK_KHR_spirv_1_4 and VK_KHR_acceleration_structure
Contact
Other Extension Metadata
Last Modified Date
2020-11-12
Interactions and External Dependencies
Contributors
  • Matthäus Chajdas, AMD
  • Greg Grebe, AMD
  • Nicolai Hähnle, AMD
  • Tobias Hector, AMD
  • Dave Oldcorn, AMD
  • Skyler Saleh, AMD
  • Mathieu Robart, Arm
  • Marius Bjorge, Arm
  • Tom Olson, Arm
  • Sebastian Tafuri, EA
  • Henrik Rydgard, Embark
  • Juan Cañada, Epic Games
  • Patrick Kelly, Epic Games
  • Yuriy O’Donnell, Epic Games
  • Michael Doggett, Facebook/Oculus
  • Andrew Garrard, Imagination
  • Don Scorgie, Imagination
  • Dae Kim, Imagination
  • Joshua Barczak, Intel
  • Slawek Grajewski, Intel
  • Jeff Bolz, NVIDIA
  • Pascal Gautron, NVIDIA
  • Daniel Koch, NVIDIA
  • Christoph Kubisch, NVIDIA
  • Ashwin Lele, NVIDIA
  • Robert Stepinski, NVIDIA
  • Martin Stich, NVIDIA
  • Nuno Subtil, NVIDIA
  • Eric Werness, NVIDIA
  • Jon Leech, Khronos
  • Jeroen van Schijndel, OTOY
  • Juul Joosten, OTOY
  • Alex Bourd, Qualcomm
  • Roman Larionov, Qualcomm
  • David McAllister, Qualcomm
  • Spencer Fricke, Samsung
  • Lewis Gordon, Samsung
  • Ralph Potter, Samsung
  • Jasper Bekkers, Traverse Research
  • Jesse Barker, Unity
  • Baldur Karlsson, Valve

Field Summary

Modifier and TypeField and Description
public static final int
VK_BUFFER_USAGE_SHADER_BINDING_TABLE_BIT_KHR

Extends VkBufferUsageFlagBits.

public static final int
public static final String
public static final int
VK_KHR_RAY_TRACING_PIPELINE_SPEC_VERSION

The extension specification version.

public static final int
VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR

Extends VkPipelineBindPoint.

public static final int
public static final int
public static final int
public static final int
public static final int
public static final int
VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR

Extends VkPipelineCreateFlagBits.

public static final int
public static final int
VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_KHR

Extends VkPipelineStageFlagBits.

public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_KHR

VkRayTracingShaderGroupTypeKHR - Shader group types Description

public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR

VkRayTracingShaderGroupTypeKHR - Shader group types Description

public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR

VkRayTracingShaderGroupTypeKHR - Shader group types Description

public static final int
VK_SHADER_GROUP_SHADER_ANY_HIT_KHR

VkShaderGroupShaderKHR - Shader group shaders Description

public static final int
VK_SHADER_GROUP_SHADER_CLOSEST_HIT_KHR

VkShaderGroupShaderKHR - Shader group shaders Description

public static final int
VK_SHADER_GROUP_SHADER_GENERAL_KHR

VkShaderGroupShaderKHR - Shader group shaders Description

public static final int
VK_SHADER_GROUP_SHADER_INTERSECTION_KHR

VkShaderGroupShaderKHR - Shader group shaders Description

public static final int
VK_SHADER_STAGE_ANY_HIT_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_CALLABLE_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_CLOSEST_HIT_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_INTERSECTION_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_MISS_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_RAYGEN_BIT_KHR

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_UNUSED_KHR

VK_SHADER_UNUSED_KHR

public static final int
public static final int
public static final int
public static final int
public static final int

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public static void
nvkCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer, long pRaygenShaderBindingTable, long pMissShaderBindingTable, long pHitShaderBindingTable, long pCallableShaderBindingTable, long indirectDeviceAddress)

Unsafe version of: CmdTraceRaysIndirectKHR

public static void
nvkCmdTraceRaysKHR(VkCommandBuffer commandBuffer, long pRaygenShaderBindingTable, long pMissShaderBindingTable, long pHitShaderBindingTable, long pCallableShaderBindingTable, int width, int height, int depth)

Unsafe version of: CmdTraceRaysKHR

public static int
nvkCreateRayTracingPipelinesKHR(VkDevice device, long deferredOperation, long pipelineCache, int
the length of the pCreateInfos and pPipelines arrays.
createInfoCount
,
long pCreateInfos, long pAllocator, long pPipelines)

Unsafe version of: CreateRayTracingPipelinesKHR

public static int
nvkGetRayTracingCaptureReplayShaderGroupHandlesKHR(VkDevice device, long pipeline, int firstGroup, int groupCount, long
the size in bytes of the buffer pointed to by pData.
dataSize
,
long pData)

Unsafe version of: GetRayTracingCaptureReplayShaderGroupHandlesKHR

public static int
nvkGetRayTracingShaderGroupHandlesKHR(VkDevice device, long pipeline, int firstGroup, int groupCount, long
the size in bytes of the buffer pointed to by pData.
dataSize
,
long pData)

Unsafe version of: GetRayTracingShaderGroupHandlesKHR

public static void
vkCmdSetRayTracingPipelineStackSizeKHR(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
int
the stack size to use for subsequent ray tracing trace commands.
pipelineStackSize
)

Set the stack size dynamically for a ray tracing pipeline.

public static void
vkCmdTraceRaysIndirectKHR(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the ray generation shader stage.
pRaygenShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the miss shader stage.
pMissShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the hit shader stage.
pHitShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the callable shader stage.
pCallableShaderBindingTable
,
long
a buffer device address which is a pointer to a VkTraceRaysIndirectCommandKHR structure containing the trace ray parameters.
indirectDeviceAddress
)

Initialize an indirect ray tracing dispatch.

public static void
vkCmdTraceRaysKHR(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the ray generation shader stage.
pRaygenShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the miss shader stage.
pMissShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the hit shader stage.
pHitShaderBindingTable
,
VkStridedDeviceAddressRegionKHR
a VkStridedDeviceAddressRegionKHR that holds the shader binding table data for the callable shader stage.
pCallableShaderBindingTable
,
int
the width of the ray trace query dimensions.
width
,
int
height of the ray trace query dimensions.
height
,
int
depth of the ray trace query dimensions.
depth
)

Initialize a ray tracing dispatch.

public static int
vkCreateRayTracingPipelinesKHR(VkDevice
the logical device that creates the ray tracing pipelines.
device
,
long
NULL_HANDLE or the handle of a valid VkDeferredOperationKHR request deferral object for this command.
deferredOperation
,
long
either NULL_HANDLE, indicating that pipeline caching is disabled, or the handle of a valid pipeline cache object, in which case use of that cache is enabled for the duration of the command.
pipelineCache
,
VkRayTracingPipelineCreateInfoKHR.Buffer
a pointer to an array of VkRayTracingPipelineCreateInfoKHR structures.
pCreateInfos
,
VkAllocationCallbacks
controls host memory allocation as described in the Memory Allocation chapter.
pAllocator
,
LongBuffer
a pointer to an array in which the resulting ray tracing pipeline objects are returned.
pPipelines
)

Creates a new ray tracing pipeline object.

public static int
vkCreateRayTracingPipelinesKHR(VkDevice device, long deferredOperation, long pipelineCache, VkRayTracingPipelineCreateInfoKHR.Buffer pCreateInfos, VkAllocationCallbacks pAllocator, long[] pPipelines)

Array version of: CreateRayTracingPipelinesKHR

public static int
vkGetRayTracingCaptureReplayShaderGroupHandlesKHR(VkDevice
the logical device containing the ray tracing pipeline.
device
,
long
the ray tracing pipeline object containing the shaders.
pipeline
,
int
the index of the first group to retrieve a handle for from the VkRayTracingPipelineCreateInfoKHR::pGroups array.
firstGroup
,
int
the number of shader handles to retrieve.
groupCount
,
ByteBuffer
a pointer to a user-allocated buffer where the results will be written.
pData
)

Query opaque capture replay data for pipeline shader group handles.

public static int
vkGetRayTracingShaderGroupHandlesKHR(VkDevice
the logical device containing the ray tracing pipeline.
device
,
long
the ray tracing pipeline object containing the shaders.
pipeline
,
int
the index of the first group to retrieve a handle for from the VkRayTracingPipelineCreateInfoKHR::pGroups or VkRayTracingPipelineCreateInfoNV::pGroups array.
firstGroup
,
int
the number of shader handles to retrieve.
groupCount
,
ByteBuffer
a pointer to a user-allocated buffer where the results will be written.
pData
)

Query ray tracing pipeline shader group handles.

public static long
vkGetRayTracingShaderGroupStackSizeKHR(VkDevice
the logical device containing the ray tracing pipeline.
device
,
long
the ray tracing pipeline object containing the shaders groups.
pipeline
,
int
the index of the shader group to query.
group
,
int
the type of shader from the group to query.
groupShader
)

Query ray tracing pipeline shader group shader stack size.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait