From 2412b0db2081664912383d41f0e368b0b243cdb5 Mon Sep 17 00:00:00 2001 From: Ariel Glasroth Date: Thu, 8 Feb 2024 11:36:06 -0500 Subject: [PATCH 01/28] implementing ray tracing functions & ray_query extension tests all functions part of ray_query, shader_invocation_reorder and ray_tracing_motion_blur are implemented for GLSL.meta. If HLSL lacks an implementation equal GLSL/SPIR-V was implemented without an HLSL equivalent in HLSL.meta (anticipation of HLSL equivalent function eventually); completed built in variables have only been stubbed thus far; NOT completed the following commit sets up formatting & tests for all ray_query functions (compute shader); completed the commit also sets up structure for compile testing glsl raytracing shaders; NOT completed --- source/slang/glsl.meta.slang | 784 +++++++++++++++++- source/slang/hlsl.meta.slang | 448 +++++++++- .../raytracing/ray-tracing-ray-query.slang | 103 +++ .../anyhit.slang | 59 ++ .../callable-caller.slang | 26 + .../callable-shared.slang | 8 + .../callable.slang | 19 + .../closesthit.slang | 48 ++ .../entry-point-params.slang | 21 + .../intersection.slang | 50 ++ .../miss.slang | 16 + .../raygen.slang | 119 +++ .../rayquery-closesthit.slang | 27 + .../hit-object-array.slang | 2 +- .../hit-object-array.slang.expected | 439 ---------- .../hit-object-assign.slang | 6 +- .../hit-object-assign.slang.1.expected | 43 - .../hit-object-assign.slang.expected | 177 ---- .../hit-object-make-hit.slang | 14 +- .../hit-object-make-hit.slang.1.expected | 114 --- .../hit-object-make-hit.slang.expected | 439 ---------- .../hit-object-make-miss.slang | 10 +- .../hit-object-make-miss.slang.1.expected | 38 - .../hit-object-make-miss.slang.expected | 139 ---- .../hit-object-make-nop.slang | 9 +- .../hit-object-make-nop.slang.1.expected | 27 - .../hit-object-make-nop.slang.expected | 131 --- .../hit-object-output.slang | 8 +- .../hit-object-output.slang.1.expected | 113 --- .../hit-object-reorder-thread.slang | 16 +- ...hit-object-reorder-thread.slang.1.expected | 122 --- .../hit-object-reorder-thread.slang.expected | 121 --- .../hit-object-trace-motion-ray.slang | 9 +- ...t-object-trace-motion-ray.slang.1.expected | 92 -- .../hit-object-trace-ray.slang | 9 +- .../hit-object-trace-ray.slang.1.expected | 90 -- .../hit-object-trace-ray.slang.expected | 225 ----- 37 files changed, 1749 insertions(+), 2372 deletions(-) create mode 100644 tests/glsl-intrinsic/raytracing/ray-tracing-ray-query.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/anyhit.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-caller.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-shared.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/closesthit.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/entry-point-params.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/intersection.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/miss.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/raygen.slang create mode 100644 tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/rayquery-closesthit.slang delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-assign.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-hit.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-miss.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-make-nop.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-output.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-reorder-thread.slang.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-motion-ray.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.1.expected delete mode 100644 tests/hlsl-intrinsic/shader-execution-reordering/hit-object-trace-ray.slang.expected diff --git a/source/slang/glsl.meta.slang b/source/slang/glsl.meta.slang index 8403d13910..93d6563684 100644 --- a/source/slang/glsl.meta.slang +++ b/source/slang/glsl.meta.slang @@ -2787,28 +2787,80 @@ public vec4 shadow2DProjLod(sampler2DShadow sampler, vec4 coord, float lod) return textureProjLod(sampler, coord, lod); } -// -// Ray tracing -// + +//// RayTracing public typealias rayQueryEXT = RayQuery; +public typealias accelerationStructureEXT = RaytracingAccelerationStructure; +public typealias hitObjectNV = HitObject; + +/// GL_EXT_ray_query + +// Raytracing constants +public const uint gl_RayFlagsNoneEXT = 0U; +public const uint gl_RayFlagsOpaqueEXT = 1U; +public const uint gl_RayFlagsNoOpaqueEXT = 2U; +public const uint gl_RayFlagsTerminateOnFirstHitEXT = 4U; +public const uint gl_RayFlagsSkipClosestHitShaderEXT = 8U; +public const uint gl_RayFlagsCullBackFacingTrianglesEXT = 16U; +public const uint gl_RayFlagsCullFrontFacingTrianglesEXT = 32U; +public const uint gl_RayFlagsCullOpaqueEXT = 64U; +public const uint gl_RayFlagsCullNoOpaqueEXT = 128U; +public const uint gl_RayQueryCommittedIntersectionNoneEXT = 0U; +public const uint gl_RayQueryCommittedIntersectionTriangleEXT = 1U; +public const uint gl_RayQueryCommittedIntersectionGeneratedEXT = 2U; +public const uint gl_RayQueryCandidateIntersectionTriangleEXT = 0U; +public const uint gl_RayQueryCandidateIntersectionAABBEXT = 1U; + +// GL_EXT_ray_query functions + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public void rayQueryInitializeEXT( + inout rayQueryEXT q, + accelerationStructureEXT topLevel, + uint rayFlags, uint cullMask, vec3 origin, + float tMin, vec3 direction, float tMax) { + + q.TraceRayInline(topLevel, rayFlags, cullMask, { origin, tMin, direction, tMax }); +} + +[__requiresNVAPI] __glsl_extension(GL_EXT_ray_query) __glsl_version(460) [ForceInline] -public void rayQueryConfirmIntersectionEXT(inout rayQueryEXT q) +public bool rayQueryProceedEXT(inout rayQueryEXT q) { - q.CommitNonOpaqueTriangleHit(); + return q.Proceed(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +[mutating] +public void rayQueryTerminateEXT(inout rayQueryEXT q) { + q.Abort(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public void rayQueryGenerateIntersectionEXT(inout rayQueryEXT q, float tHit) { + q.CommitProceduralPrimitiveHit(tHit); } +[__requiresNVAPI] __glsl_extension(GL_EXT_ray_query) __glsl_version(460) [ForceInline] -public bool rayQueryProceedEXT(inout rayQueryEXT q) +public void rayQueryConfirmIntersectionEXT(inout rayQueryEXT q) { - return q.Proceed(); + q.CommitNonOpaqueTriangleHit(); } +[__requiresNVAPI] __glsl_extension(GL_EXT_ray_query) __glsl_version(460) [__NoSideEffect] @@ -2816,30 +2868,718 @@ public uint rayQueryGetIntersectionTypeEXT(rayQueryEXT q, bool committed) { if (committed) { - q.CommittedStatus(); + return q.CommittedStatus(); } else { - q.CandidateType(); + return q.CandidateType(); } - return 0; } +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public float rayQueryGetRayTMinEXT(rayQueryEXT q) { + return q.RayTMin(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) + __glsl_version(460) +public uint rayQueryGetRayFlagsEXT(rayQueryEXT q) { + return q.RayFlags(); +} -// -// Subgroup -// +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public vec3 rayQueryGetWorldRayOriginEXT(rayQueryEXT q) { + return q.WorldRayOrigin(); +} -__glsl_extension(KHR_shader_subgroup) -__glsl_version(450) -public void subgroupBarrier() -{ - //__subgroupBarrier(); +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public vec3 rayQueryGetWorldRayDirectionEXT(rayQueryEXT q) { + return q.WorldRayDirection(); } -__glsl_extension(KHR_shader_subgroup) -__glsl_version(450) -public void subgroupMemoryBarrier() -{ +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) + __glsl_version(460) +public float rayQueryGetIntersectionTEXT(rayQueryEXT q, bool committed) { + if (committed) { + return q.CommittedRayT(); + } + else { + return q.CandidateTriangleRayT(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public int rayQueryGetIntersectionInstanceCustomIndexEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayInstanceCustomIndex(); + } + else { + return q.CandidateRayInstanceCustomIndex();; + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public int rayQueryGetIntersectionInstanceIdEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayInstanceId(); + } + else { + return q.CandidateRayInstanceId(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public uint rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayInstanceShaderBindingTableRecordOffset(); + } + else { + return q.CandidateRayInstanceShaderBindingTableRecordOffset(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public int rayQueryGetIntersectionGeometryIndexEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayGeometryIndex(); + } + else { + return q.CandidateRayGeometryIndex(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public int rayQueryGetIntersectionPrimitiveIndexEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayPrimitiveIndex(); + } + else { + return q.CandidateRayPrimitiveIndex(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public vec2 rayQueryGetIntersectionBarycentricsEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayBarycentrics(); + } + else { + return q.CandidateRayBarycentrics(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public bool rayQueryGetIntersectionFrontFaceEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayFrontFace(); + } + else { + return q.CandidateRayFrontFace(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public bool rayQueryGetIntersectionCandidateAABBOpaqueEXT(rayQueryEXT q) { + return q.CandidateProceduralPrimitiveNonOpaque(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public vec3 rayQueryGetIntersectionObjectRayDirectionEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayObjectRayDirection(); + } + else { + return q.CandidateRayObjectRayDirection(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public vec3 rayQueryGetIntersectionObjectRayOriginEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return q.CommittedRayObjectRayOrigin(); + } + else { + return q.CandidateRayObjectRayOrigin(); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) +__glsl_version(460) +public mat4x3 rayQueryGetIntersectionObjectToWorldEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return reinterpret(q.CommittedRayObjectToWorld()); + } + else { + return reinterpret(q.CandidateRayObjectToWorld()); + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_query) + __glsl_version(460) +public mat4x3 rayQueryGetIntersectionWorldToObjectEXT(rayQueryEXT q, bool committed) { + + if (committed) { + return reinterpret(q.CommittedRayWorldToObject()); + } + else { + return reinterpret(q.CandidateRayWorldToObject()); + } +} + +/// GL_NV_shader_invocation_reorder + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectTraceRayNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + uint rayFlags, + uint cullMask, + uint sbtRecordOffset, + uint sbtRecordStride, + uint missIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + int payload) { + + hitObject.TraceRay( + topLevel, + rayFlags, + cullMask, + sbtRecordOffset, + sbtRecordStride, + missIndex, + {origin, Tmin, direction, Tmax}, + payload + ); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectTraceRayMotionNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + uint rayFlags, + uint cullMask, + uint sbtRecordOffset, + uint sbtRecordStride, + uint missIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + float currentTime, + int payload){ + + hitObject.TraceMotionRay( + topLevel, + rayFlags, + cullMask, + sbtRecordOffset, + sbtRecordStride, + missIndex, + {origin, Tmin, direction, Tmax}, + currentTime, + payload + ); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordHitNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + int instanceid, + int primitiveid, + int geometryindex, + uint hitKind, + uint sbtRecordOffset, + uint sbtRecordStride, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + int attributeLocation){ + + hitObject.MakeHit( + topLevel, + uint(instanceid), + uint(primitiveid), + uint(geometryindex), + hitKind, + sbtRecordOffset, + sbtRecordStride, + {origin, Tmin, direction, Tmax}, + attributeLocation + ); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordHitMotionNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + int instanceid, + int primitiveid, + int geometryindex, + uint hitKind, + uint sbtRecordOffset, + uint sbtRecordStride, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + float currentTime, + int attributeLocation){ + + hitObject.MakeMotionHit( + topLevel, + uint(instanceid), + uint(primitiveid), + uint(geometryindex), + hitKind, + sbtRecordOffset, + sbtRecordStride, + {origin, Tmin, direction, Tmax}, + currentTime, + attributeLocation + ); + +} + +[__requiresNVAPI] +void hitObjectRecordHitWithIndexNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + int instanceid, + int primitiveid, + int geometryindex, + uint hitKind, + uint sbtRecordIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + int attributeLocation) { + + hitObject.MakeHit( + topLevel, + uint(instanceid), + uint(geometryindex), + uint(primitiveid), + hitKind, + sbtRecordIndex, + 1, + {origin, Tmin, direction, Tmax}, + attributeLocation + ); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordHitWithIndexMotionNV( + hitObjectNV hitObject, + accelerationStructureEXT topLevel, + int instanceid, + int primitiveid, + int geometryindex, + uint hitKind, + uint sbtRecordIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + float currentTime, + int attributeLocation){ + + hitObject.MakeMotionHit( + topLevel, + uint(instanceid), + uint(primitiveid), + uint(geometryindex), + hitKind, + sbtRecordIndex, + 1, + {origin, Tmin, direction, Tmax}, + currentTime, + attributeLocation + ); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordMissNV( + hitObjectNV hitObject, + uint sbtRecordIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax){ + + hitObject.MakeMiss( + sbtRecordIndex, + { origin, Tmin, direction, Tmax } + ); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordMissMotionNV( + hitObjectNV hitObject, + uint sbtRecordIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + float currentTime){ + + hitObject.MakeMotionMiss( + sbtRecordIndex, + {origin, Tmin, direction, Tmax}, + currentTime + ); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectRecordEmptyNV( + hitObjectNV hitObject){ + + hitObject.MakeNop(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +__generic +void hitObjectExecuteShaderNV( + hitObjectNV hitObject, + payload_t payload){ + + // TODO: need to get acceleration stucture associated with hitObjectExecuteShaderNV; KIRop some type fetching + handle internals? + + __target_switch + { + case glsl: + { + __intrinsic_asm "hitObjectExecuteShaderNV($0, $1)"; + } + case spirv: + { + + return spirv_asm { + OpHitObjectExecuteShaderNV + /**/ $hitObject + /**/ $payload; + }; + + } + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +bool hitObjectIsEmptyNV(hitObjectNV hitObject){ + + return hitObject.IsNop(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +bool hitObjectIsMissNV(hitObjectNV hitObject){ + + return hitObject.IsMiss(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +bool hitObjectIsHitNV(hitObjectNV hitObject){ + + return hitObject.IsHit(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +float hitObjectGetRayTMinNV(hitObjectNV hitObject) { + return hitObject.GetRayDesc().TMin; +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +float hitObjectGetRayTMaxNV(hitObjectNV hitObject) { + return hitObject.GetRayDesc().TMax; +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +vec3 hitObjectGetWorldRayOriginNV(hitObjectNV hitObject) { + return hitObject.GetRayDesc().Origin; +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +vec3 hitObjectGetWorldRayDirectionNV(hitObjectNV hitObject) { + return hitObject.GetRayDesc().Direction; +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +vec3 hitObjectGetObjectRayOriginNV(hitObjectNV hitObject){ + + return hitObject.GetObjectRayOrigin(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +vec3 hitObjectGetObjectRayDirectionNV(hitObjectNV hitObject) { + + return hitObject.GetObjectRayDirection(); + +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +mat4x3 hitObjectGetObjectToWorldNV(hitObjectNV hitObject){ + return reinterpret(hitObject.GetObjectToWorld()); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +mat4x3 hitObjectGetWorldToObjectNV(hitObjectNV hitObject) { + return bit_cast(hitObject.GetWorldToObject()); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +int hitObjectGetInstanceCustomIndexNV(hitObjectNV hitObject) { + return hitObject.GetInstanceID(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +int hitObjectGetInstanceIdNV(hitObjectNV hitObject) { + return hitObject.GetInstanceIndex(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +int hitObjectGetGeometryIndexNV(hitObjectNV hitObject) { + return hitObject.GetGeometryIndex(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +int hitObjectGetPrimitiveIndexNV(hitObjectNV hitObject) { + return hitObject.GetPrimitiveIndex(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +uint hitObjectGetHitKindNV(hitObjectNV hitObject) { + return hitObject.GetHitKind(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void hitObjectGetAttributesNV(hitObjectNV hitObject, int attributeLocation) { + // TODO: maybe make kIROp which fetches type and feeds that to HLSL to set a buffer which has hitObjectGetShaderRecordBufferHandleNV + __target_switch + { + case glsl: + { + __intrinsic_asm "hitObjectGetAttributesNV($0,$1)"; + } + case spirv: + { + spirv_asm { + OpCapability ShaderInvocationReorderNV; + OpHitObjectGetAttributesNV &hitObject $attributeLocation; + }; + } + } +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +uvec2 hitObjectGetShaderRecordBufferHandleNV(hitObjectNV hitObject) { + return hitObject.GetShaderRecordBufferHandle(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +uint hitObjectGetShaderBindingTableRecordIndexNV(hitObjectNV hitObject){ + return hitObject.GetShaderTableIndex(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +float hitObjectGetCurrentTimeNV(hitObjectNV hitObject) { + return hitObject.GetCurrentTime(); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void reorderThreadNV(uint hint, uint bits){ + ReorderThread(hint, bits); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void reorderThreadNV(hitObjectNV hitObject){ + ReorderThread(hitObject); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_shader_invocation_reorder) +__glsl_extension(GLSL_EXT_buffer_reference_uvec2) +void reorderThreadNV(hitObjectNV hitObject, uint hint, uint bits){ + ReorderThread(hitObject, hint, bits); +} + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_ray_tracing_motion_blur) +public float gl_SubgroupInvocationID; // RayCurrentTime analog + +[__requiresNVAPI] +__glsl_extension(GL_EXT_ray_tracing) +__glsl_extension(GL_NV_ray_tracing_motion_blur) +void traceRayMotionNV( + accelerationStructureEXT topLevel, + uint rayFlags, + uint cullMask, + uint sbtRecordOffset, + uint sbtRecordStride, + uint missIndex, + vec3 origin, + float Tmin, + vec3 direction, + float Tmax, + float currentTime, + int payload) { + TraceMotionRay( + topLevel, + rayFlags, + cullMask, + sbtRecordOffset, + sbtRecordStride, + missIndex, + {origin, Tmin, direction, Tmax}, + currentTime, + payload + ); } diff --git a/source/slang/hlsl.meta.slang b/source/slang/hlsl.meta.slang index 8183c2030f..e0d220dd1a 100644 --- a/source/slang/hlsl.meta.slang +++ b/source/slang/hlsl.meta.slang @@ -9531,22 +9531,32 @@ static const RAY_FLAG RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES = 0x200; __target_intrinsic(hlsl, RayDesc) __target_intrinsic(cuda, RayDesc) +//__target_intrinsic(glsl, RayDesc) +//__target_intrinsic(spirv, RayDesc) struct RayDesc { __target_intrinsic(hlsl, Origin) __target_intrinsic(cuda, Origin) + //__target_intrinsic(glsl, Origin) + //__target_intrinsic(spirv, Origin) float3 Origin; __target_intrinsic(hlsl, TMin) __target_intrinsic(cuda, TMin) + //__target_intrinsic(glsl, TMin) + //__target_intrinsic(spirv, TMin) float TMin; __target_intrinsic(hlsl, Direction) __target_intrinsic(cuda, Direction) + //__target_intrinsic(glsl, Direction) + //__target_intrinsic(spirv, Direction) float3 Direction; __target_intrinsic(hlsl, TMax) __target_intrinsic(cuda, TMax) + //__target_intrinsic(glsl, TMax) + //__target_intrinsic(spirv, TMax) float TMax; }; @@ -10644,7 +10654,7 @@ struct RayQuery __target_switch { case hlsl: __intrinsic_asm ".CandidateProceduralPrimitiveNonOpaque"; - case glsl: __intrinsic_asm "(!rayQueryGetIntersectionCandidateAABBOpaqueEXT($0, false))"; + case glsl: __intrinsic_asm "(!rayQueryGetIntersectionCandidateAABBOpaqueEXT($0))"; case spirv: uint iCandidateOrCommitted = 0; return spirv_asm @@ -10690,6 +10700,377 @@ struct RayQuery } } +///missing hlsl equivlent; only implemented for glsl & spirv + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CandidateRayInstanceCustomIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceCustomIndexEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionInstanceCustomIndexKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CommittedRayInstanceCustomIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceCustomIndexEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionInstanceCustomIndexKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CandidateRayInstanceId() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceIdEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionInstanceIdKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CommittedRayInstanceId() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceIdEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionInstanceIdKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + uint CandidateRayInstanceShaderBindingTableRecordOffset() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$uint = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + uint CommittedRayInstanceShaderBindingTableRecordOffset() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$uint = OpRayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetKHR &this $iCandidateOrCommitted; + }; + } + } + + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CandidateRayGeometryIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionGeometryIndexEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionGeometryIndexKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CommittedRayGeometryIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionGeometryIndexEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionGeometryIndexKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CandidateRayPrimitiveIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionPrimitiveIndexEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionPrimitiveIndexKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + int CommittedRayPrimitiveIndex() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionPrimitiveIndexEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$int = OpRayQueryGetIntersectionPrimitiveIndexKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float2 CandidateRayBarycentrics() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionBarycentricsEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$float2 = OpRayQueryGetIntersectionBarycentricsKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float2 CommittedRayBarycentrics() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionBarycentricsEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$float2 = OpRayQueryGetIntersectionBarycentricsKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + bool CandidateRayFrontFace() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionFrontFaceEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$bool = OpRayQueryGetIntersectionFrontFaceKHR &this $iCandidateOrCommitted; + }; + } + } + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + bool CommittedRayFrontFace() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionFrontFaceEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$bool = OpRayQueryGetIntersectionFrontFaceKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float3 CandidateRayObjectRayDirection() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectRayDirectionEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$float3 = OpRayQueryGetIntersectionObjectRayDirectionKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float3 CommittedRayObjectRayDirection() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectRayDirectionEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$float3 = OpRayQueryGetIntersectionObjectRayDirectionKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float3 CandidateRayObjectRayOrigin() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectRayOriginEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$float3 = OpRayQueryGetIntersectionObjectRayOriginKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float3 CommittedRayObjectRayOrigin() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectRayOriginEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$float3 = OpRayQueryGetIntersectionObjectRayOriginKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float4x3 CandidateRayObjectToWorld() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectToWorldEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$float4x3 = OpRayQueryGetIntersectionObjectToWorldKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float4x3 CommittedRayObjectToWorld() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionObjectToWorldEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + result:$$float4x3 = OpRayQueryGetIntersectionObjectToWorldKHR &this $iCandidateOrCommitted; + }; + } + } + + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float4x3 CandidateRayWorldToObject() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionWorldToObjectEXT($0, false)"; + case spirv: + uint iCandidateOrCommitted = 0; + return spirv_asm + { + result:$$float4x3 = OpRayQueryGetIntersectionWorldToObjectKHR &this $iCandidateOrCommitted; + }; + } + } + + __glsl_extension(GL_EXT_ray_query) + __glsl_version(460) + [__NoSideEffect] + float4x3 CommittedRayWorldToObject() + { + __target_switch + { + case glsl: __intrinsic_asm "rayQueryGetIntersectionWorldToObjectEXT($0, true)"; + case spirv: + uint iCandidateOrCommitted = 1; + return spirv_asm + { + OpRayQueryGetIntersectionWorldToObjectKHR $$float4x3 result &this $iCandidateOrCommitted; + }; + } + } +///~ + ${{{{ const char* kCandidateCommitted[] = {"Candidate", "Committed"}; @@ -11036,6 +11417,7 @@ struct HitObject let tmin = Ray.TMin; let tmax = Ray.TMax; spirv_asm { + OpCapability ShaderInvocationReorderNV; OpHitObjectTraceRayNV /**/ &__return_val /**/ $AccelerationStructure @@ -11465,6 +11847,8 @@ struct HitObject let tmin = Ray.TMin; let tmax = Ray.TMax; spirv_asm { + OpExtension "SPV_NV_shader_invocation_reorder"; + OpCapability ShaderInvocationReorderNV; OpHitObjectRecordMissNV /**/ &__return_val /**/ $MissShaderIndex @@ -11608,6 +11992,7 @@ struct HitObject case hlsl: __intrinsic_asm ".IsHit"; case glsl: __intrinsic_asm "hitObjectIsHitNV($0)"; case spirv: return spirv_asm { + OpCapability ShaderInvocationReorderNV; result:$$bool = OpHitObjectIsHitNV &this; }; } @@ -11781,7 +12166,66 @@ struct HitObject } } - /// Returns the attributes of a hit. Valid if the hit object represents a hit or a miss. + [__requiresNVAPI] + [ForceInline] + __glsl_extension(GL_NV_shader_invocation_reorder) + float GetCurrentTime() { + __target_switch + { + case glsl: + __intrinsic_asm "hitObjectGetCurrentTimeNV($0)"; + case spirv: + spirv_asm { + result:$$float = OpHitObjectGetCurrentTimeNV &this + }; + } + } + + [__requiresNVAPI] + [ForceInline] + __glsl_extension(GL_NV_shader_invocation_reorder) + float3 GetObjectRayOrigin() { + __target_switch + { + case glsl: + __intrinsic_asm "hitObjectGetObjectRayOriginNV($0)"; + case spirv: + spirv_asm { + result:$$float3 = OpHitObjectGetObjectRayOriginNV &this + }; + } + } + + [__requiresNVAPI] + [ForceInline] + __glsl_extension(GL_NV_shader_invocation_reorder) + float3 GetObjectRayDirection() { + __target_switch + { + case glsl: + __intrinsic_asm "hitObjectGetObjectRayDirectionNV($0)"; + case spirv: + spirv_asm { + result:$$float3 = OpHitObjectGetObjectRayDirectionNV &this + }; + } + } + + [__requiresNVAPI] + [ForceInline] + __glsl_extension(GL_NV_shader_invocation_reorder) + uint2 GetShaderRecordBufferHandle() { + __target_switch + { + case glsl: + __intrinsic_asm "hitObjectGetShaderRecordBufferHandleNV($0)"; + case spirv: + spirv_asm { + result:$$uint2 = OpHitObjectGetShaderRecordBufferHandleNV &this + }; + } + } + /// Returns the attributes of a hit. Valid if the hit object represents a hit or a miss. [ForceInline] attr_t GetAttributes() { diff --git a/tests/glsl-intrinsic/raytracing/ray-tracing-ray-query.slang b/tests/glsl-intrinsic/raytracing/ray-tracing-ray-query.slang new file mode 100644 index 0000000000..707e09e2f2 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/ray-tracing-ray-query.slang @@ -0,0 +1,103 @@ +// -Wreturn-type error +//DISABLE_TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -allow-glsl -d3d12 -output-using-type -use-dxil -profile sm_6_5 -render-feature ray-query + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -allow-glsl -vk -output-using-type -render-feature ray-query +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=BUF): -allow-glsl -vk -output-using-type -render-feature ray-query -emit-spirv-directly + +// note: the referenced input data is in render-test-main kVertexData; 1 triangle at {(0,0,0.5),(0,1,0.5),(1,0,0.5)} +//TEST_INPUT: set scene = AccelerationStructure +uniform accelerationStructureEXT scene; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName +{ + uint data[]; +} outputBuffer; + +uint testAbortRayTrace() { + RayQuery q; + rayQueryInitializeEXT(q, scene, gl_RayFlagsNoneEXT, 0xff, vec3(0.1, 0.1, 0.0), 0.01f, vec3(0, 0, 1), 1e4f); + rayQueryTerminateEXT(q); + + return true + && rayQueryGetIntersectionTypeEXT(q, true) == gl_RayQueryCommittedIntersectionNoneEXT + ; +} +uint testProceedRayTrace() { + RayQuery q; + rayQueryInitializeEXT(q, scene, gl_RayFlagsNoneEXT, 0xff, vec3(0.1, 0.1, 0.0), 0.01f, vec3(0, 0, 1), 1e4f); + rayQueryProceedEXT(q); + + + return true + && rayQueryGetIntersectionTypeEXT(q, true) == gl_RayQueryCommittedIntersectionTriangleEXT + && rayQueryGetIntersectionTEXT(q, true) == 0.5 + ; +} + +__generic +bool equals(matrix lhs, matrix rhs) +{ + for (int i = 0; i < N; ++i) + { + for (int j = 0; j < M; ++j) + { + if (lhs[i][j] != rhs[i][j]) + { + return false; + } + } + } + return true; +} + +uint testProceedRayAuxInfo() { + RayQuery q; + rayQueryInitializeEXT(q, scene, gl_RayFlagsNoneEXT, 0xff, vec3(0.1, 0.1, 0.0), 0.01f, vec3(0, 0, 1), 1e4f); + rayQueryProceedEXT(q); + + return true + && rayQueryGetRayTMinEXT(q) == 0.01f + && rayQueryGetRayFlagsEXT(q) == gl_RayFlagsNoneEXT + && rayQueryGetWorldRayOriginEXT(q) == vec3(0.1, 0.1, 0.0) + && rayQueryGetWorldRayDirectionEXT(q) == vec3(0, 0, 1) + && rayQueryGetIntersectionInstanceCustomIndexEXT(q, true) == 0 + && rayQueryGetIntersectionInstanceIdEXT(q, true) == 0 + && rayQueryGetIntersectionInstanceShaderBindingTableRecordOffsetEXT(q, true) == 0 + && rayQueryGetIntersectionGeometryIndexEXT(q, true) == 0 + && rayQueryGetIntersectionPrimitiveIndexEXT(q, true) == 0 + && rayQueryGetIntersectionBarycentricsEXT(q, true) == vec2(0.1) + && rayQueryGetIntersectionFrontFaceEXT(q, true) == true + && rayQueryGetIntersectionCandidateAABBOpaqueEXT(q) == true + && rayQueryGetIntersectionObjectRayDirectionEXT(q, true) == vec3(0, 0, 1) + && rayQueryGetIntersectionObjectRayOriginEXT(q, true) == vec3(0.1, 0.1, 0.0) + //&& !equals(rayQueryGetIntersectionObjectToWorldEXT(q, true), mat4x3(0)) //some compile error to sort later + //&& !equals(rayQueryGetIntersectionWorldToObjectEXT(q, true), mat4x3(0)) + ; +} +uint testRayTraceGenerate() { + RayQuery q; + rayQueryInitializeEXT(q, scene, gl_RayFlagsNoneEXT, 0xff, vec3(0.1, 0.1, 0.0), 0.01f, vec3(0, 0, 1), 1e4f); + rayQueryGenerateIntersectionEXT(q, 0.5); + rayQueryConfirmIntersectionEXT(q); + + return true + && rayQueryGetIntersectionTypeEXT(q, true) == gl_RayQueryCommittedIntersectionTriangleEXT + ; +} + + +//[shader("compute")] +layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; +void computeMain() +{ + + outputBuffer.data[0] = true + && testAbortRayTrace() + && testProceedRayTrace() + && testProceedRayAuxInfo() + && testRayTraceGenerate() + ; + + // BUF: 1 +} \ No newline at end of file diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/anyhit.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/anyhit.slang new file mode 100644 index 0000000000..14c559afc2 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/anyhit.slang @@ -0,0 +1,59 @@ +// closesthit.slang + +// Note: explicitly requesting `spirv_1_4` as part of the compiler +// options is for the benefit of the glslang pass-through path, +// where we cannot infer the required SPIR-V version from the code +// (and glslang doesn't include any such inference ability). + +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+spirv_1_4 -stage anyhit -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -stage anyhit -entry main -target spirv-assembly -emit-spirv-directly + +struct SphereHitAttributes +{ + float3 normal; +}; + + +struct ShadowRay +{ + float4 hitDistance; +}; + +struct Params +{ + Texture2D alphaMap; + SamplerState sampler; + int mode; +} +ParameterBlock gParams; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main( + SphereHitAttributes attributes, + in out ShadowRay ioPayload) +{ + if(gParams.mode != 0) + { + float val = gParams.alphaMap.SampleLevel( + gParams.sampler, + attributes.normal.xy, 0); + if(val > 0) + { + AcceptHitAndEndSearch(); + } + else + { + IgnoreHit(); + } + } + + uint index = 0U; + HitTriangleVertexPosition(index); + + index = 1U; + HitTriangleVertexPosition(index); + + index = 2U; + HitTriangleVertexPosition(index); +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-caller.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-caller.slang new file mode 100644 index 0000000000..5f5672318c --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-caller.slang @@ -0,0 +1,26 @@ +// callable-caller.slang + +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460 -capability GL_NV_ray_tracing -stage raygeneration -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -capability GL_NV_ray_tracing -stage raygeneration -entry main -target spirv-assembly -emit-spirv-directly + +import callable_shared; + +cbuffer C +{ + uint shaderIndex; +}; + +RWTexture2D gImage; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main() +{ + MaterialPayload payload; + payload.albedo = 0; + payload.uv = float2(DispatchRaysIndex().xy) / float2(DispatchRaysDimensions().xy); + + CallShader(shaderIndex, payload); + + gImage[DispatchRaysIndex().xy] = payload.albedo; +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-shared.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-shared.slang new file mode 100644 index 0000000000..85d72a5f78 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable-shared.slang @@ -0,0 +1,8 @@ +// callable-shared.slang +//TEST_IGNORE_FILE: + +public struct MaterialPayload +{ + public float4 albedo; + public float2 uv; +}; diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable.slang new file mode 100644 index 0000000000..71f0e50ccc --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/callable.slang @@ -0,0 +1,19 @@ +// callable.slang + +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+spirv_1_4 -stage callable -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -stage callable -entry main -target spirv-assembly -emit-spirv-directly + +import callable_shared; + +Texture2D gAlbedoMap; +SamplerState gSampler; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main(in out MaterialPayload ioPayload) +{ + ioPayload.albedo = gAlbedoMap.SampleLevel( + gSampler, + ioPayload.uv, + 0); +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/closesthit.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/closesthit.slang new file mode 100644 index 0000000000..2e4c12aba8 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/closesthit.slang @@ -0,0 +1,48 @@ +// closesthit.slang +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+GL_EXT_ray_tracing -stage closesthit -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -stage closesthit -entry main -target spirv-assembly -emit-spirv-directly + +struct ReflectionRay +{ + float4 color; +}; + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName +{ + vec4 data[]; +} colorBuffer; + +layout(shaderRecordNV) +cbuffer ShaderRecord +{ + uint shaderRecordID; +} + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main( + BuiltInTriangleIntersectionAttributes attributes, + in out ReflectionRay ioPayload) +{ + uint materialID = (InstanceIndex() << 1) + + InstanceID() + + PrimitiveIndex() + + HitKind() + + shaderRecordID; + + float4 color = colorBuffer.data[materialID]; + + color *= RayTCurrent() - RayTMin(); + + ioPayload.color = color; + + uint index = 0U; + HitTriangleVertexPosition(index); + + index = 1U; + HitTriangleVertexPosition(index); + + index = 2U; + HitTriangleVertexPosition(index); +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/entry-point-params.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/entry-point-params.slang new file mode 100644 index 0000000000..3b9d230721 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/entry-point-params.slang @@ -0,0 +1,21 @@ +// entry-point-params.slang + +// Test that entry-point `uniform` parameters on ray-tracing +// shaders properly map to the "shader record" in SPIR-V output. + +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+spirv_1_4 -stage raygeneration -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -stage raygeneration -entry main -target spirv-assembly -emit-spirv-directly + +//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer +buffer MyBlockName +{ + uint data[]; +} outputBuffer; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main( + uniform float value) +{ + outputBuffer.data[DispatchRaysIndex().x] = value; +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/intersection.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/intersection.slang new file mode 100644 index 0000000000..74dd0f3ae7 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/intersection.slang @@ -0,0 +1,50 @@ +// intersection.slang +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+GL_NV_ray_tracing -stage intersection -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -emit-spirv-directly -stage intersection -entry main -target spirv-assembly + +struct Sphere +{ + float3 position; + float radius; +}; + +struct SphereHitAttributes +{ + float3 normal; +}; + +bool rayIntersectsSphere( + RayDesc ray, + Sphere sphere, + out float tHit, + out SphereHitAttributes attrs) +{ + // HACK: this is obviously incorrect, + // but we just need some code for testing + tHit = sphere.radius; + attrs.normal = sphere.position; + return tHit >= ray.TMin; +} + +cbuffer U +{ + Sphere gSphere; +} + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main() +{ + RayDesc ray; + ray.Origin = ObjectRayOrigin(); + ray.Direction = ObjectRayDirection(); + ray.TMin = RayTMin(); + ray.TMax = RayTCurrent(); + + float tHit; + SphereHitAttributes attrs; + if(rayIntersectsSphere(ray, gSphere, tHit, attrs)) + { + ReportHit(tHit, 0, attrs); + } +} \ No newline at end of file diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/miss.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/miss.slang new file mode 100644 index 0000000000..f9e849aeef --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/miss.slang @@ -0,0 +1,16 @@ +//DISABLE_TEST:CROSS_COMPILE: -profile glsl_460+GL_EXT_ray_tracing -stage miss -entry main -target spirv-assembly + +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -profile glsl_460+GL_NV_ray_tracing -stage miss -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -emit-spirv-directly -stage miss -entry main -target spirv-assembly + +struct ShadowRay +{ + float hitDistance; +}; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main(in out ShadowRay ray) +{ + ray.hitDistance = 10000.0f; +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/raygen.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/raygen.slang new file mode 100644 index 0000000000..d21f61c1f9 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/raygen.slang @@ -0,0 +1,119 @@ +// DISABLE_TEST:CROSS_COMPILE: -profile glsl_460+GL_EXT_ray_tracing -stage raygeneration -entry main -target spirv-assembly +//TEST:SIMPLE(filecheck=CHECK_GLSL): -allow-glsl -emit-spirv-directly -stage raygeneration -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -allow-glsl -emit-spirv-directly -stage raygeneration -entry main -target spirv-assembly + +#define TRACING_EPSILON 1e-6 + +Texture2D samplerPosition; +Texture2D samplerNormal; +SamplerState sampler; + +struct Light { + float4 position; + float4 color; +}; + +struct Uniforms +{ + Light light; + float4 viewPos; + float4x4 view; + float4x4 model; +}; +ConstantBuffer ubo; + +layout(rgba8) +RWTexture2D outputImage; + +RaytracingAccelerationStructure as; + +struct ShadowRay +{ + float hitDistance; +}; + +struct ReflectionRay +{ + float color; +}; + +#define gl_LaunchIDNV DispatchRaysIndex() +#define gl_LaunchSizeNV DispatchRaysDimensions() + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main() +{ + float2 inUV = float2( + (float(gl_LaunchIDNV.x) + 0.5f) / float(gl_LaunchSizeNV.x), + (float(gl_LaunchIDNV.y) + 0.5f) / float(gl_LaunchSizeNV.y) + ); + + float3 P = samplerPosition.SampleLevel(sampler, inUV, 0).rgb; + float3 N = samplerNormal.SampleLevel(sampler, inUV, 0).rgb * 2.0 - 1.0; + + float3 lightPos = ubo.light.position.xyz; + float3 lightDelta = lightPos - P; + float lightDist = length(lightDelta); + float3 L = normalize(lightDelta); + float atten = 1.0f / (lightDist*lightDist); + + RayDesc ray; + ray.Origin = P; + ray.TMin = TRACING_EPSILON; + ray.Direction = lightDelta; + ray.TMax = lightDist; + + { + ShadowRay shadowRay; + shadowRay.hitDistance = 0; + + TraceRay(as, + // ray flags + 1, + // cull mask + 0xff, + // sbt record offset + 0, + // sbt record stride + 0, + // missIndex + 2, + // ray + ray, + // payload + shadowRay); + + if (shadowRay.hitDistance < lightDist) + { + atten = 0.f; + } + } + + float3 color = ubo.light.color.xyz * saturate(dot(N,L)) * atten; + + + { + ReflectionRay reflectionRay; + TraceRay(as, + // ray flags + 1, + // cull mask + 0xff, + // sbt record offset + 0, + // sbt record stride + 0, + // missIndex + 2, + // ray + ray, + // payload + reflectionRay); + + + color = color + reflectionRay.color; + } + + outputImage[int2(gl_LaunchIDNV.xy)] = float4(color, 1.0); +} diff --git a/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/rayquery-closesthit.slang b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/rayquery-closesthit.slang new file mode 100644 index 0000000000..374b73e652 --- /dev/null +++ b/tests/glsl-intrinsic/raytracing/vkray-shader-invocation-reorder/rayquery-closesthit.slang @@ -0,0 +1,27 @@ +//TEST:SIMPLE(filecheck=CHECK_GLSL): -profile glsl_460+GL_EXT_ray_tracing -stage closesthit -entry main -target glsl +//TEST:SIMPLE(filecheck=CHECK_SPIRV): -stage closesthit -entry main -target spirv-assembly -emit-spirv-directly + + +struct IntersectionPayload +{ + float3 triangleVerticeCommitted[3]; + float3 triangleVerticeCandidate[3]; +}; + +RaytracingAccelerationStructure accelerationStructure; + +// CHECK_GLSL: void main( +// CHECK_SPIRV: OpEntryPoint +void main( + BuiltInTriangleIntersectionAttributes attributes, + in out IntersectionPayload ioPayload) +{ + RayQuery rayQuery; + + uint instanceInclusionMask = 0x00; + RayDesc rayDesc; + rayQuery.TraceRayInline(accelerationStructure, RAY_FLAG_NONE, instanceInclusionMask, rayDesc); + + ioPayload.triangleVerticeCommitted = rayQuery.CandidateGetIntersectionTriangleVertexPositions(); + ioPayload.triangleVerticeCandidate = rayQuery.CommittedGetIntersectionTriangleVertexPositions(); +} diff --git a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang index 79b8411b04..ff1eb59c62 100644 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang +++ b/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang @@ -1,6 +1,6 @@ // hit-object-array.slang -//TEST:SIMPLE: -target dxil -entry rayGenerationMain -stage raygeneration -profile sm_6_5 -DNV_SHADER_EXTN_SLOT=u0 +//DISABLE_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 */ 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 deleted file mode 100644 index fdc5cf0d7e..0000000000 --- a/tests/hlsl-intrinsic/shader-execution-reordering/hit-object-array.slang.expected +++ /dev/null @@ -1,439 +0,0 @@ -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" = 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" = 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", align 4 -@"\01?scene_0@@3URaytracingAccelerationStructure@@A" = external constant %struct.RaytracingAccelerationStructure, align 4 -@"\01?outputBuffer_0@@3V?$RWStructuredBuffer@I@@A" = external constant %"class.RWStructuredBuffer", 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", %"class.RWStructuredBuffer"* @"\01?outputBuffer_0@@3V?$RWStructuredBuffer@I@@A", align 4 - %3 = load %"class.RWStructuredBuffer", %"class.RWStructuredBuffer"* @"\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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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"(i32 160, %"class.RWStructuredBuffer" %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 - -;