microsoft / DirectXShaderCompiler

This repo hosts the source for the DirectX Shader Compiler which is based on LLVM/Clang.
Other
3.11k stars 697 forks source link

DISubprogram not attached to function directly #6955

Open czw831024 opened 1 month ago

czw831024 commented 1 month ago

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

damyanp commented 1 month ago

From our initial look at this we think that this is working as expected. Is there some functionality not working as a result of this?

@AdamJMiles, @jeffnn - do you have any insights as to whether or not this is a bug?

damyanp commented 1 month ago

Oops, meant to tag @adam-yang in this. But other Adam if you have any insights they'd also be appreciated :)

czw831024 commented 1 week ago

Any update?

damyanp commented 1 week ago

Other than the update above, I'm afraid not. We've triaged this as "Dormant" which means that we don't currently think it reaches the bar for us to actively investigate it - but we would be prepared to accept a pull request with a proposed fix if one were submitted.