Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
spacehamster opened this issue Nov 1, 2020 · 0 comments

Comments

@spacehamster
Copy link

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
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant