Title: [164026] trunk/Source/WebCore
Revision
164026
Author
[email protected]
Date
2014-02-13 04:58:54 -0800 (Thu, 13 Feb 2014)

Log Message

Support ANGLE_instanced_arrays for GLES backend.
https://bugs.webkit.org/show_bug.cgi?id=128579

Reviewed by Dean Jackson.

Add some APIs to Extensions3D to support ANGLE_instanced_arrays for GLES backend.
At the same time, drawArraysInstanced, drawElementsInstanced and vertexAttribDivisor
are moved from GC3DOpenGL.cpp to GC3DOpenGLCommon.cpp since they could be shareable
through Extensions3D.

Covered by fast/canvas/webgl/angle-instanced-arrays.html

* platform/graphics/Extensions3D.h:
* platform/graphics/opengl/Extensions3DOpenGL.cpp:
(WebCore::Extensions3DOpenGL::drawArraysInstanced):
(WebCore::Extensions3DOpenGL::drawElementsInstanced):
(WebCore::Extensions3DOpenGL::vertexAttribDivisor):
* platform/graphics/opengl/Extensions3DOpenGL.h:
* platform/graphics/opengl/Extensions3DOpenGLES.cpp:
(WebCore::Extensions3DOpenGLES::Extensions3DOpenGLES):
(WebCore::Extensions3DOpenGLES::drawArraysInstanced):
(WebCore::Extensions3DOpenGLES::drawElementsInstanced):
(WebCore::Extensions3DOpenGLES::vertexAttribDivisor):
(WebCore::Extensions3DOpenGLES::supportsExtension):
* platform/graphics/opengl/Extensions3DOpenGLES.h:
* platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
* platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
(WebCore::GraphicsContext3D::drawArraysInstanced):
(WebCore::GraphicsContext3D::drawElementsInstanced):
(WebCore::GraphicsContext3D::vertexAttribDivisor):
* platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164025 => 164026)


--- trunk/Source/WebCore/ChangeLog	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/ChangeLog	2014-02-13 12:58:54 UTC (rev 164026)
@@ -1,3 +1,37 @@
+2014-02-13  ChangSeok Oh  <[email protected]>
+
+        Support ANGLE_instanced_arrays for GLES backend.
+        https://bugs.webkit.org/show_bug.cgi?id=128579
+
+        Reviewed by Dean Jackson.
+
+        Add some APIs to Extensions3D to support ANGLE_instanced_arrays for GLES backend.
+        At the same time, drawArraysInstanced, drawElementsInstanced and vertexAttribDivisor
+        are moved from GC3DOpenGL.cpp to GC3DOpenGLCommon.cpp since they could be shareable
+        through Extensions3D.
+
+        Covered by fast/canvas/webgl/angle-instanced-arrays.html
+
+        * platform/graphics/Extensions3D.h:
+        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
+        (WebCore::Extensions3DOpenGL::drawArraysInstanced):
+        (WebCore::Extensions3DOpenGL::drawElementsInstanced):
+        (WebCore::Extensions3DOpenGL::vertexAttribDivisor):
+        * platform/graphics/opengl/Extensions3DOpenGL.h:
+        * platform/graphics/opengl/Extensions3DOpenGLES.cpp:
+        (WebCore::Extensions3DOpenGLES::Extensions3DOpenGLES):
+        (WebCore::Extensions3DOpenGLES::drawArraysInstanced):
+        (WebCore::Extensions3DOpenGLES::drawElementsInstanced):
+        (WebCore::Extensions3DOpenGLES::vertexAttribDivisor):
+        (WebCore::Extensions3DOpenGLES::supportsExtension):
+        * platform/graphics/opengl/Extensions3DOpenGLES.h:
+        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
+        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
+        (WebCore::GraphicsContext3D::drawArraysInstanced):
+        (WebCore::GraphicsContext3D::drawElementsInstanced):
+        (WebCore::GraphicsContext3D::vertexAttribDivisor):
+        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
+
 2014-02-13  Xabier Rodriguez Calvar  <[email protected]>
 
         [GTK] MEDIA_CONTROLS_SCRIPT support

Modified: trunk/Source/WebCore/platform/graphics/Extensions3D.h (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/Extensions3D.h	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/Extensions3D.h	2014-02-13 12:58:54 UTC (rev 164026)
@@ -74,6 +74,7 @@
     //   GL_CHROMIUM_copy_texture
     //   GL_CHROMIUM_flipy
     //   GL_ARB_draw_buffers / GL_EXT_draw_buffers
+    //   GL_ANGLE_instanced_arrays
 
     // Takes full name of extension; for example,
     // "GL_EXT_texture_format_BGRA8888".
@@ -238,6 +239,11 @@
     // GL_ARB_draw_buffers / GL_EXT_draw_buffers
     virtual void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) = 0;
 
+    // GL_ANGLE_instanced_arrays
+    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0;
+    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) = 0;
+    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0;
+
     virtual bool isNVIDIA() = 0;
     virtual bool isAMD() = 0;
     virtual bool isIntel() = 0;

Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp	2014-02-13 12:58:54 UTC (rev 164026)
@@ -236,6 +236,44 @@
 #endif
 }
 
+void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
+{
+#if ENABLE(GTK)
+    m_context->makeContextCurrent();
+    ::glDrawArraysInstanced(mode, first, count, primcount);
+#else
+    UNUSED_PARAM(mode);
+    UNUSED_PARAM(first);
+    UNUSED_PARAM(count);
+    UNUSED_PARAM(primcount);
+#endif
+}
+
+void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
+{
+#if ENABLE(GTK)
+    m_context->makeContextCurrent();
+    ::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
+#else
+    UNUSED_PARAM(mode);
+    UNUSED_PARAM(count);
+    UNUSED_PARAM(type);
+    UNUSED_PARAM(offset);
+    UNUSED_PARAM(primcount);
+#endif
+}
+
+void Extensions3DOpenGL::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
+{
+#if ENABLE(GTK)
+    m_context->makeContextCurrent();
+    ::glVertexAttribDivisor(index, divisor);
+#else
+    UNUSED_PARAM(index);
+    UNUSED_PARAM(divisor);
+#endif
+}
+
 String Extensions3DOpenGL::getExtensions()
 {
     return String(reinterpret_cast<const char*>(::glGetString(GL_EXTENSIONS)));

Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h	2014-02-13 12:58:54 UTC (rev 164026)
@@ -53,6 +53,10 @@
     virtual void popGroupMarkerEXT(void);
     virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
 
+    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount);
+    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount);
+    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
+
 protected:
     // This class only needs to be instantiated by GraphicsContext3D implementations.
     friend class GraphicsContext3D;

Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp	2014-02-13 12:58:54 UTC (rev 164026)
@@ -1,6 +1,7 @@
 /*
  * Copyright (C) 2011 Google Inc. All rights reserved.
  * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
+ * Copyright (C) 2014 Collabora Ltd. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -40,6 +41,7 @@
     , m_contextResetStatus(GL_NO_ERROR)
     , m_supportsOESvertexArrayObject(false)
     , m_supportsIMGMultisampledRenderToTexture(false)
+    , m_supportsANGLEinstancedArrays(false)
     , m_glFramebufferTexture2DMultisampleIMG(0)
     , m_glRenderbufferStorageMultisampleIMG(0)
     , m_glBindVertexArrayOES(0)
@@ -50,6 +52,9 @@
     , m_glReadnPixelsEXT(0)
     , m_glGetnUniformfvEXT(0)
     , m_glGetnUniformivEXT(0)
+    , m_glVertexAttribDivisorANGLE(nullptr)
+    , m_glDrawArraysInstancedANGLE(nullptr)
+    , m_glDrawElementsInstancedANGLE(nullptr)
 {
 }
 
@@ -228,6 +233,39 @@
     m_context->synthesizeGLError(GL_INVALID_OPERATION);
 }
 
+void Extensions3DOpenGLES::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
+{
+    if (!m_glDrawArraysInstancedANGLE) {
+        m_context->synthesizeGLError(GL_INVALID_OPERATION);
+        return;
+    }
+
+    m_context->makeContextCurrent();
+    m_glDrawArraysInstancedANGLE(mode, first, count, primcount);
+}
+
+void Extensions3DOpenGLES::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
+{
+    if (!m_glDrawElementsInstancedANGLE) {
+        m_context->synthesizeGLError(GL_INVALID_OPERATION);
+        return;
+    }
+
+    m_context->makeContextCurrent();
+    m_glDrawElementsInstancedANGLE(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
+}
+
+void Extensions3DOpenGLES::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
+{
+    if (!m_glVertexAttribDivisorANGLE) {
+        m_context->synthesizeGLError(GL_INVALID_OPERATION);
+        return;
+    }
+
+    m_context->makeContextCurrent();
+    m_glVertexAttribDivisorANGLE(index, divisor);
+}
+
 bool Extensions3DOpenGLES::supportsExtension(const String& name)
 {
     if (m_availableExtensions.contains(name)) {
@@ -246,6 +284,11 @@
             m_glReadnPixelsEXT = reinterpret_cast<PFNGLREADNPIXELSEXTPROC>(eglGetProcAddress("glReadnPixelsEXT"));
             m_glGetnUniformfvEXT = reinterpret_cast<PFNGLGETNUNIFORMFVEXTPROC>(eglGetProcAddress("glGetnUniformfvEXT"));
             m_glGetnUniformivEXT = reinterpret_cast<PFNGLGETNUNIFORMIVEXTPROC>(eglGetProcAddress("glGetnUniformivEXT"));
+        } else if (!m_supportsANGLEinstancedArrays && name == "GL_ANGLE_instanced_arrays") {
+            m_glVertexAttribDivisorANGLE = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORANGLEPROC>(eglGetProcAddress("glVertexAttribDivisorANGLE"));
+            m_glDrawArraysInstancedANGLE = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDANGLEPROC >(eglGetProcAddress("glDrawArraysInstancedANGLE"));
+            m_glDrawElementsInstancedANGLE = reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDANGLEPROC >(eglGetProcAddress("glDrawElementsInstancedANGLE"));
+            m_supportsANGLEinstancedArrays = true;
         } else if (name == "GL_EXT_draw_buffers") {
             // FIXME: implement the support.
             return false;

Modified: trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h	2014-02-13 12:58:54 UTC (rev 164026)
@@ -80,6 +80,10 @@
     virtual void bindVertexArrayOES(Platform3DObject);
     virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
 
+    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount);
+    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount);
+    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
+
     // EXT Robustness - reset
     virtual int getGraphicsResetStatusARB();
     void setEXTContextLostCallback(PassOwnPtr<GraphicsContext3D::ContextLostCallback>);
@@ -101,6 +105,7 @@
 
     bool m_supportsOESvertexArrayObject;
     bool m_supportsIMGMultisampledRenderToTexture;
+    bool m_supportsANGLEinstancedArrays;
 
     PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG m_glFramebufferTexture2DMultisampleIMG;
     PFNGLRENDERBUFFERSTORAGEMULTISAMPLEIMG m_glRenderbufferStorageMultisampleIMG;
@@ -112,7 +117,11 @@
     PFNGLREADNPIXELSEXTPROC m_glReadnPixelsEXT;
     PFNGLGETNUNIFORMFVEXTPROC m_glGetnUniformfvEXT;
     PFNGLGETNUNIFORMIVEXTPROC m_glGetnUniformivEXT;
+    PFNGLVERTEXATTRIBDIVISORANGLEPROC m_glVertexAttribDivisorANGLE;
+    PFNGLDRAWARRAYSINSTANCEDANGLEPROC m_glDrawArraysInstancedANGLE;
+    PFNGLDRAWELEMENTSINSTANCEDANGLEPROC m_glDrawElementsInstancedANGLE;
 
+
     OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
 };
 

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp	2014-02-13 12:58:54 UTC (rev 164026)
@@ -351,26 +351,6 @@
         ::glBindFramebufferEXT(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
 }
 
-#if !PLATFORM(COCOA)
-void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
-{
-    makeContextCurrent();
-    ::glDrawArraysInstanced(mode, first, count, primcount);
 }
 
-void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
-{
-    makeContextCurrent();
-    ::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
-}
-
-void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
-{
-    makeContextCurrent();
-    ::glVertexAttribDivisor(index, divisor);
-}
-#endif
-
-}
-
 #endif // USE(3D_GRAPHICS)

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp	2014-02-13 12:58:54 UTC (rev 164026)
@@ -1630,6 +1630,23 @@
     ::glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
 }
 
+#if !PLATFORM(COCOA)
+void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
+{
+    getExtensions()->drawArraysInstanced(mode, first, count, primcount);
 }
 
+void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
+{
+    getExtensions()->drawElementsInstanced(mode, count, type, offset, primcount);
+}
+
+void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
+{
+    getExtensions()->vertexAttribDivisor(index, divisor);
+}
+#endif
+
+}
+
 #endif // USE(3D_GRAPHICS)

Modified: trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp (164025 => 164026)


--- trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2014-02-13 12:35:44 UTC (rev 164025)
+++ trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp	2014-02-13 12:58:54 UTC (rev 164026)
@@ -206,29 +206,6 @@
     ::glClearDepthf(depth);
 }
 
-void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
-{
-    UNUSED_PARAM(mode);
-    UNUSED_PARAM(first);
-    UNUSED_PARAM(count);
-    UNUSED_PARAM(primcount);
-}
-
-void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
-{
-    UNUSED_PARAM(mode);
-    UNUSED_PARAM(count);
-    UNUSED_PARAM(type);
-    UNUSED_PARAM(offset);
-    UNUSED_PARAM(primcount);
-}
-
-void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
-{
-    UNUSED_PARAM(index);
-    UNUSED_PARAM(divisor);
-}
-
 Extensions3D* GraphicsContext3D::getExtensions()
 {
     if (!m_extensions)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to