From 137700d0a20e842bc63ae1e1c6f7ce9fc8ff7661 Mon Sep 17 00:00:00 2001 From: bkaradzic Date: Sat, 23 Mar 2013 22:42:16 -0700 Subject: [PATCH] GL: Fixed initial value of binary shader hash. --- src/renderer_gl.cpp | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index a6e625af9..ddbbc7f95 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -2004,13 +2004,25 @@ namespace bgfx s_renderCtx.flip(); } - GLint glGet(GLenum _pname) + static GLint glGet(GLenum _pname) { GLint result; GL_CHECK(glGetIntegerv(_pname, &result) ); return result; } + static uint32_t glGetStringHash(GLenum _name) + { + const char* str = (const char*)glGetString(_name); + glGetError(); // ignore error if glGetString returns NULL. + if (NULL != str) + { + return bx::hashMurmur2A(str, strlen(str) ); + } + + return 0; + } + void Context::rendererInit() { s_renderCtx.init(); @@ -2056,6 +2068,13 @@ namespace bgfx BX_TRACE("GLSL version: %s", version); #endif // BGFX_CONFIG_DEBUG + // Initial binary shader hash depends on driver version. + s_renderCtx.m_hash = ( (BX_PLATFORM_WINDOWS<<1) | BX_ARCH_64BIT) + ^ (uint64_t(glGetStringHash(GL_VENDOR ) )<<32) + ^ (uint64_t(glGetStringHash(GL_RENDERER) )<<0 ) + ^ (uint64_t(glGetStringHash(GL_VERSION ) )<<16) + ; + const char* extensions = (const char*)glGetString(GL_EXTENSIONS); glGetError(); // ignore error if glGetString returns NULL. if (NULL != extensions)