Sign in to follow this  
ozkill

error X3025 and D3DXSHADER_ENABLE_BACKWARDS_COMPATIBILITY

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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:
[code]uniform float myValue;
float4 ps_main( ... )
{
myValue = myValue * 2;
return myValue.xxxx;
}[/code]Then the compiler can choose to transform it into this valid code:[code]uniform float myValue;
static float myMutableValue;
float4 ps_main( ... )
{
myMutableValue = myValue;
myMutableValue = myMutableValue * 2;
return myMutableValue.xxxx;
}[/code]
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this