Changeset 164026 in webkit


Ignore:
Timestamp:
Feb 13, 2014 4:58:54 AM (10 years ago)
Author:
ChangSeok Oh
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:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r164024 r164026  
     12014-02-13  ChangSeok Oh  <changseok.oh@collabora.com>
     2
     3        Support ANGLE_instanced_arrays for GLES backend.
     4        https://bugs.webkit.org/show_bug.cgi?id=128579
     5
     6        Reviewed by Dean Jackson.
     7
     8        Add some APIs to Extensions3D to support ANGLE_instanced_arrays for GLES backend.
     9        At the same time, drawArraysInstanced, drawElementsInstanced and vertexAttribDivisor
     10        are moved from GC3DOpenGL.cpp to GC3DOpenGLCommon.cpp since they could be shareable
     11        through Extensions3D.
     12
     13        Covered by fast/canvas/webgl/angle-instanced-arrays.html
     14
     15        * platform/graphics/Extensions3D.h:
     16        * platform/graphics/opengl/Extensions3DOpenGL.cpp:
     17        (WebCore::Extensions3DOpenGL::drawArraysInstanced):
     18        (WebCore::Extensions3DOpenGL::drawElementsInstanced):
     19        (WebCore::Extensions3DOpenGL::vertexAttribDivisor):
     20        * platform/graphics/opengl/Extensions3DOpenGL.h:
     21        * platform/graphics/opengl/Extensions3DOpenGLES.cpp:
     22        (WebCore::Extensions3DOpenGLES::Extensions3DOpenGLES):
     23        (WebCore::Extensions3DOpenGLES::drawArraysInstanced):
     24        (WebCore::Extensions3DOpenGLES::drawElementsInstanced):
     25        (WebCore::Extensions3DOpenGLES::vertexAttribDivisor):
     26        (WebCore::Extensions3DOpenGLES::supportsExtension):
     27        * platform/graphics/opengl/Extensions3DOpenGLES.h:
     28        * platform/graphics/opengl/GraphicsContext3DOpenGL.cpp:
     29        * platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp:
     30        (WebCore::GraphicsContext3D::drawArraysInstanced):
     31        (WebCore::GraphicsContext3D::drawElementsInstanced):
     32        (WebCore::GraphicsContext3D::vertexAttribDivisor):
     33        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
     34
    1352014-02-13  Xabier Rodriguez Calvar  <calvaris@igalia.com>
    236
  • trunk/Source/WebCore/platform/graphics/Extensions3D.h

    r161688 r164026  
    7575    //   GL_CHROMIUM_flipy
    7676    //   GL_ARB_draw_buffers / GL_EXT_draw_buffers
     77    //   GL_ANGLE_instanced_arrays
    7778
    7879    // Takes full name of extension; for example,
     
    239240    virtual void drawBuffersEXT(GC3Dsizei n, const GC3Denum* bufs) = 0;
    240241
     242    // GL_ANGLE_instanced_arrays
     243    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount) = 0;
     244    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount) = 0;
     245    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor) = 0;
     246
    241247    virtual bool isNVIDIA() = 0;
    242248    virtual bool isAMD() = 0;
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.cpp

    r163858 r164026  
    237237}
    238238
     239void Extensions3DOpenGL::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
     240{
     241#if ENABLE(GTK)
     242    m_context->makeContextCurrent();
     243    ::glDrawArraysInstanced(mode, first, count, primcount);
     244#else
     245    UNUSED_PARAM(mode);
     246    UNUSED_PARAM(first);
     247    UNUSED_PARAM(count);
     248    UNUSED_PARAM(primcount);
     249#endif
     250}
     251
     252void Extensions3DOpenGL::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
     253{
     254#if ENABLE(GTK)
     255    m_context->makeContextCurrent();
     256    ::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
     257#else
     258    UNUSED_PARAM(mode);
     259    UNUSED_PARAM(count);
     260    UNUSED_PARAM(type);
     261    UNUSED_PARAM(offset);
     262    UNUSED_PARAM(primcount);
     263#endif
     264}
     265
     266void Extensions3DOpenGL::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
     267{
     268#if ENABLE(GTK)
     269    m_context->makeContextCurrent();
     270    ::glVertexAttribDivisor(index, divisor);
     271#else
     272    UNUSED_PARAM(index);
     273    UNUSED_PARAM(divisor);
     274#endif
     275}
     276
    239277String Extensions3DOpenGL::getExtensions()
    240278{
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGL.h

    r162451 r164026  
    5454    virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
    5555
     56    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount);
     57    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount);
     58    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
     59
    5660protected:
    5761    // This class only needs to be instantiated by GraphicsContext3D implementations.
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.cpp

    r161699 r164026  
    22 * Copyright (C) 2011 Google Inc. All rights reserved.
    33 * Copyright (C) 2012 Research In Motion Limited. All rights reserved.
     4 * Copyright (C) 2014 Collabora Ltd. All rights reserved.
    45 *
    56 * Redistribution and use in source and binary forms, with or without
     
    4142    , m_supportsOESvertexArrayObject(false)
    4243    , m_supportsIMGMultisampledRenderToTexture(false)
     44    , m_supportsANGLEinstancedArrays(false)
    4345    , m_glFramebufferTexture2DMultisampleIMG(0)
    4446    , m_glRenderbufferStorageMultisampleIMG(0)
     
    5153    , m_glGetnUniformfvEXT(0)
    5254    , m_glGetnUniformivEXT(0)
     55    , m_glVertexAttribDivisorANGLE(nullptr)
     56    , m_glDrawArraysInstancedANGLE(nullptr)
     57    , m_glDrawElementsInstancedANGLE(nullptr)
    5358{
    5459}
     
    227232
    228233    m_context->synthesizeGLError(GL_INVALID_OPERATION);
     234}
     235
     236void Extensions3DOpenGLES::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
     237{
     238    if (!m_glDrawArraysInstancedANGLE) {
     239        m_context->synthesizeGLError(GL_INVALID_OPERATION);
     240        return;
     241    }
     242
     243    m_context->makeContextCurrent();
     244    m_glDrawArraysInstancedANGLE(mode, first, count, primcount);
     245}
     246
     247void Extensions3DOpenGLES::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount)
     248{
     249    if (!m_glDrawElementsInstancedANGLE) {
     250        m_context->synthesizeGLError(GL_INVALID_OPERATION);
     251        return;
     252    }
     253
     254    m_context->makeContextCurrent();
     255    m_glDrawElementsInstancedANGLE(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
     256}
     257
     258void Extensions3DOpenGLES::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
     259{
     260    if (!m_glVertexAttribDivisorANGLE) {
     261        m_context->synthesizeGLError(GL_INVALID_OPERATION);
     262        return;
     263    }
     264
     265    m_context->makeContextCurrent();
     266    m_glVertexAttribDivisorANGLE(index, divisor);
    229267}
    230268
     
    247285            m_glGetnUniformfvEXT = reinterpret_cast<PFNGLGETNUNIFORMFVEXTPROC>(eglGetProcAddress("glGetnUniformfvEXT"));
    248286            m_glGetnUniformivEXT = reinterpret_cast<PFNGLGETNUNIFORMIVEXTPROC>(eglGetProcAddress("glGetnUniformivEXT"));
     287        } else if (!m_supportsANGLEinstancedArrays && name == "GL_ANGLE_instanced_arrays") {
     288            m_glVertexAttribDivisorANGLE = reinterpret_cast<PFNGLVERTEXATTRIBDIVISORANGLEPROC>(eglGetProcAddress("glVertexAttribDivisorANGLE"));
     289            m_glDrawArraysInstancedANGLE = reinterpret_cast<PFNGLDRAWARRAYSINSTANCEDANGLEPROC >(eglGetProcAddress("glDrawArraysInstancedANGLE"));
     290            m_glDrawElementsInstancedANGLE = reinterpret_cast<PFNGLDRAWELEMENTSINSTANCEDANGLEPROC >(eglGetProcAddress("glDrawElementsInstancedANGLE"));
     291            m_supportsANGLEinstancedArrays = true;
    249292        } else if (name == "GL_EXT_draw_buffers") {
    250293            // FIXME: implement the support.
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLES.h

    r162451 r164026  
    8181    virtual void drawBuffersEXT(GC3Dsizei, const GC3Denum*);
    8282
     83    virtual void drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount);
     84    virtual void drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, long long offset, GC3Dsizei primcount);
     85    virtual void vertexAttribDivisor(GC3Duint index, GC3Duint divisor);
     86
    8387    // EXT Robustness - reset
    8488    virtual int getGraphicsResetStatusARB();
     
    102106    bool m_supportsOESvertexArrayObject;
    103107    bool m_supportsIMGMultisampledRenderToTexture;
     108    bool m_supportsANGLEinstancedArrays;
    104109
    105110    PFNGLFRAMEBUFFERTEXTURE2DMULTISAMPLEIMG m_glFramebufferTexture2DMultisampleIMG;
     
    113118    PFNGLGETNUNIFORMFVEXTPROC m_glGetnUniformfvEXT;
    114119    PFNGLGETNUNIFORMIVEXTPROC m_glGetnUniformivEXT;
     120    PFNGLVERTEXATTRIBDIVISORANGLEPROC m_glVertexAttribDivisorANGLE;
     121    PFNGLDRAWARRAYSINSTANCEDANGLEPROC m_glDrawArraysInstancedANGLE;
     122    PFNGLDRAWELEMENTSINSTANCEDANGLEPROC m_glDrawElementsInstancedANGLE;
     123
    115124
    116125    OwnPtr<GraphicsContext3D::ContextLostCallback> m_contextLostCallback;
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp

    r163858 r164026  
    352352}
    353353
    354 #if !PLATFORM(COCOA)
    355 void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
    356 {
    357     makeContextCurrent();
    358     ::glDrawArraysInstanced(mode, first, count, primcount);
    359 }
    360 
    361 void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
    362 {
    363     makeContextCurrent();
    364     ::glDrawElementsInstanced(mode, count, type, reinterpret_cast<GLvoid*>(static_cast<intptr_t>(offset)), primcount);
    365 }
    366 
    367 void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
    368 {
    369     makeContextCurrent();
    370     ::glVertexAttribDivisor(index, divisor);
    371 }
    372 #endif
    373 
    374354}
    375355
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp

    r162691 r164026  
    16311631}
    16321632
     1633#if !PLATFORM(COCOA)
     1634void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
     1635{
     1636    getExtensions()->drawArraysInstanced(mode, first, count, primcount);
     1637}
     1638
     1639void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
     1640{
     1641    getExtensions()->drawElementsInstanced(mode, count, type, offset, primcount);
     1642}
     1643
     1644void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
     1645{
     1646    getExtensions()->vertexAttribDivisor(index, divisor);
     1647}
     1648#endif
     1649
    16331650}
    16341651
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp

    r162600 r164026  
    207207}
    208208
    209 void GraphicsContext3D::drawArraysInstanced(GC3Denum mode, GC3Dint first, GC3Dsizei count, GC3Dsizei primcount)
    210 {
    211     UNUSED_PARAM(mode);
    212     UNUSED_PARAM(first);
    213     UNUSED_PARAM(count);
    214     UNUSED_PARAM(primcount);
    215 }
    216 
    217 void GraphicsContext3D::drawElementsInstanced(GC3Denum mode, GC3Dsizei count, GC3Denum type, GC3Dintptr offset, GC3Dsizei primcount)
    218 {
    219     UNUSED_PARAM(mode);
    220     UNUSED_PARAM(count);
    221     UNUSED_PARAM(type);
    222     UNUSED_PARAM(offset);
    223     UNUSED_PARAM(primcount);
    224 }
    225 
    226 void GraphicsContext3D::vertexAttribDivisor(GC3Duint index, GC3Duint divisor)
    227 {
    228     UNUSED_PARAM(index);
    229     UNUSED_PARAM(divisor);
    230 }
    231 
    232209Extensions3D* GraphicsContext3D::getExtensions()
    233210{
Note: See TracChangeset for help on using the changeset viewer.