Sign in to follow this  
Telanor

Error #342: device_shader_linkage_semanticname_not_found

Recommended Posts

Telanor    1486
I've stared at this for at least half an hour now and I cannot figure out what directx is complaining about. I know this error normally means you put float3 instead of a float4 or something like that, but I've checked over and over and as far as I can tell, everything matches.

This is the full error message:

[code]
D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Input Assembler - Vertex Shader linkage error: Signatures between stages are incompatible. The input stage requires Semantic/Index (COLOR,0) as input, but it is not provided by the output stage. [ EXECUTION ERROR #342: DEVICE_SHADER_LINKAGE_SEMANTICNAME_NOT_FOUND ]
[/code]

This is the vertex shader's input signature as seen in PIX:

[code]
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION 0 xyz 0 NONE float xyz
// NORMAL 0 xyz 1 NONE float
// COLOR 0 xyzw 2 NONE float
[/code]

The HLSL structure looks like this:

[code]
struct VertexShaderInput
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float4 Color: COLOR0;
};
[/code]

The input layout, from PIX, is:

[attachment=11040:InputLayouts.png]

The C# structure holding the data looks like this:

[code]
[StructLayout(LayoutKind.Sequential)]
public struct PositionColored
{
public static int SizeInBytes = Marshal.SizeOf(typeof(PositionColored));

public static InputElement[] InputElements = new[]
{
new InputElement("POSITION", 0, Format.R32G32B32_Float, 0),
new InputElement("NORMAL", 0, Format.R32G32B32_Float, 0),
new InputElement("COLOR", 0, Format.R32G32B32A32_Float, 0)
};

Vector3 position;
Vector3 normal;
Vector4 color;

#region Properties
...
#endregion

public PositionColored(Vector3 position, Vector3 normal, Vector4 color)
{
this.position = position;
this.normal = normal;
this.color = color;
}
public override string ToString()
{
StringBuilder sb = new StringBuilder(base.ToString());
sb.Append(" Position=");
sb.Append(position);
sb.Append(" Color=");
sb.Append(Color);
return sb.ToString();
}
}
[/code]

SizeInBytes comes out to 40, which is correct (4*3 + 4*3 + 4*4 = 40). Can anyone find where the mistake is?

Share this post


Link to post
Share on other sites
MJP    19753
Everything you've posted looks okay. Are you sure you have the right input layout and vertex shader bound when that error message gets output? If you capture a frame in PIX, you can double-click on the error and it will take you to the exact call that caused it. Then you can check the state of your device context, and make sure it's what you expect it to be.

Share this post


Link to post
Share on other sites
Telanor    1486
Yea, the screenshot of the input layout is from the device state on the draw call that has the warning. I also double checked in the code that it sets the right layout before drawing.

Share this post


Link to post
Share on other sites
quiSHADgho    327
I never looked that deep into deferred rendering so I can't help you on that atm but is it possible to see some shader code because when directx is complaining the error is not always where it says it should be.

Share this post


Link to post
Share on other sites
quiSHADgho    327
[quote name='riuthamus' timestamp='1346777253' post='4976474']
Yeah, def. I will have him post it as soon as he gets up. Or pm you with it, you have been most helpful quiSHAD, if you ever need some art let me know.
[/quote]

Thanks I'm always glad when I can help. Also I like challenging problems and not only within my projects.


[quote name='Hodgman' timestamp='1346778407' post='4976478']
I'm not familiar with that error, but is it possible that its complaining when trying to link the pixel/vertex shaders together? Does the PS require a COLOR0 input that the VS isn't outputting?
[/quote]

I would say everything is possible but typically D3D11 would output something like: "D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader"
So it is pointing in to VS input. But in my experience sometimes even D3D is confused. So theoretically the error could be everywhere and most likely at a point where you normally would never look for it.

Share this post


Link to post
Share on other sites
riuthamus    8361
[quote name='quiSHADgho' timestamp='1346779552' post='4976492']
I would say everything is possible but typically D3D11 would output something like: "D3D11: ERROR: ID3D11DeviceContext::DrawIndexed: Vertex Shader - Pixel Shader"
So it is pointing in to VS input. But in my experience sometimes even D3D is confused. So theoretically the error could be everywhere and most likely at a point where you normally would never look for it.
[/quote]

This was the problem that we were afraid of. We almost were hoping it was a numerical issue rather than having to deal with a "needle in a haystack" situation. Telanor should be up 3 hours, I will make sure he sees this once he does and we can go from there. Thanks again, both of you. Edited by riuthamus

Share this post


Link to post
Share on other sites
BCullis    1955
[quote name='Telanor' timestamp='1346547594' post='4975601']
This is the vertex shader's input signature as seen in PIX:
[code]
// Input signature:
//
// Name Index Mask Register SysValue Format Used
// -------------------- ----- ------ -------- -------- ------ ------
// POSITION 0 xyz 0 NONE float xyz
// NORMAL 0 xyz 1 NONE float
// COLOR 0 xyzw 2 NONE float
[/code]
[/quote]

