Jump to content

  • Log In with Google      Sign In   
  • Create Account

Error #342: device_shader_linkage_semanticname_not_found


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
15 replies to this topic

#1 Telanor   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 01 September 2012 - 06:59 PM

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:

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 ]

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

// 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      

The HLSL structure looks like this:

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

The input layout, from PIX, is:

InputLayouts.png

The C# structure holding the data looks like this:

[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();
    }
}

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

Sponsor:

#2 MJP   Moderators   -  Reputation: 11836

Like
1Likes
Like

Posted 02 September 2012 - 02:37 PM

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.

#3 Telanor   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 02 September 2012 - 03:52 PM

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.

#4 riuthamus   Moderators   -  Reputation: 5789

Like
0Likes
Like

Posted 04 September 2012 - 09:12 AM

Perhaps there is another way to put down point lights? or is this the only method when using deferred rendering? Cause we are at a dead end if there is no error with our code. *shrugs* thanks for the help MJP though.

#5 quiSHADgho   Members   -  Reputation: 325

Like
1Likes
Like

Posted 04 September 2012 - 10:34 AM

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.

#6 riuthamus   Moderators   -  Reputation: 5789

Like
1Likes
Like

Posted 04 September 2012 - 10:47 AM

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.

#7 Hodgman   Moderators   -  Reputation: 32024

Like
1Likes
Like

Posted 04 September 2012 - 11:06 AM

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?

#8 quiSHADgho   Members   -  Reputation: 325

Like
1Likes
Like

Posted 04 September 2012 - 11:25 AM

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.


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


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?


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.

#9 riuthamus   Moderators   -  Reputation: 5789

Like
0Likes
Like

Posted 04 September 2012 - 11:36 AM

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.


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, 04 September 2012 - 11:37 AM.


#10 BCullis   Crossbones+   -  Reputation: 1813

Like
0Likes
Like

Posted 04 September 2012 - 12:14 PM

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

// 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	  


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, 04 September 2012 - 12:16 PM.

Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#11 BCullis   Crossbones+   -  Reputation: 1813

Like
1Likes
Like

Posted 04 September 2012 - 12:28 PM

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?
Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

#12 kauna   Crossbones+   -  Reputation: 2864

Like
1Likes
Like

Posted 04 September 2012 - 12:56 PM

Hi,

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

Best regards!

#13 Telanor   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 04 September 2012 - 02:54 PM

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


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.

Hi,

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

Best regards!


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.

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?


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:

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()));
    }
}



#14 quiSHADgho   Members   -  Reputation: 325

Like
1Likes
Like

Posted 04 September 2012 - 04:40 PM

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.

#15 Telanor   Members   -  Reputation: 1359

Like
0Likes
Like

Posted 04 September 2012 - 04:59 PM

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.

#16 riuthamus   Moderators   -  Reputation: 5789

Like
0Likes
Like

Posted 05 September 2012 - 04:06 AM

Thanks a bunch, our lighting system is looking amazing. I will have some screenshots for you guys shortly!




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