Sign in to follow this  

Direct3D 9 Pixel and Vertex Shaders

This topic is 3594 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

Hello everyone. I am currently writing a vertex and pixel shader input binding system for a game that I am working on and have run into a little snag. I am trying to set the shader constants and it seems that my constants are not taking effect. I have narrowed the problem down to when I am setting the constants. I first set the vertex/pixel shader, then set the stream source, then set the constants, then I draw the geometry. It seems to be fine if I set the constants before setting the vertex/pixel shader. Does anyone know if it makes a difference when I set the shader constants? I cannot seem to find the answer in the API docs or anywhere else. Thanks.

Share this post


Link to post
Share on other sites
I don't know about plain old vertex/pixel shaders, but when using the Effect framework in D3D9 you need to commit changes to the device if you make changes during an active pass.

The DXSDK documentation can explain this better than I can:
Quote:
If the application changes any effect state using any of the ID3DXEffect::Setx methods inside of an ID3DXEffect::BeginPass/ID3DXEffect::EndPass matching pair, the application must call ID3DXEffect::CommitChanges before any DrawxPrimitive call to propagate state changes to the device before rendering. If no state changes occur within a ID3DXEffect::BeginPass and ID3DXEffect::EndPass matching pair, it is not necessary to call ID3DXEffect::CommitChanges.

This is slightly different for any shared parameters in a cloned effect. When a technique is active on a cloned effect (that is, when ID3DXEffect::Begin has been called but and ID3DXEffect::End has not been called), ID3DXEffect::CommitChanges updates parameters that are not shared as expected. To update a shared parameter (only for a cloned effect whose technique is active), call ID3DXEffect::End to deactivate the technique and ID3DXEffect::Begin to reactivate the technique before calling ID3DXEffect::CommitChanges.

Share this post


Link to post
Share on other sites

This topic is 3594 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.

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