microsoft / microsoft/DirectXShaderCompiler
Shader reflection broken in DXIL if struct's name starts with "Buffer"
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
The information gathered from a RWStructuredBuffer using ID3D12ShaderReflection isn't the same for DXBC and DXIL if the template argument type name starts with "Buffer". The DXBC information is the expected one.
After a very quick investigation, the problem seems to come from here:
https://github.com/microsoft/DirectXShaderCompiler/blob/ef1472a14a0d8b85e5f0807d985f739eb47bb9e9/lib/HLSL/DxilContainerReflection.cpp#L1258
https://github.com/microsoft/DirectXShaderCompiler/blob/ef1472a14a0d8b85e5f0807d985f739eb47bb9e9/lib/HLSL/DxilContainerReflection.cpp#L941
Steps to Reproduce
Build a shader with a declaration like:
struct BufferData { int i; int j; };
RWStructuredBuffer<BufferData> resource;
Accessing the information about that resource through ID3D12ShaderReflection will not get you the correct information about BufferData if the reflection is on DXIL. Getting to the D3D12_SHADER_TYPE_DESC of the BufferData struct through the ID3D12ShaderReflectionConstantBuffer associated to the declared RWStructuredBuffer will give you different results whether you're reflecting on DXBC or DXIL.
DXBC:
DXIL:
Actual Behavior
Note that if the struct name does not start with "Buffer", the behavior is the same for both DXIL and DXBC.
The DXIL information should be the same as that of DXBC in all cases.
Environment
- DXC version: dxcompiler.dll: 1.8.2407.12; dxil.dll: 101.8.2407.17
- Host Operating System: Windows 11
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 in lib/HLSL/DxilContainerReflection.cpp at the referenced areas around lines 1258 and 941, then reproduce the issue with the provided HLSL declaration and ID3D12ShaderReflection. Compare the D3D12_SHADER_TYPE_DESC results for DXIL and DXBC, including a struct whose name starts with "Buffer". Done means DXIL reports the same BufferData information as DXBC.
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
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100