Title: [102055] trunk/Source
Revision
102055
Author
[email protected]
Date
2011-12-05 15:43:15 -0800 (Mon, 05 Dec 2011)

Log Message

Source/WebCore: [chromium] Use ANGLE's texture_usage and texture_storage extensions when allocating compositor textures
https://bugs.webkit.org/show_bug.cgi?id=73621

When the extensions are available, compositor textures are allocated via
glTexStorage2DEXT instead of glTexImage2D to eliminate creation of unnecessary
mip levels on the service side. In addition, the GL_FRAMEBUFFER_ATTACHMENT_ANGLE
is specified for all textures used by RenderSurfaces to eliminate the need for
a system memory bitmap allocation.

Reviewed by Kenneth Russell.

* platform/graphics/chromium/Extensions3DChromium.h:
* platform/graphics/chromium/LayerRendererChromium.cpp:
(WebCore::LayerRendererChromium::initialize):
(WebCore::LayerRendererChromium::initializeSharedObjects):
* platform/graphics/chromium/TrackingTextureAllocator.cpp:
(WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
(WebCore::textureToStorageFormat):
(WebCore::isTextureFormatSupportedForStorage):
(WebCore::TrackingTextureAllocator::createTexture):
* platform/graphics/chromium/TrackingTextureAllocator.h:
(WebCore::TrackingTextureAllocator::setTextureUsageHint):
(WebCore::TrackingTextureAllocator::setUseTextureStorageExt):
* platform/graphics/chromium/cc/CCLayerTreeHost.h:
(WebCore::LayerRendererCapabilities::LayerRendererCapabilities):

Source/WebKit/chromium: Use ANGLE's texture_usage and texture_storage extensions when allocating compositor textures.
https://bugs.webkit.org/show_bug.cgi?id=73621

Add the necessary entry points and enums to GraphicsContext3D.

Reviewed by Kenneth Russell.

* public/platform/WebGraphicsContext3D.h:
* src/Extensions3DChromium.cpp:
(WebCore::Extensions3DChromium::texStorage2DEXT):
* src/GraphicsContext3DChromium.cpp:
* src/GraphicsContext3DPrivate.h:
* tests/MockWebGraphicsContext3D.h:
(WebKit::MockWebGraphicsContext3D::texStorage2DEXT):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (102054 => 102055)


--- trunk/Source/WebCore/ChangeLog	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/ChangeLog	2011-12-05 23:43:15 UTC (rev 102055)
@@ -1,3 +1,31 @@
+2011-12-01  Vangelis Kokkevis  <[email protected]>
+
+        [chromium] Use ANGLE's texture_usage and texture_storage extensions when allocating compositor textures
+        https://bugs.webkit.org/show_bug.cgi?id=73621
+
+        When the extensions are available, compositor textures are allocated via
+        glTexStorage2DEXT instead of glTexImage2D to eliminate creation of unnecessary
+        mip levels on the service side. In addition, the GL_FRAMEBUFFER_ATTACHMENT_ANGLE
+        is specified for all textures used by RenderSurfaces to eliminate the need for
+        a system memory bitmap allocation.
+
+        Reviewed by Kenneth Russell.
+
+        * platform/graphics/chromium/Extensions3DChromium.h:
+        * platform/graphics/chromium/LayerRendererChromium.cpp:
+        (WebCore::LayerRendererChromium::initialize):
+        (WebCore::LayerRendererChromium::initializeSharedObjects):
+        * platform/graphics/chromium/TrackingTextureAllocator.cpp:
+        (WebCore::TrackingTextureAllocator::TrackingTextureAllocator):
+        (WebCore::textureToStorageFormat):
+        (WebCore::isTextureFormatSupportedForStorage):
+        (WebCore::TrackingTextureAllocator::createTexture):
+        * platform/graphics/chromium/TrackingTextureAllocator.h:
+        (WebCore::TrackingTextureAllocator::setTextureUsageHint):
+        (WebCore::TrackingTextureAllocator::setUseTextureStorageExt):
+        * platform/graphics/chromium/cc/CCLayerTreeHost.h:
+        (WebCore::LayerRendererCapabilities::LayerRendererCapabilities):
+
 2011-12-05  Chris Fleizach  <[email protected]>
 
         AX: aria-hidden doesn't work on iframe elements

Modified: trunk/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h (102054 => 102055)


--- trunk/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -46,6 +46,8 @@
     //   GL_CHROMIUM_rate_limit_offscreen_context
     //   GL_CHROMIUM_paint_framebuffer_canvas
     //   GL_CHROMIUM_iosurface (Mac OS X specific)
+    //   GL_ANGLE_texture_usage
+    //   GL_EXT_texture_storage
 
     // Extensions3D methods.
     virtual bool supports(const String&);
@@ -63,7 +65,14 @@
     enum {
         // GL_CHROMIUM_map_sub (enums inherited from GL_ARB_vertex_buffer_object)
         READ_ONLY = 0x88B8,
-        WRITE_ONLY = 0x88B9
+        WRITE_ONLY = 0x88B9,
+
+        // GL_ANGLE_texture_usage
+        GL_TEXTURE_USAGE_ANGLE = 0x93A2,
+        GL_FRAMEBUFFER_ATTACHMENT_ANGLE = 0x93A3,
+
+        // GL_EXT_texture_storage
+        BGRA8_EXT = 0x93A1
     };
 
     // GL_CHROMIUM_post_sub_buffer
@@ -97,6 +106,9 @@
     // RGBA, format BGRA, and type UNSIGNED_INT_8_8_8_8_REV.
     void texImageIOSurface2DCHROMIUM(unsigned target, int width, int height, uint32_t ioSurfaceId, unsigned plane);
 
+    // GL_EXT_texture_storage
+    void texStorage2DEXT(unsigned target, int levels, unsigned internalformat, int width, int height);
+
 private:
     // Instances of this class are strictly owned by the GraphicsContext3D implementation and do not
     // need to be instantiated by any other code.

Modified: trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp (102054 => 102055)


--- trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp	2011-12-05 23:43:15 UTC (rev 102055)
@@ -240,6 +240,14 @@
         extensions->ensureEnabled("GL_CHROMIUM_iosurface");
     }
 
