summaryrefslogtreecommitdiffstats
path: root/xbmc/utils/EGLFence.cpp
diff options
context:
space:
mode:
authormanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
committermanuel <manuel@mausz.at>2020-10-19 00:52:24 +0200
commitbe933ef2241d79558f91796cc5b3a161f72ebf9c (patch)
treefe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /xbmc/utils/EGLFence.cpp
parent5f8335c1e49ce108ef3481863833c98efa00411b (diff)
downloadkodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2
kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip
sync with upstream
Diffstat (limited to 'xbmc/utils/EGLFence.cpp')
-rw-r--r--xbmc/utils/EGLFence.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/xbmc/utils/EGLFence.cpp b/xbmc/utils/EGLFence.cpp
new file mode 100644
index 0000000..369c40a
--- /dev/null
+++ b/xbmc/utils/EGLFence.cpp
@@ -0,0 +1,70 @@
1/*
2 * Copyright (C) 2017-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9#include "EGLFence.h"
10
11#include "EGLUtils.h"
12#include "utils/log.h"
13
14using namespace KODI::UTILS::EGL;
15
16CEGLFence::CEGLFence(EGLDisplay display) :
17 m_display(display)
18{
19 m_eglCreateSyncKHR = CEGLUtils::GetRequiredProcAddress<PFNEGLCREATESYNCKHRPROC>("eglCreateSyncKHR");
20 m_eglDestroySyncKHR = CEGLUtils::GetRequiredProcAddress<PFNEGLDESTROYSYNCKHRPROC>("eglDestroySyncKHR");
21 m_eglGetSyncAttribKHR = CEGLUtils::GetRequiredProcAddress<PFNEGLGETSYNCATTRIBKHRPROC>("eglGetSyncAttribKHR");
22}
23
24void CEGLFence::CreateFence()
25{
26 m_fence = m_eglCreateSyncKHR(m_display, EGL_SYNC_FENCE_KHR, nullptr);
27 if (m_fence == EGL_NO_SYNC_KHR)
28 {
29 CEGLUtils::Log(LOGERROR, "failed to create egl sync fence");
30 throw std::runtime_error("failed to create egl sync fence");
31 }
32}
33
34void CEGLFence::DestroyFence()
35{
36 if (m_fence == EGL_NO_SYNC_KHR)
37 {
38 return;
39 }
40
41 if (m_eglDestroySyncKHR(m_display, m_fence) != EGL_TRUE)
42 {
43 CEGLUtils::Log(LOGERROR, "failed to destroy egl sync fence");
44 }
45
46 m_fence = EGL_NO_SYNC_KHR;
47}
48
49bool CEGLFence::IsSignaled()
50{
51 // fence has been destroyed so return true immediately so buffer can be used
52 if (m_fence == EGL_NO_SYNC_KHR)
53 {
54 return true;
55 }
56
57 EGLint status = EGL_UNSIGNALED_KHR;
58 if (m_eglGetSyncAttribKHR(m_display, m_fence, EGL_SYNC_STATUS_KHR, &status) != EGL_TRUE)
59 {
60 CEGLUtils::Log(LOGERROR, "failed to query egl sync fence");
61 return false;
62 }
63
64 if (status == EGL_SIGNALED_KHR)
65 {
66 return true;
67 }
68
69 return false;
70}