Skip to content

GetInputSignatureFromRegister does not resolve input signature for PrimativeID operands correctly #49

Description

@spacehamster

When declaring an input such as

// Input signature:
//
// Name                 Index   Mask Register SysValue  Format   Used
// -------------------- ----- ------ -------- -------- ------- ------
// SV_PrimitiveID           0    N/A   primID   PRIMID    uint    YES
gs_4_0
dcl_input vPrim

vPrim in dcl_input vPrim is encoded as 0x0, while primID in the input signature is encoded as 0xFFFFFFFF, so GetInputSignatureFromRegister will either return the wrong input signature when there are multiple, or null if SV_PrimitiveID is the only input signature.

I would expect there would need to be a new GetInputSignatureFromX method to resolve it properly, similiar to how GetOutputSignatureFromSystemValue works, but dcl_input vPrim does not have an eSpecialName.

An example of a shader that will trigger this bug:

Shader "Unlit/TestShader"
{
    Properties
    {
        _MainTex ("Texture", 2D) = "white" {}
    }
    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 100

        Pass
        {
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            #pragma geometry geom

            struct appdata {

            };

            struct v2g {
            };

            struct g2f
            {
                float4 pos : SV_POSITION;
                float4 color: texcoord1;
                float3 normal : TEXCOORD2;
            };

            v2g vert(appdata v) 
            {
                v2g o = (v2g)0;
                return o;
            }

            [maxvertexcount(3)]
            void geom(triangle v2g IN[3], uint prim : SV_PrimitiveID, inout LineStream<g2f> tristream)
            {
                g2f o;
                for (int i = 0; i < 2; i++)
                {
                    o.pos = 0;
                    o.color = 0;
                    o.normal = 0;
                    tristream.Append(o);
                }
            }


            float4 frag(g2f i) : COLOR{

                float3 col = i.color;
                return fixed4(col, 1);
            }
            ENDCG
        }
    }
}

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions