Top Description Fields Constructors Methods
org.lwjgl.vulkan

public Class NVRayTracing

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_NV_ray_tracing : require
layout(set = 0, binding = 0, rgba8) uniform image2D image;
layout(set = 0, binding = 1) uniform accelerationStructureNV as;
layout(location = 0) rayPayloadNV float payload;

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

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

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

   col.y = payload;

   imageStore(image, ivec2(gl_LaunchIDNV.xy), col);
}
VK_NV_ray_tracing
Name String
VK_NV_ray_tracing
Extension Type
Device extension
Registered Extension Number
166
Revision
3
Extension and Version Dependencies
VK_KHR_get_physical_device_properties2 and VK_KHR_get_memory_requirements2
Contact
Other Extension Metadata
Last Modified Date
2018-11-20
Interactions and External Dependencies
Contributors
  • Eric Werness, NVIDIA
  • Ashwin Lele, NVIDIA
  • Robert Stepinski, NVIDIA
  • Nuno Subtil, NVIDIA
  • Christoph Kubisch, NVIDIA
  • Martin Stich, NVIDIA
  • Daniel Koch, NVIDIA
  • Jeff Bolz, NVIDIA
  • Joshua Barczak, Intel
  • Tobias Hector, AMD
  • Henrik Rydgard, NVIDIA
  • Pascal Gautron, NVIDIA

Field Summary

Modifier and TypeField and Description
public static final int
VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_BUILD_SCRATCH_NV

VkAccelerationStructureMemoryRequirementsTypeNV - Acceleration structure memory requirement type Description

public static final int
VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_OBJECT_NV

VkAccelerationStructureMemoryRequirementsTypeNV - Acceleration structure memory requirement type Description

public static final int
VK_ACCELERATION_STRUCTURE_MEMORY_REQUIREMENTS_TYPE_UPDATE_SCRATCH_NV

VkAccelerationStructureMemoryRequirementsTypeNV - Acceleration structure memory requirement type Description

public static final int
VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV

Extends VkAccelerationStructureTypeKHR.

public static final int
VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV

Extends VkAccelerationStructureTypeKHR.

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

Extends VkBufferUsageFlagBits.

public static final int
VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_COMPACTION_BIT_NV

Extends VkBuildAccelerationStructureFlagBitsKHR.

public static final int
VK_BUILD_ACCELERATION_STRUCTURE_ALLOW_UPDATE_BIT_NV

Extends VkBuildAccelerationStructureFlagBitsKHR.

public static final int
VK_BUILD_ACCELERATION_STRUCTURE_LOW_MEMORY_BIT_NV

Extends VkBuildAccelerationStructureFlagBitsKHR.

public static final int
VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV

Extends VkBuildAccelerationStructureFlagBitsKHR.

public static final int
VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV

Extends VkBuildAccelerationStructureFlagBitsKHR.

public static final int
VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_NV

Extends VkCopyAccelerationStructureModeKHR.

public static final int
VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_NV

Extends VkCopyAccelerationStructureModeKHR.

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

Extends VkGeometryInstanceFlagBitsKHR.

public static final int
VK_GEOMETRY_INSTANCE_FORCE_OPAQUE_BIT_NV

Extends VkGeometryInstanceFlagBitsKHR.

public static final int
VK_GEOMETRY_INSTANCE_TRIANGLE_CULL_DISABLE_BIT_NV

Extends VkGeometryInstanceFlagBitsKHR.

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

Extends VkGeometryFlagBitsKHR.

public static final int
VK_GEOMETRY_TYPE_AABBS_NV

Extends VkGeometryTypeKHR.

public static final int
VK_GEOMETRY_TYPE_TRIANGLES_NV

Extends VkGeometryTypeKHR.

public static final int
VK_INDEX_TYPE_NONE_NV

Extends VkIndexType.

public static final String
public static final int
VK_NV_RAY_TRACING_SPEC_VERSION

The extension specification version.

public static final int
public static final int
VK_PIPELINE_BIND_POINT_RAY_TRACING_NV

Extends VkPipelineBindPoint.

public static final int
VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV

Extends VkPipelineCreateFlagBits.

public static final int
public static final int
VK_PIPELINE_STAGE_RAY_TRACING_SHADER_BIT_NV

Extends VkPipelineStageFlagBits.

public static final int
public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_GENERAL_NV

Extends VkRayTracingShaderGroupTypeKHR.

public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_NV

Extends VkRayTracingShaderGroupTypeKHR.

public static final int
VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_NV

Extends VkRayTracingShaderGroupTypeKHR.

