99static const int32_t s_sampleCount = 10 ;
1010static const float32_t3 s_clearColor = float32_t3 (0.3 , 0.3 , 0.8 );
1111
12+ using namespace nbl::hlsl;
13+
1214[[vk::push_constant]] SPushConstants pc;
1315
1416[[vk::binding (0 , 0 )]] RaytracingAccelerationStructure topLevelAS;
@@ -23,8 +25,8 @@ float32_t nextRandomUnorm(inout nbl::hlsl::Xoroshiro64StarStar rnd)
2325[shader ("raygeneration" )]
2426void main ()
2527{
26- const uint32_t3 launchID = DispatchRaysIndex () ;
27- const uint32_t3 launchSize = DispatchRaysDimensions () ;
28+ const uint32_t3 launchID = spirv::LaunchIdKHR ;
29+ const uint32_t3 launchSize = spirv::LaunchSizeKHR ;
2830 const uint32_t2 coords = launchID.xy;
2931
3032 const uint32_t seed1 = nbl::hlsl::random::Pcg::create (pc.frameCounter)();
@@ -53,9 +55,11 @@ void main()
5355 rayDesc.TMin = 0.01 ;
5456 rayDesc.TMax = 10000.0 ;
5557
58+ [[vk::ext_storage_class (spv::StorageClassRayPayloadKHR)]]
5659 PrimaryPayload payload;
5760 payload.pcg = PrimaryPayload::generator_t::create (rnd ());
58- TraceRay (topLevelAS, RAY_FLAG_NONE, 0xff , ERT_PRIMARY, 0 , EMT_PRIMARY, rayDesc, payload);
61+ spirv::traceRayKHR (topLevelAS, spv::RayFlagsMaskNone, 0xff , ERT_PRIMARY, 0 , EMT_PRIMARY, rayDesc.Origin, rayDesc.TMin, rayDesc.Direction, rayDesc.TMax, payload);
62+ // TraceRay(topLevelAS, RAY_FLAG_NONE, 0xff, ERT_PRIMARY, 0, EMT_PRIMARY, rayDesc, payload);
5963
6064 const float32_t rayDistance = payload.rayDistance;
6165 if (rayDistance < 0 )
@@ -67,9 +71,10 @@ void main()
6771 const float32_t3 worldPosition = pc.camPos + (camDirection * rayDistance);
6872
6973 // make sure to call with least live state
74+ [[vk::ext_storage_class (spv::StorageClassCallableDataKHR)]]
7075 RayLight cLight;
7176 cLight.inHitPosition = worldPosition;
72- CallShader (pc.light.type, cLight);
77+ spirv:: executeCallable (pc.light.type, cLight);
7378
7479 const float32_t3 worldNormal = payload.worldNormal;
7580
@@ -97,12 +102,16 @@ void main()
97102 rayDesc.TMin = 0.01 ;
98103 rayDesc.TMax = cLight.outLightDistance;
99104
105+ [[vk::ext_storage_class (spv::StorageClassRayPayloadKHR)]]
100106 OcclusionPayload occlusionPayload;
101107 // negative means its a hit, the miss shader will flip it back around to positive
102108 occlusionPayload.attenuation = -1.f ;
103109 // abuse of miss shader to mean "not hit shader" solves us having to call closest hit shaders
104- uint32_t shadowRayFlags = RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER;
105- TraceRay (topLevelAS, shadowRayFlags, 0xFF , ERT_OCCLUSION, 0 , EMT_OCCLUSION, rayDesc, occlusionPayload);
110+ uint32_t shadowRayFlags = spv::RayFlagsTerminateOnFirstHitKHRMask | spv::RayFlagsSkipClosestHitShaderKHRMask;
111+ spirv::traceRayKHR (topLevelAS, shadowRayFlags, 0xFF , ERT_OCCLUSION, 0 , EMT_OCCLUSION, rayDesc.Origin, rayDesc.TMin, rayDesc.Direction, rayDesc.TMax, occlusionPayload);
112+
113+ // uint32_t shadowRayFlags = RAY_FLAG_ACCEPT_FIRST_HIT_AND_END_SEARCH | RAY_FLAG_SKIP_CLOSEST_HIT_SHADER;
114+ // TraceRay(topLevelAS, shadowRayFlags, 0xFF, ERT_OCCLUSION, 0, EMT_OCCLUSION, rayDesc, occlusionPayload);
106115
107116 attenuation = occlusionPayload.attenuation;
108117 if (occlusionPayload.attenuation > 1.f /1024.f )
0 commit comments