diff --git a/code/nel/include/nel/3d/uniform_buffer_format.h b/code/nel/include/nel/3d/uniform_buffer_format.h index 060bf269b..1a55d5c12 100644 --- a/code/nel/include/nel/3d/uniform_buffer_format.h +++ b/code/nel/include/nel/3d/uniform_buffer_format.h @@ -38,6 +38,8 @@ namespace NL3D { class CUniformBufferFormat { public: + CUniformBufferFormat() : m_Hash(0) { } + // When changing, update // - s_TypeAlignment // - s_TypeSize @@ -96,7 +98,7 @@ public: inline const CEntry &get(sint i) const { return m_Entries[i]; } inline size_t size() const { return m_Entries.size(); } - inline void clear() { m_Entries.clear(); } + inline void clear() { m_Entries.clear(); m_Hash = 0; } private: static const sint s_TypeAlignment[]; @@ -104,6 +106,7 @@ private: typedef std::vector TEntries; TEntries m_Entries; + size_t m_Hash; }; diff --git a/code/nel/src/3d/uniform_buffer_format.cpp b/code/nel/src/3d/uniform_buffer_format.cpp index 61e558c05..c86cd4db3 100644 --- a/code/nel/src/3d/uniform_buffer_format.cpp +++ b/code/nel/src/3d/uniform_buffer_format.cpp @@ -30,6 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include +#include namespace NL3D { @@ -107,6 +108,12 @@ sint CUniformBufferFormat::push(const std::string &name, TType type, sint count) entry.Type = type; entry.Offset = alignOffset; entry.Count = count; +#if (HAVE_X86_64) + m_Hash = NLMISC::wangHash64(m_Hash ^ ((uint64)type | ((uint64)count << 32))); +#else + m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)type); + m_Hash = NLMISC::wangHash(m_Hash ^ (uint32)count); +#endif return alignOffset; }