Hi all,
In the journey of creating my new d3d11 engine, I've come to the point where I'm going to add and create the shader classes and system.
My struggle:
- I want to create a base/ parent class CD3dShader
-- there will be child classes inherited from the CD3dShader class, for pixelshader, vertexshader etc. etc.
In my current D3D11 experience I've always linked an inputlayout (ID3D11InputLayout) to a shader.
This is very convenient for several reasons:
- when creating/ compiling the shader I have the blob around and can easily create the inputlayout
- I have a 'GetInputLayout' member function in the shader class, which returns a pointer to the inputlayout for that shader
But... I think there's cost in this approach, because now I would always set the needed InputLayout when switching to another shader. Which potentially is the same inputlayout that was already set.
My questions:
- how would you handle this?
- is there significant cost (performance wise) in setting inputlayouts which are already set?
(or is ignored for the biggest part, because D3D11 recognizes it?)
- would it be a good idea to create a shadermanager class, which keeps track of the current shader and stores the input layouts, where each shader class object simply has an ID to the corresponding inputlayout?
-- I could also store a std::vector within the shader class, with all the shader class objects