Skip to content

Commit f132e0e

Browse files
Render state cache: make hash computation consistent between 32 and 64 bit architectures
1 parent 5677120 commit f132e0e

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

Graphics/GraphicsTools/include/RenderStateCacheImpl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ class RenderStateCacheImpl final : public ObjectBase<IRenderStateCache>
137137
private:
138138
RefCntAutoPtr<IRenderDevice> m_pDevice;
139139
const RENDER_DEVICE_TYPE m_DeviceType;
140-
const size_t m_DeviceHash; // Hash of the device-specific properties
141140
const RenderStateCacheCreateInfo m_CI;
142141
RefCntAutoPtr<IShaderSourceInputStreamFactory> m_pReloadSource;
143142
RefCntAutoPtr<ISerializationDevice> m_pSerializationDevice;

Graphics/GraphicsTools/src/RenderStateCacheImpl.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -144,13 +144,13 @@ std::string RenderStateCacheImpl::MakeHashStr(const char* Name, const XXH128Hash
144144
}
145145

146146

147-
static size_t ComputeDeviceAttribsHash(IRenderDevice* pDevice)
147+
static void ComputeDeviceAttribsHash(XXH128State& Hasher, IRenderDevice* pDevice)
148148
{
149-
if (pDevice == nullptr)
150-
return 0;
151-
152-
const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo();
153-
return ComputeHash(DeviceInfo.Type, DeviceInfo.NDC.MinZ, DeviceInfo.Features.SeparablePrograms);
149+
if (pDevice != nullptr)
150+
{
151+
const RenderDeviceInfo& DeviceInfo = pDevice->GetDeviceInfo();
152+
Hasher.Update(DeviceInfo.Type, DeviceInfo.NDC.MinZ, DeviceInfo.Features.SeparablePrograms);
153+
}
154154
}
155155

156156
RenderStateCacheImpl::RenderStateCacheImpl(IReferenceCounters* pRefCounters,
@@ -159,7 +159,6 @@ RenderStateCacheImpl::RenderStateCacheImpl(IReferenceCounters* pRe
159159
// clang-format off
160160
m_pDevice {CreateInfo.pDevice},
161161
m_DeviceType {CreateInfo.pDevice != nullptr ? CreateInfo.pDevice->GetDeviceInfo().Type : RENDER_DEVICE_TYPE_UNDEFINED},
162-
m_DeviceHash {ComputeDeviceAttribsHash(CreateInfo.pDevice)},
163162
m_CI {CreateInfo},
164163
m_pReloadSource{CreateInfo.pReloadSource}
165164
// clang-format on
@@ -318,7 +317,8 @@ bool RenderStateCacheImpl::CreateShaderInternal(const ShaderCreateInfo& ShaderCI
318317
#else
319318
constexpr bool IsDebug = false;
320319
#endif
321-
Hasher.Update(ShaderCI, m_DeviceHash, IsDebug);
320+
ComputeDeviceAttribsHash(Hasher, m_pDevice);
321+
Hasher.Update(ShaderCI, IsDebug);
322322
const XXH128Hash Hash = Hasher.Digest();
323323

324324
// First, try to check if the shader has already been requested
@@ -765,7 +765,8 @@ bool RenderStateCacheImpl::CreatePipelineStateInternal(const CreateInfoType& PSO
765765
}
766766

767767
XXH128State Hasher;
768-
Hasher.Update(PSOCreateInfo, m_DeviceHash);
768+
ComputeDeviceAttribsHash(Hasher, m_pDevice);
769+
Hasher.Update(PSOCreateInfo);
769770
const auto Hash = Hasher.Digest();
770771

771772
// First, try to check if the PSO has already been requested

0 commit comments

Comments
 (0)