Just trying to help think outloud, but is it a problem that your normal and color values show as unused in this PIX data?

edit: oh god that converted horribly. Quote tool doth not preserve tab spacing Edited by BCullis

Share this post


Link to post
Share on other sites
BCullis    1955
Also, just for clarification, what does the (SlimDX?) documentation say on the InputElement constructor that doesn't take an offset value for each element? Is it auto-calculated?

Share this post


Link to post
Share on other sites
kauna    2922
Hi,

I guess that you have verified with debugger that you are actually using the correct vertex declaration with correct vertex shader?

Best regards!

Share this post


Link to post
Share on other sites
Telanor    1486
[quote name='BCullis' timestamp='1346782487' post='4976511']
Just trying to help think outloud, but is it a problem that your normal and color values show as unused in this PIX data?
[/quote]

I have other shaders that show unused inputs and they dont error. And I tried changing it so the vertex shader passes those along to the pixel shader, still errors.

[quote name='kauna' timestamp='1346784980' post='4976532']
Hi,

I guess that you have verified with debugger that you are actually using the correct vertex declaration with correct vertex shader?

Best regards!
[/quote]

Yea, the input layout and input signature in the original post are from PIX on the draw call that is erroring. The vertex shader and input layout are correct.

[quote name='BCullis' timestamp='1346783336' post='4976518']
Also, just for clarification, what does the (SlimDX?) documentation say on the InputElement constructor that doesn't take an offset value for each element? Is it auto-calculated?
[/quote]

The constructor I'm using sets the offset to APPEND_ELEMENT_ALIGNED. I've tried explicitly setting the offsets to 0, 12, and 24. It still errors with that though.

For those wanting to see the shader code:

[code]
float4x4 World;
float4x4 View;
float4x4 Projection;
float FarPlane;

//color of the light
float3 Color;

//position of the camera, for specular light
float3 CameraPosition;

//this is used to compute the world-position
float4x4 InvertViewProjection;

//this is the position of the light
float3 LightPosition;

//how far does this light reach
float LightRadius;

//control the brightness of the light
float LightIntensity;

// diffuse color, and specularIntensity in the alpha channel
Texture2D ColorMap : register(t0);
// normals, and specularPower in the alpha channel
Texture2D NormalMap : register(t1);
//depth
Texture2D DepthMap : register(t2);

SamplerState colorSampler
{
Filter = Min_Mag_Mip_Linear;
AddressU = Clamp;
AddressV = Clamp;
};

SamplerState normalSampler
{
Filter = Min_Mag_Mip_Point;
AddressU = Clamp;
AddressV = Clamp;
};

SamplerState depthSampler
{
Filter = Min_Mag_Mip_Point;
AddressU = Clamp;
AddressV = Clamp;
};

struct VertexShaderInput
{
float3 Position : POSITION0;
float3 Normal : NORMAL0;
float4 Color : COLOR0;
};

struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 ScreenPosition : TEXCOORD0;
};

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
{
VertexShaderOutput output;
float4 worldPosition = mul(float4(input.Position, 1), World);
float4 viewPosition = mul(worldPosition, View);
output.Position = mul(viewPosition, Projection);

output.ScreenPosition = output.Position;

output.Position.z = log(0.001 * output.Position.z + 1) / log(0.001 * FarPlane + 1) * output.Position.w;
return output;
}

float4 PixelShaderFunction(VertexShaderOutput input) : SV_TARGET0
{
--snip--
}

technique11 Technique1
{
pass Pass1
{
SetVertexShader(CompileShader(vs_4_0, VertexShaderFunction()));
SetPixelShader(CompileShader(ps_4_0, PixelShaderFunction()));
}
}

[/code]

Share this post


Link to post
Share on other sites
quiSHADgho    327
The shader code is absolutely fine, unfortunately. Just to sum it up:
The shader is ok, the struct is ok and the InputLayout is set correctly. Then there are only a few things I can think about which may cause this but they are rather unlikely and I'm sure you checked it already..
First: The constructor never receives a valid value. To test it set the color to fixed value in the constructor instead of using the input.
Second: I'm guessing you are using instancing anywhere in your code. Is it possible that there is something messed up with different vertex streams?
And the last one: Using the wrong technique may cause it when the previous VS input was bigger.

Oh and one last thing. If this is the whole relevant shader code and since your not using the color and normal values just try:
VertexShaderOutput VertexShaderFunction(float3 inPosition : POSITION)
and see if the error is the same.

Share this post


Link to post
Share on other sites
Telanor    1486
Believe it or not, removing the normal and color from the struct fixed it. I feel like maybe that's just masking the real issue but... its just a warning, so I suppose its fine. The shader is still not producing the right output but at least I know its not because of a directx error now. Thanks for your help guys.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this