Jump to content
  • Advertisement
Sign in to follow this  
belfegor

VS->PS linker error

This topic is 2068 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I got this error:

 

Direct3D9: VS->PS Linker: X777: (Error) The current pixel shader expects vertex declaration to provide semantic 'texcoord0' including components(s): 'xyzw',

however the current transformed vertex declaration (vertex proc. disabled) provides 'texcoord0' with component(s): 'xy'. 

The vertex declaration's component set needs to be a superset of pixel shader input component set.

 

Vertex shader

struct A2V
{
    float4 Position  : POSITION;
    float2 TexCoord0 : TEXCOORD0;
    float4 Color     : TEXCOORD1;
};

struct V2P
{
    float4 Position  : POSITION;
    float4 TexCoord0 : TEXCOORD0;
    float4 Color     : TEXCOORD1;
};

void VertexProgram(in A2V IN, out V2P OUT)
{
    OUT.Position.x  = IN.Position.x;
    OUT.Position.y  = IN.Position.y;
    OUT.Position.z  = IN.Position.z;
    OUT.Position.w  = IN.Position.w;
    OUT.TexCoord0.x = IN.TexCoord0.x;
    OUT.TexCoord0.y = IN.TexCoord0.y;
    OUT.TexCoord0.z = IN.TexCoord0.x * 0.25f;
    OUT.TexCoord0.w = IN.TexCoord0.y * 0.25f;
    OUT.Color       = IN.Color;
}

 

Pixel shader

sampler fontSamp : register(s0);

struct V2P
{
    float4 Position  : POSITION;
    float4 TexCoord0 : TEXCOORD0;
    float4 Color     : TEXCOORD1;
};

struct P2A
{
    float4 Color     : COLOR;
};

void PixelProgram(in V2P IN, out P2A OUT)
{
    float2 alphaRange = float2(0.1f, 1.0f);
    float4 base       = float4(IN.Color.rgb, tex2D(fontSamp, IN.TexCoord0.xy).a);
    float sdf         = tex2D(fontSamp, IN.TexCoord0.zw).r;
    float alpha       = smoothstep(alphaRange.x, alphaRange.y, sdf);
    OUT.Color         = lerp(base, IN.Color, alpha);
}

 

and my vertex elements

D3DVERTEXELEMENT9 vertexElements[] =
{
    {0,  0,  D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITIONT, 0},
    {0, 16,  D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,  0},
    {0, 24,  D3DDECLTYPE_FLOAT4,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD,  1},
    D3DDECL_END()
};

 

I don't see whats wrong?

Share this post


Link to post
Share on other sites
Advertisement

When you use POSITIONT, it means that the vertex positions are pre-transformed and that the vertex shader isn't run. Therefore the contents of your vertex buffer get passed directly to the pixel shader. In your vertex decaration TEXCOORD0 is a float2, but your pixel shader expects a float4. Either change your vertex buffer and declaration so that it has a float4, or change your pixel shader to take a float2.

Edited by MJP

Share this post


Link to post
Share on other sites
That's that. Thanks.

EDIT:
Now i have other issue. I want to use vertex shader so i removed 'T' from (POSITION) vertex declaration .
And now have this vertex shader
#pragma pack_matrix(row_major)

float4x4 mat2D : register(c0);

struct A2V
{
	float4 Position  : POSITION;
	float2 TexCoord0 : TEXCOORD0;
	float4 Color     : TEXCOORD1;
};

struct V2P
{
	float4 Position  : POSITION;
	float4 TexCoord0 : TEXCOORD0;
	float4 Color     : TEXCOORD1;
};

void VertexProgram(in A2V IN, out V2P OUT)
{
	OUT.Position    = mul(float4(IN.Position.xyz, 1.0f), mat2D);
	OUT.TexCoord0.x = IN.TexCoord0.x;
	OUT.TexCoord0.y = IN.TexCoord0.y;
	OUT.TexCoord0.z = IN.TexCoord0.x * 0.25f;
	OUT.TexCoord0.w = IN.TexCoord0.y * 0.25f;
	OUT.Color       = IN.Color;
}

and code
D3DXMATRIX mat2D;
D3DXMatrixTransformation2D(&mat2D, NULL, 0.0f, NULL, NULL, 0.0f, NULL);
...
d3d9device->SetVertexShaderConstantF(0, mat2D, 4);

and my quads are in "screen coordinate".

But now i cannot display anything to screen. Any help? Edited by belfegor

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!