diff options
author | Jesse Hall <jessehall@google.com> | 2012-05-21 11:23:57 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-05-31 12:22:14 -0700 |
commit | 212ffd9f6f9685cfa2d6d4556b6ab545b34237a3 (patch) | |
tree | cd37c0297ea193a3c9595b68e87ef6812a5bd9ff | |
parent | 9cf3be76e1a4a478fab213919bd102949ac13649 (diff) | |
download | sdk-212ffd9f6f9685cfa2d6d4556b6ab545b34237a3.zip sdk-212ffd9f6f9685cfa2d6d4556b6ab545b34237a3.tar.gz sdk-212ffd9f6f9685cfa2d6d4556b6ab545b34237a3.tar.bz2 |
DO NOT MERGE Implement the EGL_KHR_fence_sync extension
Cherry-pick from aosp-master into jb-dev.
Bug: 6515813
Change-Id: I78f1bd115044aa9dcc534db855eaed24eb92ecee
-rw-r--r-- | emulator/opengl/system/egl/egl.cpp | 75 | ||||
-rw-r--r-- | emulator/opengl/system/egl/eglDisplay.cpp | 3 | ||||
-rw-r--r-- | emulator/opengl/system/egl/egl_ftable.h | 1 |
3 files changed, 61 insertions, 18 deletions
diff --git a/emulator/opengl/system/egl/egl.cpp b/emulator/opengl/system/egl/egl.cpp index 5aa5bda..ee195ac 100644 --- a/emulator/opengl/system/egl/egl.cpp +++ b/emulator/opengl/system/egl/egl.cpp @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + #include "HostConnection.h" #include "ThreadInfo.h" #include "eglDisplay.h" @@ -1180,32 +1181,74 @@ EGLBoolean eglDestroyImageKHR(EGLDisplay dpy, EGLImageKHR img) return EGL_TRUE; } -EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, const EGLint *attrib_list) +#define FENCE_SYNC_HANDLE (EGLSyncKHR)0xFE4CE + +EGLSyncKHR eglCreateSyncKHR(EGLDisplay dpy, EGLenum type, + const EGLint *attrib_list) { - //TODO later - return 0; + // TODO: This implementation could be faster. We should require the host EGL + // to support KHR_fence_sync, or at least pipe the fence command to the host + // and wait for it (probably involving a glFinish on the host) in + // eglClientWaitSyncKHR. + + VALIDATE_DISPLAY(dpy, EGL_NO_SYNC_KHR); + + if (type != EGL_SYNC_FENCE_KHR || + (attrib_list != NULL && attrib_list[0] != EGL_NONE)) { + setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_NO_SYNC_KHR); + } + + EGLThreadInfo *tInfo = getEGLThreadInfo(); + if (!tInfo || !tInfo->currentContext) { + setErrorReturn(EGL_BAD_MATCH, EGL_NO_SYNC_KHR); + } + + if (tInfo->currentContext->version == 2) { + s_display.gles2_iface()->finish(); + } else { + s_display.gles_iface()->finish(); + } + + return FENCE_SYNC_HANDLE; } EGLBoolean eglDestroySyncKHR(EGLDisplay dpy, EGLSyncKHR sync) { - //TODO later - return 0; -} + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } -EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, EGLTimeKHR timeout) -{ - //TODO - return 0; + return EGL_TRUE; } -EGLBoolean eglSignalSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLenum mode) +EGLint eglClientWaitSyncKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint flags, + EGLTimeKHR timeout) { - //TODO later - return 0; + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + return EGL_CONDITION_SATISFIED_KHR; } -EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, EGLint attribute, EGLint *value) +EGLBoolean eglGetSyncAttribKHR(EGLDisplay dpy, EGLSyncKHR sync, + EGLint attribute, EGLint *value) { - //TODO later - return 0; + if (sync != FENCE_SYNC_HANDLE) { + setErrorReturn(EGL_BAD_PARAMETER, EGL_FALSE); + } + + switch (attribute) { + case EGL_SYNC_TYPE_KHR: + *value = EGL_SYNC_FENCE_KHR; + return EGL_TRUE; + case EGL_SYNC_STATUS_KHR: + *value = EGL_SIGNALED_KHR; + return EGL_TRUE; + case EGL_SYNC_CONDITION_KHR: + *value = EGL_SYNC_PRIOR_COMMANDS_COMPLETE_KHR; + return EGL_TRUE; + default: + setErrorReturn(EGL_BAD_ATTRIBUTE, EGL_FALSE); + } } diff --git a/emulator/opengl/system/egl/eglDisplay.cpp b/emulator/opengl/system/egl/eglDisplay.cpp index 2497548..bcb0d4b 100644 --- a/emulator/opengl/system/egl/eglDisplay.cpp +++ b/emulator/opengl/system/egl/eglDisplay.cpp @@ -24,7 +24,8 @@ static const char systemEGLVendor[] = "Google Android emulator"; // list of extensions supported by this EGL implementation // NOTE that each extension name should be suffixed with space static const char systemStaticEGLExtensions[] = - "EGL_ANDROID_image_native_buffer "; + "EGL_ANDROID_image_native_buffer " + "EGL_KHR_fence_sync "; // list of extensions supported by this EGL implementation only if supported // on the host implementation. diff --git a/emulator/opengl/system/egl/egl_ftable.h b/emulator/opengl/system/egl/egl_ftable.h index b21da72..16d130c 100644 --- a/emulator/opengl/system/egl/egl_ftable.h +++ b/emulator/opengl/system/egl/egl_ftable.h @@ -58,7 +58,6 @@ static const struct _egl_funcs_by_name { {"eglCreateSyncKHR", (void *)eglCreateSyncKHR}, {"eglDestroySyncKHR", (void *)eglDestroySyncKHR}, {"eglClientWaitSyncKHR", (void *)eglClientWaitSyncKHR}, - {"eglSignalSyncKHR", (void *)eglSignalSyncKHR}, {"eglGetSyncAttribKHR", (void *)eglGetSyncAttribKHR} }; |