Jump to content
  • Advertisement
Sign in to follow this  
BattleCollie

Shader prob: semantics in type overridden by variable/function or enclosing type

This topic is 3348 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Let me preface this by saying I'm really new to shaders and pretty much fumbling my way through by trial and error. So that being said...I had this deferred rendering engine I've been playing with running previously but suddenly when I try to load my shaders I get the following kinds of errors: ERROR: Failed to load FX effect:E:\Projects\src\Dungeonscape\Shaders\gbuffer_basic.fx ERROR: E:\Projects\src\Dungeonscape\Shaders\gbuffer_basic.fx(75,11): warning X3576: semantics in type overridden by variable/function or enclosing type The function call I'm making to load the file is: hr = D3DX10CreateEffectFromFile((LPCSTR)pData, NULL, NULL, "fx_4_0", D3D10_SHADER_ENABLE_STRICTNESS, D3D10_EFFECT_COMPILE_CHILD_EFFECT, m_pDevice, m_pEffectPool, NULL, &pEffect, &pError, NULL); I'm really not sure what the error is referring to since it worked previously and the only thing I did was pull out some of the debug vertex/pixel shaders from the file I was loading. Specifically in that file it's pointing to my MRT ps declaration, but I just can't figure out what's really wrong. Any hints, pointers to documents that would help me understand things better would help. Right now it's pretty hacktastic how I'm going about this. I'm more confused as to why it worked before but cleaning out debugging code from the file would cause it to have this error again. I didn't even touch the parts it's complaining about! //////////////////////////////////////////////// // Input/Output Declarations //////////////////////////////////////////////// struct mrtvs_out { float4 pposition : SV_POSITION; float2 texcoord : TEXCOORD0; float2 depth : TEXCOORD1; float3 normal : TEXCOORD2; }; struct mrtps_out { float4 diffuse : COLOR0; float4 normal : COLOR1; float4 material : COLOR2; float4 depth : COLOR3; float dbuffer : DEPTH0; }; //////////////////////////////////////////////// // Gbuffer Shaders /////////////////////////////////////////////// mrtvs_out mrtVS(float4 position : POSITION, float3 normal : NORMAL, float3 tangent : TANGENT, float3 bitangent : BINORMAL, float2 texcoord : TEXCOORD0 ) { mrtvs_out OUT; // Projected position OUT.pposition = mul(position, gWorldView); OUT.pposition = mul(OUT.pposition, gProjection); // Normal in world space OUT.normal = normalize(mul(normal, gWorldIT)); // Texture coordinates OUT.texcoord = texcoord; // Depth OUT.depth.xy = OUT.pposition.zw; return OUT; } mrtps_out mrtPS(mrtvs_out IN) : SV_Target { mrtps_out OUT; // TEXTURE1: | DiffuseR | DiffuseG | DiffuseB | SpecularIntensity | // TEXTURE2: | NormalX | NormalY | NormalZ | SpecularPower | // TEXTURE3: | | | | | // TEXTURE4: |---------------------Depth----------------------------| // Color texture (TEXTURE1) ///////////////////////////////////////// #ifdef DEBUG_SHADER OUT.diffuse = gBaseTexture.Sample(samLinear, IN.texcoord); if(OUT.diffuse.a == 0.0) #endif OUT.diffuse = gTexture1.Sample(samLinear, IN.texcoord); // Discard on alpha? //if(diffuse.a == 0.0) // discard; // Specular intensity OUT.diffuse.a = 1.0; // Normal texture (TEXTURE2) /////////////////////////////////////// OUT.normal.xyz = 0.5f * (IN.normal + 1.0f); // specular power OUT.normal.w = log2(gMatfPower) / 10.5; // Material texture (TEXTURE3) ///////////////////////////////////// OUT.material.rgb = float3(1.0, 0.0, 0.0); OUT.material.a = 0.0; // Depth texture (TEXTURE4) //////////////////////////////////////// OUT.depth = IN.depth.x / IN.depth.y; // Actual depth buffer OUT.dbuffer = IN.pposition.z / IN.pposition.w; return OUT; } /////////////////////////////////////////////// // Techniques /////////////////////////////////////////////// technique10 gbuffer_basic { pass P0 { SetVertexShader(CompileShader(vs_4_0, mrtVS())); SetGeometryShader(NULL ); SetPixelShader(CompileShader(ps_4_0, mrtPS())); SetBlendState(DisableBlend, float4(0.0f, 0.0f, 0.0f, 0.0f), 0xFFFFFFFF); } }

