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) ) { diff --git a/Templates/Empty/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl b/Templates/Empty/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl index 6b7cf4eca..17f23e487 100644 --- a/Templates/Empty/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl +++ b/Templates/Empty/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl @@ -84,13 +84,16 @@ void main() // The CoC will be 1 if the depth is negative, so use "min" to pick // between "sceneCoc" and "viewCoc". + coc = half4(0); for ( int i = 0; i < 4; i++ ) { depth[0] = prepassUncondition( depthSampler, ( IN_tcDepth0.xy + rowOfs[i] ) ).w; depth[1] = prepassUncondition( depthSampler, ( IN_tcDepth1.xy + rowOfs[i] ) ).w; depth[2] = prepassUncondition( depthSampler, ( IN_tcDepth2.xy + rowOfs[i] ) ).w; depth[3] = prepassUncondition( depthSampler, ( IN_tcDepth3.xy + rowOfs[i] ) ).w; - coc[i] = clamp( dofEqWorld.x * depth + dofEqWorld.y, 0.0, maxWorldCoC ); + + // @todo OPENGL INTEL need review + coc = max( coc, clamp( half4(dofEqWorld.x) * depth + half4(dofEqWorld.y), half4(0.0), half4(maxWorldCoC) ) ); } /* diff --git a/Templates/Empty/game/shaders/common/postFx/gl/glowBlurP.glsl b/Templates/Empty/game/shaders/common/postFx/gl/glowBlurP.glsl index 910c512b6..d00bee26f 100644 --- a/Templates/Empty/game/shaders/common/postFx/gl/glowBlurP.glsl +++ b/Templates/Empty/game/shaders/common/postFx/gl/glowBlurP.glsl @@ -40,7 +40,7 @@ void main() { vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f; - vec4 OUT_col = vec4(0); + OUT_col = vec4(0); OUT_col += texture( diffuseMap, uv0 ) * kernel.x; OUT_col += texture( diffuseMap, uv1 ) * kernel.y; OUT_col += texture( diffuseMap, uv2 ) * kernel.z; diff --git a/Templates/Empty/game/shaders/common/terrain/terrain.glsl b/Templates/Empty/game/shaders/common/terrain/terrain.glsl index 414c5de24..79f80888c 100644 --- a/Templates/Empty/game/shaders/common/terrain/terrain.glsl +++ b/Templates/Empty/game/shaders/common/terrain/terrain.glsl @@ -35,8 +35,7 @@ float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample // match the current texture id. vec4 factors = vec4(0); for(int i = 0; i < 4; i++) - if(layerSample[i] == texId) - factors[i] = 1; + factors[i] = (layerSample[i] == texId) ? 1 : 0; // workaround for Intel // This is a custom bilinear filter. diff --git a/Templates/Full/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl b/Templates/Full/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl index 6b7cf4eca..17f23e487 100644 --- a/Templates/Full/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl +++ b/Templates/Full/game/shaders/common/postFx/dof/gl/DOF_DownSample_P.glsl @@ -84,13 +84,16 @@ void main() // The CoC will be 1 if the depth is negative, so use "min" to pick // between "sceneCoc" and "viewCoc". + coc = half4(0); for ( int i = 0; i < 4; i++ ) { depth[0] = prepassUncondition( depthSampler, ( IN_tcDepth0.xy + rowOfs[i] ) ).w; depth[1] = prepassUncondition( depthSampler, ( IN_tcDepth1.xy + rowOfs[i] ) ).w; depth[2] = prepassUncondition( depthSampler, ( IN_tcDepth2.xy + rowOfs[i] ) ).w; depth[3] = prepassUncondition( depthSampler, ( IN_tcDepth3.xy + rowOfs[i] ) ).w; - coc[i] = clamp( dofEqWorld.x * depth + dofEqWorld.y, 0.0, maxWorldCoC ); + + // @todo OPENGL INTEL need review + coc = max( coc, clamp( half4(dofEqWorld.x) * depth + half4(dofEqWorld.y), half4(0.0), half4(maxWorldCoC) ) ); } /* diff --git a/Templates/Full/game/shaders/common/postFx/gl/glowBlurP.glsl b/Templates/Full/game/shaders/common/postFx/gl/glowBlurP.glsl index 0a70fb6aa..9ebca32fa 100644 --- a/Templates/Full/game/shaders/common/postFx/gl/glowBlurP.glsl +++ b/Templates/Full/game/shaders/common/postFx/gl/glowBlurP.glsl @@ -40,7 +40,7 @@ void main() { vec4 kernel = vec4( 0.175, 0.275, 0.375, 0.475 ) * 0.5f; - vec4 OUT_col = vec4(0); + OUT_col = vec4(0); OUT_col += texture( diffuseMap, uv0 ) * kernel.x; OUT_col += texture( diffuseMap, uv1 ) * kernel.y; OUT_col += texture( diffuseMap, uv2 ) * kernel.z; diff --git a/Templates/Full/game/shaders/common/terrain/terrain.glsl b/Templates/Full/game/shaders/common/terrain/terrain.glsl index 414c5de24..79f80888c 100644 --- a/Templates/Full/game/shaders/common/terrain/terrain.glsl +++ b/Templates/Full/game/shaders/common/terrain/terrain.glsl @@ -35,8 +35,7 @@ float calcBlend( float texId, vec2 layerCoord, float layerSize, vec4 layerSample // match the current texture id. vec4 factors = vec4(0); for(int i = 0; i < 4; i++) - if(layerSample[i] == texId) - factors[i] = 1; + factors[i] = (layerSample[i] == texId) ? 1 : 0; // workaround for Intel // This is a custom bilinear filter.