add internal function to pack blend state into 32 bits.

This commit is contained in:
Sasha Szpakowski
2024-09-07 17:34:10 -03:00
parent e6e5ec0ab5
commit 26a7389a4d
+19
View File
@@ -147,6 +147,25 @@ struct BlendState
&& srcFactorRGB == b.srcFactorRGB && srcFactorA == b.srcFactorA
&& dstFactorRGB == b.dstFactorRGB && dstFactorA == b.dstFactorA;
}
uint32 toKey() const
{
return (dstFactorA << 0) | (dstFactorRGB << 4) | (srcFactorA << 8) | (srcFactorRGB << 12)
| (operationA << 16) | (operationRGB << 20) | ((enable ? 1 : 0) << 24);
}
static BlendState fromKey(uint32 key)
{
BlendState b;
b.enable = (bool)((key >> 24) & 1);
b.operationRGB = (BlendOperation)((key >> 20) & 0x7);
b.operationA = (BlendOperation)((key >> 16) & 0x7);
b.srcFactorRGB = (BlendFactor)((key >> 12) & 0xF);
b.srcFactorA = (BlendFactor)((key >> 8) & 0xF);
b.dstFactorRGB = (BlendFactor)((key >> 4) & 0xF);
b.dstFactorA = (BlendFactor)((key >> 0) & 0xF);
return b;
}
};
struct DepthState