+    m_capabilities.usingTextureUsageHint = extensions->supports("GL_ANGLE_texture_usage");
+    if (m_capabilities.usingTextureUsageHint)
+        extensions->ensureEnabled("GL_ANGLE_texture_usage");
+
+    m_capabilities.usingTextureStorageExtension = extensions->supports("GL_EXT_texture_storage");
+    if (m_capabilities.usingTextureStorageExtension)
+        extensions->ensureEnabled("GL_EXT_texture_storage");
+
     GLC(m_context.get(), m_context->getIntegerv(GraphicsContext3D::MAX_TEXTURE_SIZE, &m_capabilities.maxTextureSize));
     m_capabilities.bestTextureFormat = PlatformColor::bestTextureFormat(m_context.get());
 
@@ -740,6 +748,13 @@
     m_renderSurfaceTextureManager = TextureManager::create(TextureManager::highLimitBytes(), m_capabilities.maxTextureSize);
     m_contentsTextureAllocator = TrackingTextureAllocator::create(m_context.get());
     m_renderSurfaceTextureAllocator = TrackingTextureAllocator::create(m_context.get());
+    if (m_capabilities.usingTextureUsageHint)
+        m_renderSurfaceTextureAllocator->setTextureUsageHint(TrackingTextureAllocator::FramebufferAttachment);
+    if (m_capabilities.usingTextureStorageExtension) {
+        m_contentsTextureAllocator->setUseTextureStorageExt(true);
+        m_renderSurfaceTextureAllocator->setUseTextureStorageExt(true);
+    }
+
     return true;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp (102054 => 102055)


--- trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.cpp	2011-12-05 23:43:15 UTC (rev 102055)
@@ -26,6 +26,7 @@
 
 #include "TrackingTextureAllocator.h"
 
+#include "Extensions3DChromium.h"
 #include "IntRect.h"
 #include "LayerRendererChromium.h" // For the GLC() macro
 
@@ -34,6 +35,8 @@
 TrackingTextureAllocator::TrackingTextureAllocator(PassRefPtr<GraphicsContext3D> context)
     : m_context(context)
     , m_currentMemoryUseBytes(0)
+    , m_textureUsageHint(Any)
+    , m_useTextureStorageExt(false)
 {
 }
 
