Rafael Ferreira
Rafael Ferreira

Reputation: 91

How to use multiple shader states?

For example, if I want to use ID3D11RasterizerState with CullMode set to D3D11_CULL_BACK, and then I want to change it to D3D11_CULL_FRONT during runtime, what is the best approach? I was creating one state for each option and setting the right one during runtime, but this is very troublesome, as I need to set a lot of different shader states for each combination. Is retrieving the description from the shader on runtime( e.g. ID3D11DepthStencilState::GetDesc()) and changing it on the fly a good option?

Upvotes: 1

Views: 150

Answers (1)

Chuck Walbourn
Chuck Walbourn

Reputation: 41057

Generally you create a rasterizer state for each combination of states you want to use. Setting the active state is a pretty cheap operation--it's creating the state object that's expensive.

Note in DirectX 12 you have to put all states into each Pipeline State Object so that means every possible permutation of states, shaders, and render target format/configuration will result in the need for a new PSO.

Upvotes: 1

Related Questions