Move capture right before glfencesync if possible

This commit is contained in:
Benau 2017-04-13 13:59:36 +08:00
parent fe0fe828a0
commit 4de0ca83aa
3 changed files with 23 additions and 16 deletions

View File

@ -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()

View File

@ -34,6 +34,9 @@
#include "utils/profiler.hpp"
#include <numeric>
#ifdef ENABLE_RECORDER
#include <openglrecorder.h>
#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);

View File

@ -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