From 4de0ca83aa14672f9303c6e15bbd26a67359d5f1 Mon Sep 17 00:00:00 2001 From: Benau Date: Thu, 13 Apr 2017 13:59:36 +0800 Subject: [PATCH] Move capture right before glfencesync if possible --- CMakeLists.txt | 8 +++++--- src/graphics/draw_calls.cpp | 12 ++++++++++++ src/graphics/irr_driver.cpp | 19 ++++++------------- 3 files changed, 23 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index deaf506ea..fdc6f611c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,11 +134,13 @@ else() include_directories(${JPEG_INCLUDE_DIR}) endif() -if(BUILD_RECORDER) - find_library(OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") - find_path(OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include") +if (BUILD_RECORDER) find_library(OPENGLRECORDER_LIBRARY NAMES openglrecorder libopenglrecorder PATHS "${PROJECT_SOURCE_DIR}/dependencies/lib") find_path(OPENGLRECORDER_INCLUDEDIR NAMES openglrecorder.h PATHS "${PROJECT_SOURCE_DIR}/dependencies/include") + if (NOT OPENGLRECORDER_LIBRARY OR NOT OPENGLRECORDER_INCLUDEDIR) + message(FATAL_ERROR "libopenglrecorder not found. " + "Either install libopenglrecorder or disable ingame recorder with -DBUILD_RECORDER=0") + endif() include_directories(${OPENGLRECORDER_INCLUDEDIR}) mark_as_advanced(OPENGLRECORDER_LIBRARY OPENGLRECORDER_INCLUDEDIR) endif() diff --git a/src/graphics/draw_calls.cpp b/src/graphics/draw_calls.cpp index 49d4ed167..5b4b4706c 100644 --- a/src/graphics/draw_calls.cpp +++ b/src/graphics/draw_calls.cpp @@ -34,6 +34,9 @@ #include "utils/profiler.hpp" #include +#ifdef ENABLE_RECORDER +#include +#endif // ---------------------------------------------------------------------------- void DrawCalls::clearLists() @@ -646,6 +649,15 @@ void DrawCalls::prepareDrawCalls( ShadowMatrices& shadow_matrices, PROFILER_POP_CPU_MARKER(); irr_driver->setSkinningJoint(getSkinningOffset()); +#ifdef ENABLE_RECORDER + if (irr_driver->isRecording()) + { + PROFILER_PUSH_CPU_MARKER("- Recording", 0x0, 0x50, 0x40); + ogrCapture(); + PROFILER_POP_CPU_MARKER(); + } +#endif + // Add a 1 s timeout if (!m_sync) m_sync = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); diff --git a/src/graphics/irr_driver.cpp b/src/graphics/irr_driver.cpp index 15c8409a3..677ba1cfb 100644 --- a/src/graphics/irr_driver.cpp +++ b/src/graphics/irr_driver.cpp @@ -642,17 +642,13 @@ void IrrDriver::initDevice() ogrRegGeneralCallback(OGR_CBT_START_RECORDING, [] (void* user_data) { MessageQueue::add (MessageQueue::MT_GENERIC, _("Video recording started.")); }, NULL); - ogrRegGeneralCallback(OGR_CBT_ERROR_RECORDING, - [] (void* user_data) { MessageQueue::add - (MessageQueue::MT_ERROR, _("Error when saving video.")); }, NULL); - ogrRegGeneralCallback(OGR_CBT_SLOW_RECORDING, - [] (void* user_data) { MessageQueue::add - (MessageQueue::MT_ERROR, _("Encoding is too slow, dropping frames.")); - }, NULL); ogrRegGeneralCallback(OGR_CBT_WAIT_RECORDING, [] (void* user_data) { MessageQueue::add (MessageQueue::MT_GENERIC, _("Please wait while encoding is finished." )); }, NULL); + ogrRegStringCallback(OGR_CBT_ERROR_RECORDING, + [](const char* s, void* user_data) + { Log::error("openglrecorder", "%s", s); }, NULL); ogrRegStringCallback(OGR_CBT_SAVED_RECORDING, [] (const char* s, void* user_data) { MessageQueue::add (MessageQueue::MT_GENERIC, _("Video saved in \"%s\".", s)); @@ -1968,7 +1964,7 @@ void IrrDriver::update(float dt) //if(World::getWorld() && World::getWorld()->isRacePhase()) // printRenderStats(); #ifdef ENABLE_RECORDER - if (m_recording) + if (!world && m_recording) ogrCapture(); #endif } // update @@ -1982,13 +1978,11 @@ void IrrDriver::setRecording(bool val) Log::warn("irr_driver", "PBO extension missing, can't record video."); return; } - if (m_recording == val) + if (val == (ogrCapturing() == 1)) return; + m_recording = val; if (val == true) { - if (ogrCapturing() > 0) - return; - m_recording = val; std::string track_name = World::getWorld() != NULL ? race_manager->getTrackName() : "menu"; time_t rawtime; @@ -2005,7 +1999,6 @@ void IrrDriver::setRecording(bool val) } else { - m_recording = val; ogrStopCapture(); } #endif