Alex Vakulenko | e4eec20 | 2017-01-27 14:41:04 -0800 | [diff] [blame^] | 1 | #include "include/private/dvr/gl_fenced_flush.h" |
| 2 | |
| 3 | #include <EGL/eglext.h> |
| 4 | #include <GLES3/gl31.h> |
| 5 | |
| 6 | #define ATRACE_TAG ATRACE_TAG_GRAPHICS |
| 7 | #include <utils/Trace.h> |
| 8 | |
| 9 | #include <base/logging.h> |
| 10 | |
| 11 | using android::pdx::LocalHandle; |
| 12 | |
| 13 | namespace android { |
| 14 | namespace dvr { |
| 15 | |
| 16 | LocalHandle CreateGLSyncAndFlush(EGLDisplay display) { |
| 17 | ATRACE_NAME("CreateGLSyncAndFlush"); |
| 18 | |
| 19 | EGLint attribs[] = {EGL_SYNC_NATIVE_FENCE_FD_ANDROID, |
| 20 | EGL_NO_NATIVE_FENCE_FD_ANDROID, EGL_NONE}; |
| 21 | EGLSyncKHR sync_point = |
| 22 | eglCreateSyncKHR(display, EGL_SYNC_NATIVE_FENCE_ANDROID, attribs); |
| 23 | glFlush(); |
| 24 | if (sync_point == EGL_NO_SYNC_KHR) { |
| 25 | LOG(ERROR) << "sync_point == EGL_NO_SYNC_KHR"; |
| 26 | return LocalHandle(); |
| 27 | } |
| 28 | EGLint fence_fd = eglDupNativeFenceFDANDROID(display, sync_point); |
| 29 | eglDestroySyncKHR(display, sync_point); |
| 30 | |
| 31 | if (fence_fd == EGL_NO_NATIVE_FENCE_FD_ANDROID) { |
| 32 | LOG(ERROR) << "fence_fd == EGL_NO_NATIVE_FENCE_FD_ANDROID"; |
| 33 | return LocalHandle(); |
| 34 | } |
| 35 | return LocalHandle(fence_fd); |
| 36 | } |
| 37 | |
| 38 | } // namespace dvr |
| 39 | } // namespace android |