Jump to content

  • Log In with Google      Sign In   
  • Create Account

VS->PS linker error


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 belfegor   Crossbones+   -  Reputation: 2717

Like
0Likes
Like

Posted 24 January 2013 - 04:07 PM

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?



Sponsor:

#2 MJP   Moderators   -  Reputation: 11751

Like
2Likes
Like

Posted 24 January 2013 - 04:17 PM

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, 24 January 2013 - 04:36 PM.


#3 belfegor   Crossbones+   -  Reputation: 2717

Like
0Likes
Like

Posted 24 January 2013 - 04:22 PM

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, 24 January 2013 - 05:08 PM.


#4 belfegor   Crossbones+   -  Reputation: 2717

Like
0Likes
Like

Posted 25 January 2013 - 10:09 AM

Solution: http://www.gamedev.net/topic/462401-d3dxmatrixorthooffcenterlh-replacement-2d-graphics-without-rhw/






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS