Modulevulkan-3.27GHC2021
Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorder
Name
VK_NV_ray_tracing_invocation_reorder - device extension
VK_NV_ray_tracing_invocation_reorder
- Name String
VK_NV_ray_tracing_invocation_reorder
- Extension Type
Device extension
- Registered Extension Number
491
- Revision
1
- Ratification Status
Not ratified
- Extension and Version Dependencies
- SPIR-V Dependencies
- Deprecation State
Promoted to VK_EXT_ray_tracing_invocation_reorder extension
- Contact
Other Extension Metadata
- Last Modified Date
2022-11-02
- Interactions and External Dependencies
This extension provides API support for GL_NV_shader_invocation_reorder
- Contributors
Eric Werness, NVIDIA
Ashwin Lele, NVIDIA
Description
The ray tracing pipeline API provides some ability to reorder for locality, but it is useful to have more control over how the reordering happens and what information is included in the reordering. The shader API provides a hit object to contain result information from the hit which can be used as part of the explicit sorting plus options that contain an integer for hint bits to use to add more locality.
New Structures
Extending PhysicalDeviceFeatures2, DeviceCreateInfo:
New Enums
New Enum Constants
Extending RayTracingInvocationReorderModeEXT:
Extending StructureType:
HLSL Mapping
HLSL does not provide this functionality natively yet.
However, it is possible to use this functionality via SPIR-V Intrinsics.
The codes for shader invocation reorder are obtained from this page:
#define ShaderInvocationReorderNV 5383
#define HitObjectAttributeNV 5385
#define OpHitObjectRecordHitMotionNV 5249
#define OpHitObjectRecordHitWithIndexMotionNV 5250
#define OpHitObjectRecordMissMotionNV 5251
#define OpHitObjectGetWorldToObjectNV 5252
#define OpHitObjectGetObjectToWorldNV 5253
#define OpHitObjectGetObjectRayDirectionNV 5254
#define OpHitObjectGetObjectRayOriginNV 5255
#define OpHitObjectTraceRayMotionNV 5256
#define OpHitObjectGetShaderRecordBufferHandleNV 5257
#define OpHitObjectGetShaderBindingTableRecordIndexNV 5258
#define OpHitObjectRecordEmptyNV 5259
#define OpHitObjectTraceRayNV 5260
#define OpHitObjectRecordHitNV 5261
#define OpHitObjectRecordHitWithIndexNV 5262
#define OpHitObjectRecordMissNV 5263
#define OpHitObjectExecuteShaderNV 5264
#define OpHitObjectGetCurrentTimeNV 5265
#define OpHitObjectGetAttributesNV 5266
#define OpHitObjectGetHitKindNV 5267
#define OpHitObjectGetPrimitiveIndexNV 5268
#define OpHitObjectGetGeometryIndexNV 5269
#define OpHitObjectGetInstanceIdNV 5270
#define OpHitObjectGetInstanceCustomIndexNV 5271
#define OpHitObjectGetWorldRayDirectionNV 5272
#define OpHitObjectGetWorldRayOriginNV 5273
#define OpHitObjectGetRayTMaxNV 5274
#define OpHitObjectGetRayTMinNV 5275
#define OpHitObjectIsEmptyNV 5276
#define OpHitObjectIsHitNV 5277
#define OpHitObjectIsMissNV 5278
#define OpReorderThreadWithHitObjectNV 5279
#define OpReorderThreadWithHintNV 5280
#define OpTypeHitObjectNV 5281The capability and extension need to be added:
[[vk::ext_capability(ShaderInvocationReorderNV)]]
[[vk::ext_extension("SPV_NV_shader_invocation_reorder")]]The creation of the HitObject type can be done like this:
[[vk::ext_type_def(HitObjectAttributeNV, OpTypeHitObjectNV)]]
void createHitObjectNV();
#define HitObjectNV vk::ext_type<HitObjectAttributeNV>The payload:
must be global
needs the
RayPayloadKHRattribute as an extra storage class
struct [raypayload] HitPayload
{
float hitT : write(closesthit, miss) : read(caller);
int instanceIndex : write(closesthit) : read(caller);
float3 pos : write(closesthit) : read(caller);
float3 nrm : write(closesthit) : read(caller);
};
#define RayPayloadKHR 5338
[[vk::ext_storage_class(RayPayloadKHR)]] static HitPayload payload;Here is the declaration of a few invocation reordering functions:
[[vk::ext_instruction(OpHitObjectRecordEmptyNV)]]
void hitObjectRecordEmptyNV([[vk::ext_reference]] HitObjectNV hitObject);
[[vk::ext_instruction(OpHitObjectTraceRayNV)]]
void hitObjectTraceRayNV(
[[vk::ext_reference]] HitObjectNV hitObject,
RaytracingAccelerationStructure as,
uint RayFlags,
uint CullMask,
uint SBTOffset,
uint SBTStride,
uint MissIndex,
float3 RayOrigin,
float RayTmin,
float3 RayDirection,
float RayTMax,
[[vk::ext_reference]] [[vk::ext_storage_class(RayPayloadKHR)]] HitPayload payload
);
[[vk::ext_instruction(OpReorderThreadWithHintNV)]]
void reorderThreadWithHintNV(int Hint, int Bits);
[[vk::ext_instruction(OpReorderThreadWithHitObjectNV)]]
void reorderThreadWithHitObjectNV([[vk::ext_reference]] HitObjectNV hitObject);
[[vk::ext_instruction(OpHitObjectExecuteShaderNV)]]
void hitObjectExecuteShaderNV([[vk::ext_reference]] HitObjectNV hitObject, [[vk::ext_reference]] [[vk::ext_storage_class(RayPayloadKHR)]] HitPayload payload);
[[vk::ext_instruction(OpHitObjectIsHitNV)]]
bool hitObjectIsHitNV([[vk::ext_reference]] HitObjectNV hitObject);Using the function in the code, can be done like this
if (USE_SER == 1)
{
createHitObjectNV();
HitObjectNV hObj; // hitObjectNV hObj;
hitObjectRecordEmptyNV(hObj); //Initialize to an empty hit object
hitObjectTraceRayNV(hObj, topLevelAS, rayFlags, 0xFF, 0, 0, 0, r.Origin, 0.0, r.Direction, INFINITE, payload);
reorderThreadWithHitObjectNV(hObj);
hitObjectExecuteShaderNV(hObj, payload);
}Note:
createHitObjectNV() needs to be call at least once. This can be also done in the main entry of the shader.
Function with a payload parameter, needs to have the payload struct defined before. There are no templated declaration of the function.
Version History
Revision 1, 2020-09-12 (Eric Werness, Ashwin Lele)
Initial external release
See Also
No cross-references are available
Document Notes
For more information, see the Vulkan Specification.
This page is a generated document. Fixes and changes should be made to the generator scripts, not directly.
- 6 types
- Packagevulkan-3.27
- Exports12
- LanguageGHC2021
- LicenceBSD-3-Clause
- SourceVK_NV_ray_tracing_invocation_reorder.hs
VkPhysicalDeviceRayTracingInvocationReorderFeaturesNV - Structure describing feature to control ray tracing invocation reordering
Members
This structure describes the following feature:
Description
If the PhysicalDeviceRayTracingInvocationReorderFeaturesNV structure
is included in the pNext chain of the
PhysicalDeviceFeatures2
structure passed to
getPhysicalDeviceFeatures2,
it is filled in to indicate whether each corresponding feature is
supported. If the application wishes to use a
Device with any features described by
PhysicalDeviceRayTracingInvocationReorderFeaturesNV, it must add an
instance of the structure, with the desired feature members set to
TRUE, to the pNext chain of
DeviceCreateInfo when creating the
Device.
Structure Chaining
See Also
Constructors
PhysicalDeviceRayTracingInvocationReorderFeaturesNVrayTracingInvocationReorder :: BoolrayTracingInvocationReorderindicates that the implementation supportsSPV_NV_shader_invocation_reorder.
Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero
Eq PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderShow PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderStorable PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderFromCStruct PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderToCStruct PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderZero PhysicalDeviceRayTracingInvocationReorderFeaturesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorder
VkPhysicalDeviceRayTracingInvocationReorderPropertiesNV - Structure describing shader module identifier properties of an implementation
Description
Because the extension changes how hits are managed there is a compatibility reason to expose the extension even when an implementation does not have sorting active.
If the PhysicalDeviceRayTracingInvocationReorderPropertiesNV structure
is included in the pNext chain of the
PhysicalDeviceProperties2
structure passed to
getPhysicalDeviceProperties2,
it is filled in with each corresponding implementation-dependent
property.
Structure Chaining
See Also
VK_NV_ray_tracing_invocation_reorder, RayTracingInvocationReorderModeEXT, StructureType
Constructors
PhysicalDeviceRayTracingInvocationReorderPropertiesNVrayTracingInvocationReorderReorderingHint :: RayTracingInvocationReorderModeEXTrayTracingInvocationReorderReorderingHintis a hint indicating if the implementation will actually reorder at the reorder calls.
Instances6Eq, Show, Storable, FromCStruct, ToCStruct, Zero
Eq PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderShow PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderStorable PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderFromCStruct PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderToCStruct PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorderZero PhysicalDeviceRayTracingInvocationReorderPropertiesNVDefined in vulkan-3.27 · Vulkan.Extensions.VK_NV_ray_tracing_invocation_reorder
VkRayTracingInvocationReorderModeEXT - Enum providing a hint on how the application may reorder
Description
RAY_TRACING_INVOCATION_REORDER_MODE_NONE_EXT specifies that the implementation does not reorder at reorder calls.
RAY_TRACING_INVOCATION_REORDER_MODE_REORDER_EXT specifies that the implementation may reorder at reorder calls.
See Also
VK_EXT_ray_tracing_invocation_reorder, VK_NV_ray_tracing_invocation_reorder, PhysicalDeviceRayTracingInvocationReorderPropertiesEXT, PhysicalDeviceRayTracingInvocationReorderPropertiesNV
Constructors
Instances6Eq, Ord, Read, Show, Storable, Zero
Eq RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorderOrd RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorderRead RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorderShow RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorderStorable RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorderZero RayTracingInvocationReorderModeEXTDefined in vulkan-3.27 · Vulkan.Extensions.VK_EXT_ray_tracing_invocation_reorder