Jump to content
  • Advertisement
Sign in to follow this  
Solitude

ID3DXEffect, HLSL, global variables

This topic is 4810 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!