diff options
author | Jesse Hall <jessehall@google.com> | 2012-05-21 11:23:57 -0700 |
---|---|---|
committer | Jesse Hall <jessehall@google.com> | 2012-05-30 14:56:21 -0700 |
commit | 29292ac6d0e59728ea7fae577c145a9b6dddce16 (patch) | |
tree | 3ba958f70c5e51949f12e73c9449868cb7743b40 /emulator | |
parent | 266f4b90e0aaafb7cbba969c093a8f58c2653fa8 (diff) | |
download | sdk-29292ac6d0e59728ea7fae577c145a9b6dddce16.zip sdk-29292ac6d0e59728ea7fae577c145a9b6dddce16.tar.gz sdk-29292ac6d0e59728ea7fae577c145a9b6dddce16.tar.bz2 |
Implement the EGL_KHR_fence_sync extension
Bug: 6515813
Change-Id: I738fc2663d81876dc75ad560fd08506b423a21bf
Diffstat (limited to 'emulator')
-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} }; |