Error: Invalid vs_2_0 output semantic

Viewed 8693

Its says: Invalid vs_2_0 output semantic SV_Target.

So for some reason Visual Studio 2017 is compiling my pixel shader as if it is a vertex shader. But in the properties panel I specified it to be a ps_5_0. Is there something I'm missing that should be specified?

Vertex shader:-

cbuffer ConstantBuffer : register(b0)
{
    matrix World;
    matrix View;
    matrix Projection;
}

struct Input {
    float3 Pos  : POSITION;
    float4 Color: COLOR;
};

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR0;
};

VS_OUTPUT main(Input input)
{
    VS_OUTPUT output = (VS_OUTPUT)0;

    output.Pos = mul(input.Pos, World);
    output.Pos = mul(output.Pos, View);
    output.Pos = mul(output.Pos, Projection);

    output.Color = input.Color;
    return output;
}

Pixel shader:-

struct VS_OUTPUT
{
    float4 Pos : SV_POSITION;
    float4 Color : COLOR0;
};

float4 main(VS_OUTPUT input) : SV_Target
{
    return input.Color;
}

And here are my settings for the pixel shader. I hope someone can help me.

3 Answers

Open the Property page for the .hlsl file, and in HLSL Compiler/General/Shader Type select Pixel Shader.

And don't forget to set this propertie for debug and release.

You can resolve the issue by modifying the shader property

properties -> HLSL Compiler -> General -> Shader Type -> Pixel Shader (/ps)

OR

Configuration properties -> General -> Excluded from Build = Yes.

Related