老版本HLSL编译时提示error x3025

编译vertex shader出现:\error X3025:global variables are implicitly constant,enable compatibility mode to allow modification.

这是因为当前编译的shader基于一个较老的shader版本,必须指定兼容模式D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY才能 编译通过

也就是在调用D3DXCompileShaderFromFile编译shader时,第6个参数必须包含此值。

一般常见的代码更改后变为:


hr = D3DXCompileShaderFromFile(
"toon.txt",
0,
0,
"Main", // entry point function name
"vs_1_1",
D3DXSHADER_DEBUG|D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY,
&toonCompiledCode,
&toonErrorBuffer,
&ToonConstTable);

posted @ 2012-01-17 22:50  重甲土拨鼠  阅读(418)  评论(0编辑  收藏  举报