diff --git a/rpcs3/Emu/RSX/Common/ProgramStateCache.h b/rpcs3/Emu/RSX/Common/ProgramStateCache.h index 6a732e7bd7..3c1f85bae3 100644 --- a/rpcs3/Emu/RSX/Common/ProgramStateCache.h +++ b/rpcs3/Emu/RSX/Common/ProgramStateCache.h @@ -223,6 +223,8 @@ private: { size_t hashValue = 0; hashValue ^= std::hash()(key.vpIdx); + hashValue ^= std::hash()(key.fpIdx); + hashValue ^= std::hash()(key.properties); return hashValue; } }; diff --git a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h index 38566e5ecc..d264b7ae28 100644 --- a/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h +++ b/rpcs3/Emu/RSX/D3D12/D3D12PipelineState.h @@ -47,6 +47,33 @@ struct D3D12PipelineProperties } }; +template +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()(data[i]); + return result; +} + +namespace std +{ + template <> + struct hash { + size_t operator()(const D3D12PipelineProperties &pipelineProperties) const { + size_t seed = hash()(pipelineProperties.DepthStencilFormat) ^ + (hash()(pipelineProperties.RenderTargetsFormat) << 2) ^ + (hash()(pipelineProperties.Topology) << 2) ^ + (hash()(pipelineProperties.numMRT) << 4); + seed ^= hashStructContent(pipelineProperties.Blend); + seed ^= hashStructContent(pipelineProperties.DepthStencil); + seed ^= hashStructContent(pipelineProperties.Rasterization); + return hash()(seed); + } + }; +} + /** Storage for a shader * Embeds the D3DBlob */