1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
#ifndef VSYNCTHREAD_H
#define VSYNCTHREAD_H
#include <QTime>
#include <QThread>
#include <QSemaphore>
#include <QPair>
#include <QGLWidget>
#if defined(__APPLE__)
#elif defined(__WINDOWS__)
#else
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#ifndef QT_OPENGL_ES_2
#include <qx11info_x11.h>
#include <GL/glx.h>
//#include "GL/glxext.h"
// clean up after Xlib.h, which #defines values that conflict with QT.
#undef Bool
#undef Unsorted
#endif // QT_OPENGL_ES_2
#endif // QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
#endif
#include "util/performancetimer.h"
class GuiTick;
class MixxxMainWindow;
class VSyncThread : public QThread {
Q_OBJECT
public:
enum VSyncMode {
ST_TIMER = 0,
ST_MESA_VBLANK_MODE_1,
ST_SGI_VIDEO_SYNC,
ST_OML_SYNC_CONTROL,
ST_FREE,
ST_COUNT // Dummy Type at last, counting possible types
};
static void swapGl(QGLWidget* glw, int index);
VSyncThread(MixxxMainWindow* mixxMainWindow);
~VSyncThread();
void run();
void stop();
bool waitForVideoSync(QGLWidget* glw);
int elapsed();
int usToNextSync();
void setUsSyncIntervalTime(int usSyncTimer);
void setVSyncType(int mode);
int droppedFrames();
void setSwapWait(int sw);
int usFromTimerToNextSync(PerformanceTimer* timer);
void vsyncSlotFinished();
void getAvailableVSyncTypes(QList<QPair<int, QString > >* list);
void setupSync(QGLWidget* glw, int index);
void waitUntilSwap(QGLWidget* glw);
signals:
void vsyncRender();
void vsyncSwap();
private:
bool m_bDoRendering;
//QGLWidget *m_glw;
#if defined(__APPLE__)
#elif defined(__WINDOWS__)
#else
void initGlxext(QGLWidget* glw);
bool glXExtensionSupported(Display *dpy, int screen, const char *extension);
/* Currently unused, but probably part of later a hardware sync solution
PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI;
PFNGLXWAITVIDEOSYNCSGIPROC glXWaitVideoSyncSGI;
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI;
PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT;
PFNGLXGETSYNCVALUESOMLPROC glXGetSyncValuesOML;
PFNGLXGETMSCRATEOMLPROC glXGetMscRateOML;
PFNGLXSWAPBUFFERSMSCOMLPROC glXSwapBuffersMscOML;
PFNGLXWAITFORMSCOMLPROC glXWaitForMscOML;
PFNGLXWAITFORSBCOMLPROC glXWaitForSbcOML;
PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalMESA;
*/
//int64_t m_target_msc;
//Display* m_dpy;
//GLXDrawable m_drawable;
#endif
bool m_vSyncTypeChanged;
int m_usSyncIntervalTime;
int m_usWaitToSwap;
enum VSyncMode m_vSyncMode;
bool m_syncOk;
int m_droppedFrames;
int m_swapWait;
PerformanceTimer m_timer;
QSemaphore m_semaVsyncSlot;
double m_displayFrameRate;
int m_vSyncPerRendering;
GuiTick* m_pGuiTick;
};
#endif // VSYNCTHREAD_H
|