ID3DXEffect, HLSL, global variables

Started by
2 comments, last by neneboricua19 18 years, 8 months ago
I have created ID3DXEffect interface using D3DXCreateEffect. I need to set c[n] register using IDirect3DDevice9::SetVertexShaderConstantF out of ID3DXEffect::BeginPass ID3DXEffect::EndPass block, but I need the value to persist in c[n] register. Variable in shader code is declared as: float4x4 g_matrix : register(c0); When I call ID3DXEffect::BeginPass, registers c0 - c4 are set to 0 (set from some ID3DXEffect constant table) So the question is, how to declare and use variable, which is not affect by ID3DXEffect::BeginPass call. Thanx
Advertisement
Why not use ID3DXEffect::SetMatrix or ID3DXEffect::SetValue? If you're using the effect interface, you need to set the shade constans using the effect interface. IDirect3DDevice9::SetVertexShaderConstantF is meant to be used for assembly shaders.

When you call ID3DXEffect::BeginPass, the effect system batches all the state changes you've done and sends them all to the graphics card. That may be why the c0-c4 constants are being set to zero; because you never set them using the effect interface.

neneboricua
Yes, I know that, but it is not answer to my question which still persists,
how to declare and use a variable which is binded to a particular register and which is not affected by ID3DXEffect::BeginPass call...
...is there any way how to remove variable from ID3DXEffect constants table?

Anyway thanx for reply
Quote:Original post by Solitude
Yes, I know that, but it is not answer to my question which still persists,
how to declare and use a variable which is binded to a particular register and which is not affected by ID3DXEffect::BeginPass call...

Like I said in the previous reply, if you are using the ID3DEffect interface, you _have_ to use the methods of the interface to set the constants. Calling ID3DXEffect::BeginPass will batch all the constant changes and sent them to the graphics card. Since the effect interface never sees you set the values of those constants, it will feel free to set them to whatever it wants because it doesn't know that you're going to be using them.

Quote:Original post by Solitude
...is there any way how to remove variable from ID3DXEffect constants table?

No. The effect interface does not expose access to the constant table. Even if it did, there would be no guarantee that the effect interface wouldn't set the values in those constant registers to whatever value it wants.

Why do you need to do this? Perhaps there is another way to accomplish what you're trying to do.

neneboricua

This topic is closed to new replies.

Advertisement