To set the rasterizer state I have to ID3D11Device::CreateRasterizerState() and then ID3D11DeviceContext::RSSetState. And then I should ID3D11RasterizerState::Release() it, right?

  • How about when I want to change the state? Do I follow the above 3 steps again?
  • When I want to change just 1 setting (i.e. only CullMode) do I still have to fill and set whole structure?
  • Also, do I have to create and release the state object each time (assuming I don't want to set the exact same state again in the future)?
  • How about performance? If I set the exact same state again does it do anything? Is there a difference between changing only 1 setting or most/all of them?

You have to set entire state blocks at a time, even if you want to change only a single value.

You should create all the state blocks you need and hold on to them as long as you may need them. Don't create-set-release. That introduces unnecessary resource churn. The API will share redundant state block data under the hood so you shouldn't need to worry about that.

The underlying API will handle state changes for an entire state block efficiently. The debug layer will notify you of entirely redundant state block sets, however.

To improve performance, aim for minimal state change anywhere in a graphics API. That usually means batching operations on geometry that shares needed state. However, don't be afraid to change state when you need to.

  • \$\begingroup\$ But if I want to set a state that differs in some way from the RasterizerStates I've already created then I have to create another one? There's no way of changing the settings of an already created RasterizerState? \$\endgroup\$ – NPS Feb 24 '14 at 2:54
  • \$\begingroup\$ Correct; they are immutable objects. \$\endgroup\$ – user1430 Feb 24 '14 at 3:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.