public static final int
VK_SHADER_STAGE_ANY_HIT_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_CALLABLE_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_INTERSECTION_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_MISS_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_STAGE_RAYGEN_BIT_NV

Extends VkShaderStageFlagBits.

public static final int
VK_SHADER_UNUSED_NV

VK_SHADER_UNUSED_NV

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

Extends VkStructureType.

public static final int
VK_STRUCTURE_TYPE_GEOMETRY_NV

Extends VkStructureType.

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 int
nvkBindAccelerationStructureMemoryNV(VkDevice device, int
the number of elements in pBindInfos.
bindInfoCount
,
long pBindInfos)

Unsafe version of: BindAccelerationStructureMemoryNV

public static void
nvkCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, long pInfo, long instanceData, long instanceOffset, int update, long dst, long src, long scratch, long scratchOffset)

Unsafe version of: CmdBuildAccelerationStructureNV

public static void
nvkCmdWriteAccelerationStructuresPropertiesNV(VkCommandBuffer commandBuffer, int
the count of acceleration structures for which to query the property.
accelerationStructureCount
,
long pAccelerationStructures, int queryType, long queryPool, int firstQuery)

Unsafe version of: CmdWriteAccelerationStructuresPropertiesNV

public static int
nvkCreateAccelerationStructureNV(VkDevice device, long pCreateInfo, long pAllocator, long pAccelerationStructure)

Unsafe version of: CreateAccelerationStructureNV

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

Unsafe version of: CreateRayTracingPipelinesNV

public static void
nvkDestroyAccelerationStructureNV(VkDevice device, long accelerationStructure, long pAllocator)

Unsafe version of: DestroyAccelerationStructureNV

public static int
nvkGetAccelerationStructureHandleNV(VkDevice device, long accelerationStructure, long
the size in bytes of the buffer pointed to by pData.
dataSize
,
long pData)

Unsafe version of: GetAccelerationStructureHandleNV

public static void
nvkGetAccelerationStructureMemoryRequirementsNV(VkDevice device, long pInfo, long pMemoryRequirements)

Unsafe version of: GetAccelerationStructureMemoryRequirementsNV

