diff --git a/Source/Core/VideoBackends/OGL/Src/Render.cpp b/Source/Core/VideoBackends/OGL/Src/Render.cpp index 4dca112031..e507fc45cd 100644 --- a/Source/Core/VideoBackends/OGL/Src/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Src/Render.cpp @@ -386,6 +386,7 @@ Renderer::Renderer() g_ogl_config.bSupportCoverageMSAA = false; // XXX: GLES3 spec has MSAA g_ogl_config.bSupportSampleShading = false; g_ogl_config.bSupportOGL31 = false; + g_ogl_config.bSupportViewportFloat = false; if (DriverDetails::HasBug(DriverDetails::BUG_ISTEGRA) || DriverDetails::HasBug(DriverDetails::BUG_ISPOWERVR)) g_ogl_config.eSupportedGLSLVersion = GLSLES2; else @@ -496,6 +497,7 @@ Renderer::Renderer() g_ogl_config.bSupportCoverageMSAA = GLEW_NV_framebuffer_multisample_coverage; g_ogl_config.bSupportSampleShading = GLEW_ARB_sample_shading; g_ogl_config.bSupportOGL31 = GLEW_VERSION_3_1; + g_ogl_config.bSupportViewportFloat = GLEW_ARB_viewport_array; if(strstr(g_ogl_config.glsl_version, "1.00") || strstr(g_ogl_config.glsl_version, "1.10") || strstr(g_ogl_config.glsl_version, "1.20")) { @@ -1105,12 +1107,12 @@ void Renderer::UpdateViewport(Matrix44& vpCorrection) int scissorYOff = bpmem.scissorOffset.y * 2; // TODO: ceil, floor or just cast to int? - int X = EFBToScaledX((int)ceil(xfregs.viewport.xOrig - xfregs.viewport.wd - (float)scissorXOff)); - int Y = EFBToScaledY((int)ceil((float)EFB_HEIGHT - xfregs.viewport.yOrig + xfregs.viewport.ht + (float)scissorYOff)); - int Width = EFBToScaledX((int)ceil(2.0f * xfregs.viewport.wd)); - int Height = EFBToScaledY((int)ceil(-2.0f * xfregs.viewport.ht)); - double GLNear = (xfregs.viewport.farZ - xfregs.viewport.zRange) / 16777216.0f; - double GLFar = xfregs.viewport.farZ / 16777216.0f; + float X = EFBToScaledXf(xfregs.viewport.xOrig - xfregs.viewport.wd - (float)scissorXOff); + float Y = EFBToScaledYf((float)EFB_HEIGHT - xfregs.viewport.yOrig + xfregs.viewport.ht + (float)scissorYOff); + float Width = EFBToScaledXf(2.0f * xfregs.viewport.wd); + float Height = EFBToScaledYf(-2.0f * xfregs.viewport.ht); + float GLNear = (xfregs.viewport.farZ - xfregs.viewport.zRange) / 16777216.0f; + float GLFar = xfregs.viewport.farZ / 16777216.0f; if (Width < 0) { X += Width; @@ -1126,7 +1128,14 @@ void Renderer::UpdateViewport(Matrix44& vpCorrection) Matrix44::LoadIdentity(vpCorrection); // Update the view port - glViewport(X, Y, Width, Height); + if(g_ogl_config.bSupportViewportFloat) + { + glViewportIndexedf(0, X, Y, Width, Height); + } + else + { + glViewport(round(X), round(Y), round(Width), round(Height)); + } glDepthRangef(GLNear, GLFar); } diff --git a/Source/Core/VideoBackends/OGL/Src/Render.h b/Source/Core/VideoBackends/OGL/Src/Render.h index 8c6a8ca8f8..efafb8708d 100644 --- a/Source/Core/VideoBackends/OGL/Src/Render.h +++ b/Source/Core/VideoBackends/OGL/Src/Render.h @@ -27,6 +27,7 @@ extern struct VideoConfig { bool bSupportSampleShading; GLSL_VERSION eSupportedGLSLVersion; bool bSupportOGL31; + bool bSupportViewportFloat; const char *gl_vendor; const char *gl_renderer;