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
1.1 KiB37 linesraw
1//TEST:SIMPLE(filecheck=CHECK): -target hlsl -profile lib_6_7 -stage raygeneration -entry rayGenShaderA
2//TEST:SIMPLE(filecheck=DXIL): -target dxil -profile lib_6_7 -stage raygeneration -entry rayGenShaderA
3
4// CHECK: struct [raypayload]
5// CHECK: float4 color_0 : read(caller, anyhit) : write(caller);
6// DXIL: define void @
7// DXIL: !dx.dxrPayloadAnnotations
8
9struct [raypayload] RayPayload
10{
11    float4 color : read(caller, anyhit) : write(caller);
12};
13
14uniform RWTexture2D<float4> resultTexture;
15uniform RaytracingAccelerationStructure sceneBVH;
16
17[shader("raygeneration")]
18void rayGenShaderA()
19{
20    int2 threadIdx = DispatchRaysIndex().xy;
21
22    float3 rayDir = float3(0, 0, 1);
23    float3 rayOrigin = 0;
24    rayOrigin.x = (threadIdx.x * 2) - 1;
25    rayOrigin.y = (threadIdx.y * 2) - 1;
26
27    // Trace the ray.
28    RayDesc ray;
29    ray.Origin = rayOrigin;
30    ray.Direction = rayDir;
31    ray.TMin = 0.001;
32    ray.TMax = 10000.0;
33    RayPayload payload = { float4(0, 0, 0, 0) };
34    TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload);
35
36    resultTexture[threadIdx.xy] = payload.color;
37}