Earlier, I have been setting render states (shaders, shader resources, etc.) without checking if it is really necessary. Maybe they had been bound earlier and I could use them without setting them again.

So now I am checking for currently set render state before setting it. If there is a mismatch, then I set it. Setting a pixel shader for example:

```
typedef ID3D11DeviceContext*        DeviceContext;
typedef ID3D11PixelShader*          PixelShader;

inline static void BindPS(PixelShader shader, DeviceContext context){
    if(context!=nullptr){
        PixelShader s;
        context->PSGetShader(&s,nullptr,0);
        if(s!=shader)
            context->PSSetShader(shader, nullptr, 0);
        if(s!=nullptr)
            s->Release();
    }
}

```

I wonder if it is a welcome practice to get current render state from the device context context so often, or should I roll my own solution for checking them? Keeping pointers for currently bound states for example and checking with those? 

I ask this now, because I only started implementing this for some states (PSSetshader and PSSetShaderresources), and I have a lot more, so I would opt-out early if this method could be problematic.