summaryrefslogtreecommitdiff
path: root/src/render/OpenGL.cpp
diff options
context:
space:
mode:
authorVaxry <43317083+vaxerski@users.noreply.github.com>2024-08-06 14:52:19 +0100
committerGitHub <noreply@github.com>2024-08-06 15:52:19 +0200
commit640d1618519d42dd592f7af5e9984ad52eb8b820 (patch)
treef44a5b58822eb60e7fd2dfc3e18af9bba0ab2cb0 /src/render/OpenGL.cpp
parent0e86808e5912823f1c6bea1b6d5fcae297fc9f57 (diff)
renderer: Explicit sync fixes (#7151)
Enables explicit sync by default for most platforms `misc:no_direct_scanout` -> `render:direct_scanout`
Diffstat (limited to 'src/render/OpenGL.cpp')
-rw-r--r--src/render/OpenGL.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/src/render/OpenGL.cpp b/src/render/OpenGL.cpp
index ea388df0..8875d8f4 100644
--- a/src/render/OpenGL.cpp
+++ b/src/render/OpenGL.cpp
@@ -2870,7 +2870,7 @@ SP<CEGLSync> CHyprOpenGLImpl::createEGLSync(int fenceFD) {
std::vector<EGLint> attribs;
int dupFd = -1;
if (fenceFD > 0) {
- int dupFd = fcntl(fenceFD, F_DUPFD_CLOEXEC, 0);
+ dupFd = fcntl(fenceFD, F_DUPFD_CLOEXEC, 0);
if (dupFd < 0) {
Debug::log(ERR, "createEGLSync: dup failed");
return nullptr;
@@ -2889,8 +2889,18 @@ SP<CEGLSync> CHyprOpenGLImpl::createEGLSync(int fenceFD) {
return nullptr;
}
- auto eglsync = SP<CEGLSync>(new CEGLSync);
- eglsync->sync = sync;
+ // we need to flush otherwise we might not get a valid fd
+ glFlush();
+
+ int fd = g_pHyprOpenGL->m_sProc.eglDupNativeFenceFDANDROID(g_pHyprOpenGL->m_pEglDisplay, sync);
+ if (fd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
+ Debug::log(ERR, "eglDupNativeFenceFDANDROID failed");
+ return nullptr;
+ }
+
+ auto eglsync = SP<CEGLSync>(new CEGLSync);
+ eglsync->sync = sync;
+ eglsync->m_iFd = fd;
return eglsync;
}
@@ -2983,19 +2993,13 @@ CEGLSync::~CEGLSync() {
if (g_pHyprOpenGL->m_sProc.eglDestroySyncKHR(g_pHyprOpenGL->m_pEglDisplay, sync) != EGL_TRUE)
Debug::log(ERR, "eglDestroySyncKHR failed");
-}
-int CEGLSync::dupFenceFD() {
- if (sync == EGL_NO_SYNC_KHR)
- return -1;
-
- int fd = g_pHyprOpenGL->m_sProc.eglDupNativeFenceFDANDROID(g_pHyprOpenGL->m_pEglDisplay, sync);
- if (fd == EGL_NO_NATIVE_FENCE_FD_ANDROID) {
- Debug::log(ERR, "eglDupNativeFenceFDANDROID failed");
- return -1;
- }
+ if (m_iFd >= 0)
+ close(m_iFd);
+}
- return fd;
+int CEGLSync::fd() {
+ return m_iFd;
}
bool CEGLSync::wait() {