From ecc7d2913e73fffb5786d5d812245a370d6e9bb5 Mon Sep 17 00:00:00 2001 From: vladislavbelov Date: Wed, 29 Jan 2020 22:03:44 +0000 Subject: [PATCH] Moves GL error check after SwapBuffers to decrease a possible synchronization during rendering process. Comments By: Stan, elexis Differential Revision: https://code.wildfiregames.com/D2600 This was SVN commit r23462. --- source/main.cpp | 4 +++- source/renderer/Renderer.cpp | 17 ++++++++--------- source/renderer/Renderer.h | 7 ++++++- source/tools/atlas/GameInterface/View.cpp | 3 ++- 4 files changed, 19 insertions(+), 12 deletions(-) diff --git a/source/main.cpp b/source/main.cpp index d8553dcc40..eaf7d70942 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -420,6 +420,8 @@ static void Frame() SDL_GL_SwapWindow(g_VideoMode.GetWindow()); ogl_WarnIfError(); } + + g_Renderer.OnSwapBuffers(); } g_Profiler.Frame(); diff --git a/source/renderer/Renderer.cpp b/source/renderer/Renderer.cpp index 59da4544b6..df866d3fc9 100644 --- a/source/renderer/Renderer.cpp +++ b/source/renderer/Renderer.cpp @@ -1456,17 +1456,16 @@ void CRenderer::EndFrame() m->Model.TranspUnskinned->EndFrame(); ogl_tex_bind(0, 0); - - { - PROFILE3("error check"); - int err = glGetError(); - if (err) - { - ONCE(LOGERROR("CRenderer::EndFrame: GL errors %s (%04x) occurred", ogl_GetErrorName(err), err)); - } - } } +void CRenderer::OnSwapBuffers() +{ + PROFILE3("error check"); + // We have to check GL errors after SwapBuffer to avoid possible + // synchronizations during rendering. + //if (GLenum err = glGetError()) + // ONCE(LOGERROR("GL error %s (0x%04x) occurred", ogl_GetErrorName(err), err)); +} /////////////////////////////////////////////////////////////////////////////////////////////////// // DisplayFrustum: debug displays diff --git a/source/renderer/Renderer.h b/source/renderer/Renderer.h index 7c3161e494..7f349f67ec 100644 --- a/source/renderer/Renderer.h +++ b/source/renderer/Renderer.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -137,6 +137,11 @@ public: // signal frame end void EndFrame(); + /** + * Should be called after each SwapBuffers call. + */ + void OnSwapBuffers(); + /** * Set simulation context for rendering purposes. * Must be called at least once when the game has started and before diff --git a/source/tools/atlas/GameInterface/View.cpp b/source/tools/atlas/GameInterface/View.cpp index 928da509f8..ef3776443a 100644 --- a/source/tools/atlas/GameInterface/View.cpp +++ b/source/tools/atlas/GameInterface/View.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -231,6 +231,7 @@ void AtlasViewGame::Render() ::Render(); Atlas_GLSwapBuffers((void*)g_AtlasGameLoop->glCanvas); + g_Renderer.OnSwapBuffers(); } void AtlasViewGame::DrawCinemaPathTool()