Hello,
I've recently introduces my own meta language that basically generates shader for DX9, DX11 and OpenGL4. Now I've encountered a strange error when trying to compile a shader generated that way:
#pragma pack_matrix( row_major )
cbuffer Instance : register(b2)
{
matrix mWorld;
};
cbuffer Stage : register(b3)
{
matrix mViewProj;
};
struct VERTEX_IN
{
float3 vPos: SV_POSITION0;
};
struct VERTEX_OUT
{
float4 vPos: SV_POSITION0;
float depth: TEXCOORD0;
};
VERTEX_OUT mainVS(VERTEX_IN in)
{
VERTEX_OUT out;
matrix mWorldViewProj = mul(mWorld, mViewProj);
out.vPos = mul(float4(in.vPos, 1.0f), mWorldViewProj);
out.depth = out.vPos.z;
return out;
}
struct PIXEL_OUT
{
float4 depth: SV_TARGET0
};
PIXEL_OUT mainPS(VERTEX_OUT in)
{
PIXEL_OUT out;
out.depth = in.depth;
return out;
}
The error message I got says:
C:\Acclimate Engine\Techdemo\Game\Modules\Base3D\Effects\Depth.afx(23,29): error X3000: syntax error: unexpected token 'in'
Now, this is the line that its talking about:
VERTEX_OUT mainVS(VERTEX_IN in)
Now, I've double checked that as you can see in the shader VERTEX_OUT and VERTEX_IN do exist. I'm really stunned and can't see anything wrong here. For comparison, here is what the original hand-written shader looks like:
#pragma pack_matrix( row_major )
cbuffer instance : register(b2)
{
matrix mWorld;
};
cbuffer stage : register(b3)
{
matrix mViewProj;
};
struct VS_INPUT
{
float3 vPos : SV_POSITION;
};
struct VS_OUTPUT
{
float4 vPos : SV_POSITION;
float vDepth : TEXCOORD0;
};
VS_OUTPUT mainVS(VS_INPUT i)
{
VS_OUTPUT o;
matrix mWorldViewProj = mul(mWorld, mViewProj);
o.vPos = mul(float4(i.vPos, 1.0f), mWorldViewProj);
o.vDepth = o.vPos.z;
return o;
}
float4 mainPS(VS_OUTPUT i) : SV_TARGET0
{
return i.vDepth;
}
Now that one does compile, while the other doesn't. Does somebody see anything wrong in the first shader that I just fail to see, or has some clue what could be going wrong?