yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
ce87ab925
master
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// CHECK: float4 color 6// DXIL: define void @ 7struct RayPayload 8{ 9 float4 color; 10}; 11 12uniform RWTexture2D resultTexture; 13uniform RaytracingAccelerationStructure sceneBVH; 14 15[shader("raygeneration")] 16void rayGenShaderA() 17{ 18 int2 threadIdx = DispatchRaysIndex().xy; 19 20 float3 rayDir = float3(0, 0, 1); 21 float3 rayOrigin = 0; 22 rayOrigin.x = (threadIdx.x * 2) - 1; 23 rayOrigin.y = (threadIdx.y * 2) - 1; 24 25 // Trace the ray. 26 RayDesc ray; 27 ray.Origin = rayOrigin; 28 ray.Direction = rayDir; 29 ray.TMin = 0.001; 30 ray.TMax = 10000.0; 31 RayPayload payload = { float4(0, 0, 0, 0) }; 32 TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload); 33 34 resultTexture[threadIdx.xy] = payload.color; 35}