RSX/D3D12: Improve shader lookup performance

This commit is contained in:
Vincent Lejeune 2015-08-24 20:27:42 +02:00
parent 9c24bb9d75
commit 095c8fa19b
2 changed files with 29 additions and 0 deletions

View File

@ -223,6 +223,8 @@ private:
{ {
size_t hashValue = 0; size_t hashValue = 0;
hashValue ^= std::hash<unsigned>()(key.vpIdx); hashValue ^= std::hash<unsigned>()(key.vpIdx);
hashValue ^= std::hash<unsigned>()(key.fpIdx);
hashValue ^= std::hash<typename BackendTraits::PipelineProperties>()(key.properties);
return hashValue; return hashValue;
} }
}; };

View File

@ -47,6 +47,33 @@ struct D3D12PipelineProperties
} }
}; };
template<typename T>
size_t hashStructContent(const T& structure)
{
char *data = (char*)(&structure);
size_t result = 0;
for (unsigned i = 0; i < sizeof(T); i++)
result ^= std::hash<char>()(data[i]);
return result;
}
namespace std
{
template <>
struct hash<D3D12PipelineProperties> {
size_t operator()(const D3D12PipelineProperties &pipelineProperties) const {
size_t seed = hash<unsigned>()(pipelineProperties.DepthStencilFormat) ^
(hash<unsigned>()(pipelineProperties.RenderTargetsFormat) << 2) ^
(hash<unsigned>()(pipelineProperties.Topology) << 2) ^
(hash<unsigned>()(pipelineProperties.numMRT) << 4);
seed ^= hashStructContent(pipelineProperties.Blend);
seed ^= hashStructContent(pipelineProperties.DepthStencil);
seed ^= hashStructContent(pipelineProperties.Rasterization);
return hash<size_t>()(seed);
}
};
}
/** Storage for a shader /** Storage for a shader
* Embeds the D3DBlob * Embeds the D3DBlob
*/ */