Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Latest DXC requires a new keyword [raypayload] on a struct when used as ray-tracing payload #6104

Open
jkwak-work opened this issue Jan 16, 2025 · 2 comments
Assignees
Labels
goal:client support Feature or fix needed for a current slang user.

Comments

@jkwak-work
Copy link
Collaborator

jkwak-work commented Jan 16, 2025

When using the latest DXC binary, we are failing on two existing tests,

gfx-unit-test-tool/RayTracingTestAD3D12.internal
gfx-unit-test-tool/RayTracingTestBD3D12.internal

This failure is observed on the CI testing of PR 6095.

Reproduce step
It can be reproduced with the following command,

$ build/Release/bin/slang-test.exe gfx-unit-test-tool/RayTracingTestBD3D12
Supported backends: fxc dxc glslang spirv-dis clang visualstudio genericcpp nvrtc llvm spirv-opt metal tint
error: !SLANG_FAILED(loadShaderProgram(device, rayTracingProgram.writeRef())) - D:\sbf\git\slang\test_server_should_use_a_custom_d3d12core_dll\tools\gfx-unit-test\ray-tracing-tests.cpp (363)
FAILED test: 'gfx-unit-test-tool/RayTracingTestBD3D12.internal'
0% of tests passed (0/1)
failing tests:
---
gfx-unit-test-tool/RayTracingTestBD3D12.internal
---

Error message
The real error message can be seen only with a debugger and it says,

dxc 1.7: tools/gfx-unit-test/ray-tracing-test-shaders.slang(26): error :  type 'RayPayload_0' used as payload requires that it is annotated with the [raypayload] attribute
dxc 1.7: note :     RayPayload_0 payload_0;
dxc 1.7: note :                  ^

This seems to be a new requirement given that the shader was working fine before.
DXC document states the following,

Syntax
Any structure type used as payload must carry the [raypayload] type attribute as part of the type declaration as follows:
struct [raypayload] MyPayload{ ... };

Goal
The goal is to add [raypayload] attribute to any struct that is used as a ray-tracing payload when targeting HLSL.
Currently the testing shader is translated into HLSL without the keyword,

build/Release/bin/slangc.exe -target hlsl -stage raygeneration -entry rayGenShaderA tools/gfx-unit-test/ray-tracing-test-shaders.slang

RaytracingAccelerationStructure sceneBVH_0 : register(t0);

RWTexture2D<float4 > resultTexture_0 : register(u0);

struct RayPayload_0
{
    float4 color_0;
};

[shader("raygeneration")]void rayGenShaderA()
{
    uint3 _S1 = DispatchRaysIndex();
......
    RayPayload_0 payload_0;
......
}

The line struct RayPayload_0 should have [raypayload] attribute when the issue is fixed.

@jkwak-work jkwak-work self-assigned this Jan 16, 2025
@skallweitNV
Copy link
Collaborator

I also just stumbled over this with dxc 1.8

@jkwak-work
Copy link
Collaborator Author

jkwak-work commented Jan 16, 2025

It seems that GLSL and SPIRV target uses [__vulkanRayPayload].
For HLSL target, it seems like the payload always goes through a function,

__generic<T>
__intrinsic_op($(kIROp_ForceVarIntoStructTemporarily))
Ref<T> __forceVarIntoStructTemporarily(inout T maybeStruct);

I am guessing the function should emit [RayPayload] attribute when synthesize a struct.
And it will need to legalize if the parameter was already a struct.

@jkwak-work jkwak-work added the goal:client support Feature or fix needed for a current slang user. label Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
goal:client support Feature or fix needed for a current slang user.
Projects
None yet
Development

No branches or pull requests

2 participants