public static int
nvkGetRayTracingShaderGroupHandlesNV(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: GetRayTracingShaderGroupHandlesNV

public static int
vkBindAccelerationStructureMemoryNV(VkDevice
the logical device that owns the acceleration structures and memory.
device
,
VkBindAccelerationStructureMemoryInfoNV.Buffer
a pointer to an array of VkBindAccelerationStructureMemoryInfoNV structures describing acceleration structures and memory to bind.
pBindInfos
)

Bind acceleration structure memory.

public static void
vkCmdBuildAccelerationStructureNV(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
VkAccelerationStructureInfoNV
contains the shared information for the acceleration structure’s structure.
pInfo
,
long
the buffer containing an array of VkAccelerationStructureInstanceKHR structures defining acceleration structures. This parameter must be NULL for bottom level acceleration structures.
instanceData
,
long
the offset in bytes (relative to the start of instanceData) at which the instance data is located.
instanceOffset
,
boolean
specifies whether to update the dst acceleration structure with the data in src.
update
,
long
a pointer to the target acceleration structure for the build.
dst
,
long
a pointer to an existing acceleration structure that is to be used to update the dst acceleration structure.
src
,
long
the VkBuffer that will be used as scratch memory for the build.
scratch
,
long
the offset in bytes relative to the start of scratch that will be used as a scratch memory.
scratchOffset
)

Build an acceleration structure.

public static void
vkCmdCopyAccelerationStructureNV(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
long
the target acceleration structure for the copy.
dst
,
long
the source acceleration structure for the copy.
src
,
int
a VkCopyAccelerationStructureModeKHR value specifying additional operations to perform during the copy.
mode
)

Copy an acceleration structure.

public static void
vkCmdTraceRaysNV(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
long
the buffer object that holds the shader binding table data for the ray generation shader stage.
raygenShaderBindingTableBuffer
,
long
the offset in bytes (relative to raygenShaderBindingTableBuffer) of the ray generation shader being used for the trace.
raygenShaderBindingOffset
,
long
the buffer object that holds the shader binding table data for the miss shader stage.
missShaderBindingTableBuffer
,
long
the offset in bytes (relative to missShaderBindingTableBuffer) of the miss shader being used for the trace.
missShaderBindingOffset
,
long
the size in bytes of each shader binding table record in missShaderBindingTableBuffer.
missShaderBindingStride
,
long
the buffer object that holds the shader binding table data for the hit shader stages.
hitShaderBindingTableBuffer
,
long
the offset in bytes (relative to hitShaderBindingTableBuffer) of the hit shader group being used for the trace.
hitShaderBindingOffset
,
long
the size in bytes of each shader binding table record in hitShaderBindingTableBuffer.
hitShaderBindingStride
,
long
the buffer object that holds the shader binding table data for the callable shader stage.
callableShaderBindingTableBuffer
,
long
the offset in bytes (relative to callableShaderBindingTableBuffer) of the callable shader being used for the trace.
callableShaderBindingOffset
,
long
the size in bytes of each shader binding table record in callableShaderBindingTableBuffer.
callableShaderBindingStride
,
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 void
vkCmdWriteAccelerationStructuresPropertiesNV(VkCommandBuffer
the command buffer into which the command will be recorded.
commandBuffer
,
LongBuffer
a pointer to an array of existing previously built acceleration structures.
pAccelerationStructures
,
int
a VkQueryType value specifying the type of queries managed by the pool.
queryType
,
long
the query pool that will manage the results of the query.
queryPool
,
int
the first query index within the query pool that will contain the accelerationStructureCount number of results.
firstQuery
)

Write acceleration structure result parameters to query results.

public static void
vkCmdWriteAccelerationStructuresPropertiesNV(VkCommandBuffer commandBuffer, long[] pAccelerationStructures, int queryType, long queryPool, int firstQuery)

Array version of: CmdWriteAccelerationStructuresPropertiesNV

public static int
vkCompileDeferredNV(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 shader to compile.
shader
)

Deferred compilation of shaders.

public static int
vkCreateAccelerationStructureNV(VkDevice
the logical device that creates the buffer object.
device
,
VkAccelerationStructureCreateInfoNV
a pointer to a VkAccelerationStructureCreateInfoNV structure containing parameters affecting creation of the acceleration structure.
pCreateInfo
,
VkAllocationCallbacks
controls host memory allocation as described in the Memory Allocation chapter.
pAllocator
,
LongBuffer
a pointer to a VkAccelerationStructureNV handle in which the resulting acceleration structure object is returned.
pAccelerationStructure
)

Create a new acceleration structure object.

public static int
vkCreateAccelerationStructureNV(VkDevice device, VkAccelerationStructureCreateInfoNV pCreateInfo, VkAllocationCallbacks pAllocator, long[] pAccelerationStructure)

Array version of: CreateAccelerationStructureNV

public static int
vkCreateRayTracingPipelinesNV(VkDevice
the logical device that creates the ray tracing pipelines.
device
,
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
,
VkRayTracingPipelineCreateInfoNV.Buffer
a pointer to an array of VkRayTracingPipelineCreateInfoNV 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
vkCreateRayTracingPipelinesNV(VkDevice device, long pipelineCache, VkRayTracingPipelineCreateInfoNV.Buffer pCreateInfos, VkAllocationCallbacks pAllocator, long[] pPipelines)

Array version of: CreateRayTracingPipelinesNV

public static void
vkDestroyAccelerationStructureNV(VkDevice
the logical device that destroys the buffer.
device
,
long
the acceleration structure to destroy.
accelerationStructure
,
VkAllocationCallbacks
controls host memory allocation as described in the Memory Allocation chapter.
pAllocator
)

Destroy an acceleration structure object.

public static int
vkGetAccelerationStructureHandleNV(VkDevice
the logical device that owns the acceleration structures.
device
,
long
the acceleration structure.
accelerationStructure
,
ByteBuffer
a pointer to a user-allocated buffer where the results will be written.
pData
)

Get opaque acceleration structure handle.

public static int
vkGetAccelerationStructureHandleNV(VkDevice
the logical device that owns the acceleration structures.
device
,
long
the acceleration structure.
accelerationStructure
,
LongBuffer
a pointer to a user-allocated buffer where the results will be written.
pData
)

Get opaque acceleration structure handle.

public static int
vkGetAccelerationStructureHandleNV(VkDevice device, long accelerationStructure, long[] pData)

Array version of: GetAccelerationStructureHandleNV

public static void
vkGetAccelerationStructureMemoryRequirementsNV(VkDevice
the logical device on which the acceleration structure was created.
device
,
VkAccelerationStructureMemoryRequirementsInfoNV
a pointer to a VkAccelerationStructureMemoryRequirementsInfoNV structure specifying the acceleration structure to get memory requirements for.
pInfo
,
VkMemoryRequirements2KHR
a pointer to a VkMemoryRequirements2KHR structure in which the requested acceleration structure memory requirements are returned.
pMemoryRequirements
)

Get acceleration structure memory requirements.

public static int
vkGetRayTracingShaderGroupHandlesNV(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
)

See GetRayTracingShaderGroupHandlesKHR.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait