0
\$\begingroup\$

I have a HLSl pixel shader that I'm using to create a deferred buffer, I have simplified the code to show you:

struct PS_INPUT
{
    float4 PosWVP                   : SV_POSITION;
    float4 NormalWorld              : NORMAL2;
};

struct PS_OUTPUT
{
    float4 PosWorld                 : POSITION;
    float4 NormalWorld              : NORMAL2;
};

PS_OUTPUT main(PS_INPUT input) : SV_Target
{
    PS_OUTPUT output = (PS_OUTPUT)0;

    output.PosWorld = input.PosWorld;
    output.NormalWorld = input.NormalWorld;

    return output; 
}

When I compile this code, I get this warning warning X3576: semantics in type overridden by variable/function or enclosing type, what is this warning and how can I fix it?

\$\endgroup\$
1
\$\begingroup\$

I think the problem is that your pixel shader returns a structure, so each element of that structure need to have an SV_TARGET semantic and not the whole struct, so:

struct PS_OUTPUT
{
    float4 PosWorld                 : SV_TARGET0; //changed sematic
    float4 NormalWorld              : SV_TARGET1; //changed sematic
};

PS_OUTPUT main(PS_INPUT input) //there is no semantic here
{
    PS_OUTPUT output = (PS_OUTPUT)0;

    output.PosWorld = input.PosWorld;
    output.NormalWorld = input.NormalWorld;

    return output; 
}
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.