diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp index b1980e56c..9a2091995 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_pixel_program.cpp @@ -133,24 +133,45 @@ namespace std { size_t hash::operator()(const NL3D::CPPBuiltin & v) const { - uint32_t h; +#if (HAVE_X86_64) + uint32 h32; + uint64 h64; + + // Material state + h32 = NLMISC::wangHash((uint32)v.Shader); + h64 = NLMISC::wangHash64(((uint64)v.Flags) | ((uint64)v.TextureActive << 32)); + h64 = NLMISC::wangHash64(h64 ^ (uint64)v.TexSamplerMode); + uint maxTex = NL3D::maxTextures(v.Shader); + if (NL3D::useTexEnv(v.Shader)) + for (uint stage = 0; stage < maxTex; ++stage) + h32 = NLMISC::wangHash(h32 ^ (uint32)v.TexEnvMode[stage]); + + // Driver state + h32 = NLMISC::wangHash(h32 ^ (((uint32)v.VertexFormat) | (v.Fog ? 1 << 16 : 0))); + + h64 = h64 ^ h32; // NLMISC::wangHash64(h64 ^ h32); + nlctassert(sizeof(size_t) >= sizeof(uint64)); + return (size_t)h64; +#else + uint32 h; // Material state h = NLMISC::wangHash((uint32)v.Shader); h = NLMISC::wangHash(h ^ (uint32)v.Flags); h = NLMISC::wangHash(h ^ (uint32)v.TextureActive); - h = NLMISC::wangHash(h ^ (uint32)v.TexSamplerMode); + h = NLMISC::wangHash(h ^ (uint32)(v.TexSamplerMode & 0xFFFFFFFF)); + h = NLMISC::wangHash(h ^ (uint32)(v.TexSamplerMode >> 32)); uint maxTex = NL3D::maxTextures(v.Shader); if (NL3D::useTexEnv(v.Shader)) for (uint stage = 0; stage < maxTex; ++stage) h = NLMISC::wangHash(h ^ (uint32)v.TexEnvMode[stage]); // Driver state - h = NLMISC::wangHash(h ^ (uint32)v.VertexFormat); - h = NLMISC::wangHash(h ^ (uint32)v.Fog); + h = NLMISC::wangHash(h ^ (((uint32)v.VertexFormat) | (v.Fog ? 1 << 16 : 0))); - nlctassert(sizeof(size_t) > sizeof(uint32)); + nlctassert(sizeof(size_t) >= sizeof(uint32)); return (size_t)h; +#endif } } diff --git a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_program.cpp b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_program.cpp index fc5258e2e..7a63291ad 100644 --- a/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_program.cpp +++ b/code/nel/src/3d/driver/opengl3/driver_opengl_vertex_program.cpp @@ -89,7 +89,7 @@ namespace std { size_t hash::operator()(const NL3D::CVPBuiltin & v) const { - uint32_t h; + uint32 h; h = NLMISC::wangHash(((uint32)v.VertexFormat) | (v.Lighting ? (1 << 16) : 0) | (v.Specular ? (1 << 17) : 0) | (v.Fog ? (1 << 18) : 0)); if (v.Lighting) @@ -98,7 +98,7 @@ size_t hash::operator()(const NL3D::CVPBuiltin & v) const for (sint i = 0; i < NL3D::IDRV_MAT_MAXTEXTURES; ++i) h = NLMISC::wangHash(h ^ v.TexGenMode[i]); - nlctassert(sizeof(size_t) > sizeof(uint32)); + nlctassert(sizeof(size_t) >= sizeof(uint32)); return (size_t)h; }