@@ -42,6 +45,28 @@
     ASSERT(!m_currentMemoryUseBytes);
 }
 
+static GC3Denum textureToStorageFormat(GC3Denum textureFormat)
+{
+    GC3Denum storageFormat = Extensions3D::RGBA8_OES;
+    switch (textureFormat) {
+    case GraphicsContext3D::RGBA:
+        break;
+    case Extensions3D::BGRA_EXT:
+        storageFormat = Extensions3DChromium::BGRA8_EXT;
+        break;
+    default:
+        ASSERT_NOT_REACHED();
+        break;
+    }
+
+    return storageFormat;
+}
+
+static bool isTextureFormatSupportedForStorage(GC3Denum format)
+{
+    return (format == GraphicsContext3D::RGBA || format == Extensions3D::BGRA_EXT);
+}
+
 unsigned TrackingTextureAllocator::createTexture(const IntSize& size, GC3Denum format)
 {
     m_currentMemoryUseBytes += TextureManager::memoryUseBytes(size, format);
@@ -55,7 +80,15 @@
     // NPOT textures in GL ES only work when the wrap mode is set to GraphicsContext3D::CLAMP_TO_EDGE.
     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE));
     GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE));
-    GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE));
+
+    if (m_textureUsageHint == FramebufferAttachment)
+        GLC(m_context.get(), m_context->texParameteri(GraphicsContext3D::TEXTURE_2D, Extensions3DChromium::GL_TEXTURE_USAGE_ANGLE, Extensions3DChromium::GL_FRAMEBUFFER_ATTACHMENT_ANGLE));
+    if (m_useTextureStorageExt && isTextureFormatSupportedForStorage(format)) {
+        Extensions3DChromium* extensions = static_cast<Extensions3DChromium*>(m_context->getExtensions());
+        GC3Denum storageFormat = textureToStorageFormat(format);
+        extensions->texStorage2DEXT(GraphicsContext3D::TEXTURE_2D, 1, storageFormat, size.width(), size.height());
+    } else
+        GLC(m_context.get(), m_context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, format, size.width(), size.height(), 0, format, GraphicsContext3D::UNSIGNED_BYTE));
     return textureId;
 }
 

Modified: trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h (102054 => 102055)


--- trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/platform/graphics/chromium/TrackingTextureAllocator.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -45,11 +45,18 @@
 
     size_t currentMemoryUseBytes() const { return m_currentMemoryUseBytes; }
 
+    enum TextureUsageHint { Any, FramebufferAttachment };
+
+    void setTextureUsageHint(TextureUsageHint hint) { m_textureUsageHint = hint; }
+    void setUseTextureStorageExt(bool useStorageExt) { m_useTextureStorageExt = useStorageExt; }
+
 protected:
     explicit TrackingTextureAllocator(PassRefPtr<GraphicsContext3D>);
 
     RefPtr<GraphicsContext3D> m_context;
     size_t m_currentMemoryUseBytes;
+    TextureUsageHint m_textureUsageHint;
+    bool m_useTextureStorageExt;
 };
 
 }

Modified: trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h (102054 => 102055)


--- trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebCore/platform/graphics/chromium/cc/CCLayerTreeHost.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -92,6 +92,8 @@
         , usingAcceleratedPainting(false)
         , usingSetVisibility(false)
         , usingSwapCompleteCallback(false)
+        , usingTextureUsageHint(false)
+        , usingTextureStorageExtension(false)
         , maxTextureSize(0) { }
 
     GC3Denum bestTextureFormat;
@@ -101,6 +103,8 @@
     bool usingAcceleratedPainting;
     bool usingSetVisibility;
     bool usingSwapCompleteCallback;
+    bool usingTextureUsageHint;
+    bool usingTextureStorageExtension;
     int maxTextureSize;
 };
 

Modified: trunk/Source/WebKit/chromium/ChangeLog (102054 => 102055)


