yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Harsh Aggarwal (NVIDIA)Support for Payload Access Qualifiers (#3448) (#6595)ce87ab925

master
881 B30 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
2//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_6 -stage raygeneration -entry rayGenShaderA
3
4// CHECK: struct RayPayload
5// DXIL: define void @
6
7uniform RWTexture2D resultTexture;
8uniform RaytracingAccelerationStructure sceneBVH;
9
10[shader("raygeneration")]
11void rayGenShaderA()
12{
13    int2 threadIdx = DispatchRaysIndex().xy;
14
15    float3 rayDir = float3(0, 0, 1);
16    float3 rayOrigin = 0;
17    rayOrigin.x = (threadIdx.x * 2) - 1;
18    rayOrigin.y = (threadIdx.y * 2) - 1;
19
20    // Trace the ray.
21    RayDesc ray;
22    ray.Origin = rayOrigin;
23    ray.Direction = rayDir;
24    ray.TMin = 0.001;
25    ray.TMax = 10000.0;
26    float4 payload = float4(0, 0, 0, 0);
27    TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
28
29    resultTexture[threadIdx.xy] = payload;
30}