DirectX 9 및 10 효과는 정적 표현식이 CPU에서 자동으로 실행되도록 꺼내는 "preshaders"를 지원합니다.
이 동작을 억제하는 플래그 인 설명서에서 D3DXSHADER_NO_PRESHADER
을 참조하십시오. 웹 링크는 다음과 같습니다. http://msdn.microsoft.com/en-us/library/windows/desktop/bb205441(v=vs.85).aspx
g_C
신고에 static
과 유형이 모두 누락되었습니다. float
. 또한 전역 범위로 이동해야합니다. 다음 내가 컴파일
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
};
}
}
: fxc /Tfx_2_0 t.fx
와
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로를 컴파일 할 때
, 당신은 (주석 블록 후 preshader
블록에주의) 다음과 같은 것을 볼 수 있습니다 목록을 생성합니다. 그들은 매우 흥미로운 쉐이더가 아닙니다 ...