yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
0b2d7533d
master
1// ray-query-subroutine.slang 2 3// Regression test for passing a `RayQuery` value into a subroutine. 4 5//TEST:CROSS_COMPILE: -profile sm_6_5 -stage compute -entry computeMain -target dxil-assembly 6 7RWStructuredBuffer<int> gOutput; 8RaytracingAccelerationStructure gScene; 9 10float3 helper<let N : uint>(inout RayQuery<N> q) 11{ 12 RayDesc ray; 13 ray.Origin = 0; 14 ray.Direction = 0; 15 ray.TMin = 0; 16 ray.TMax = 1000.0; 17 q.TraceRayInline( 18 /* accellerationStructure: */ gScene, 19 /* rayFlags: */ N, 20 /* instanceInclusionmask: */ 0xFFFFFFFF, 21 /* ray: */ ray ); 22 23 return q.WorldRayDirection(); 24} 25 26[shader("compute")] 27void computeMain(uint tid : SV_DispatchThreadID) 28{ 29 // Note: The original issue was due to "folding" of an instruction 30 // into use sites as part of emitting high-level-language code. 31 // 32 // In this case, the initial value of `rayQuery` has only a single 33 // use (in the call to `helper()`) and as a result was subject to 34 // "folding" during emit, because it had no side-effects. 35 36 RayQuery<0> rayQuery; 37 let result = helper(rayQuery); 38 39 gOutput[tid.x] = int(result.x); 40}