microsoft / microsoft/DirectXShaderCompiler

DISubprogram not attached to function directly

Open
#6,955 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

We found that ray tracing shaders from D3D12RaytracingRealTimeDenoisedAmbientOcclusion in MSFT's DirectX-Graphics-Samples from Github don't have DISubprogram s attached to their corresponding functions in DXIL. For example, in Pathtracer.hlsl

define void @MyMissShader_RadianceRay() {
%WorldRayDirection.i = call float @dx.op.worldRayDirection.f32(i32 148, i8 0) #3, !dbg !344
%WorldRayDirection1.i = call float @dx.op.worldRayDirection.f32(i32 148, i8 1) #3, !dbg !344
%WorldRayDirection2.i = call float @dx.op.worldRayDirection.f32(i32 148, i8 2) #3, !dbg !344
%1 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 0, i32 0, i32 12, i1 false), !dbg !362
%2 = call %dx.types.Handle @dx.op.createHandle(i32 57, i8 3, i32 0, i32 0, i1 false), !dbg !362
...

!481 = !DISubprogram(name: "MyMissShader_RadianceRay", linkageName: "\01?MyMissShader_RadianceRay@@YAXUPathtracerRayPayload@@@Z", scope: !1, file: !1, line: 536, type: !482, isLocal: false, isDefinition: true, scopeLine: 537, flags: DIFlagPrototyped, isOptimized: false, function: void (%struct.PathtracerRayPayload*)* @"\01?MyMissShader_RadianceRay@@YAXUPathtracerRayPayload@@@Z")

We expect something like

define void @MyMissShader_RadianceRay() !dbg !481{

to connect the DISubprogram and its function directly.

To compile the shader and reproduce, you can modify the following command, which I got from the build

D:\Codes\MSFT\DirectX-Graphics-Samples\Samples\Desktop\D3D12Raytracing\src\D3D12RaytracingRealTimeDenoisedAmbientOcclusion>D:\Downloads\dxc_2024_07_31\bin\x64\dxc.exe /I"D:\Codes\MSFT\DirectX-Graphics-Samples\Samples\Desktop\D3D12Raytracing\src\D3D12RaytracingRealTimeDenoisedAmbientOcclusion\" /I"D:\Codes\MSFT\DirectX-Graphics-Samples\Samples\Desktop\D3D12Raytracing\src\D3D12RaytracingRealTimeDenoisedAmbientOcclusion\" /IRTAO/shaders /ISampleCore/shaders /ISampleCore/shaders/util /nologo /T lib_6_3 /Fh "obj\x64\Debug\CompiledShaders\Pathtracer.hlsl.h" /Vn "g_pPathtracer" /Zi /Zpr -Qembed_debug -HV 2021 SampleCore\Shaders\Pathtracer.hlsl

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with SampleCore\Shaders\Pathtracer.hlsl using the provided dxc command and inspect the generated DXIL. Compare the function definition for MyMissShader_RadianceRay with its DISubprogram metadata. Done means the corresponding function is directly connected to the DISubprogram as shown in the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.