--- trunk/Source/WebKit/chromium/ChangeLog	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/ChangeLog	2011-12-05 23:43:15 UTC (rev 102055)
@@ -1,3 +1,20 @@
+2011-12-01  Vangelis Kokkevis  <[email protected]>
+
+        Use ANGLE's texture_usage and texture_storage extensions when allocating compositor textures.
+        https://bugs.webkit.org/show_bug.cgi?id=73621
+
+        Add the necessary entry points and enums to GraphicsContext3D.
+
+        Reviewed by Kenneth Russell.
+
+        * public/platform/WebGraphicsContext3D.h:
+        * src/Extensions3DChromium.cpp:
+        (WebCore::Extensions3DChromium::texStorage2DEXT):
+        * src/GraphicsContext3DChromium.cpp:
+        * src/GraphicsContext3DPrivate.h:
+        * tests/MockWebGraphicsContext3D.h:
+        (WebKit::MockWebGraphicsContext3D::texStorage2DEXT):
+
 2011-12-05  Adam Barth  <[email protected]>
 
         Another attempted build fix.

Modified: trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h (102054 => 102055)


--- trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/public/platform/WebGraphicsContext3D.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -381,6 +381,11 @@
     // GL_CHROMIUM_iosurface
     virtual void texImageIOSurface2DCHROMIUM(WGC3Denum target, WGC3Dint width, WGC3Dint height, WGC3Duint ioSurfaceId, WGC3Duint plane) { }
 
+    // GL_EXT_texture_storage
+    virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
+                                 WGC3Dint width, WGC3Dint height) { }
+
+
 #if WEBKIT_USING_SKIA
     GrGLInterface* createGrGLInterface();
 #endif

Modified: trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp (102054 => 102055)


--- trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp	2011-12-05 23:43:15 UTC (rev 102055)
@@ -150,6 +150,11 @@
     m_private->texImageIOSurface2DCHROMIUM(target, width, height, ioSurfaceId, plane);
 }
 
+void Extensions3DChromium::texStorage2DEXT(unsigned int target, int levels, unsigned int internalFormat, int width, int height)
+{
+    m_private->texStorage2DEXT(target, levels, internalFormat, width, height);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(WEBGL)

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp (102054 => 102055)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp	2011-12-05 23:43:15 UTC (rev 102055)
@@ -907,6 +907,7 @@
 
 DELEGATE_TO_IMPL_1R(getTranslatedShaderSourceANGLE, Platform3DObject, String)
 DELEGATE_TO_IMPL_5(texImageIOSurface2DCHROMIUM, GC3Denum, GC3Dint, GC3Dint, GC3Duint, GC3Duint)
+DELEGATE_TO_IMPL_5(texStorage2DEXT, GC3Denum, GC3Dint, GC3Duint, GC3Dint, GC3Dint)
 
 //----------------------------------------------------------------------
 // GraphicsContext3D

Modified: trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h (102054 => 102055)


--- trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/src/GraphicsContext3DPrivate.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -312,6 +312,9 @@
     // GL_CHROMIUM_iosurface
     void texImageIOSurface2DCHROMIUM(GC3Denum target, GC3Dint width, GC3Dint height, GC3Duint ioSurfaceId, GC3Duint plane);
 
+    // GL_EXT_texture_storage
+    void texStorage2DEXT(GC3Denum target, GC3Dint levels, GC3Duint internalformat, GC3Dint width, GC3Dint height);
+
 private:
     GraphicsContext3DPrivate(WebKit::WebViewImpl*, PassOwnPtr<WebKit::WebGraphicsContext3D>, GraphicsContext3D::Attributes);
 

Modified: trunk/Source/WebKit/chromium/tests/MockWebGraphicsContext3D.h (102054 => 102055)


--- trunk/Source/WebKit/chromium/tests/MockWebGraphicsContext3D.h	2011-12-05 23:39:26 UTC (rev 102054)
+++ trunk/Source/WebKit/chromium/tests/MockWebGraphicsContext3D.h	2011-12-05 23:43:15 UTC (rev 102055)
@@ -251,6 +251,9 @@
     virtual void deleteRenderbuffer(WebGLId) { }
     virtual void deleteShader(WebGLId) { }
     virtual void deleteTexture(WebGLId) { }
+
+    virtual void texStorage2DEXT(WGC3Denum target, WGC3Dint levels, WGC3Duint internalformat,
+                                 WGC3Dint width, WGC3Dint height) { }
 };
 
 } // namespace WebKit
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to