From d000a1e7c572a49e96fbed8d23f6c1a02a7b2272 Mon Sep 17 00:00:00 2001 From: LuisAntonRebollo Date: Thu, 11 Dec 2014 01:20:39 +0100 Subject: [PATCH] OpenGL Intel - Workaround for warning spam or even crash with actual framebuffer code, remove when implemented TGL layer. --- Engine/source/gfx/gl/gfxGLDevice.cpp | 31 +++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/Engine/source/gfx/gl/gfxGLDevice.cpp b/Engine/source/gfx/gl/gfxGLDevice.cpp index 2e22530ed..b3e3badbc 100644 --- a/Engine/source/gfx/gl/gfxGLDevice.cpp +++ b/Engine/source/gfx/gl/gfxGLDevice.cpp @@ -98,6 +98,27 @@ void STDCALL glAmdDebugCallback(GLuint id, GLenum category, GLenum severity, GLs Con::errorf("OPENGL: %s",message); } + +// >>>> OPENGL INTEL WORKAROUND @todo OPENGL INTEL remove +PFNGLBINDFRAMEBUFFERPROC __openglBindFramebuffer = NULL; + +void STDCALL _t3d_glBindFramebuffer(GLenum target, GLuint framebuffer) +{ + if( target == GL_FRAMEBUFFER ) + { + if( GFXGL->getOpenglCache()->getCacheBinded( GL_DRAW_FRAMEBUFFER ) == framebuffer + && GFXGL->getOpenglCache()->getCacheBinded( GL_READ_FRAMEBUFFER ) == framebuffer ) + return; + } + else if( GFXGL->getOpenglCache()->getCacheBinded( target ) == framebuffer ) + return; + + __openglBindFramebuffer(target, framebuffer); + GFXGL->getOpenglCache()->setCacheBinded( target, framebuffer); +} +// <<<< OPENGL INTEL WORKAROUND + + void GFXGLDevice::initGLState() { // We don't currently need to sync device state with a known good place because we are @@ -120,9 +141,17 @@ void GFXGLDevice::initGLState() mSupportsAnisotropic = mCardProfiler->queryProfile( "GL::suppAnisotropic" ); String vendorStr = (const char*)glGetString( GL_VENDOR ); - if( vendorStr.find("NVIDIA") != String::NPos) + if( vendorStr.find("NVIDIA", 0, String::NoCase | String::Left) != String::NPos) mUseGlMap = false; + + if( vendorStr.find("INTEL", 0, String::NoCase | String::Left ) != String::NPos) + { + // @todo OPENGL INTEL - This is a workaround for a warning spam or even crashes with actual framebuffer code, remove when implemented TGL layer. + __openglBindFramebuffer = glBindFramebuffer; + glBindFramebuffer = &_t3d_glBindFramebuffer; + } + #if TORQUE_DEBUG if( gglHasExtension(ARB_debug_output) ) {