Jump to content
  • Advertisement
Sign in to follow this  
jaafit

Render States: Fixed Function vs Programmable

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

What happens last, the FF SetRenderState or the HLSL effect's renderstate declarations? Please explain to me why yesterday certain objects in my app would randomly change between alpha blending and not alpha blending. I was setting alphablendenable = true via the fixed function pipe and setting to false via the effect file. The bug was fixed when I took out the effect state change and just used SetRenderState. The way I thought it worked was, whatever it is set to last is the value it remains at for the draw and that a FF Set would take place before an effect Set. That does not seem to be the case, in fact it seems that if you do both and the value conflict, the result is undefined. So what is the rule governing this behavior?

Share this post


Link to post
Share on other sites
Advertisement
I'm not sure, but I think you are right in assuming that the value at draw time will be whatever value you set last, whether it's through the FF or an effect. However, you should take note that the default behavior for effects is the effect system will reset whatever render state value that is changed inside the effect. But I'm unsure whether it resets the changed render states to their defaults or to the value before the effect is started, but I think it's more likely the default is used since you supposedly can't get the values of render states for pure devices.

Wow, I don't think that was useful at all! Sorry.

Share this post


Link to post
Share on other sites
There aren't two render states. The effect file is just an alternate method of setting the same state.

The effect's state setting behaviour is governed by the flags of the Begin function. By default the state is saved when Begin start and is restored when Begin ends. You can use the flags to cause it (or part of it) not to be saved.

Share this post


Link to post
Share on other sites
You could try running it on the REF device and see what behavior you get, but I think you're pretty much at the mercy of the runtime/driver on something like this. The Effect system does a lot of work behind the scenes to try to optimize things as best it can. The states you set in the effect may not be applied until you call CommitChanges or perhaps even until you call DrawPrimitive. These kind of low-level workings of the Effect system aren't documented. This is probably to allow IHV's room to optimize things as best they can.

Typically, mixing fixed-function SetRenderState with states in Effect files on the same draw call is not a good idea. In general, you should choose one or the other. You could use fixed-function for some things and Effects for others as long as you know what states your Effects are leaving the settings at, but this could be a little confusing so most projects choose either Effects or SetRenderState and limit the mixing of the two.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!