Also, maybe the stateblock should be passed as an argument to all functions that use its states. I don't like walking up the tree to find what you need (this->wineD3Ddevice) - it's a hidden dependency on device state, which isn't even all the time - that's why you had to move the point where the shader is compiled [ this needs better documentation ].
isn't even < valid > all the time Texture dimensions are set in drawprim's upload function.