   [DX10] Input Layouts - how do you manage them?
  Hi!I'm currently porting my old engine to DX10.Now, my InputLayout-class used to be (basically) just a container of the VertexDeclaration with an Apply() function.As in DX10 every InputLayout must be linked to the shader, I'm struggling to find an elegant solution to encapsulating this behaviour.Now there's two approaches I'm currently considering:1) Each CInputLayout stores one ID3D10InputLayout for every pass in those effects it is used in. (Possibly in an associative array?)2) A dedicated manager creates ID3D10InputLayouts for any needed Layout-shader-combination. Now I could do this like CInputLayout.Apply(Shader); with CInputLayou having pointers to the manager-created layouts-or- I could have the manager apply them via Manager->Apply(Layout, Shader);3) some truly elegant way I don't see.So, which way would you prefer in terms of good OO design? Any other ideas?How do you manage and encapsulate the new InputLayouts in your engines?Thanks for any ideas and advice!
  I settled on creating quite a few different input layouts (like 6 or so) and making a dummy shader with all the various vertex shader input structs. You can also put these vertex shader input structs in a global fx header file that is included in other fx files so your shaders only use those formats. That seemed to work pretty well for me. I think you could also use shader reflection via the ID3D10ShaderReflection interface, but unless you need to work with any type of input layout, I think it might be too much work.I then store a pointer to an input layout on a per mesh basis, since you need the input layout when rendering. You could choose this at load time based on the vertex layout of your mesh's vertex buffer.I don't claim this is the 'best' way to do things, but it seems Hellgate London uses a similar approach (see: pg 61 of http://developer.download.nvidia.com/presentations/2007/gdc/UsingD3D10Now.pdf). There are probably much more elegant ways, but this method is pretty simple and easy to implement.   