Hi,
I'm looking for fast and flexible ways to handle the following problems:
-How to match different types of geometry with the appropriate shader input layout?
-How to update shader constants and pass them correctly to the shader since they need to be stored in a specific constant buffer at the currect position?
Currently I don't do any check regarding input layouts during run-time (loading of assets). The correct shader is chosen manually at asset creation time, is this "ok"?
An idea I have is to write a function to check model data/shader input layout compatibility and integrate it in the model utility (a tool to assign materials to each mesh subset etc), this will be done at asset creation time.
For shader constants:
I allocate chunks of data the size of each constant buffer used by the shader of that material. And store a table of pairs (constant name, pointer to the data).
This is quite fast since I have a number of pointers to POD equal to the number of constant buffers, so to update the constant buffers I just use those pointers.
To change the value of constants I use the table to find the pointer of the constant I want to update. Maybe this is how the D3D Effects framework handles it.
Any suggestions to improve performance/flexibility? How do you handle this?
Thanks.