microsoft / microsoft/DirectXShaderCompiler
[Debug info] Unbounded resource array is described as `DISubrange(count: 1)`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Version: dxcompiler.dll 1.9(5402-0d3ee6b5)(1.9.0.5402) - 1.9.0.5402 (0d3ee6b55-dirty)
Repro files: unbounded_texture_array.zip
dxc -T cs_6_6 -Zi -Qembed_debug -Od -Fc unbounded_texture_array.ll unbounded_texture_array.hlsl
Texture2D<float4> tex[] : register(t0); // unbounded
Texture2D<float4> tex8[8] : register(t0, space1); // bounded, for comparison
SamplerState samp : register(s0);
RWStructuredBuffer<float4> outBuf : register(u0);
[numthreads(1, 1, 1)]
void main(uint2 tid : SV_DispatchThreadID)
{
float2 uv = float2(tid) / 2.0;
outBuf[0] = tex[tid.x].SampleLevel(samp, uv, 0) + tex8[tid.y].SampleLevel(samp, uv, 0);
}
Actual
; unbounded Texture2D<float4> tex[]
!27 = !DIGlobalVariable(name: "tex", ..., type: !28, ...)
!28 = !DICompositeType(tag: DW_TAG_array_type, baseType: !29, size: 160, align: 32, elements: !40)
!40 = !{!41}
!41 = !DISubrange(count: 1)
; bounded Texture2D<float4> tex8[8]
!42 = !DIGlobalVariable(name: "tex8", ..., type: !43, ...)
!43 = !DICompositeType(tag: DW_TAG_array_type, baseType: !29, size: 1280, align: 32, elements: !44)
!44 = !{!45}
!45 = !DISubrange(count: 8)
The unbounded array is emitted as if declared Texture2D<float4> tex[1]:
count: 1 and size: 160 (one element). Nothing in the metadata distinguishes
tex[] from tex[1].
Expected
A subrange with no upper bound, should probably be !DISubrange(count: -1), and 0
for size: on the DICompositeType.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with unbounded_texture_array.zip and run the provided dxc command to reproduce the LLVM metadata. Compare the unbounded tex[] metadata with bounded tex8[8], then trace the compiler's debug-type emission for resource arrays. Done means tex[] is distinguishable from tex[1] through its subrange and composite-type size metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 58/100