microsoft / microsoft/DirectXShaderCompiler

Empty bitfield reflection in DXIL

Open
#8,489 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
dxc generates invalid reflection for structures with bitfields. This leads to structure parsing issues when using debugging software (PIX, RenderDoc).

Steps to Reproduce

  1. Create sample compute shader test.hlsl
StructuredBuffer<float> InputBuffer : register(t0);
RWStructuredBuffer<float> OutputBuffer : register(u0);

struct PPP
{
    uint test : 1;
    uint pad : 31;
};

cbuffer Constants : register(b0)
{
    PPP inner;
};

[numthreads(256, 1, 1)] void main(uint3 DispatchThreadID : SV_DispatchThreadID)
{
    int index = DispatchThreadID.x;

    OutputBuffer[index] = InputBuffer[index] * inner.test;
}
  1. Run dxc on it using this command line: dxc.exe -HV 2021 -T cs_6_5 -E main test.hlsl

Actual Behavior
Generated DXIL Buffer Definitions looks like this:

; Buffer Definitions:
;
; cbuffer Constants
; {
;
;   struct Constants
;   {
;
;       struct struct.PPP
;       {
;
;           uint ;                                    ; Offset:    0
;       
;       } inner;                                      ; Offset:    0
;
;   
;   } Constants;                                      ; Offset:    0 Size:     4
;
; }

Expected Behavior

;       struct struct.PPP
;       {
;
;           uint test : 1;                                    ; Offset:    0
;
;           uint pad : 31;                                    ; Offset:    0
;       
;       } inner;                                      ; Offset:    0

Offset: probably should stay the same for the whole uint in bitset.
Environment

  • DXC version: dxcompiler.dll: 1.9(5184-21d28f72)(1.9.2602.17) - 1.9.2602.17 (21d28f727)
  • Host Operating System: Windows 10

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 with the test.hlsl reproduction and run the provided dxc command to inspect the generated DXIL buffer definitions. Trace the compiler's reflection handling for the PPP bitfield structure. Done means the reflection lists test and pad with their bitfield widths while retaining offset 0 for both fields, without the empty field shown in the report.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.