   SlimDX shader compiler problem
  I'm porting a large application over from MDX.  I have a shader that compiled and worked nicely with the August 2007 DirectX SDK in Visual Studio C# 2003.  My OS is XP, and this is a DX9 app.Now, using the March 2009 release of SlimDX and Visual C# Express 2008 the same shader throws an unhandled exception when I load it.  The shader ends with the following codetechnique RenderScene_2_0{    pass P0    {   VertexShader = compile vs_2_0 VertScene();   PixelShader = compile ps_2_0 PixScene();    }}technique RenderScene_3_0{    pass P0    {   VertexShader = compile vs_3_0 VertScene();   PixelShader = compile ps_3_0 PixScene();    }}I've experimented and found that if I comment out the entire 3_0 technique it compiles nicely.  But when I leave it in the compilationErrors string points to the "c" in "compile" in the VertexShader line of the 3_0 technique.  I hate to give up the 3.0 capabilities, but right now I'm stuck with only 2.0.Help!   
  Unless I'm reading this wrong, you're compiling shaders for vs/ps_2_0 and then the exact same shaders for vs/ps_3_0. (VertScene and PixScene)Surely if you're using SM3.0 specific stuff in the vs/ps_3_0 version it should be compiling different shaders?   ;  I had originally set it up to be flexible, test the capabilities of the card and load the appropriate technique.  Here's the code I used for that:effect = Effect.FromFile(dev, fullPathName, null, null, null, sf, null, out errors);Version pv = caps.PixelShaderVersion;Version vv = caps.VertexShaderVersion;if ((pv < new Version(3, 0)) || (vv < new Version(3, 0)))  effect.Technique = "RenderScene_2_0";else  effect.Technique = "RenderScene_3_0";In that way, if someone runs the app with a card that doesn't support 3.0 or better, it still runs, albiet with less capability.In any case, I also tried commenting out the 2_0 technique so there was nothing left but the 3_0, and the effect compiler still throws an unhandled exception at the same point.???????????;  Are you using some abs functions?Because the preshader generation of the march 2009 hlsl compiler with abs functions is freaked up and won't be resolved till the june 2009 sdk.   ;  Yes I was, in one place.  So I removed the abs() function and handled it conditionally, but it still throws the same exception at the same place.   ;Quote:Original post by ElectricManYes I was, in one place.  So I removed the abs() function and handled it conditionally, but it still throws the same exception at the same place.So, post up an example shader that crashes so I can test on my machine and figure out why. :);  Also, does FXC say anything notable about the shader? That seems to be helpful in narrowing down this type of problem.   ;  I'm not very familiar with the fxc syntax. I did the following:fxc /T vs_3_0 /E VertScene MainEffect.fxandfxc /T ps_3_0 /E PixScene MainEffect.fxIn both cases it spit out a lot of info and assembly code, but no error messages.The shader itself is fairly straight forward, nothing fancy.  But I couldn't figure out how to post it without just dumping it into this message.  As soon as I figure that out I'll post it.;  Here's the shader code:<source lang="c#">//--------------------------------------------------------------------------------------// Global variables//--------------------------------------------------------------------------------------//float fx_appTime;// App's time in secondstexture  fx_TexScene;float4 fx_EyePos;int fx_LightType; //1 = Point, 2 = Spot, 3 = Directional//the Spot light uses a simple cos(theta) fallofffloat4 fx_LightPos;//fx_LightDir must be normalized with fx_LightDir.w = 0float4 fx_LightDir;//Light directionfloat4   fx_LightDiffuse;// Light diffuse colorfloat4   fx_LightAmbient;// Light ambient colorfloat4   fx_LightSpecular;// Light specular colorfloat4   fx_matDiffuse;// Material diffuse colorfloat4   fx_matAmbient;// Material ambient colorfloat4   fx_matSpecular;// Material specular colorfloat4   fx_matEmissive;// Material Emissive colorfloat fx_matSpecSharpness;// Material diffuse colorfloat4x4 fx_mWorld;// World matrix for objectfloat4x4 fx_mViewProj;// View * Projection matrixfloat4x4 fx_mWorldViewProj;// World * View * Projection matrixsampler g_samScene =sampler_state{    Texture = <fx_TexScene>;    MinFilter = Linear;    MagFilter = Linear;    MipFilter = Linear;};void VertScene( float4 inPos : POSITION, float3 inNormal : NORMAL, float2 inTex : TEXCOORD0, out float4 outPos : POSITION, out float2 outTex : TEXCOORD0, out float4 outColor : COLOR0 ){    outPos = mul( inPos, fx_mWorldViewProj );    //position in View space    float4 viewPos = mul(inPos, fx_mWorld); //Normal in View space    float3 viewNorm = normalize( mul( inNormal, (float3x3)fx_mWorld ) ); float falloff;float4 v_LightRay;if (fx_LightType == 1) //Point    {v_LightRay = viewPos - fx_LightPos;//v_LightRay.w = 0;v_LightRay = normalize(v_LightRay);falloff = 1.0f;    }    else if (fx_LightType == 2) //Spot{v_LightRay = viewPos - fx_LightPos;//v_LightRay.w = 0;v_LightRay = normalize(v_LightRay);falloff = dot(v_LightRay, fx_LightDir);}else if (fx_LightType == 3) //Directional{v_LightRay = fx_LightDir;//v_LightRay.w = 0;falloff = 1.0f;}//cosine of angle between viewNorm and I (incident light)    float cosI = dot( (float3)viewNorm, -v_LightRay );float4 viewEye = normalize(fx_EyePos - viewPos);    float4 viewHalf = normalize(viewEye - v_LightRay);//tried this and it doesn't make a difference//    float3 viewEye = normalize((float3)fx_EyePos - (float3)viewPos);//    float3 viewHalf = normalize((float3)viewEye - (float3)fx_LightDir );//cosine of angle between viewNorm and viewHalf    //need to handle negative values    float cosHalf = max(0, dot( (float3)viewNorm, viewHalf ));    //This matches the Phong and DirectX lighting more closely//    float specFactor = pow(cosHalf, fx_matSpecSharpness);    //This is more accurate    //cosine of angle between viewEye and R (specular reflection)    float cosDel = 2.0 * pow(cosHalf, 2) - 1.0;    float specFactor = falloff * pow(cosHalf, fx_matSpecSharpness);//float diffFactor = max( 0, cosI );    float diffFactor = falloff * cosI ;    outColor = saturate(fx_matEmissive +fx_matAmbient * fx_LightAmbient +fx_matSpecular * fx_LightSpecular * specFactor +fx_matDiffuse * fx_LightDiffuse * diffFactor);    outTex = inTex;}float4 PixScene( float2 Tex : TEXCOORD0,  float4 Color : COLOR0 ) : COLOR0{    return tex2D( g_samScene, Tex ) * Color;} //--------------------------------------------------------------------------------------// Techniques//--------------------------------------------------------------------------------------technique RenderScene_2_0{    pass P0    {   VertexShader = compile vs_2_0 VertScene();   PixelShader = compile ps_2_0 PixScene();    }}technique RenderScene_3_0{    pass P0    {   VertexShader = compile vs_3_0 VertScene();   PixelShader = compile ps_3_0 PixScene();    }}</source>;  Tried on my engine and it compile and work without any problem in either HLSL 2_0 and 3_0...   