error X3025 and D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY

Started by
2 comments, last by Hodgman 11 years, 8 months ago
Hi.

i tried to compile shader effect. and i met error "error X3025: global variables are implicitly constant, enable compatibility mode to allow modification"
but when i try to compile with flag D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY, works well.
If i use this flag, no error and no trouble. When i googling, can find many same troubles and same solutions.
Well... OK. however it's works.

but i confused.
according to MSDN, D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY flag compile to higher level than ps_1_x. that's all. it just control shader level.
But as a result, It really be involved in semantic and syntax.

Why this happen?
Moreover, I never use ps_1_x.
Why Why Why Why this happen?

thank you.
Advertisement
You're modifying a uniform shader variable, which is pretty bad practice, hence why they decided to turn it into an error.

Can you post the code?

If you just want to make the error go away without understanding why your code is bad, try adding the [font=courier new,courier,monospace]static[/font] keyword on the front of the variable.
thank you for reply.
but i understand why that error happen.
I want to know why this error does not appear with D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY flag.
i want to know correlation between error X3025 and ps_1_x.
It is possible for the compiler to let you modify uniform variables, but they decided to turn it into an error, because it's not good practice and the modifications are only local (they don't affect other pixels, or persist after the current pixel is finished).

e.g. if you wrote some code like this:
uniform float myValue;
float4 ps_main( ... )
{
myValue = myValue * 2;
return myValue.xxxx;
}
Then the compiler can choose to transform it into this valid code:uniform float myValue;
static float myMutableValue;
float4 ps_main( ... )
{
myMutableValue = myValue;
myMutableValue = myMutableValue * 2;
return myMutableValue.xxxx;
}

And in the old version, the compiler did used to do this. In the new version, they decided that you should do this yourself, instead of it being automatic.

The backwards compatibility flag tells the compiler to revert to the old behaviour, so you can compile old shaders.

This topic is closed to new replies.

Advertisement