microsoft / microsoft/DirectXShaderCompiler

dxil missing inlineAt in debug info for sampler annotations

Open
#8,592 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Description
annotateHandle calls associated with global samples do not get attributed to the right source location in debug info.

Steps to Reproduce

Compile

struct A
{
    uint i;
};

ConstantBuffer<A> C : register(b0);
Texture2D<float4> T : register(t0);

SamplerState F()
{
    return SamplerDescriptorHeap[NonUniformResourceIndex(C.i)];
}

static const SamplerState S = F();

float4 main(float2 uv : TEXCOORD0) : SV_Target
{
    return T.Sample(S, uv);
}

dxc.exe repro.hlsl -T ps_6_6 -E main -HV 2021 -Zi -Fd "repro.pdb" -Fo "repro.dxil" -Fc "repro.ll"

Actual Behavior
%7 = call %dx.types.Handle @dx.op.annotateHandle(i32 216, %dx.types.Handle %6, %dx.types.ResourceProperties { i32 14, i32 0 }), !dbg !90 ; line:14 col:0 ; AnnotateHandle(res,props) resource: SamplerState
!29 = !DISubprogram(name: "F", linkageName: "\01?F@@YA?AUSamplerState@@XZ", scope: !1, file: !1, line: 9, type: !30, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: false)
!90 = !DILocation(line: 14, scope: !29)

%7 is physically inside @main, but its debug scope is !29 / F, with no inlinedAt chain back to main.
Also, If DXC wants to attribute %7 to the global initializer (line 14), maybe it should be scoped to the global initializer subprogram, not F? (line 14 isn't in F).

Environment

  • DXC version dxcompiler.dll: 1.10(5180-e3554182)(1.9.0.5180) - 1.9.0.5180 (e35541826)
  • Host Operating System Windows 11

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

Start by compiling the supplied HLSL repro with the shown dxc command and inspect the generated LLVM/debug metadata for dx.op.annotateHandle in F and main. Determine the intended scope and inlineAt attribution for the global sampler initializer; done when the emitted debug information attributes the instruction consistently to the appropriate source location and scope.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.