diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-09-13 13:24:19 -0700 |
---|---|---|
committer | Teng-Hui Zhu <ztenghui@google.com> | 2011-09-13 14:05:29 -0700 |
commit | 4b648c3e437f1b1fd983af4f6e8d232e59e2985c (patch) | |
tree | c8fcd76e080719fe68cc2d550e9ddb607c1fe91d /Source/WebCore/platform/graphics/android/TransferQueue.cpp | |
parent | 9be67d65f88609c74e3093bb47dc0fe2f2b5e894 (diff) | |
download | external_webkit-4b648c3e437f1b1fd983af4f6e8d232e59e2985c.zip external_webkit-4b648c3e437f1b1fd983af4f6e8d232e59e2985c.tar.gz external_webkit-4b648c3e437f1b1fd983af4f6e8d232e59e2985c.tar.bz2 |
A better WAR of driver issue by using GPU fence
bug:5270526
Change-Id: I790a3fc995edc73192b2bcb24eaa29e99434f2fb
Diffstat (limited to 'Source/WebCore/platform/graphics/android/TransferQueue.cpp')
-rw-r--r-- | Source/WebCore/platform/graphics/android/TransferQueue.cpp | 40 |
1 files changed, 28 insertions, 12 deletions
diff --git a/Source/WebCore/platform/graphics/android/TransferQueue.cpp b/Source/WebCore/platform/graphics/android/TransferQueue.cpp index 50502f6..df9aede 100644 --- a/Source/WebCore/platform/graphics/android/TransferQueue.cpp +++ b/Source/WebCore/platform/graphics/android/TransferQueue.cpp @@ -34,9 +34,11 @@ #include <gui/SurfaceTexture.h> #include <gui/SurfaceTextureClient.h> -#ifdef DEBUG #include <cutils/log.h> #include <wtf/text/CString.h> +#define XLOGC(...) android_printLog(ANDROID_LOG_DEBUG, "TransferQueue", __VA_ARGS__) + +#ifdef DEBUG #undef XLOG #define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "TransferQueue", __VA_ARGS__) @@ -64,10 +66,6 @@ TransferQueue::TransferQueue() m_emptyItemCount = ST_BUFFER_NUMBER; m_transferQueue = new TileTransferData[ST_BUFFER_NUMBER]; - for (int i = 0; i < ST_BUFFER_NUMBER; i++) { - m_transferQueue[i].savedBaseTilePtr = 0; - m_transferQueue[i].status = emptyItem; - } } TransferQueue::~TransferQueue() @@ -132,7 +130,9 @@ bool TransferQueue::checkObsolete(int index) return false; } -void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, GLuint srcTexId, GLenum srcTexTarget) +void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, + GLuint srcTexId, GLenum srcTexTarget, + int index) { // guarantee that we have a texture to blit into destTex->requireTexture(); @@ -158,14 +158,23 @@ void TransferQueue::blitTileFromQueue(GLuint fboID, BaseTileTexture* destTex, GL TilesManager::instance()->shader()->drawQuad(rect, srcTexId, 1.0, srcTexTarget); + // To workaround a sync issue on some platforms, we should insert the sync + // here while in the current FBO. + // This will essentially kick off the GPU command buffer, and the Tex Gen + // thread will then have to wait for this buffer to finish before writing + // into the same memory. + EGLDisplay dpy = eglGetCurrentDisplay(); + if (m_transferQueue[index].m_syncKHR != EGL_NO_SYNC_KHR) + eglDestroySyncKHR(dpy, m_transferQueue[index].m_syncKHR); + m_transferQueue[index].m_syncKHR = eglCreateSyncKHR(eglGetCurrentDisplay(), + EGL_SYNC_FENCE_KHR, + 0); + if (m_transferQueue[index].m_syncKHR == EGL_NO_SYNC_KHR) + XLOGC("ERROR: eglClientWaitSyncKHR return error"); + // Clean up FBO setup. glBindFramebuffer(GL_FRAMEBUFFER, 0); // rebind the standard FBO - // Add a sync point here to WAR a driver bug. - glViewport(0, 0, 0, 0); - TilesManager::instance()->shader()->drawQuad(rect, destTex->m_ownTextureId, - 1.0, GL_TEXTURE_2D); - GLUtils::checkGlError("copy the surface texture into the normal one"); } @@ -198,6 +207,12 @@ bool TransferQueue::readyForUpdate() if (!getHasGLContext()) return false; + // Check the GPU fence + eglClientWaitSyncKHR(eglGetCurrentDisplay(), + m_transferQueue[getNextTransferQueueIndex()].m_syncKHR, + EGL_SYNC_FLUSH_COMMANDS_BIT_KHR, + EGL_FOREVER_KHR); + return true; } @@ -270,7 +285,8 @@ void TransferQueue::updateDirtyBaseTiles() #else blitTileFromQueue(m_fboID, destTexture, m_sharedSurfaceTextureId, - m_sharedSurfaceTexture->getCurrentTextureTarget()); + m_sharedSurfaceTexture->getCurrentTextureTarget(), + index); #endif // After the base tile copied into the GL texture, we need to |