summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/slang/core.meta.slang3
-rw-r--r--source/slang/hlsl.meta.slang660
-rw-r--r--source/slang/slang-ast-modifier.h10
-rw-r--r--source/slang/slang-check-modifier.cpp9
-rwxr-xr-xsource/slang/slang-compiler.h2
-rw-r--r--source/slang/slang-emit-c-like.cpp90
-rw-r--r--source/slang/slang-emit-c-like.h57
-rw-r--r--source/slang/slang-emit-glsl.cpp71
-rw-r--r--source/slang/slang-intrinsic-expand.cpp75
-rw-r--r--source/slang/slang-ir-inst-defs.h2
-rw-r--r--source/slang/slang-ir-insts.h11
-rw-r--r--source/slang/slang-ir.cpp1
-rw-r--r--source/slang/slang-lower-to-ir.cpp6
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang100
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected439
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang33
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.1.expected42
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.expected153
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang3
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected108
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang1
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.1.expected39
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang1
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.1.expected28
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang3
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected116
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang79
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected89
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang3
-rw-r--r--tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected86
30 files changed, 2140 insertions, 180 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang
index e1eb9c776..0a6278ec1 100644
--- a/source/slang/core.meta.slang
+++ b/source/slang/core.meta.slang
@@ -2797,6 +2797,9 @@ __attributeTarget(VarDeclBase)
attribute_syntax [__vulkanCallablePayload(location : int = -1)] : VulkanCallablePayloadAttribute;
__attributeTarget(VarDeclBase)
+attribute_syntax [__vulkanHitObjectAttributes(location : int = -1)] : VulkanHitObjectAttributesAttribute;
+
+__attributeTarget(VarDeclBase)
attribute_syntax [__vulkanHitAttributes] : VulkanHitAttributesAttribute;
__attributeTarget(FunctionDeclBase)
diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang
index 2a9a9f9d3..81df2b5e4 100644
--- a/source/slang/hlsl.meta.slang
+++ b/source/slang/hlsl.meta.slang
@@ -5557,12 +5557,44 @@ struct VkSubpassInputMS<T>
///
/// https://developer.nvidia.com/rtx/path-tracing/nvapi/get-started
///
+/// For VK the specification is currently in this PR
+///
+/// https://github.com/KhronosGroup/GLSL/pull/196/files
+
+/// Internal helper functions
+
+// This is a bit of a hack for GLSL HitObjectAttributes
+// It relies on [ForceInline] removing the surrounding function and just inserting the *contained* `t` as a global
+// The __ref should indicate the desire for the returned value to not be a copy of t, but *t*.
+// In practive __ref doesn't have this effect in practice.
+//
+// We need this to be able access the payload outside of a function (which is all that TraceRay for example needs)
+// We access the HitObjectAttributes via this function for the desired type, and it acts *as if* it's just an access
+// to the global t.
+[ForceInline]
+__ref T __hitObjectAttributes<T>()
+{
+ [__vulkanHitObjectAttributes]
+ static T t;
+ return t;
+}
+
+// Next is the custom intrinsic that will compute the hitObjectAttributes location
+// for GLSL-based targets.
+//
+__generic<Payload>
+__target_intrinsic(__glslRayTracing, "$XH")
+[__readNone]
+int __hitObjectAttributesLocation(Payload payload);
/// Immutable data type representing a ray hit or a miss. Can be used to invoke hit or miss shading,
/// or as a key in ReorderThread. Created by one of several methods described below. HitObject
/// and its related functions are available in raytracing shader types only.
-__target_intrinsic(hlsl, NvHitObject)
[__requiresNVAPI]
+__target_intrinsic(hlsl, NvHitObject)
+__glsl_extension(GL_NV_shader_invocation_reorder)
+__glsl_extension(GL_EXT_ray_tracing)
+__target_intrinsic(glsl, hitObjectNV)
struct HitObject
{
/// Executes ray traversal (including anyhit and intersection shaders) like TraceRay, but returns the
@@ -5577,20 +5609,104 @@ struct HitObject
uint MissShaderIndex,
RayDesc Ray,
inout payload_t Payload)
- {
- HitObject hitObj;
- __traceRay(
- AccelerationStructure,
- RayFlags,
- InstanceInclusionMask,
- RayContributionToHitGroupIndex,
- MultiplierForGeometryContributionToHitGroupIndex,
- MissShaderIndex,
- Ray,
- Payload,
- hitObj);
- return hitObj;
- }
+ {
+ HitObject hitObj;
+ __hlslTraceRay(
+ AccelerationStructure,
+ RayFlags,
+ InstanceInclusionMask,
+ RayContributionToHitGroupIndex,
+ MultiplierForGeometryContributionToHitGroupIndex,
+ MissShaderIndex,
+ Ray,
+ Payload,
+ hitObj);
+ return hitObj;
+ }
+
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject TraceRay<payload_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint RayFlags,
+ uint InstanceInclusionMask,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ uint MissShaderIndex,
+ RayDesc Ray,
+ inout payload_t Payload)
+ {
+ HitObject hitObj;
+
+ [__vulkanRayPayload]
+ static payload_t p;
+
+ // Save the payload
+ p = Payload;
+
+ __glslTraceRay(
+ hitObj,
+ AccelerationStructure,
+ RayFlags, // Assumes D3D/VK have some RayFlags values
+ InstanceInclusionMask, // cullMask
+ RayContributionToHitGroupIndex, // sbtRecordOffset
+ MultiplierForGeometryContributionToHitGroupIndex, // sbtRecordStride
+ MissShaderIndex,
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ __rayPayloadLocation(p));
+
+ // Write the payload out
+ Payload = p;
+
+ return hitObj;
+ }
+
+ /// Executes motion ray traversal (including anyhit and intersection shaders) like TraceRay, but returns the
+ /// resulting hit information as a HitObject and does not trigger closesthit or miss shaders.
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject TraceMotionRay<payload_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint RayFlags,
+ uint InstanceInclusionMask,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ uint MissShaderIndex,
+ RayDesc Ray,
+ float CurrentTime,
+ inout payload_t Payload)
+ {
+ HitObject hitObj;
+
+ [__vulkanRayPayload]
+ static payload_t p;
+
+ // Save the payload
+ p = Payload;
+
+ __glslTraceMotionRay(
+ hitObj,
+ AccelerationStructure,
+ RayFlags, // Assumes D3D/VK have some RayFlags values
+ InstanceInclusionMask, // cullMask
+ RayContributionToHitGroupIndex, // sbtRecordOffset
+ MultiplierForGeometryContributionToHitGroupIndex, // sbtRecordStride
+ MissShaderIndex,
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ CurrentTime,
+ __rayPayloadLocation(p));
+
+ // Write the payload out
+ Payload = p;
+
+ return hitObj;
+ }
/// Creates a HitObject representing a hit based on values explicitly passed as arguments, without
/// tracing a ray. The primitive specified by AccelerationStructure, InstanceIndex, GeometryIndex,
@@ -5611,8 +5727,8 @@ struct HitObject
attr_t attributes)
{
HitObject hitObj;
- __makeHit(
- AccelerationStructure,
+ __hlslMakeHit(
+ AccelerationStructure,
InstanceIndex,
GeometryIndex,
PrimitiveIndex,
@@ -5625,6 +5741,84 @@ struct HitObject
return hitObj;
}
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeHit<attr_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ RayDesc Ray,
+ attr_t attributes)
+ {
+ HitObject hitObj;
+
+ // Save the attributes
+ __ref attr_t attr = __hitObjectAttributes<attr_t>();
+
+ attr = attributes;
+
+ __glslMakeHit(hitObj,
+ AccelerationStructure,
+ InstanceIndex,
+ PrimitiveIndex,
+ GeometryIndex,
+ HitKind,
+ RayContributionToHitGroupIndex, /// sbtRecordOffset?
+ MultiplierForGeometryContributionToHitGroupIndex, /// sbtRecordStride?
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ __hitObjectAttributesLocation(__hitObjectAttributes<attr_t>()));
+
+ return hitObj;
+ }
+
+ /// See MakeHit but handles Motion
+ /// Currently only supported on VK
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeMotionHit<attr_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ RayDesc Ray,
+ float CurrentTime,
+ attr_t attributes)
+ {
+ HitObject hitObj;
+
+ // Save the attributes
+ __ref attr_t attr = __hitObjectAttributes<attr_t>();
+
+ attr = attributes;
+
+ __glslMakeMotionHit(hitObj,
+ AccelerationStructure,
+ InstanceIndex,
+ PrimitiveIndex,
+ GeometryIndex,
+ HitKind,
+ RayContributionToHitGroupIndex, /// sbtRecordOffset?
+ MultiplierForGeometryContributionToHitGroupIndex, /// sbtRecordStride?
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ CurrentTime,
+ __hitObjectAttributesLocation(__hitObjectAttributes<attr_t>()));
+
+ return hitObj;
+ }
+
/// Creates a HitObject representing a hit based on values explicitly passed as arguments, without
/// tracing a ray. The primitive specified by AccelerationStructure, InstanceIndex, GeometryIndex,
/// and PrimitiveIndex must exist. The shader table index is explicitly provided as an argument
@@ -5644,9 +5838,9 @@ struct HitObject
attr_t attributes)
{
HitObject hitObj;
- __makeHitWithRecordIndex(
- HitGroupRecordIndex,
- AccelerationStructure,
+ __hlslMakeHitWithRecordIndex(
+ HitGroupRecordIndex,
+ AccelerationStructure,
InstanceIndex,
GeometryIndex,
PrimitiveIndex,
@@ -5657,81 +5851,221 @@ struct HitObject
return hitObj;
}
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeHit<attr_t>(
+ uint HitGroupRecordIndex,
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ RayDesc Ray,
+ attr_t attributes)
+ {
+ HitObject hitObj;
+
+ // Save the attributes
+ __ref attr_t attr = __hitObjectAttributes<attr_t>();
+ attr = attributes;
+
+ __glslMakeHitWithIndex(hitObj,
+ AccelerationStructure,
+ InstanceIndex, ///? Same as instanceid ?
+ GeometryIndex,
+ PrimitiveIndex,
+ HitKind, /// Assuming HitKinds are compatible
+ HitGroupRecordIndex, /// sbtRecordIndex
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ __hitObjectAttributesLocation(__hitObjectAttributes<attr_t>()));
+
+ return hitObj;
+ }
+
+ /// See MakeHit but handles Motion
+ /// Currently only supported on VK
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeMotionHit<attr_t>(
+ uint HitGroupRecordIndex,
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ RayDesc Ray,
+ float CurrentTime,
+ attr_t attributes)
+ {
+ HitObject hitObj;
+
+ // Save the attributes
+ __ref attr_t attr = __hitObjectAttributes<attr_t>();
+ attr = attributes;
+
+ __glslMakeMotionHitWithIndex(hitObj,
+ AccelerationStructure,
+ InstanceIndex, ///? Same as instanceid ?
+ GeometryIndex,
+ PrimitiveIndex,
+ HitKind, /// Assuming HitKinds are compatible
+ HitGroupRecordIndex, /// sbtRecordIndex
+ Ray.Origin,
+ Ray.TMin,
+ Ray.Direction,
+ Ray.TMax,
+ CurrentTime,
+ __hitObjectAttributesLocation(__hitObjectAttributes<attr_t>()));
+
+ return hitObj;
+ }
+
/// Creates a HitObject representing a miss based on values explicitly passed as arguments, without
/// tracing a ray. The provided shader table index must reference a valid miss record in the shader
/// table.
- __target_intrinsic(hlsl, "NvMakeMiss")
[__requiresNVAPI]
- static HitObject MakeMiss(
- uint MissShaderIndex,
+ __target_intrinsic(hlsl, "NvMakeMiss")
+ static HitObject MakeMiss(
+ uint MissShaderIndex,
RayDesc Ray);
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeMiss(
+ uint MissShaderIndex,
+ RayDesc Ray)
+ {
+ HitObject hitObj;
+ __glslMakeMiss(hitObj, MissShaderIndex, Ray.Origin, Ray.TMin, Ray.Direction, Ray.TMax);
+ return hitObj;
+ }
+
+ /// See MakeMiss but handles Motion
+ /// Currently only supported on VK
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeMotionMiss(
+ uint MissShaderIndex,
+ RayDesc Ray,
+ float CurrentTime)
+ {
+ HitObject hitObj;
+ __glslMakeMotionMiss(hitObj, MissShaderIndex, Ray.Origin, Ray.TMin, Ray.Direction, Ray.TMax, CurrentTime);
+ return hitObj;
+ }
+
/// Creates a HitObject representing “NOP” (no operation) which is neither a hit nor a miss. Invoking a
/// NOP hit object using HitObject::Invoke has no effect. Reordering by hit objects using
/// ReorderThread will group NOP hit objects together. This can be useful in some reordering
/// scenarios where future control flow for some threads is known to process neither a hit nor a
/// miss.
- __target_intrinsic(hlsl, "NvMakeNop")
[__requiresNVAPI]
+ __target_intrinsic(hlsl, "NvMakeNop")
static HitObject MakeNop();
+ [ForceInline]
+ __specialized_for_target(glsl)
+ static HitObject MakeNop()
+ {
+ HitObject hitObj;
+ __glslMakeNop(hitObj);
+ return hitObj;
+ }
+
/// Invokes closesthit or miss shading for the specified hit object. In case of a NOP HitObject, no
/// shader is invoked.
- __target_intrinsic(hlsl, "NvInvokeHitObject")
[__requiresNVAPI]
+ __target_intrinsic(hlsl, "NvInvokeHitObject")
static void Invoke<payload_t>(
RaytracingAccelerationStructure AccelerationStructure,
HitObject HitOrMiss,
inout payload_t Payload);
+ __specialized_for_target(glsl)
+ static void Invoke<payload_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ HitObject HitOrMiss,
+ inout payload_t Payload)
+ {
+ [__vulkanRayPayload]
+ static payload_t p;
+
+ // Save the payload
+ p = Payload;
+
+ __glslInvoke(HitOrMiss, __rayPayloadLocation(p));
+
+ // Write payload result
+ Payload = p;
+ }
+
/// Returns true if the HitObject encodes a miss, otherwise returns false.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectIsMissNV($0)")
bool IsMiss();
/// Returns true if the HitObject encodes a hit, otherwise returns false.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectIsHitNV($0)")
bool IsHit();
/// Returns true if the HitObject encodes a nop, otherwise returns false.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectIsEmptyNV($0)")
bool IsNop();
/// Queries ray properties from HitObject. Valid if the hit object represents a hit or a miss.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
RayDesc GetRayDesc();
+ __specialized_for_target(glsl)
+ RayDesc GetRayDesc()
+ {
+ RayDesc ray = { __glslGetRayWorldOrigin(), __glslGetTMin(), __glslGetRayDirection(), __glslGetTMax() };
+ return ray;
+ }
+
/// Queries shader table index from HitObject. Valid if the hit object represents a hit or a miss.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetShaderBindingTableRecordIndexNV($0)")
uint GetShaderTableIndex();
/// Returns the instance index of a hit. Valid if the hit object represents a hit.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetInstanceCustomIndexNV($0)")
uint GetInstanceIndex();
/// Returns the instance ID of a hit. Valid if the hit object represents a hit.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetInstanceIdNV($0)")
uint GetInstanceID();
/// Returns the geometry index of a hit. Valid if the hit object represents a hit.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetGeometryIndexNV($0)")
uint GetGeometryIndex();
/// Returns the primitive index of a hit. Valid if the hit object represents a hit.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetPrimitiveIndexNV($0)")
uint GetPrimitiveIndex();
/// Returns the hit kind. Valid if the hit object represents a hit.
- __target_intrinsic(hlsl)
[__requiresNVAPI]
+ __target_intrinsic(hlsl)
+ __target_intrinsic(glsl, "hitObjectGetHitKindNV($0)")
uint GetHitKind();
/// Returns the attributes of a hit. Valid if the hit object represents a hit or a miss.
@@ -5739,61 +6073,245 @@ struct HitObject
attr_t GetAttributes<attr_t>()
{
attr_t v;
- __getAttributesFromHitObject(v);
+ __hlslGetAttributesFromHitObject(v);
return v;
}
+ __specialized_for_target(glsl)
+ attr_t GetAttributes<attr_t>()
+ {
+ // Work out the location
+ int attributeLocation = __hitObjectAttributesLocation(__hitObjectAttributes<attr_t>());
+
+ // Load the attributes from the location
+ __glslGetAttributes(attributeLocation);
+
+ // Return the attributes
+ return __hitObjectAttributes<attr_t>();
+ }
/// Loads a root constant from the local root table referenced by the hit object. Valid if the hit object
/// represents a hit or a miss. RootConstantOffsetInBytes must be a multiple of 4.
__target_intrinsic(hlsl)
[__requiresNVAPI]
uint LoadLocalRootTableConstant(uint RootConstantOffsetInBytes);
- ///
- /// !!!! Internal impl. Do not use!
- ///
+ ///
+ /// !!!! Internal NVAPI HLSL impl. Not part of interface! !!!!!!!!!!!!
+ ///
__target_intrinsic(hlsl, "NvGetAttributesFromHitObject($0, $1)")
[__requiresNVAPI]
- void __getAttributesFromHitObject<T>(out T t);
+ void __hlslGetAttributesFromHitObject<T>(out T t);
__target_intrinsic(hlsl, "NvMakeHitWithRecordIndex")
[__requiresNVAPI]
- static void __makeHitWithRecordIndex<attr_t>(uint HitGroupRecordIndex,
- RaytracingAccelerationStructure AccelerationStructure,
- uint InstanceIndex,
- uint GeometryIndex,
- uint PrimitiveIndex,
- uint HitKind,
- RayDesc Ray,
- attr_t attributes,
+ static void __hlslMakeHitWithRecordIndex<attr_t>(uint HitGroupRecordIndex,
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ RayDesc Ray,
+ attr_t attributes,
out HitObject hitObj);
__target_intrinsic(hlsl, "NvMakeHit")
[__requiresNVAPI]
- static void __makeHit<attr_t>(RaytracingAccelerationStructure AccelerationStructure,
- uint InstanceIndex,
- uint GeometryIndex,
- uint PrimitiveIndex,
- uint HitKind,
- uint RayContributionToHitGroupIndex,
- uint MultiplierForGeometryContributionToHitGroupIndex,
- RayDesc Ray,
- attr_t attributes,
+ static void __hlslMakeHit<attr_t>(RaytracingAccelerationStructure AccelerationStructure,
+ uint InstanceIndex,
+ uint GeometryIndex,
+ uint PrimitiveIndex,
+ uint HitKind,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ RayDesc Ray,
+ attr_t attributes,
out HitObject hitObj);
__target_intrinsic(hlsl, "NvTraceRayHitObject")
[__requiresNVAPI]
- static void __traceRay<payload_t>(
- RaytracingAccelerationStructure AccelerationStructure,
- uint RayFlags,
- uint InstanceInclusionMask,
- uint RayContributionToHitGroupIndex,
- uint MultiplierForGeometryContributionToHitGroupIndex,
- uint MissShaderIndex,
- RayDesc Ray,
+ static void __hlslTraceRay<payload_t>(
+ RaytracingAccelerationStructure AccelerationStructure,
+ uint RayFlags,
+ uint InstanceInclusionMask,
+ uint RayContributionToHitGroupIndex,
+ uint MultiplierForGeometryContributionToHitGroupIndex,
+ uint MissShaderIndex,
+ RayDesc Ray,
inout payload_t Payload,
out HitObject hitObj);
+
+ ///
+ /// !!!! Internal GLSL GL_NV_shader_invocation_reorder impl. Not part of interface! !!!!!!!!!!!!
+ ///
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GL_EXT_ray_tracing)
+ __target_intrinsic(glsl, "hitObjectRecordMissNV")
+ static void __glslMakeMiss(
+ HitObject hitObj,
+ uint MissShaderIndex,
+ float3 Origin,
+ float TMin,
+ float3 Direction,
+ float TMax);
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GLSL_NV_ray_tracing_motion_blur)
+ __target_intrinsic(glsl, "hitObjectRecordMissNV")
+ static void __glslMakeMotionMiss(
+ HitObject hitObj,
+ uint MissShaderIndex,
+ float3 Origin,
+ float TMin,
+ float3 Direction,
+ float TMax,
+ float CurrentTime);
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GL_EXT_ray_tracing)
+ __target_intrinsic(glsl, "hitObjectRecordEmptyNV($0)")
+ static void __glslMakeNop(HitObject hitObj);
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectGetObjectRayDirectionNV($0)")
+ float3 __glslGetRayDirection();
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectGetWorldRayOriginNV($0)")
+ float3 __glslGetRayWorldOrigin();
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectGetRayTMaxNV($0)")
+ float __glslGetTMax();
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectGetRayTMinNV($0)")
+ float __glslGetTMin();
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GL_EXT_ray_tracing)
+ __target_intrinsic(glsl, "hitObjectRecordHitWithIndexNV")
+ static void __glslMakeHitWithIndex(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint instanceid,
+ uint primitiveid,
+ uint geometryindex,
+ uint hitKind,
+ uint sbtRecordIndex,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ int attributeLocation);
+
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GLSL_NV_ray_tracing_motion_blur)
+ __target_intrinsic(glsl, "hitObjectRecordHitWithIndexMotionNV ")
+ static void __glslMakeMotionHitWithIndex(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint instanceid,
+ uint primitiveid,
+ uint geometryindex,
+ uint hitKind,
+ uint sbtRecordIndex,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ float CurrentTime,
+ int attributeLocation);
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectRecordHitNV")
+ static void __glslMakeHit(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint instanceid,
+ uint primitiveid,
+ uint geometryindex,
+ uint hitKind,
+ uint sbtRecordOffset,
+ uint sbtRecordStride,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ int attributeLocation);
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GLSL_NV_ray_tracing_motion_blur)
+ __target_intrinsic(glsl, "hitObjectRecordHitMotionNV")
+ static void __glslMakeMotionHit(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint instanceid,
+ uint primitiveid,
+ uint geometryindex,
+ uint hitKind,
+ uint sbtRecordOffset,
+ uint sbtRecordStride,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ float CurrentTime,
+ int attributeLocation);
+
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectGetAttributesNV($0, $1)")
+ void __glslGetAttributes(int attributeLocation);
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectTraceRayNV")
+ static void __glslTraceRay(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint rayFlags,
+ uint cullMask,
+ uint sbtRecordOffset,
+ uint sbtRecordStride,
+ uint missIndex,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ int payload);
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __glsl_extension(GLSL_NV_ray_tracing_motion_blur)
+ __target_intrinsic(glsl, "hitObjectTraceRayMotionNV")
+ static void __glslTraceMotionRay(
+ HitObject hitObj,
+ RaytracingAccelerationStructure accelerationStructure,
+ uint rayFlags,
+ uint cullMask,
+ uint sbtRecordOffset,
+ uint sbtRecordStride,
+ uint missIndex,
+ float3 origin,
+ float Tmin,
+ float3 direction,
+ float Tmax,
+ float currentTime,
+ int payload);
+
+ __glsl_extension(GL_EXT_ray_tracing)
+ __glsl_extension(GL_NV_shader_invocation_reorder)
+ __target_intrinsic(glsl, "hitObjectExecuteShaderNV")
+ static void __glslInvoke(
+ HitObject hitObj,
+ int payload);
};
/// Reorders threads based on a coherence hint value. NumCoherenceHintBits indicates how many of
@@ -5803,8 +6321,11 @@ struct HitObject
/// NumCoherenceHintBits.
/// Where possible, reordering will also attempt to retain locality in the thread’s launch indices
/// (DispatchRaysIndex in DXR).
-__target_intrinsic(hlsl, "NvReorderThread")
[__requiresNVAPI]
+__target_intrinsic(hlsl, "NvReorderThread")
+__glsl_extension(GL_NV_shader_invocation_reorder)
+__glsl_extension(GL_EXT_ray_tracing)
+__target_intrinsic(glsl, "reorderThreadNV")
void ReorderThread( uint CoherenceHint, uint NumCoherenceHintBitsFromLSB );
/// Reorders threads based on a hit object, optionally extended by a coherence hint value. Coherence
@@ -5822,8 +6343,11 @@ void ReorderThread( uint CoherenceHint, uint NumCoherenceHintBitsFromLSB );
/// same shader ID. (Miss shaders and NOP HitObjects are grouped separately). Within each of these
/// groups, it will attempt to order threads by the value of their coherence hints. And within ranges
/// of equal coherence hints, it will attempt to maximize locality in 3D space of the ray hit (if any).
-__target_intrinsic(hlsl, "NvReorderThread")
[__requiresNVAPI]
+__target_intrinsic(hlsl, "NvReorderThread")
+__glsl_extension(GL_NV_shader_invocation_reorder)
+__glsl_extension(GL_EXT_ray_tracing)
+__target_intrinsic(glsl, "reorderThreadNV")
void ReorderThread( HitObject HitOrMiss, uint CoherenceHint, uint NumCoherenceHintBitsFromLSB );
/// Is equivalent to
@@ -5833,4 +6357,6 @@ void ReorderThread( HitObject HitOrMiss, uint CoherenceHint, uint NumCoherenceHi
/// With CoherenceHint and NumCoherenceHintBitsFromLSB as 0, meaning they are ignored.
[__requiresNVAPI]
__target_intrinsic(hlsl, "NvReorderThread")
+__glsl_extension(GL_NV_shader_invocation_reorder)
+__target_intrinsic(glsl, "reorderThreadNV")
void ReorderThread( HitObject HitOrMiss );
diff --git a/source/slang/slang-ast-modifier.h b/source/slang/slang-ast-modifier.h
index 8419facce..9146c21d9 100644
--- a/source/slang/slang-ast-modifier.h
+++ b/source/slang/slang-ast-modifier.h
@@ -829,6 +829,16 @@ class VulkanHitAttributesAttribute : public Attribute
SLANG_AST_CLASS(VulkanHitAttributesAttribute)
};
+// A `[__vulkanHitObjectAttributes(location)]` attribute, which is used in the
+// standard library implementation to indicate that a variable
+// actually represents the attributes on a HitObject as part of
+// Shader ExecutionReordering
+class VulkanHitObjectAttributesAttribute : public Attribute
+{
+ SLANG_AST_CLASS(VulkanHitObjectAttributesAttribute)
+
+ int location;
+};
// A `[mutating]` attribute, which indicates that a member
// function is allowed to modify things through its `this`
diff --git a/source/slang/slang-check-modifier.cpp b/source/slang/slang-check-modifier.cpp
index b8ac21e2d..aa28571a7 100644
--- a/source/slang/slang-check-modifier.cpp
+++ b/source/slang/slang-check-modifier.cpp
@@ -604,6 +604,15 @@ namespace Slang
callablePayloadAttr->location = (int32_t)val->value;
}
+ else if (auto hitObjectAttributesAttr = as<VulkanHitObjectAttributesAttribute>(attr))
+ {
+ SLANG_ASSERT(attr->args.getCount() == 1);
+ auto val = checkConstantIntVal(attr->args[0]);
+
+ if (!val) return false;
+
+ hitObjectAttributesAttr->location = (int32_t)val->value;
+ }
else if (auto forwardDerivativeAttr = as<ForwardDerivativeAttribute>(attr))
{
SLANG_ASSERT(attr->args.getCount() == 1);
diff --git a/source/slang/slang-compiler.h b/source/slang/slang-compiler.h
index eb6d6c1a5..14ac63531 100755
--- a/source/slang/slang-compiler.h
+++ b/source/slang/slang-compiler.h
@@ -2267,7 +2267,7 @@ namespace Slang
///
ProgramLayout* getOrCreateLayout(DiagnosticSink* sink);
- /// Get the layout for the program on the taarget.
+ /// Get the layout for the program on the target.
///
/// This routine assumes that `getOrCreateLayout`
/// has already been called previously.
diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp
index 09a18a31c..e872bffb1 100644
--- a/source/slang/slang-emit-c-like.cpp
+++ b/source/slang/slang-emit-c-like.cpp
@@ -41,6 +41,56 @@ struct CLikeSourceEmitter::ComputeEmitActionsContext
List<EmitAction>* actions;
};
+/* !!!!!!!!!!!!!!!!!!!!!!!!!!!! LocationTracker !!!!!!!!!!!!!!!!!!!!!!!!!! */
+
+/* static */LocationTracker::Kind LocationTracker::getKindFromDecoration(IRDecoration* decoration)
+{
+ switch (decoration->getOp())
+ {
+ case kIROp_VulkanRayPayloadDecoration: return Kind::RayPayload;
+ case kIROp_VulkanCallablePayloadDecoration: return Kind::CallablePayload;
+ case kIROp_VulkanHitObjectAttributesDecoration: return Kind::HitObjectAttribute;
+ default: break;
+ }
+ return Kind::Invalid;
+}
+
+Index LocationTracker::getValue(IRInst* inst, IRDecoration* decoration)
+{
+ const Kind kind = getKindFromDecoration(decoration);
+ SLANG_RELEASE_ASSERT(kind != Kind::Invalid);
+ if (kind == Kind::Invalid)
+ {
+ return -1;
+ }
+
+ return getValue(kind, inst, decoration);
+}
+
+Index LocationTracker::getValue(Kind kind, IRInst* inst, IRDecoration* decoration)
+{
+ if (decoration->getOperandCount() > 0)
+ {
+ // TODO(JS):
+ // There could be a clash with the auto generated location, and the user set value/
+ // Perhaps the implication in practice is that either all are marked or none.
+ const int explicitLocation = int(getIntVal(decoration->getOperand(0)));
+ if (explicitLocation >= 0)
+ return UInt(explicitLocation);
+ }
+
+ auto& nextValue = m_nextValueForKind[Index(kind)];
+
+ const Location defaultLocation{kind, nextValue};
+ const Location foundLocation = m_mapIRToLocations.GetOrAddValue(inst, defaultLocation);
+
+ // Increase if it was the default
+ nextValue += Index(defaultLocation == foundLocation);
+
+ // Has to match the kind
+ return (foundLocation.kind == kind) ? foundLocation.value : -1;
+}
+
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!! CLikeSourceEmitter !!!!!!!!!!!!!!!!!!!!!!!!!! */
/* static */SourceLanguage CLikeSourceEmitter::getSourceLanguage(CodeGenTarget target)
@@ -3009,46 +3059,6 @@ void CLikeSourceEmitter::emitInterpolationModifiers(IRInst* varInst, IRType* val
emitInterpolationModifiersImpl(varInst, valueType, layout);
}
-UInt CLikeSourceEmitter::getRayPayloadLocation(IRInst* inst)
-{
- if (auto rayPayloadDecoration = inst->findDecoration<IRVulkanRayPayloadDecoration>())
- {
- int explicitLocation = int(getIntVal(rayPayloadDecoration->getOperand(0)));
-
- if (explicitLocation >= 0)
- return UInt(explicitLocation);
- }
-
- auto& map = m_mapIRValueToRayPayloadLocation;
- UInt value = 0;
- if(map.TryGetValue(inst, value))
- return value;
-
- value = map.Count();
- map.Add(inst, value);
- return value;
-}
-
-UInt CLikeSourceEmitter::getCallablePayloadLocation(IRInst* inst)
-{
- if (auto callablePayloadDecoration = inst->findDecoration<IRVulkanCallablePayloadDecoration>())
- {
- int explicitLocation = int(getIntVal(callablePayloadDecoration->getOperand(0)));
-
- if (explicitLocation >= 0)
- return UInt(explicitLocation);
- }
-
- auto& map = m_mapIRValueToCallablePayloadLocation;
- UInt value = 0;
- if(map.TryGetValue(inst, value))
- return value;
-
- value = map.Count();
- map.Add(inst, value);
- return value;
-}
-
/// Emit modifiers that should apply even for a declaration of an SSA temporary.
void CLikeSourceEmitter::emitTempModifiers(IRInst* temp)
{
diff --git a/source/slang/slang-emit-c-like.h b/source/slang/slang-emit-c-like.h
index d85e336e0..e702dbf01 100644
--- a/source/slang/slang-emit-c-like.h
+++ b/source/slang/slang-emit-c-like.h
@@ -17,6 +17,48 @@
namespace Slang
{
+class LocationTracker
+{
+public:
+ enum class Kind
+ {
+ Invalid = -1,
+ RayPayload, ///< GLSL rayPayload
+ CallablePayload, ///< GLSL callableData
+ HitObjectAttribute, ///< GLSL hitObjectAttribute
+ CountOf,
+ };
+
+ /// Given a decoration returns the Kind, or Kind::Invalid if that is not appropriate
+ static Kind getKindFromDecoration(IRDecoration* decoration);
+
+ /// Get the location value associated with inst (and decoration).
+ /// Will return -1, if no location is associated
+ Index getValue(IRInst* inst, IRDecoration* decoration);
+
+ /// Get the location value associated with inst (and decoration).
+ /// The kind must match that for the decoration.
+ /// Will return -1, if no location is associated
+ Index getValue(Kind kind, IRInst* inst, IRDecoration* decoration);
+
+protected:
+ struct Location
+ {
+ typedef Location ThisType;
+
+ bool operator==(const ThisType& rhs) const { return kind == rhs.kind && value == rhs.value; }
+ bool operator!=(const ThisType& rhs) const { return !(*this == rhs); }
+
+ Kind kind; ///< The kind of location
+ Index value; ///< The value of the location. Must be >= 0
+ };
+
+ Index m_nextValueForKind[Count(Kind::CountOf)] = { 0, };
+
+ Dictionary<IRInst*, Location> m_mapIRToLocations;
+};
+
+
class CLikeSourceEmitter: public SourceEmitterBase
{
public:
@@ -201,6 +243,8 @@ public:
{}
};
+
+
/// Must be called before used
virtual SlangResult init();
@@ -233,6 +277,8 @@ public:
ComponentType* getProgram() { return m_codeGenContext->getProgram(); }
TargetProgram* getTargetProgram() { return m_codeGenContext->getTargetProgram(); }
+ LocationTracker& getLocationTracker() { return m_locationTracker; }
+
//
// Types
//
@@ -357,16 +403,12 @@ public:
void emitStruct(IRStructType* structType);
void emitClass(IRClassType* structType);
-
-
/// Emit type attributes that should appear after, e.g., a `struct` keyword
void emitPostKeywordTypeAttributes(IRInst* inst) { emitPostKeywordTypeAttributesImpl(inst); }
void emitInterpolationModifiers(IRInst* varInst, IRType* valueType, IRVarLayout* layout);
- UInt getRayPayloadLocation(IRInst* inst);
-
- UInt getCallablePayloadLocation(IRInst* inst);
+
/// Emit modifiers that should apply even for a declaration of an SSA temporary.
virtual void emitTempModifiers(IRInst* temp);
@@ -540,8 +582,9 @@ public:
// to use for it when emitting code.
Dictionary<IRInst*, String> m_mapInstToName;
- Dictionary<IRInst*, UInt> m_mapIRValueToRayPayloadLocation;
- Dictionary<IRInst*, UInt> m_mapIRValueToCallablePayloadLocation;
+ // Maps instructions to locations. Used for GLSL output for locations, but could potentially
+ // be used for other kinds of location.
+ LocationTracker m_locationTracker;
};
}
diff --git a/source/slang/slang-emit-glsl.cpp b/source/slang/slang-emit-glsl.cpp
index 48dcd21f7..e187f5e59 100644
--- a/source/slang/slang-emit-glsl.cpp
+++ b/source/slang/slang-emit-glsl.cpp
@@ -2240,45 +2240,62 @@ void GLSLSourceEmitter::emitVarDecorationsImpl(IRInst* varDecl)
// the payload won't automatically get a layout applied
// (it isn't part of the user-visible interface...)
//
- if (varDecl->findDecoration<IRVulkanRayPayloadDecoration>())
- {
- m_writer->emit("layout(location = ");
- m_writer->emit(getRayPayloadLocation(varDecl));
- m_writer->emit(")\n");
- if( getTargetCaps().implies(CapabilityAtom::GL_NV_ray_tracing) )
- {
- m_writer->emit("rayPayloadNV\n");
- }
- else
- {
- m_writer->emit("rayPayloadEXT\n");
- }
- }
- if (varDecl->findDecoration<IRVulkanCallablePayloadDecoration>())
+
+ for (auto decoration : varDecl->getDecorations())
{
- m_writer->emit("layout(location = ");
- m_writer->emit(getCallablePayloadLocation(varDecl));
- m_writer->emit(")\n");
- if( getTargetCaps().implies(CapabilityAtom::GL_NV_ray_tracing) )
+ typedef LocationTracker::Kind LocationKind;
+
+ LocationKind locationKind = LocationKind::Invalid;
+ UnownedStringSlice prefix;
+ if (as<IRVulkanHitAttributesDecoration>(decoration))
{
- m_writer->emit("callableDataNV\n");
+ prefix = toSlice("hitAttribute");
}
else
{
- m_writer->emit("callableDataEXT\n");
+ // Handle attributes that have location
+ const LocationKind decorationLocationKind = LocationTracker::getKindFromDecoration(decoration);
+ if (decorationLocationKind == LocationKind::Invalid)
+ {
+ // Next decoration
+ continue;
+ }
+
+ locationKind = decorationLocationKind;
+
+ // Get the location value
+ const auto locationValue = m_locationTracker.getValue(locationKind, varDecl, decoration);
+
+ m_writer->emit(toSlice("layout(location = "));
+ m_writer->emit(locationValue);
+ m_writer->emit(toSlice(")\n"));
+
+ switch (locationKind)
+ {
+ case LocationKind::CallablePayload: prefix = toSlice("callableData"); break;
+ case LocationKind::HitObjectAttribute: prefix = toSlice("hitObjectAttribute"); break;
+ case LocationKind::RayPayload: prefix = toSlice("rayPayload"); break;
+ default: break;
+ }
}
- }
- if (varDecl->findDecoration<IRVulkanHitAttributesDecoration>())
- {
- if( getTargetCaps().implies(CapabilityAtom::GL_NV_ray_tracing) )
+ SLANG_ASSERT(prefix.getLength());
+ m_writer->emit(prefix);
+
+ // Special case hitObjectAttribute as is only NV currently
+ if (locationKind == LocationKind::HitObjectAttribute ||
+ getTargetCaps().implies(CapabilityAtom::GL_NV_ray_tracing))
{
- m_writer->emit("hitAttributeNV\n");
+ m_writer->emit(toSlice("NV"));
}
else
{
- m_writer->emit("hitAttributeEXT\n");
+ m_writer->emit(toSlice("EXT"));
}
+ m_writer->emit(toSlice("\n"));
+
+ // If we emit a location we are done.
+ break;
}
if (varDecl->findDecoration<IRGloballyCoherentDecoration>())
diff --git a/source/slang/slang-intrinsic-expand.cpp b/source/slang/slang-intrinsic-expand.cpp
index 48186b94a..64ef4e761 100644
--- a/source/slang/slang-intrinsic-expand.cpp
+++ b/source/slang/slang-intrinsic-expand.cpp
@@ -710,46 +710,53 @@ const char* IntrinsicExpandContext::_emitSpecial(const char* cursor)
// shaders.
case 'X':
{
+ typedef LocationTracker::Kind LocationKind;
+
SLANG_RELEASE_ASSERT(*cursor);
- switch (*cursor++)
+ const auto kindChar = *cursor++;
+
+ LocationKind kind = LocationKind::Invalid;
+
+ // The `$XP`/`$XC`/`$XH` case handles looking up
+ // the associated `location` for a variable
+ // used as the argument.
+ switch (kindChar)
{
- case 'P':
- {
- // The `$XP` case handles looking up
- // the associated `location` for a variable
- // used as the argument ray payload at a
- // trace call site.
-
- Index argIndex = 0;
- SLANG_RELEASE_ASSERT(m_argCount > argIndex);
- auto arg = m_args[argIndex].get();
- auto argLoad = as<IRLoad>(arg);
- SLANG_RELEASE_ASSERT(argLoad);
- auto argVar = argLoad->getOperand(0);
- m_writer->emit(m_emitter->getRayPayloadLocation(argVar));
- }
- break;
+ case 'P': kind = LocationKind::RayPayload; break;
+ case 'C': kind = LocationKind::CallablePayload; break;
+ case 'H': kind = LocationKind::HitObjectAttribute; break;
+ default: break;
+ }
- case 'C':
+ SLANG_ASSERT(kind != LocationKind::Invalid);
+
+ if (kind != LocationKind::Invalid)
+ {
+ Index argIndex = 0;
+ SLANG_RELEASE_ASSERT(m_argCount > argIndex);
+ auto arg = m_args[argIndex].get();
+ auto argLoad = as<IRLoad>(arg);
+ SLANG_RELEASE_ASSERT(argLoad);
+
+ auto argVar = argLoad->getOperand(0);
+
+ // Find the associated decoration
+ IRDecoration* foundDecoration = nullptr;
+ for (auto decoration : argVar->getDecorations())
{
- // The `$XC` case handles looking up
- // the associated `location` for a variable
- // used as the argument callable payload at a
- // call site.
-
- Index argIndex = 0;
- SLANG_RELEASE_ASSERT(m_argCount > argIndex);
- auto arg = m_args[argIndex].get();
- auto argLoad = as<IRLoad>(arg);
- SLANG_RELEASE_ASSERT(argLoad);
- auto argVar = argLoad->getOperand(0);
- m_writer->emit(m_emitter->getCallablePayloadLocation(argVar));
+ const auto curKind = LocationTracker::getKindFromDecoration(decoration);
+ if (curKind == kind)
+ {
+ foundDecoration = decoration;
+ break;
+ }
}
- break;
- default:
- SLANG_RELEASE_ASSERT(false);
- break;
+ // Must have found the decoration
+ SLANG_ASSERT(foundDecoration);
+
+ const auto location = m_emitter->getLocationTracker().getValue(kind, argVar, foundDecoration);
+ m_writer->emit(location);
}
}
break;
diff --git a/source/slang/slang-ir-inst-defs.h b/source/slang/slang-ir-inst-defs.h
index 51811f59e..9f3111b87 100644
--- a/source/slang/slang-ir-inst-defs.h
+++ b/source/slang/slang-ir-inst-defs.h
@@ -586,6 +586,8 @@ INST(HighLevelDeclDecoration, highLevelDecl, 1, 0)
INST(VulkanRayPayloadDecoration, vulkanRayPayload, 0, 0)
INST(VulkanHitAttributesDecoration, vulkanHitAttributes, 0, 0)
+ INST(VulkanHitObjectAttributesDecoration, vulkanHitObjectAttributes, 0, 0)
+
INST(RequireSPIRVVersionDecoration, requireSPIRVVersion, 1, 0)
INST(RequireGLSLVersionDecoration, requireGLSLVersion, 1, 0)
INST(RequireGLSLExtensionDecoration, requireGLSLExtension, 1, 0)
diff --git a/source/slang/slang-ir-insts.h b/source/slang/slang-ir-insts.h
index 5eea12de8..f5c3d10ae 100644
--- a/source/slang/slang-ir-insts.h
+++ b/source/slang/slang-ir-insts.h
@@ -239,6 +239,11 @@ IR_SIMPLE_DECORATION(VulkanCallablePayloadDecoration)
/// to it.
IR_SIMPLE_DECORATION(VulkanHitAttributesDecoration)
+/// A decoration that indicates that a variable represents
+/// vulkan hit object attributes, and should have a location assigned
+/// to it.
+IR_SIMPLE_DECORATION(VulkanHitObjectAttributesDecoration)
+
struct IRRequireGLSLVersionDecoration : IRDecoration
{
enum { kOp = kIROp_RequireGLSLVersionDecoration };
@@ -3358,6 +3363,12 @@ public:
{
addDecoration(inst, kIROp_VulkanCallablePayloadDecoration, getIntValue(getIntType(), location));
}
+
+ void addVulkanHitObjectAttributesDecoration(IRInst* inst, int location)
+ {
+ addDecoration(inst, kIROp_VulkanHitObjectAttributesDecoration, getIntValue(getIntType(), location));
+ }
+
};
void addHoistableInst(
diff --git a/source/slang/slang-ir.cpp b/source/slang/slang-ir.cpp
index 6112beaf2..7aa51f31b 100644
--- a/source/slang/slang-ir.cpp
+++ b/source/slang/slang-ir.cpp
@@ -48,6 +48,7 @@ namespace Slang
case kIROp_VulkanCallablePayloadDecoration:
case kIROp_VulkanHitAttributesDecoration:
case kIROp_VulkanRayPayloadDecoration:
+ case kIROp_VulkanHitObjectAttributesDecoration:
{
return true;
}
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp
index a0158cf38..cf3781415 100644
--- a/source/slang/slang-lower-to-ir.cpp
+++ b/source/slang/slang-lower-to-ir.cpp
@@ -2115,7 +2115,11 @@ void addVarDecorations(
{
builder->addVulkanCallablePayloadDecoration(inst, callablePayloadAttr->location);
}
- else if(as<VulkanHitAttributesAttribute>(mod))
+ else if (auto hitObjectAttr = as<VulkanHitObjectAttributesAttribute>(mod))
+ {
+ builder->addVulkanHitObjectAttributesDecoration(inst, hitObjectAttr->location);
+ }
+ else if (as<VulkanHitAttributesAttribute>(mod))
{
builder->addSimpleDecoration<IRVulkanHitAttributesDecoration>(inst);
}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang
new file mode 100644
index 000000000..79b8411b0
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang
@@ -0,0 +1,100 @@
+// hit-object-array.slang
+
+//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+
+/* This doesn't work correctly currently because it produces assignments to the HitObject array in GLSL output.
+But that is not valid for hitObjectNV int he extension */
+
+//DISABLE_TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
+
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
+
+//TEST_INPUT: set scene = AccelerationStructure
+uniform RaytracingAccelerationStructure scene;
+
+//TEST_INPUT:set outputBuffer = out ubuffer(data=[0, 0, 0, 0], stride=4)
+RWStructuredBuffer<uint> outputBuffer;
+
+struct SomeValues
+{
+ int a;
+ float b;
+};
+
+uint calcValue(HitObject hit)
+{
+ uint r = 0;
+
+ if (hit.IsHit())
+ {
+ uint instanceIndex = hit.GetInstanceIndex();
+ uint instanceID = hit.GetInstanceID();
+ uint geometryIndex = hit.GetGeometryIndex();
+ uint primitiveIndex = hit.GetPrimitiveIndex();
+ uint hitKind = hit.GetHitKind();
+
+ r += hitKind;
+ r += instanceIndex;
+ r += instanceID;
+ r += geometryIndex;
+ r += primitiveIndex;
+
+ RayDesc ray = hit.GetRayDesc();
+
+ r += uint(ray.TMin > 0);
+ r += uint(ray.TMax < ray.TMin);
+
+ SomeValues objSomeValues = hit.GetAttributes<SomeValues>();
+
+ r += objSomeValues.a;
+ }
+ else if (hit.IsMiss())
+ {
+ r += 1;
+ }
+
+ return r;
+}
+
+void rayGenerationMain()
+{
+ int2 launchID = int2(DispatchRaysIndex().xy);
+ int2 launchSize = int2(DispatchRaysDimensions().xy);
+
+ int idx = launchID.x;
+
+ SomeValues someValues = { idx, idx * 2.0f };
+
+ RayDesc ray;
+ ray.Origin = float3(idx, 0, 0);
+ ray.TMin = 0.01f;
+ ray.Direction = float3(0, 1, 0);
+ ray.TMax = 1e4f;
+
+ uint hitKind = 0;
+
+ HitObject hitObjs[2];
+
+ hitObjs[0] = HitObject::MakeHit(0, scene, idx, idx * 2, idx * 3, hitKind, ray, someValues);
+
+ {
+ int rayContributionToHitGroupIndex = 0;
+ int multiplierForGeometryContributionToHitGroupIndex = 4;
+
+ hitObjs[1] = HitObject::MakeHit(scene,
+ idx,
+ idx * 2,
+ idx * 3,
+ hitKind,
+ rayContributionToHitGroupIndex,
+ multiplierForGeometryContributionToHitGroupIndex,
+ ray,
+ someValues);
+ }
+
+
+ uint r = calcValue(hitObjs[0]) + calcValue(hitObjs[1]);
+
+ outputBuffer[idx] = r;
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected
new file mode 100644
index 000000000..fdc5cf0d7
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected
@@ -0,0 +1,439 @@
+result code = 0
+standard error = {
+}
+standard output = {
+;
+; Note: shader requires additional functionality:
+; UAVs at every shader stage
+;
+; shader hash: 1376fe501fef02e2587aacc2b18e252f
+;
+; Buffer Definitions:
+;
+; Resource bind info for g_NvidiaExt
+; {
+;
+; struct struct.NvShaderExtnStruct
+; {
+;
+; uint opcode; ; Offset: 0
+; uint rid; ; Offset: 4
+; uint sid; ; Offset: 8
+; uint4 dst1u; ; Offset: 12
+; uint4 src3u; ; Offset: 28
+; uint4 src4u; ; Offset: 44
+; uint4 src5u; ; Offset: 60
+; uint4 src0u; ; Offset: 76
+; uint4 src1u; ; Offset: 92
+; uint4 src2u; ; Offset: 108
+; uint4 dst0u; ; Offset: 124
+; uint markUavRef; ; Offset: 140
+; uint numOutputsForIncCounter; ; Offset: 144
+; float padding1[27]; ; Offset: 148
+;
+; } $Element; ; Offset: 0 Size: 256
+;
+; }
+;
+; Resource bind info for outputBuffer_0
+; {
+;
+; uint $Element; ; Offset: 0 Size: 4
+;
+; }
+;
+;
+; Resource Bindings:
+;
+; Name Type Format Dim ID HLSL Bind Count
+; ------------------------------ ---------- ------- ----------- ------- -------------- ------
+; scene_0 texture i32 ras T0 t0 1
+; g_NvidiaExt UAV struct r/w+cnt U0 u0 1
+; outputBuffer_0 UAV struct r/w U1 u1 1
+;
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxil-ms-dx"
+
+%"class.RWStructuredBuffer<NvShaderExtnStruct>" = type { %struct.NvShaderExtnStruct }
+%struct.NvShaderExtnStruct = type { i32, i32, i32, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, i32, i32, [27 x float] }
+%struct.RaytracingAccelerationStructure = type { i32 }
+%"class.RWStructuredBuffer<unsigned int>" = type { i32 }
+%struct.SomeValues_0 = type { i32, float }
+%struct.NvHitObjectMacroDummyPayloadType = type { i32 }
+%dx.types.Handle = type { i8* }
+
+@"\01?g_NvidiaExt@@3V?$RWStructuredBuffer@UNvShaderExtnStruct@@@@A" = external constant %"class.RWStructuredBuffer<NvShaderExtnStruct>", align 4
+@"\01?scene_0@@3URaytracingAccelerationStructure@@A" = external constant %struct.RaytracingAccelerationStructure, align 4
+@"\01?outputBuffer_0@@3V?$RWStructuredBuffer@I@@A" = external constant %"class.RWStructuredBuffer<unsigned int>", align 4
+
+; Function Attrs: nounwind
+define void @"\01?rayGenerationMain@@YAXXZ"() #0 {
+ %1 = load %struct.RaytracingAccelerationStructure, %struct.RaytracingAccelerationStructure* @"\01?scene_0@@3URaytracingAccelerationStructure@@A", align 4, !noalias !18
+ %2 = load %"class.RWStructuredBuffer<unsigned int>", %"class.RWStructuredBuffer<unsigned int>"* @"\01?outputBuffer_0@@3V?$RWStructuredBuffer@I@@A", align 4
+ %3 = load %"class.RWStructuredBuffer<NvShaderExtnStruct>", %"class.RWStructuredBuffer<NvShaderExtnStruct>"* @"\01?g_NvidiaExt@@3V?$RWStructuredBuffer@UNvShaderExtnStruct@@@@A", align 4, !noalias !21
+ %4 = alloca %struct.SomeValues_0, align 8
+ %5 = alloca %struct.SomeValues_0, align 8
+ %6 = alloca %struct.SomeValues_0, align 8
+ %7 = alloca %struct.NvHitObjectMacroDummyPayloadType, align 4
+ %8 = alloca %struct.SomeValues_0, align 8
+ %9 = alloca %struct.NvHitObjectMacroDummyPayloadType, align 4
+ %10 = call i32 @dx.op.dispatchRaysIndex.i32(i32 145, i8 0) ; DispatchRaysIndex(col)
+ %11 = sitofp i32 %10 to float
+ %12 = fmul fast float %11, 2.000000e+00
+ %13 = sitofp i32 %10 to float
+ %14 = mul nsw i32 %10, 3
+ %15 = shl nsw i32 %10, 1
+ %16 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %8, i32 0, i32 0
+ store i32 %10, i32* %16, align 8
+ %17 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %8, i32 0, i32 1
+ store float %12, float* %17, align 4
+ %18 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %19 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %18, i8 1) ; BufferUpdateCounter(uav,inc)
+ %20 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %20, i32 %19, i32 0, i32 69, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %21 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %21, i32 %19, i32 144, i32 2, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %22 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %22, i32 %19, i32 76, i32 %10, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %23 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %23, i32 %19, i32 80, i32 %15, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %24 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %24, i32 %19, i32 84, i32 %14, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %25 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %25, i32 %19, i32 88, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %26 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %26, i32 %19, i32 92, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %27 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %28 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %27, i8 1) ; BufferUpdateCounter(uav,inc)
+ %29 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %30 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %29, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.callShader.struct.SomeValues_0(i32 159, i32 %30, %struct.SomeValues_0* nonnull %8) ; CallShader(ShaderIndex,Parameter)
+ %31 = call %dx.types.Handle @dx.op.createHandleForLib.struct.RaytracingAccelerationStructure(i32 160, %struct.RaytracingAccelerationStructure %1) ; CreateHandleForLib(Resource)
+ call void @dx.op.traceRay.struct.NvHitObjectMacroDummyPayloadType(i32 157, %dx.types.Handle %31, i32 0, i32 0, i32 0, i32 0, i32 %30, float %13, float 0.000000e+00, float 0.000000e+00, float 0x3F847AE140000000, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+04, %struct.NvHitObjectMacroDummyPayloadType* nonnull %9) ; TraceRay(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToShaderIndex,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax,payload)
+ %32 = mul nsw i32 %10, 3
+ %33 = shl nsw i32 %10, 1
+ %34 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %6, i32 0, i32 0
+ store i32 %10, i32* %34, align 8
+ %35 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %6, i32 0, i32 1
+ store float %12, float* %35, align 4
+ %36 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %37 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %36, i8 1) ; BufferUpdateCounter(uav,inc)
+ %38 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %38, i32 %37, i32 0, i32 68, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %39 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %39, i32 %37, i32 144, i32 2, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %40 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %40, i32 %37, i32 76, i32 %10, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %41 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %41, i32 %37, i32 80, i32 %33, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %42 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %42, i32 %37, i32 84, i32 %32, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %43 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %43, i32 %37, i32 88, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %44 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %44, i32 %37, i32 92, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %45 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %45, i32 %37, i32 96, i32 4, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %46 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %47 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %46, i8 1) ; BufferUpdateCounter(uav,inc)
+ %48 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %49 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %48, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.callShader.struct.SomeValues_0(i32 159, i32 %49, %struct.SomeValues_0* nonnull %6) ; CallShader(ShaderIndex,Parameter)
+ %50 = call %dx.types.Handle @dx.op.createHandleForLib.struct.RaytracingAccelerationStructure(i32 160, %struct.RaytracingAccelerationStructure %1) ; CreateHandleForLib(Resource)
+ call void @dx.op.traceRay.struct.NvHitObjectMacroDummyPayloadType(i32 157, %dx.types.Handle %50, i32 0, i32 0, i32 0, i32 0, i32 %49, float %13, float 0.000000e+00, float 0.000000e+00, float 0x3F847AE140000000, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+04, %struct.NvHitObjectMacroDummyPayloadType* nonnull %7) ; TraceRay(AccelerationStructure,RayFlags,InstanceInclusionMask,RayContributionToHitGroupIndex,MultiplierForGeometryContributionToShaderIndex,MissShaderIndex,Origin_X,Origin_Y,Origin_Z,TMin,Direction_X,Direction_Y,Direction_Z,TMax,payload)
+ %51 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %52 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %51, i8 1) ; BufferUpdateCounter(uav,inc)
+ %53 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %53, i32 %52, i32 0, i32 83, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %54 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %54, i32 %52, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %55 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %56 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %55, i8 1) ; BufferUpdateCounter(uav,inc)
+ %57 = icmp eq i32 %56, 0
+ br i1 %57, label %130, label %58
+
+; <label>:58 ; preds = %0
+ %59 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %60 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %59, i8 1) ; BufferUpdateCounter(uav,inc)
+ %61 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %61, i32 %60, i32 0, i32 75, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %62 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %62, i32 %60, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %63 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %64 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %63, i8 1) ; BufferUpdateCounter(uav,inc)
+ %65 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %66 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %65, i8 1) ; BufferUpdateCounter(uav,inc)
+ %67 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %67, i32 %66, i32 0, i32 74, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %68 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %68, i32 %66, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %69 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %70 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %69, i8 1) ; BufferUpdateCounter(uav,inc)
+ %71 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %72 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %71, i8 1) ; BufferUpdateCounter(uav,inc)
+ %73 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %73, i32 %72, i32 0, i32 77, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %74 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %74, i32 %72, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %75 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %76 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %75, i8 1) ; BufferUpdateCounter(uav,inc)
+ %77 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %78 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %77, i8 1) ; BufferUpdateCounter(uav,inc)
+ %79 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %79, i32 %78, i32 0, i32 76, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %80 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %80, i32 %78, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %81 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %82 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %81, i8 1) ; BufferUpdateCounter(uav,inc)
+ %83 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %84 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %83, i8 1) ; BufferUpdateCounter(uav,inc)
+ %85 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %85, i32 %84, i32 0, i32 78, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %86 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %86, i32 %84, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %87 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %88 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %87, i8 1) ; BufferUpdateCounter(uav,inc)
+ %89 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %90 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %89, i8 1) ; BufferUpdateCounter(uav,inc)
+ %91 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %91, i32 %90, i32 0, i32 79, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %92 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %92, i32 %90, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %93 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %94 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %93, i8 1) ; BufferUpdateCounter(uav,inc)
+ %95 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %96 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %95, i8 1) ; BufferUpdateCounter(uav,inc)
+ %97 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %98 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %97, i8 1) ; BufferUpdateCounter(uav,inc)
+ %99 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %100 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %99, i8 1) ; BufferUpdateCounter(uav,inc)
+ %101 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %102 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %101, i8 1) ; BufferUpdateCounter(uav,inc)
+ %103 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %104 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %103, i8 1) ; BufferUpdateCounter(uav,inc)
+ %105 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %106 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %105, i8 1) ; BufferUpdateCounter(uav,inc)
+ %107 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %108 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %107, i8 1) ; BufferUpdateCounter(uav,inc)
+ %109 = bitcast i32 %94 to float
+ %110 = bitcast i32 %96 to float
+ %111 = fcmp fast ogt float %109, 0.000000e+00
+ %112 = zext i1 %111 to i32
+ %113 = fcmp fast olt float %110, %109
+ %114 = zext i1 %113 to i32
+ %115 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %116 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %115, i8 1) ; BufferUpdateCounter(uav,inc)
+ %117 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %117, i32 %116, i32 0, i32 80, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %118 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %118, i32 %116, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %119 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %120 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %119, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.callShader.struct.SomeValues_0(i32 159, i32 %120, %struct.SomeValues_0* nonnull %5) ; CallShader(ShaderIndex,Parameter)
+ %121 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %5, i32 0, i32 0
+ %122 = load i32, i32* %121, align 8
+ %123 = add i32 %70, %64
+ %124 = add i32 %123, %76
+ %125 = add i32 %124, %82
+ %126 = add i32 %125, %88
+ %127 = add i32 %126, %112
+ %128 = add i32 %127, %114
+ %129 = add i32 %128, %122
+ br label %139
+
+; <label>:130 ; preds = %0
+ %131 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %132 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %131, i8 1) ; BufferUpdateCounter(uav,inc)
+ %133 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %133, i32 %132, i32 0, i32 73, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %134 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %134, i32 %132, i32 76, i32 %28, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %135 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %136 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %135, i8 1) ; BufferUpdateCounter(uav,inc)
+ %137 = icmp ne i32 %136, 0
+ %138 = zext i1 %137 to i32
+ br label %139
+
+; <label>:139 ; preds = %130, %58
+ %140 = phi i32 [ %129, %58 ], [ %138, %130 ]
+ %141 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %142 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %141, i8 1) ; BufferUpdateCounter(uav,inc)
+ %143 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %143, i32 %142, i32 0, i32 83, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %144 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %144, i32 %142, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %145 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %146 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %145, i8 1) ; BufferUpdateCounter(uav,inc)
+ %147 = icmp eq i32 %146, 0
+ br i1 %147, label %220, label %148
+
+; <label>:148 ; preds = %139
+ %149 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %150 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %149, i8 1) ; BufferUpdateCounter(uav,inc)
+ %151 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %151, i32 %150, i32 0, i32 75, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %152 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %152, i32 %150, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %153 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %154 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %153, i8 1) ; BufferUpdateCounter(uav,inc)
+ %155 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %156 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %155, i8 1) ; BufferUpdateCounter(uav,inc)
+ %157 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %157, i32 %156, i32 0, i32 74, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %158 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %158, i32 %156, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %159 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %160 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %159, i8 1) ; BufferUpdateCounter(uav,inc)
+ %161 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %162 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %161, i8 1) ; BufferUpdateCounter(uav,inc)
+ %163 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %163, i32 %162, i32 0, i32 77, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %164 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %164, i32 %162, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %165 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %166 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %165, i8 1) ; BufferUpdateCounter(uav,inc)
+ %167 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %168 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %167, i8 1) ; BufferUpdateCounter(uav,inc)
+ %169 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %169, i32 %168, i32 0, i32 76, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %170 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %170, i32 %168, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %171 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %172 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %171, i8 1) ; BufferUpdateCounter(uav,inc)
+ %173 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %174 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %173, i8 1) ; BufferUpdateCounter(uav,inc)
+ %175 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %175, i32 %174, i32 0, i32 78, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %176 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %176, i32 %174, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %177 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %178 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %177, i8 1) ; BufferUpdateCounter(uav,inc)
+ %179 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %180 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %179, i8 1) ; BufferUpdateCounter(uav,inc)
+ %181 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %181, i32 %180, i32 0, i32 79, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %182 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %182, i32 %180, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %183 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %184 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %183, i8 1) ; BufferUpdateCounter(uav,inc)
+ %185 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %186 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %185, i8 1) ; BufferUpdateCounter(uav,inc)
+ %187 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %188 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %187, i8 1) ; BufferUpdateCounter(uav,inc)
+ %189 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %190 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %189, i8 1) ; BufferUpdateCounter(uav,inc)
+ %191 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %192 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %191, i8 1) ; BufferUpdateCounter(uav,inc)
+ %193 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %194 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %193, i8 1) ; BufferUpdateCounter(uav,inc)
+ %195 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %196 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %195, i8 1) ; BufferUpdateCounter(uav,inc)
+ %197 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %198 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %197, i8 1) ; BufferUpdateCounter(uav,inc)
+ %199 = bitcast i32 %184 to float
+ %200 = bitcast i32 %186 to float
+ %201 = fcmp fast ogt float %199, 0.000000e+00
+ %202 = zext i1 %201 to i32
+ %203 = fcmp fast olt float %200, %199
+ %204 = zext i1 %203 to i32
+ %205 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %206 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %205, i8 1) ; BufferUpdateCounter(uav,inc)
+ %207 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %207, i32 %206, i32 0, i32 80, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %208 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %208, i32 %206, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %209 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %210 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %209, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.callShader.struct.SomeValues_0(i32 159, i32 %210, %struct.SomeValues_0* nonnull %4) ; CallShader(ShaderIndex,Parameter)
+ %211 = getelementptr inbounds %struct.SomeValues_0, %struct.SomeValues_0* %4, i32 0, i32 0
+ %212 = load i32, i32* %211, align 8
+ %213 = add i32 %160, %154
+ %214 = add i32 %213, %166
+ %215 = add i32 %214, %172
+ %216 = add i32 %215, %178
+ %217 = add i32 %216, %202
+ %218 = add i32 %217, %204
+ %219 = add i32 %218, %212
+ br label %229
+
+; <label>:220 ; preds = %139
+ %221 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %222 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %221, i8 1) ; BufferUpdateCounter(uav,inc)
+ %223 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %223, i32 %222, i32 0, i32 73, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %224 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %224, i32 %222, i32 76, i32 %47, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %225 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32 160, %"class.RWStructuredBuffer<NvShaderExtnStruct>" %3) ; CreateHandleForLib(Resource)
+ %226 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %225, i8 1) ; BufferUpdateCounter(uav,inc)
+ %227 = icmp ne i32 %226, 0
+ %228 = zext i1 %227 to i32
+ br label %229
+
+; <label>:229 ; preds = %220, %148
+ %230 = phi i32 [ %219, %148 ], [ %228, %220 ]
+ %231 = add i32 %230, %140
+ %232 = call %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<unsigned int>"(i32 160, %"class.RWStructuredBuffer<unsigned int>" %2) ; CreateHandleForLib(Resource)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %232, i32 %10, i32 0, i32 %231, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ ret void
+}
+
+; Function Attrs: nounwind
+declare i32 @dx.op.bufferUpdateCounter(i32, %dx.types.Handle, i8) #0
+
+; Function Attrs: nounwind
+declare void @dx.op.rawBufferStore.i32(i32, %dx.types.Handle, i32, i32, i32, i32, i32, i32, i8, i32) #0
+
+; Function Attrs: nounwind
+declare void @dx.op.callShader.struct.SomeValues_0(i32, i32, %struct.SomeValues_0*) #0
+
+; Function Attrs: nounwind
+declare void @dx.op.traceRay.struct.NvHitObjectMacroDummyPayloadType(i32, %dx.types.Handle, i32, i32, i32, i32, i32, float, float, float, float, float, float, float, float, %struct.NvHitObjectMacroDummyPayloadType*) #0
+
+; Function Attrs: nounwind readnone
+declare i32 @dx.op.dispatchRaysIndex.i32(i32, i8) #1
+
+; Function Attrs: nounwind readonly
+declare %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<NvShaderExtnStruct>"(i32, %"class.RWStructuredBuffer<NvShaderExtnStruct>") #2
+
+; Function Attrs: nounwind readonly
+declare %dx.types.Handle @dx.op.createHandleForLib.struct.RaytracingAccelerationStructure(i32, %struct.RaytracingAccelerationStructure) #2
+
+; Function Attrs: nounwind readonly
+declare %dx.types.Handle @"dx.op.createHandleForLib.class.RWStructuredBuffer<unsigned int>"(i32, %"class.RWStructuredBuffer<unsigned int>") #2
+
+attributes #0 = { nounwind }
+attributes #1 = { nounwind readnone }
+attributes #2 = { nounwind readonly }
+
+!llvm.ident = !{!0}
+!dx.version = !{!1}
+!dx.valver = !{!2}
+!dx.shaderModel = !{!3}
+!dx.resources = !{!4}
+!dx.entryPoints = !{!13, !15}
+
+!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
+!1 = !{i32 1, i32 5}
+!2 = !{i32 1, i32 7}
+!3 = !{!"lib", i32 6, i32 5}
+!4 = !{!5, !8, null, null}
+!5 = !{!6}
+!6 = !{i32 0, %struct.RaytracingAccelerationStructure* @"\01?scene_0@@3URaytracingAccelerationStructure@@A", !"scene_0", i32 0, i32 0, i32 1, i32 16, i32 0, !7}
+!7 = !{i32 0, i32 4}
+!8 = !{!9, !11}
+!9 = !{i32 0, %"class.RWStructuredBuffer<NvShaderExtnStruct>"* @"\01?g_NvidiaExt@@3V?$RWStructuredBuffer@UNvShaderExtnStruct@@@@A", !"g_NvidiaExt", i32 0, i32 0, i32 1, i32 12, i1 false, i1 true, i1 false, !10}
+!10 = !{i32 1, i32 256}
+!11 = !{i32 1, %"class.RWStructuredBuffer<unsigned int>"* @"\01?outputBuffer_0@@3V?$RWStructuredBuffer@I@@A", !"outputBuffer_0", i32 0, i32 1, i32 1, i32 12, i1 false, i1 false, i1 false, !12}
+!12 = !{i32 1, i32 4}
+!13 = !{null, !"", null, !4, !14}
+!14 = !{i32 0, i64 8454160}
+!15 = !{void ()* @"\01?rayGenerationMain@@YAXXZ", !"\01?rayGenerationMain@@YAXXZ", null, null, !16}
+!16 = !{i32 8, i32 7, i32 5, !17}
+!17 = !{i32 0}
+!18 = !{!19}
+!19 = distinct !{!19, !20, !"\01?HitObject_MakeHit_1@@YA?AUNvHitObject@@URaytracingAccelerationStructure@@IIIIIIURayDesc@@USomeValues_0@@@Z: %agg.result"}
+!20 = distinct !{!20, !"\01?HitObject_MakeHit_1@@YA?AUNvHitObject@@URaytracingAccelerationStructure@@IIIIIIURayDesc@@USomeValues_0@@@Z"}
+!21 = !{!22}
+!22 = distinct !{!22, !23, !"\01?HitObject_GetAttributes_0@@YA?AUSomeValues_0@@UNvHitObject@@@Z: %agg.result"}
+!23 = distinct !{!23, !"\01?HitObject_GetAttributes_0@@YA?AUSomeValues_0@@UNvHitObject@@@Z"}
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang
new file mode 100644
index 000000000..c4b40c2ac
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang
@@ -0,0 +1,33 @@
+// hit-object-assign.slang
+
+//TEST:SIMPLE: -target dxil -entry computeMain -stage compute -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry computeMain -stage compute -profile sm_6_5 -line-directive-mode none
+
+//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -profile sm_6_5 -nvapi-slot u0
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ RayDesc ray;
+ ray.Origin = float3(idx, 0, 0);
+ ray.TMin = 0.01f;
+ ray.Direction = float3(0, 1, 0);
+ ray.TMax = 1e4f;
+
+ HitObject hit = HitObject::MakeMiss(idx, ray);
+
+ // Let's try assigning. This should work on VK
+ // because it will SSA out such there isn't an assignment in GLSL output.
+ hit = HitObject::MakeMiss(idx + 1, ray);
+
+ int r = int(hit.IsMiss());
+
+ outputBuffer[idx] = r;
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.1.expected
new file mode 100644
index 000000000..e7b370664
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.1.expected
@@ -0,0 +1,42 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 450
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+layout(std430, binding = 0) buffer _S1 {
+ uint _data[];
+} outputBuffer_0;
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
+void main()
+{
+ int idx_0 = int(gl_GlobalInvocationID.x);
+ RayDesc_0 ray_0;
+ ray_0.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMin_0 = 0.00999999977648258209;
+ ray_0.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S2 = ray_0;
+ hitObjectNV hitObj_0;
+ hitObjectRecordMissNV(hitObj_0, uint(idx_0), _S2.Origin_0, _S2.TMin_0, _S2.Direction_0, _S2.TMax_0);
+ RayDesc_0 _S3 = ray_0;
+ hitObjectNV hitObj_1;
+ hitObjectRecordMissNV(hitObj_1, uint(idx_0 + 1), _S3.Origin_0, _S3.TMin_0, _S3.Direction_0, _S3.TMax_0);
+ bool _S4 = (hitObjectIsMissNV((hitObj_1)));
+ uint _S5 = uint(int(_S4));
+ ((outputBuffer_0)._data[(uint(idx_0))]) = _S5;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.expected
new file mode 100644
index 000000000..db8b93407
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.expected
@@ -0,0 +1,153 @@
+result code = 0
+standard error = {
+}
+standard output = {
+;
+; Input signature:
+;
+; Name Index Mask Register SysValue Format Used
+; -------------------- ----- ------ -------- -------- ------- ------
+; no parameters
+;
+; Output signature:
+;
+; Name Index Mask Register SysValue Format Used
+; -------------------- ----- ------ -------- -------- ------- ------
+; no parameters
+; shader hash: 04bfde91b0cbfbe401b763d621f07e2a
+;
+; Pipeline Runtime Information:
+;
+; Compute Shader
+; NumThreads=(4,1,1)
+;
+;
+; Buffer Definitions:
+;
+; Resource bind info for g_NvidiaExt
+; {
+;
+; struct struct.NvShaderExtnStruct
+; {
+;
+; uint opcode; ; Offset: 0
+; uint rid; ; Offset: 4
+; uint sid; ; Offset: 8
+; uint4 dst1u; ; Offset: 12
+; uint4 src3u; ; Offset: 28
+; uint4 src4u; ; Offset: 44
+; uint4 src5u; ; Offset: 60
+; uint4 src0u; ; Offset: 76
+; uint4 src1u; ; Offset: 92
+; uint4 src2u; ; Offset: 108
+; uint4 dst0u; ; Offset: 124
+; uint markUavRef; ; Offset: 140
+; uint numOutputsForIncCounter; ; Offset: 144
+; float padding1[27]; ; Offset: 148
+;
+; } $Element; ; Offset: 0 Size: 256
+;
+; }
+;
+; Resource bind info for outputBuffer_0
+; {
+;
+; uint $Element; ; Offset: 0 Size: 4
+;
+; }
+;
+;
+; Resource Bindings:
+;
+; Name Type Format Dim ID HLSL Bind Count
+; ------------------------------ ---------- ------- ----------- ------- -------------- ------
+; g_NvidiaExt UAV struct r/w+cnt U0 u0 1
+; outputBuffer_0 UAV struct r/w U1 u1 1
+;
+target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
+target triple = "dxil-ms-dx"
+
+%dx.types.Handle = type { i8* }
+%"class.RWStructuredBuffer<NvShaderExtnStruct>" = type { %struct.NvShaderExtnStruct }
+%struct.NvShaderExtnStruct = type { i32, i32, i32, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, <4 x i32>, i32, i32, [27 x float] }
+%"class.RWStructuredBuffer<unsigned int>" = type { i32 }
+
+define void @computeMain() {
+ %1 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 1, i32 1, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
+ %2 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 1, i32 0, i32 0, i1 false) ; CreateHandle(resourceClass,rangeId,index,nonUniformIndex)
+ %3 = call i32 @dx.op.threadId.i32(i32 93, i32 0) ; ThreadId(component)
+ %4 = sitofp i32 %3 to float
+ %5 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 0, i32 70, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 76, i32 %3, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 80, i32 1008981770, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 84, i32 1176256512, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %6 = bitcast float %4 to i32
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 92, i32 %6, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 96, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 100, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 108, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 112, i32 1065353216, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %5, i32 116, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %7 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ %8 = add nsw i32 %3, 1
+ %9 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 0, i32 70, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 76, i32 %8, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 80, i32 1008981770, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 84, i32 1176256512, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %10 = bitcast float %4 to i32
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 92, i32 %10, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 96, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 100, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 108, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 112, i32 1065353216, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %9, i32 116, i32 0, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %11 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ %12 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %12, i32 0, i32 73, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %2, i32 %12, i32 76, i32 %11, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ %13 = call i32 @dx.op.bufferUpdateCounter(i32 70, %dx.types.Handle %2, i8 1) ; BufferUpdateCounter(uav,inc)
+ %14 = icmp ne i32 %13, 0
+ %15 = zext i1 %14 to i32
+ call void @dx.op.rawBufferStore.i32(i32 140, %dx.types.Handle %1, i32 %3, i32 0, i32 %15, i32 undef, i32 undef, i32 undef, i8 1, i32 4) ; RawBufferStore(uav,index,elementOffset,value0,value1,value2,value3,mask,alignment)
+ ret void
+}
+
+; Function Attrs: nounwind readnone
+declare i32 @dx.op.threadId.i32(i32, i32) #0
+
+; Function Attrs: nounwind
+declare void @dx.op.rawBufferStore.i32(i32, %dx.types.Handle, i32, i32, i32, i32, i32, i32, i8, i32) #1
+
+; Function Attrs: nounwind
+declare i32 @dx.op.bufferUpdateCounter(i32, %dx.types.Handle, i8) #1
+
+; Function Attrs: nounwind readonly
+declare %dx.types.Handle @dx.op.createHandle(i32, i8, i32, i32, i1) #2
+
+attributes #0 = { nounwind readnone }
+attributes #1 = { nounwind }
+attributes #2 = { nounwind readonly }
+
+!llvm.ident = !{!0}
+!dx.version = !{!1}
+!dx.valver = !{!2}
+!dx.shaderModel = !{!3}
+!dx.resources = !{!4}
+!dx.entryPoints = !{!10}
+
+!0 = !{!"clang version 3.7 (tags/RELEASE_370/final)"}
+!1 = !{i32 1, i32 5}
+!2 = !{i32 1, i32 7}
+!3 = !{!"cs", i32 6, i32 5}
+!4 = !{null, !5, null, null}
+!5 = !{!6, !8}
+!6 = !{i32 0, %"class.RWStructuredBuffer<NvShaderExtnStruct>"* undef, !"", i32 0, i32 0, i32 1, i32 12, i1 false, i1 true, i1 false, !7}
+!7 = !{i32 1, i32 256}
+!8 = !{i32 1, %"class.RWStructuredBuffer<unsigned int>"* undef, !"", i32 0, i32 1, i32 1, i32 12, i1 false, i1 false, i1 false, !9}
+!9 = !{i32 1, i32 4}
+!10 = !{void ()* @computeMain, !"computeMain", null, !4, !11}
+!11 = !{i32 0, i64 8388624, i32 4, !12}
+!12 = !{i32 4, i32 1, i32 1}
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang
index 9ba631c9f..e38b29446 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang
@@ -1,6 +1,7 @@
// hit-object-make-hit.slang
-//DISABLE_TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected
new file mode 100644
index 000000000..167c93aff
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected
@@ -0,0 +1,108 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 460
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+struct SomeValues_0
+{
+ int a_0;
+ float b_0;
+};
+
+layout(location = 0)
+hitObjectAttributeNV
+SomeValues_0 t_0;
+
+layout(binding = 0)
+uniform accelerationStructureEXT scene_0;
+
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+RayDesc_0 HitObject_GetRayDesc_0(hitObjectNV this_0)
+{
+ vec3 _S1 = (hitObjectGetWorldRayOriginNV((this_0)));
+ float _S2 = (hitObjectGetRayTMinNV((this_0)));
+ vec3 _S3 = (hitObjectGetObjectRayDirectionNV((this_0)));
+ float _S4 = (hitObjectGetRayTMaxNV((this_0)));
+ RayDesc_0 ray_0 = { _S1, _S2, _S3, _S4 };
+ return ray_0;
+}
+
+SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_1)
+{
+ hitObjectGetAttributesNV((this_1), ((0)));
+ return t_0;
+}
+
+uint calcValue_0(hitObjectNV hit_0)
+{
+ bool _S5 = (hitObjectIsHitNV((hit_0)));
+ uint r_0;
+ if(_S5)
+ {
+ uint instanceIndex_0 = (hitObjectGetInstanceCustomIndexNV((hit_0)));
+ uint instanceID_0 = (hitObjectGetInstanceIdNV((hit_0)));
+ uint geometryIndex_0 = (hitObjectGetGeometryIndexNV((hit_0)));
+ uint primitiveIndex_0 = (hitObjectGetPrimitiveIndexNV((hit_0)));
+ uint hitKind_0 = (hitObjectGetHitKindNV((hit_0)));
+ uint r_1 = 0U + hitKind_0 + instanceIndex_0 + instanceID_0 + geometryIndex_0 + primitiveIndex_0;
+ RayDesc_0 ray_1 = HitObject_GetRayDesc_0(hit_0);
+ uint r_2 = r_1 + uint(ray_1.TMin_0 > 0.00000000000000000000) + uint(ray_1.TMax_0 < ray_1.TMin_0);
+ SomeValues_0 objSomeValues_0 = HitObject_GetAttributes_0(hit_0);
+ r_0 = r_2 + uint(objSomeValues_0.a_0);
+ }
+ else
+ {
+ bool _S6 = (hitObjectIsMissNV((hit_0)));
+ uint r_3;
+ if(_S6)
+ {
+ r_3 = 1U;
+ }
+ else
+ {
+ r_3 = 0U;
+ }
+ r_0 = r_3;
+ }
+ return r_0;
+}
+
+layout(std430, binding = 1) buffer _S7 {
+ uint _data[];
+} outputBuffer_0;
+void main()
+{
+ uvec3 _S8 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S8.xy);
+ uvec3 _S9 = ((gl_LaunchSizeEXT));
+ int idx_0 = launchID_0.x;
+ RayDesc_0 ray_2;
+ ray_2.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_2.TMin_0 = 0.00999999977648258209;
+ ray_2.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_2.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S10 = ray_2;
+ hitObjectNV hitObj_0;
+ hitObjectRecordHitWithIndexNV(hitObj_0, scene_0, uint(idx_0), uint(idx_0 * 2), uint(idx_0 * 3), 0U, 0U, _S10.Origin_0, _S10.TMin_0, _S10.Direction_0, _S10.TMax_0, (0));
+ uint r_4 = calcValue_0(hitObj_0);
+ RayDesc_0 _S11 = ray_2;
+ hitObjectNV hitObj_1;
+ hitObjectRecordHitNV(hitObj_1, scene_0, uint(idx_0), uint(idx_0 * 3), uint(idx_0 * 2), 0U, 0U, 4U, _S11.Origin_0, _S11.TMin_0, _S11.Direction_0, _S11.TMax_0, (0));
+ uint _S12 = calcValue_0(hitObj_1);
+ uint r_5 = r_4 + _S12;
+ ((outputBuffer_0)._data[(uint(idx_0))]) = r_5;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang
index cf4262c53..421063987 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang
@@ -1,6 +1,7 @@
// hit-object-make-miss.slang
//TEST:SIMPLE: -target dxil -entry computeMain -stage compute -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry computeMain -stage compute -profile sm_6_5 -line-directive-mode none
//DISABLE_TEST:COMPARE_COMPUTE_EX:-slang -compute -dx12 -output-using-type -profile sm_6_5 -nvapi-slot u0
//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.1.expected
new file mode 100644
index 000000000..33eb46da3
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.1.expected
@@ -0,0 +1,39 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 450
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+layout(std430, binding = 0) buffer _S1 {
+ uint _data[];
+} outputBuffer_0;
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+layout(local_size_x = 4, local_size_y = 1, local_size_z = 1) in;
+void main()
+{
+ int idx_0 = int(gl_GlobalInvocationID.x);
+ RayDesc_0 ray_0;
+ ray_0.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMin_0 = 0.00999999977648258209;
+ ray_0.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S2 = ray_0;
+ hitObjectNV hitObj_0;
+ hitObjectRecordMissNV(hitObj_0, uint(idx_0), _S2.Origin_0, _S2.TMin_0, _S2.Direction_0, _S2.TMax_0);
+ bool _S3 = (hitObjectIsMissNV((hitObj_0)));
+ uint _S4 = uint(int(_S3));
+ ((outputBuffer_0)._data[(uint(idx_0))]) = _S4;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang
index c5f379898..b1d72c47e 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang
@@ -1,6 +1,7 @@
// hit-object-make-nop.slang
//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.1.expected
new file mode 100644
index 000000000..956dddad3
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.1.expected
@@ -0,0 +1,28 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 460
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+layout(std430, binding = 0) buffer _S1 {
+ uint _data[];
+} outputBuffer_0;
+void main()
+{
+ uvec3 _S2 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S2.xy);
+ uvec3 _S3 = ((gl_LaunchSizeEXT));
+ int idx_0 = launchID_0.x;
+ hitObjectNV hitObj_0;
+ hitObjectRecordEmptyNV((hitObj_0));
+ uint _S4 = uint(idx_0);
+ bool _S5 = (hitObjectIsEmptyNV((hitObj_0)));
+ uint _S6 = uint(_S5);
+ ((outputBuffer_0)._data[(_S4)]) = _S6;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang
index 89b01b29a..ed83b8d47 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang
@@ -1,6 +1,7 @@
// hit-object-reorder-thread.slang
-//DISABLE_TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query
//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected
new file mode 100644
index 000000000..90223115b
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected
@@ -0,0 +1,116 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 460
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+struct SomeValues_0
+{
+ int a_0;
+ float b_0;
+};
+
+layout(location = 0)
+rayPayloadEXT
+SomeValues_0 p_0;
+
+layout(binding = 0)
+uniform accelerationStructureEXT scene_0;
+
+layout(location = 0)
+hitObjectAttributeNV
+SomeValues_0 t_0;
+
+SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0)
+{
+ hitObjectGetAttributesNV((this_0), ((0)));
+ return t_0;
+}
+
+uint calcValue_0(hitObjectNV hit_0)
+{
+ bool _S1 = (hitObjectIsHitNV((hit_0)));
+ uint r_0;
+ if(_S1)
+ {
+ uint instanceIndex_0 = (hitObjectGetInstanceCustomIndexNV((hit_0)));
+ uint instanceID_0 = (hitObjectGetInstanceIdNV((hit_0)));
+ uint geometryIndex_0 = (hitObjectGetGeometryIndexNV((hit_0)));
+ uint primitiveIndex_0 = (hitObjectGetPrimitiveIndexNV((hit_0)));
+ SomeValues_0 objSomeValues_0 = HitObject_GetAttributes_0(hit_0);
+ r_0 = 0U + instanceIndex_0 + instanceID_0 + geometryIndex_0 + primitiveIndex_0 + uint(objSomeValues_0.a_0);
+ }
+ else
+ {
+ r_0 = 0U;
+ }
+ return r_0;
+}
+
+layout(location = 1)
+rayPayloadEXT
+SomeValues_0 p_1;
+
+void HitObject_Invoke_0(accelerationStructureEXT AccelerationStructure_0, hitObjectNV HitOrMiss_0, inout SomeValues_0 Payload_0)
+{
+ p_1 = Payload_0;
+ hitObjectExecuteShaderNV(HitOrMiss_0, (1));
+ Payload_0 = p_1;
+ return;
+}
+
+layout(std430, binding = 1) buffer _S2 {
+ uint _data[];
+} outputBuffer_0;
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+void main()
+{
+ uvec3 _S3 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S3.xy);
+ uvec3 _S4 = ((gl_LaunchSizeEXT));
+ int idx_0 = launchID_0.x;
+ SomeValues_0 someValues_0 = { idx_0, float(idx_0) * 2.00000000000000000000 };
+ RayDesc_0 ray_0;
+ ray_0.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMin_0 = 0.00999999977648258209;
+ ray_0.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S5 = ray_0;
+ p_0 = someValues_0;
+ hitObjectNV hitObj_0;
+ hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S5.Origin_0, _S5.TMin_0, _S5.Direction_0, _S5.TMax_0, (0));
+ uint r_1 = calcValue_0(hitObj_0);
+ reorderThreadNV(hitObj_0);
+ SomeValues_0 otherValues_0;
+ SomeValues_0 _S6 = { idx_0 * -1, float(idx_0) * 4.00000000000000000000 };
+ otherValues_0 = _S6;
+ HitObject_Invoke_0(scene_0, hitObj_0, otherValues_0);
+ uint _S7 = calcValue_0(hitObj_0);
+ uint r_2 = r_1 + _S7;
+ reorderThreadNV(hitObj_0, uint(idx_0 & 3), 2U);
+ SomeValues_0 _S8 = { idx_0 * -2, float(idx_0) * 8.00000000000000000000 };
+ otherValues_0 = _S8;
+ HitObject_Invoke_0(scene_0, hitObj_0, otherValues_0);
+ uint _S9 = calcValue_0(hitObj_0);
+ uint r_3 = r_2 + _S9;
+ reorderThreadNV(uint(idx_0 & 1), 1U);
+ SomeValues_0 _S10 = { idx_0 * -4, float(idx_0) * 16.00000000000000000000 };
+ otherValues_0 = _S10;
+ HitObject_Invoke_0(scene_0, hitObj_0, otherValues_0);
+ uint _S11 = calcValue_0(hitObj_0);
+ uint r_4 = r_3 + _S11;
+ ((outputBuffer_0)._data[(uint(idx_0))]) = r_4;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang
new file mode 100644
index 000000000..f57ecf02a
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang
@@ -0,0 +1,79 @@
+// hit-object-trace-motion-ray.slang
+
+// Motion rays not supported on HLSL impl currently
+//DISABLE_TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
+
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_6 -render-feature ray-query
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
+
+//TEST_INPUT: set scene = AccelerationStructure
+uniform RaytracingAccelerationStructure scene;
+
+//TEST_INPUT:set outputBuffer = out ubuffer(data=[0, 0, 0, 0], stride=4)
+RWStructuredBuffer<uint> outputBuffer;
+
+struct SomeValues
+{
+ int a;
+ float b;
+};
+
+uint calcValue(HitObject hit)
+{
+ uint r = 0;
+
+ if (hit.IsHit())
+ {
+ uint instanceIndex = hit.GetInstanceIndex();
+ uint instanceID = hit.GetInstanceID();
+ uint geometryIndex = hit.GetGeometryIndex();
+ uint primitiveIndex = hit.GetPrimitiveIndex();
+
+ SomeValues objSomeValues = hit.GetAttributes<SomeValues>();
+
+ r += instanceIndex;
+ r += instanceID;
+ r += geometryIndex;
+ r += primitiveIndex;
+ r += objSomeValues.a;
+ }
+
+ return r;
+}
+
+void rayGenerationMain()
+{
+ int2 launchID = int2(DispatchRaysIndex().xy);
+ int2 launchSize = int2(DispatchRaysDimensions().xy);
+
+ int idx = launchID.x;
+
+ float currentTime = idx / 4;
+
+ SomeValues someValues = { idx, idx * 2.0f };
+
+ RayDesc ray;
+ ray.Origin = float3(idx, 0, 0);
+ ray.TMin = 0.01f;
+ ray.Direction = float3(0, 1, 0);
+ ray.TMax = 1e4f;
+
+ RAY_FLAG rayFlags = RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_CULL_BACK_FACING_TRIANGLES;
+ uint instanceInclusionMask = 0xff;
+ uint rayContributionToHitGroupIndex = 0;
+ uint multiplierForGeometryContributionToHitGroupIndex = 4;
+ uint missShaderIndex = 0;
+
+ HitObject hit = HitObject::TraceMotionRay(scene,
+ rayFlags,
+ instanceInclusionMask,
+ rayContributionToHitGroupIndex,
+ multiplierForGeometryContributionToHitGroupIndex,
+ missShaderIndex,
+ ray,
+ currentTime,
+ someValues);
+
+ outputBuffer[idx] = calcValue(hit);
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected
new file mode 100644
index 000000000..2d1ef23ed
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected
@@ -0,0 +1,89 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 460
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+#extension GLSL_NV_ray_tracing_motion_blur : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+struct SomeValues_0
+{
+ int a_0;
+ float b_0;
+};
+
+layout(location = 0)
+rayPayloadEXT
+SomeValues_0 p_0;
+
+layout(binding = 0)
+uniform accelerationStructureEXT scene_0;
+
+layout(location = 0)
+hitObjectAttributeNV
+SomeValues_0 t_0;
+
+SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0)
+{
+ hitObjectGetAttributesNV((this_0), ((0)));
+ return t_0;
+}
+
+uint calcValue_0(hitObjectNV hit_0)
+{
+ bool _S1 = (hitObjectIsHitNV((hit_0)));
+ uint r_0;
+ if(_S1)
+ {
+ uint instanceIndex_0 = (hitObjectGetInstanceCustomIndexNV((hit_0)));
+ uint instanceID_0 = (hitObjectGetInstanceIdNV((hit_0)));
+ uint geometryIndex_0 = (hitObjectGetGeometryIndexNV((hit_0)));
+ uint primitiveIndex_0 = (hitObjectGetPrimitiveIndexNV((hit_0)));
+ SomeValues_0 objSomeValues_0 = HitObject_GetAttributes_0(hit_0);
+ r_0 = 0U + instanceIndex_0 + instanceID_0 + geometryIndex_0 + primitiveIndex_0 + uint(objSomeValues_0.a_0);
+ }
+ else
+ {
+ r_0 = 0U;
+ }
+ return r_0;
+}
+
+layout(std430, binding = 1) buffer _S2 {
+ uint _data[];
+} outputBuffer_0;
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+void main()
+{
+ uvec3 _S3 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S3.xy);
+ uvec3 _S4 = ((gl_LaunchSizeEXT));
+ int idx_0 = launchID_0.x;
+ int _S5 = idx_0 / 4;
+ float currentTime_0 = float(_S5);
+ SomeValues_0 someValues_0 = { idx_0, float(idx_0) * 2.00000000000000000000 };
+ RayDesc_0 ray_0;
+ ray_0.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMin_0 = 0.00999999977648258209;
+ ray_0.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S6 = ray_0;
+ p_0 = someValues_0;
+ hitObjectNV hitObj_0;
+ hitObjectTraceRayMotionNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S6.Origin_0, _S6.TMin_0, _S6.Direction_0, _S6.TMax_0, currentTime_0, (0));
+ uint _S7 = uint(idx_0);
+ uint _S8 = calcValue_0(hitObj_0);
+ ((outputBuffer_0)._data[(_S7)]) = _S8;
+ return;
+}
+
+}
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang
index 54f45e35b..63ae4c957 100644
--- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang
@@ -1,6 +1,7 @@
// hit-object-trace-ray.slang
-//DISABLE_TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0
+//TEST:SIMPLE: -target glsl -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -line-directive-mode none
//DISABLE_TEST(compute):COMPARE_COMPUTE:-d3d12 -output-using-type -use-dxil -profile sm_6_6 -render-feature ray-query
//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -output-using-type -render-feature ray-query
diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected
new file mode 100644
index 000000000..38ddbf233
--- /dev/null
+++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected
@@ -0,0 +1,86 @@
+result code = 0
+standard error = {
+}
+standard output = {
+#version 460
+#extension GL_EXT_ray_tracing : require
+#extension GL_NV_shader_invocation_reorder : require
+layout(row_major) uniform;
+layout(row_major) buffer;
+struct SomeValues_0
+{
+ int a_0;
+ float b_0;
+};
+
+layout(location = 0)
+rayPayloadEXT
+SomeValues_0 p_0;
+
+layout(binding = 0)
+uniform accelerationStructureEXT scene_0;
+
+layout(location = 0)
+hitObjectAttributeNV
+SomeValues_0 t_0;
+
+SomeValues_0 HitObject_GetAttributes_0(hitObjectNV this_0)
+{
+ hitObjectGetAttributesNV((this_0), ((0)));
+ return t_0;
+}
+
+uint calcValue_0(hitObjectNV hit_0)
+{
+ bool _S1 = (hitObjectIsHitNV((hit_0)));
+ uint r_0;
+ if(_S1)
+ {
+ uint instanceIndex_0 = (hitObjectGetInstanceCustomIndexNV((hit_0)));
+ uint instanceID_0 = (hitObjectGetInstanceIdNV((hit_0)));
+ uint geometryIndex_0 = (hitObjectGetGeometryIndexNV((hit_0)));
+ uint primitiveIndex_0 = (hitObjectGetPrimitiveIndexNV((hit_0)));
+ SomeValues_0 objSomeValues_0 = HitObject_GetAttributes_0(hit_0);
+ r_0 = 0U + instanceIndex_0 + instanceID_0 + geometryIndex_0 + primitiveIndex_0 + uint(objSomeValues_0.a_0);
+ }
+ else
+ {
+ r_0 = 0U;
+ }
+ return r_0;
+}
+
+layout(std430, binding = 1) buffer _S2 {
+ uint _data[];
+} outputBuffer_0;
+struct RayDesc_0
+{
+ vec3 Origin_0;
+ float TMin_0;
+ vec3 Direction_0;
+ float TMax_0;
+};
+
+void main()
+{
+ uvec3 _S3 = ((gl_LaunchIDEXT));
+ ivec2 launchID_0 = ivec2(_S3.xy);
+ uvec3 _S4 = ((gl_LaunchSizeEXT));
+ int idx_0 = launchID_0.x;
+ SomeValues_0 someValues_0 = { idx_0, float(idx_0) * 2.00000000000000000000 };
+ RayDesc_0 ray_0;
+ ray_0.Origin_0 = vec3(float(idx_0), 0.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMin_0 = 0.00999999977648258209;
+ ray_0.Direction_0 = vec3(0.00000000000000000000, 1.00000000000000000000, 0.00000000000000000000);
+ ray_0.TMax_0 = 10000.00000000000000000000;
+ RayDesc_0 _S5 = ray_0;
+ p_0 = someValues_0;
+ hitObjectNV hitObj_0;
+ hitObjectTraceRayNV(hitObj_0, scene_0, 20U, 255U, 0U, 4U, 0U, _S5.Origin_0, _S5.TMin_0, _S5.Direction_0, _S5.TMax_0, (0));
+ uint _S6 = uint(idx_0);
+ uint _S7 = calcValue_0(hitObj_0);
+ ((outputBuffer_0)._data[(_S6)]) = _S7;
+ return;
+}
+
+}