microsoft / microsoft/DirectXShaderCompiler
[Debug info] Only the first four elements of a matrix loaded from a buffer get debug values
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: matrix_buffer_load.zip
dxc -T cs_6_0 -Zi -Qembed_debug -Od -Fc float4x4.ll float4x4.hlsl
RWStructuredBuffer<float4x4> buffer : register(u0);
[numthreads(1, 1, 1)]
void main()
{
float4x4 value = buffer[0];
float4x4 result = value * 2;
buffer[1] = result;
}
Actual
All 16 elements of value are live SSA values, but only the four produced by the first bufferLoad get a dbg.value:
%1 = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %buffer_UAV_structbuf, i32 0, i32 0)
%2 = extractvalue %dx.types.ResRet.f32 %1, 0
%3 = extractvalue %dx.types.ResRet.f32 %1, 1
%4 = extractvalue %dx.types.ResRet.f32 %1, 2
%5 = extractvalue %dx.types.ResRet.f32 %1, 3
%6 = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %buffer_UAV_structbuf, i32 0, i32 16)
%7 = extractvalue %dx.types.ResRet.f32 %6, 0
...
%20 = extractvalue %dx.types.ResRet.f32 %16, 3
; nothing for %7..%10, %12..%15, %17..%20
call void @llvm.dbg.value(metadata float %2, ...) ; var:"value" !DIExpression(DW_OP_bit_piece, 0, 32)
call void @llvm.dbg.value(metadata float %3, ...) ; var:"value" !DIExpression(DW_OP_bit_piece, 32, 32)
call void @llvm.dbg.value(metadata float %4, ...) ; var:"value" !DIExpression(DW_OP_bit_piece, 64, 32)
call void @llvm.dbg.value(metadata float %5, ...) ; var:"value" !DIExpression(DW_OP_bit_piece, 96, 32)
result on the other hand is computed rather than loaded, gets all 16 fragments.
| repro | matrix | elements | fragments for value |
fragments for result |
|---|---|---|---|---|
float2x3.hlsl |
float2x3 | 6 | 4 | 6 |
float2x4.hlsl |
float2x4 | 8 | 4 | 8 |
float3x2.hlsl |
float3x2 | 6 | 4 | 6 |
float3x3.hlsl |
float3x3 | 9 | 4 | 9 |
float3x4.hlsl |
float3x4 | 12 | 4 | 12 |
float4x2.hlsl |
float4x2 | 8 | 4 | 8 |
float4x3.hlsl |
float4x3 | 12 | 4 | 12 |
float4x4.hlsl |
float4x4 | 16 | 4 | 16 |
int4x4.hlsl |
int4x4 | 16 | 4 | 16 |
half4x4.hlsl |
half4x4 | 16 | 4 | 16 |
double4x4.hlsl |
double4x4 | 16 | 4 | 16 |
float2x2 is unaffected because it has exactly four elements.
Expected
value should get one dbg.value per element, like result does.
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
Unpack matrix_buffer_load.zip and begin with the float4x4.hlsl reproduction using the reported dxc command, then inspect float4x4.ll. Compare the dbg.value fragments emitted for the loaded value with those for the computed result across the listed matrix cases. Done means every matrix element receives a dbg.value entry, including the unaffected float2x2 baseline.
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
- 55/100