aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Hall <jessehall@google.com>2012-05-30 21:12:52 -0700
committerandroid code review <noreply-gerritcodereview@google.com>2012-05-30 21:12:53 -0700
commit35d3406603038ab3e34a4fdb237730a87b478520 (patch)
tree8c9e95dc40fce08ea52f1acd48540ecd1b6fcf17
parent7578d4af99c266f36ed961d91bc2cd5b69c8c4ed (diff)
parent29292ac6d0e59728ea7fae577c145a9b6dddce16 (diff)
downloadsdk-35d3406603038ab3e34a4fdb237730a87b478520.zip
sdk-35d3406603038ab3e34a4fdb237730a87b478520.tar.gz
sdk-35d3406603038ab3e34a4fdb237730a87b478520.tar.bz2
Merge "Implement the EGL_KHR_fence_sync extension"
-rw-r--r--emulator/opengl/system/egl/egl.cpp75
-rw-r--r--emulator/opengl/system/egl/eglDisplay.cpp3
-rw-r--r--emulator/opengl/system/egl/egl_ftable.h1
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}
};