Share this post


Link to post
Share on other sites
Advertisement
I believe your problem is that in your mrtps_out struct you're defining your render target outputs using the COLOR semantics, but then for your actual pixel shader function (mrtPS) you're specifying the SV_Target semantic, which will get applied to the output of that function. So when the debug runtimes say "semantics in type overridden by variable/function or enclosing type", they mean specifically that the semantics you defined for your custom mrtps_out type are being overriden by the semantic you defined for the function. You shouldn't need that SV_Target semantic anyway, since you've already defined the outputs in your struct (COLOR and SV_Target basically mean the same thing, the COLOR semantic is the old legacy DX9 name).

Also there's no need to output to DEPTH if you're just going to write z / w, since this is what will get written there automatically. In fact writing to DEPTH in a shader is bad for performance, since it forces the driver to disable early-z optimizations that let the GPU prevent shading of pixels that will fail the depth test.

Share this post


Link to post
Share on other sites
So I basically need either but not both. What about using SV_Target0 in the structure like shown below. It seems both of these work inside FX Composer fine but when I try to load it the results I get from the load are still an E_FAIL but pEffect and pError are both NULL pointers. Which is a bit frustrating to get no error in that case to go on.

I also tried with just taking out the SV_Target semantic and leaving COLOR0 in there and same thing.


struct mrtps_out {
float4 diffuse : SV_Target0;
float4 normal : SV_Target1;
float4 material : SV_Target2;
float4 depth : SV_Target3;
};

and...

mrtps_out mrtPS(mrtvs_out IN)

or...

struct mrtps_out {
float4 diffuse;
float4 normal;
float4 material;
float4 depth;
};

and...

mrtps_out mrtPS(mrtvs_out IN) : SV_Target

Share this post


Link to post
Share on other sites
Oh.. I forgot too that when I use COLOR0 and that syntax in the output struct but remove the SV_Target off the end of the function I get this error:

Error Error: error X4571: ps_4_0 output limit (9) exceeded, shader uses 15 outputs. e:\projects\src\dungeonscape\shaders\gbuffer_basic.fx -1

Which actually does have a few entries on google to dig through about. Limit 9...bytes? Registers? Snickerdoodles? I don't understand what it's considering an "output".

Share this post


Link to post
Share on other sites
I think I found the problem. I had a shared header file that contained some information for all my shaders. Well me in all my naive glory put some "shared" texture samplers, render state functions, and a technique in there.

Well apparently it doesn't like that. After pulling them out and putting them back into the actual files it works fine. How obscure of a message though. If anyone has an explanation as to why that would cause that it'd be appreciated.

Share this post


Link to post
Share on other sites
Hurpty durrr...

I had the following in the shared header..

SamplerState samPoint
{
Filter = MIN_MAG_MIP_POINT;
AddressU = Clamp;
AddressV = Clamp;
};

but didn't declare it as shared like...

shared SamplerState samPoint
{
Filter = MIN_MAG_MIP_POINT;
AddressU = Clamp;
AddressV = Clamp;
};

But I don't know if it really makes sense to have a sampler state in a shared header. Does it?

Share this post


Link to post
Share on other sites
shared is only interesting if you are using the shader in an Effects pool.

When doing anything shader model 4+ you should stick to the SV_* semantics and avoid things like Color or other legacy semantics. Those semantics only carry system value meaning if you are using the /Gec flag. You probably don't need to do that. Use SV_Target[0-7] instead. Use SV_Depth instead.

Using D3D10_SHADER_ENABLE_STRICTNESS will forbid you from using DX9 semantics. This is part of your problem.

If your output structure already has semantics for each member, then you don't need to label your function with another semantic. The semantic on the function level will override (hide) the semantics in the structure you're using.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!