From cf8decc13849ddb1a0fcc890ff5870b4fc835519 Mon Sep 17 00:00:00 2001 From: Rahul Singhal Date: Mon, 25 Jun 2012 15:20:26 +0530 Subject: [PATCH] TextureBinders: Remove redundant texture uploads on every texture bind EGLImages can be created once and reused so we don't need to specify & upload them every time we use them. --- .../Graphic/src/TextureBinders/WaylandGLESTexture.cpp | 13 +++++++------ .../Renderers/Graphic/src/TextureBinders/X11EglImage.cpp | 16 +++++++--------- .../src/WindowSystems/WaylandBaseWindowSystem.cpp | 6 ++++++ .../Graphic/src/WindowSystems/X11WindowSystem.cpp | 6 ++++++ 4 files changed, 26 insertions(+), 15 deletions(-) diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp index 2950c2c..7ce7efc 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/WaylandGLESTexture.cpp @@ -92,11 +92,6 @@ bool WaylandGLESTexture::bindSurfaceTexture(Surface* surface) { LOG_DEBUG("WaylandGLESTexture", "nativeSurface->eglImage:"<eglImage); glBindTexture(GL_TEXTURE_2D, nativeSurface->texture); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage); return true; } } @@ -162,7 +157,13 @@ void WaylandGLESTexture::createClientBuffer(Surface* surface) { nativeSurface->eglImage = eglImage; glGenTextures(1,&nativeSurface->texture); - } + glBindTexture(GL_TEXTURE_2D, nativeSurface->texture); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage); + } } } } diff --git a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11EglImage.cpp b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11EglImage.cpp index 7e08adc..8ed04d7 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11EglImage.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/TextureBinders/X11EglImage.cpp @@ -48,15 +48,7 @@ bool X11EglImage::bindSurfaceTexture(Surface* surface) if (nativeSurface && nativeSurface->isReadyForRendering()) { glBindTexture(GL_TEXTURE_2D, nativeSurface->texture); - if (nativeSurface->eglImage) - { - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage); - return true; - } + return true; } return false; } @@ -104,6 +96,12 @@ void X11EglImage::createClientBuffer(Surface* surface) { nativeSurface->eglImage = eglImage; glGenTextures(1,&nativeSurface->texture); + glBindTexture(GL_TEXTURE_2D, nativeSurface->texture); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + m_pfGLEglImageTargetTexture2DOES(GL_TEXTURE_2D, nativeSurface->eglImage); } } } diff --git a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp index 16d1c76..aa31f48 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/WaylandBaseWindowSystem.cpp @@ -511,7 +511,9 @@ void WaylandBaseWindowSystem::destroySurfaceCallback(struct wl_resource* resourc delete ilmSurface->platform; ilmSurface->platform = NULL; } + windowSystem->graphicSystem->activateGraphicContext(); windowSystem->graphicSystem->getTextureBinder()->destroyClientBuffer(ilmSurface); + windowSystem->graphicSystem->releaseGraphicContext(); } wl_list_remove(&nativeSurface->link); @@ -566,7 +568,9 @@ void WaylandBaseWindowSystem::attachBufferToNativeSurface(struct wl_buffer* buff WaylandPlatformSurface* nativePlatformSurface = (WaylandPlatformSurface*)ilmSurface->platform; if (0 != nativePlatformSurface) { + windowSystem->graphicSystem->activateGraphicContext(); windowSystem->graphicSystem->getTextureBinder()->createClientBuffer(ilmSurface); + windowSystem->graphicSystem->releaseGraphicContext(); LOG_DEBUG("WaylandBaseWindowSystem","nativePlatformSurface->enable"); nativePlatformSurface->enableRendering(); } @@ -1174,7 +1178,9 @@ void WaylandBaseWindowSystem::deallocatePlatformSurface(Surface* surface) { LOG_DEBUG("WaylandBaseWindowSystem","destroyingnative surface"); #if 0 // TODO + graphicSystem->activateGraphicContext(); graphicSystem->getTextureBinder()->destroyClientBuffer(surface); + graphicSystem->releaseGraphicContext(); surface->renderPropertyChanged = true; delete surface->platform; diff --git a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp index f50eac4..61382d9 100644 --- a/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp +++ b/LayerManagerPlugins/Renderers/Graphic/src/WindowSystems/X11WindowSystem.cpp @@ -331,7 +331,9 @@ void X11WindowSystem::MapWindow(Window window) surface->OriginalSourceWidth = winWidth; surface->renderPropertyChanged = true; + graphicSystem->activateGraphicContext(); graphicSystem->getTextureBinder()->createClientBuffer(surface); + graphicSystem->releaseGraphicContext(); XSync(x11Display, 0); LOG_DEBUG("X11WindowSystem", "Mapping Surface " << surface->getID() << " to window " << window); @@ -369,7 +371,9 @@ void X11WindowSystem::UnMapWindow(Window window) LOG_DEBUG("X11WindowSystem", "Destroying ClientBuffer"); + graphicSystem->activateGraphicContext(); graphicSystem->getTextureBinder()->destroyClientBuffer(surface); + graphicSystem->releaseGraphicContext(); XSync(x11Display, 0); LOG_DEBUG("X11WindowSystem", "Removing X Pixmap"); @@ -457,7 +461,9 @@ void X11WindowSystem::DestroyWindow(Window window) LOG_WARNING("X11WindowSystem", "Could not find surface for window " << window); return; } + graphicSystem->activateGraphicContext(); graphicSystem->getTextureBinder()->destroyClientBuffer(surface); + graphicSystem->releaseGraphicContext(); LOG_DEBUG("X11WindowSystem", "Unmapping window " << window); UnMapWindow(window); LOG_DEBUG("X11WindowSystem", "Remove Native Content from Surface " << surface->getID()); -- 2.7.4