diff --git a/Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp b/Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp index 40e9365ac0..3d82e06b25 100644 --- a/Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp +++ b/Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp @@ -137,7 +137,7 @@ class RenderStateCacheImpl final : public ObjectBase private: RefCntAutoPtr m_pDevice; const RENDER_DEVICE_TYPE m_DeviceType; - const size_t m_DeviceHash; // Hash of the device-specific properties + const XXH128Hash m_DeviceHash; // Hash of the device-specific properties const RenderStateCacheCreateInfo m_CI; RefCntAutoPtr m_pReloadSource; RefCntAutoPtr m_pSerializationDevice; diff --git a/Graphics/GraphicsTools/interface/XXH128Hasher.hpp b/Graphics/GraphicsTools/interface/XXH128Hasher.hpp index 44c433b779..8b1e1e12c9 100644 --- a/Graphics/GraphicsTools/interface/XXH128Hasher.hpp +++ b/Graphics/GraphicsTools/interface/XXH128Hasher.hpp @@ -123,6 +123,8 @@ struct XXH128State final void Update(const ShaderCreateInfo& ShaderCI) noexcept; + void Update(const XXH128Hash& Hash) noexcept; + template typename std::enable_if<(std::is_same::type, SamplerDesc>::value || std::is_same::type, StencilOpDesc>::value || diff --git a/Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp b/Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp index ce8d2d888d..245afcca11 100644 --- a/Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp +++ b/Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp @@ -144,13 +144,15 @@ std::string RenderStateCacheImpl::MakeHashStr(const char* Name, const XXH128Hash } -static size_t ComputeDeviceAttribsHash(IRenderDevice* pDevice) +static XXH128Hash ComputeDeviceAttribsHash(IRenderDevice* pDevice) { if (pDevice == nullptr) - return 0; + return {}; const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo(); - return ComputeHash(DeviceInfo.Type, DeviceInfo.NDC.MinZ, DeviceInfo.Features.SeparablePrograms); + XXH128State Hasher; + Hasher.Update(DeviceInfo.Type, DeviceInfo.NDC.MinZ, DeviceInfo.Features.SeparablePrograms); + return Hasher.Digest(); } RenderStateCacheImpl::RenderStateCacheImpl(IReferenceCounters* pRefCounters, diff --git a/Graphics/GraphicsTools/src/XXH128Hasher.cpp b/Graphics/GraphicsTools/src/XXH128Hasher.cpp index f08fff788d..1fea7f30c5 100644 --- a/Graphics/GraphicsTools/src/XXH128Hasher.cpp +++ b/Graphics/GraphicsTools/src/XXH128Hasher.cpp @@ -108,4 +108,9 @@ void XXH128State::Update(const ShaderCreateInfo& ShaderCI) noexcept } } +void XXH128State::Update(const XXH128Hash& Hash) noexcept +{ + Update(Hash.LowPart, Hash.HighPart); +} + } // namespace Diligent