2015-03-22 20:19:06 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the DXX-Rebirth project <http://www.dxx-rebirth.com/>.
|
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* OpenGL Synchronization code:
|
|
|
|
* either use fence sync objects or glFinish() to prevent the GPU from
|
|
|
|
* lagging behind too much.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2015-05-09 17:39:01 +00:00
|
|
|
#include <memory>
|
2015-07-25 23:10:45 +00:00
|
|
|
#include "maths.h"
|
2015-03-22 20:19:06 +00:00
|
|
|
#include "args.h"
|
|
|
|
#include "ogl_extensions.h"
|
|
|
|
|
|
|
|
class ogl_sync {
|
2015-05-09 17:39:01 +00:00
|
|
|
class sync_deleter
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef GLsync pointer;
|
|
|
|
void operator()(pointer p) const;
|
|
|
|
};
|
2015-03-22 20:19:06 +00:00
|
|
|
private:
|
|
|
|
SyncGLMethod method;
|
|
|
|
fix wait_timeout;
|
2015-05-09 17:39:01 +00:00
|
|
|
std::unique_ptr<GLsync, sync_deleter> fence;
|
2015-03-22 20:19:06 +00:00
|
|
|
public:
|
|
|
|
ogl_sync();
|
|
|
|
~ogl_sync();
|
|
|
|
|
|
|
|
void before_swap();
|
|
|
|
void after_swap();
|
|
|
|
void init(SyncGLMethod sync_method, int wait);
|
|
|
|
void deinit();
|
|
|
|
};
|