In the D3D11_INPUT_ELEMENT_DESC structure, "SemanticName" is a pointer (LPCSTR) which would make the result non nondeterministic. The idea of an integer key is appealing though.
Sorry, just figured I should mention that and edited in. See explanation above, you would do something like this:
enum class AttributeSemantics
{
POSITION = 0, TEXCOORD
};
AttributeSemantics convertSemantic(LPCSTR semantic)
{
if(!strcmp(semantic, "SV_POSITION"))
return AttributeSemantic::POSITION;
else if(!strcmp(semantic, "TEXCOORD"))
return AttributeSemantic::TEXCOORD;
// and so on
}
This gives you the value of the bitsection for "semantic", now you have to do this for all the rest of the attributes that matter for the key and put them together, and you are done.
Would you mind explaining what Int128::add does ? I'm not sure i understand.
All it pretty much does is a bitshift, like in the first function. The only reason I need it is as I said, I need more then 64 bits for which I had a custom class. Int128::add equals to:
unsigned long long key;
key += (attributeKey << 7 + numAttribute * 12);
for a 64 bit integer variable. Whether this is enough depends on your needs - you should be able to stuff 6 input attributes in such a key with 64 bit, if you need more you need a larger integer class (or, if you have to/want to support an arbitrary number of integers you might need to use a variable sized integer class; or somebody else has an even better idea for this case).
EDIT: Alternatively in case of an arbitrary number of input attributes, you can always just store a custom struct with a vector of attribute keys for each layout, with a custom compare operator if you know what I mean.
struct LayoutKey
{
std::vector<unsigned int> vAttributesKeys; // 32 bits is more than enough for each attribute
bool operator<(const LayoutKey& key) const; // so the map can actually sort those
}