DirectX 9 および 10 のエフェクトは、CPU 上で自動的に実行される静的な式が引き出される「プレシェーダー」をサポートします。
D3DXSHADER_NO_PRESHADER
この動作を抑制するフラグであるドキュメントを参照してください。Web リンクは次のとおりです: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205441(v=vs.85).aspx
の宣言には、タイプ eg のg_C
両方がありません。また、グローバル スコープに移動する必要があります。static
float
fxc でコンパイルすると、次のようになります (preshader
コメント ブロックの後のブロックに注意してください)。
technique RenderScene
{
pass P0
{
vertexshader =
asm {
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4 g_A;
// float4 g_B;
//
//
// Registers:
//
// Name Reg Size
// ------------ ----- ----
// g_A c0 1
// g_B c1 1
//
preshader
mul c0, c0, c1
// approximately 1 instruction used
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
vs_2_0
mov oPos, c0
// approximately 1 instruction slot used
};
pixelshader =
asm {
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
ps_2_0
def c0, 0, 0, 0, 0
mov r0, c0.x
mov oC0, r0
// approximately 2 instruction slots used
};
}
}
私は以下をコンパイルしました:
float4 g_A;
float4 g_B;
static float4 g_C = g_A * g_B;
float4 RenderSceneVS() : POSITION
{
return g_C;
}
float4 RenderScenePS() : COLOR
{
return 0.0;
}
technique RenderScene
{
pass P0
{
VertexShader = compile vs_2_0 RenderSceneVS();
PixelShader = compile ps_2_0 RenderScenePS();
}
}
fxc /Tfx_2_0 t.fx
リストを生成します。それらはあまり興味深いシェーダーではありません...