Skip to content

Retrieving reflection data for structs used in input signatures #3535

Open

Description

I am writing a code generator based on D3D12 shader reflection data. Given a simple vertex shader:

struct VertexIn
{
    float3 mPos : POSITION;
    float3 mColor : COLOR;
};
struct VertexOut;  // layout unimportant to question

VertexOut VS(VertexIn vin) 
{ 
    // some math here, return a VertexOut
}

I can use ID3D12ShaderReflection::GetInputParameterDesc to get the type and semantic for each member of VertexIn, as well as the register it is mapped to. However, I would like to retrieve the names of the VertexIn members (i.e. "mPos" and "mColor") for my generated code. Is there a way to do this?

Activity

  1. added
    user-support
    and removed
    needs-triage
    on Apr 17, 2024
  2. damyanp commented on Apr 17, 2024

    @damyanp
    Member

    Cooper Partin (@coopp) - as you're looking in to the reflection stuff at the moment you may be able to answer whether or not this is possible.

  3. coopp commented on Apr 18, 2024

    @coopp
    Contributor

    I think the SemanticName is available as part of the _D3D12_SIGNATURE_PARAMETER_DESC

    typedef struct _D3D12_SIGNATURE_PARAMETER_DESC
    {
        LPCSTR                      SemanticName;   // Name of the semantic
        UINT                        SemanticIndex;  // Index of the semantic
        UINT                        Register;       // Number of member variables
        D3D_NAME                    SystemValueType;// A predefined system value, or D3D_NAME_UNDEFINED if not applicable
        D3D_REGISTER_COMPONENT_TYPE ComponentType;  // Scalar type (e.g. uint, float, etc.)
        BYTE                        Mask;           // Mask to indicate which components of the register
                                                    // are used (combination of D3D10_COMPONENT_MASK values)
        BYTE                        ReadWriteMask;  // Mask to indicate whether a given component is 
                                                    // never written (if this is an output signature) or
                                                    // always read (if this is an input signature).
                                                    // (combination of D3D_MASK_* values)
        UINT                        Stream;         // Stream index
        D3D_MIN_PRECISION           MinPrecision;   // Minimum desired interpolation precision
    } D3D12_SIGNATURE_PARAMETER_DESC;
    
  4. damyanp commented on Apr 18, 2024

    @damyanp
    Member

    The question is about obtaining the member name (eg mPos) as opposed to the semantic name (eg POSITION).

  5. coopp commented on Apr 18, 2024

    @coopp
    Contributor

    OH! I misread the question. I'll look some more to see if that information can be retrieved.

  6. coopp commented on Apr 18, 2024

    @coopp
    Contributor

    I do not see a way to get this information. Looks like there are ways to inspect buffers/resources etc and get their names but not the names of members on these inputs.

  7. aclysma commented on Sep 8, 2024

    @aclysma

    I've noticed that ID3D12ShaderReflectionType::GetMemberTypeName returns the member name, not the type name. While this seems like a bug to me, it is currently doing what was requested in this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    user-support

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions