| 1 |
/* |
| 2 |
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>. |
| 3 |
* It is copyright by its individual contributors, as recorded in the |
| 4 |
* project's Git history. See COPYING.txt at the top level for license |
| 5 |
* terms and a link to the Git history. |
| 6 |
*/ |
| 7 |
|
| 8 |
/* OpenGL Synchronization code: |
| 9 |
* either use fence sync objects or glFinish() to prevent the GPU from |
| 10 |
* lagging behind too much. |
| 11 |
*/ |
| 12 |
|
| 13 |
#pragma once |
| 14 |
|
| 15 |
#include "dxxsconf.h" |
| 16 |
|
| 17 |
#if !DXX_USE_OGL |
| 18 |
#error "This file can only be included in OpenGL enabled builds." |
| 19 |
#endif |
| 20 |
|
| 21 |
#include <memory> |
| 22 |
#include "maths.h" |
| 23 |
#include "args.h" |
| 24 |
#include "ogl_extensions.h" |
| 25 |
|
| 26 |
namespace dcx { |
| 27 |
|
| 28 |
class ogl_sync { |
| 29 |
class sync_deleter |
| 30 |
{ |
| 31 |
public: |
| 32 |
typedef GLsync pointer; |
| 33 |
void operator()(pointer p) const; |
| 34 |
}; |
| 35 |
private: |
| 36 |
SyncGLMethod method{SYNC_GL_NONE}; |
| 37 |
fix wait_timeout{0}; |
| 38 |
std::unique_ptr<GLsync, sync_deleter> fence; |
| 39 |
public: |
| 40 |
~ogl_sync(); |
| 41 |
|
| 42 |
void before_swap(); |
| 43 |
void after_swap(); |
| 44 |
void init(SyncGLMethod sync_method, int wait); |
| 45 |
void deinit(); |
| 46 |
}; |
| 47 |
|
| 48 |
} |