microsoft / microsoft/DirectXShaderCompiler

[Feature Request] PS output variable names in reflection

Open
#6,150 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement reflection
Dominant language
C++
Stars
3.7k
Forks
900
Avg merge
2d 11h
Merged PRs (30d)
44

Description

Is your feature request related to a problem? Please describe.
One problem I have ran into lately is trying to validate pixel shader outputs (SV_Target[N]) against the attached render targets. I wanted to encode that information in the shader output variables name, however I don't think its possible to get the name through reflection, you can only get semantic names. It would be great to have that info during reflection.

Describe the solution you'd like
Name of the variable that is assigned to SV_Target[N]
For example the following PS shader:

struct Out {
    float4 color1 : SV_Target0;
};

Out main() {
    Out x;
    x.color1 = float4(1, 1, 1, 1);
    return x;
}

When using ID3D12ShaderReflection to get the output variable name:

...
D3D12_SIGNATURE_PARAMETER_DESC desc;
reflection->GetOutputParameterDesc(0, &desc);
log_debugl("%s", desc.Name); // desc.Name should contain the variable that writes to that output

Describe alternatives you've considered
One alternative was to parse disassembled blob with embedded debug info that contains type annotations, this proved to be a bit inconsistent as some shaders did not produce type annotations (could be my mistake too)

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 HLSL pixel-shader example and the ID3D12ShaderReflection::GetOutputParameterDesc call described in the issue. Trace how the output signature's D3D12_SIGNATURE_PARAMETER_DESC is produced and determine how the source variable name could be exposed. Done means desc.Name reports the variable assigned to SV_Target[N] through reflection.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
compilers, computer-graphics
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.