forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add raypayload decoration to ray payload structs
Closes shader-slang#6104
- Loading branch information
1 parent
67dfc9b
commit a0a24ae
Showing
9 changed files
with
125 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA | ||
|
||
// CHECK: struct SLANG_RAYPAYLOAD | ||
|
||
uniform RWTexture2D resultTexture; | ||
uniform RaytracingAccelerationStructure sceneBVH; | ||
|
||
[shader("raygeneration")] | ||
void rayGenShaderA() | ||
{ | ||
int2 threadIdx = DispatchRaysIndex().xy; | ||
|
||
float3 rayDir = float3(0, 0, 1); | ||
float3 rayOrigin = 0; | ||
rayOrigin.x = (threadIdx.x * 2) - 1; | ||
rayOrigin.y = (threadIdx.y * 2) - 1; | ||
|
||
// Trace the ray. | ||
RayDesc ray; | ||
ray.Origin = rayOrigin; | ||
ray.Direction = rayDir; | ||
ray.TMin = 0.001; | ||
ray.TMax = 10000.0; | ||
float4 payload = float4(0, 0, 0, 0); | ||
TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload); | ||
|
||
resultTexture[threadIdx.xy] = payload; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
//TEST:SIMPLE(filecheck=CHECK): -target hlsl -stage raygeneration -entry rayGenShaderA | ||
|
||
// CHECK: struct SLANG_RAYPAYLOAD | ||
|
||
struct RayPayload | ||
{ | ||
float4 color; | ||
}; | ||
|
||
uniform RWTexture2D resultTexture; | ||
uniform RaytracingAccelerationStructure sceneBVH; | ||
|
||
[shader("raygeneration")] | ||
void rayGenShaderA() | ||
{ | ||
int2 threadIdx = DispatchRaysIndex().xy; | ||
|
||
float3 rayDir = float3(0, 0, 1); | ||
float3 rayOrigin = 0; | ||
rayOrigin.x = (threadIdx.x * 2) - 1; | ||
rayOrigin.y = (threadIdx.y * 2) - 1; | ||
|
||
// Trace the ray. | ||
RayDesc ray; | ||
ray.Origin = rayOrigin; | ||
ray.Direction = rayDir; | ||
ray.TMin = 0.001; | ||
ray.TMax = 10000.0; | ||
RayPayload payload = { float4(0, 0, 0, 0) }; | ||
TraceRay(sceneBVH, RAY_FLAG_NONE, ~0, 0, 0, 0, ray, payload); | ||
|
||
resultTexture[threadIdx.xy] = payload.color; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters