Skip to main content
GameDev.net gamedev.net
🔒 Locked

[MDX 2.0] Error compiling HLSL shaders

Started by Helius Dec 27, 2005 at 9:38 AM 4 replies 7.5k views
Original Post
Helius
Helius
Hi, I'm trying to port my engine to the new MDX 2.0 and all my shaders compile without errors with MDX 1.1 but I can't figure out how to compile the shaders with the new Shader.FromFile() function in MDX 2.0 This new function does not accept the shader version and I think that the version is supposed to be inside the shader... I don't know how to set it in order to compile without errors. I'm not using effects, I use stand alone shaders. This is an example of shader, and it gives me the following error when compiling: error X2000: syntax error : unexpected token 'float4x4'.

vs_2_0;

float4x4 view_proj_matrix;

struct VS_INPUT
{ 
 float4 Pos:   POSITION;
 float2 Tex0:  TEXCOORD0;
 float3 Normal:  NORMAL;
 float3 Tangent:     TANGENT0;
 float3 Binormal:    BINORMAL0;
};

struct VS_OUTPUT
{
 float4 Pos:   POSITION;
 float2 Tex0:  TEXCOORD0;
};

VS_OUTPUT Main(VS_INPUT In)
{
 VS_OUTPUT Out;
 Out.Pos = mul(view_proj_matrix, In.Pos);
 Out.Tex0 = In.Tex0;
 return Out;
}
Muhammad Haggag
Muhammad Haggag
Well, the "vs_2_0;" statement is invalid. There must be a way to tell the shader compiler what profile to compile for, but I can't find the damn .NET 2.0 docs anywhere [embarrass]

Helius
Helius
If I remove that statement the compiler says: "error X2001: Shader version expected", so maybe is working this way but it requires something else?? [looksaround]

If I put "vs.2.0" instead of "vs_2_0" goes the same way and "error X2000: syntax error : unexpected token 'float4x4'" happens.

Please help. [dead]
xyzzy00
xyzzy00
You specify the target as a parameter when you make the call to compile the shader. Not as the first statement (as with assembly shaders).

xyzzy
Helius
Helius
The new "Shader.FromFile()" function in MDX 2.0 does not accept the shader version as a parameter and I think it must be inside the shader. [depressed]

Shader.FromFile Method:public static GraphicsBuffer FromFile(   string sourceFile,   Macro[] preprocessorDefines,   Include includeFile,   ShaderFlags flags);
The old "ShaderLoader.CompileShaderFromFile()" does not exists in this new version of MDX.
Muhammad Haggag
Muhammad Haggag
I used reflector on Shader.FromFile, and it seems that it works on assembly shaders only. I couldn't find an equivalent of the old ShaderLoader functionality, but there's Effect.CompileShader which takes a function name and a target. So I suppose you could try creating an effect out of your shader file first, then use the created effect to compile it.

Whether that works or not, I also suggest you mail directx at microsoft.com a report about this.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.