Changeset 166563 in webkit


Ignore:
Timestamp:
Mar 31, 2014, 10:37:12 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

[WebGL][OpenGLES] Enable MSAA support for WebGL Canvas
https://bugs.webkit.org/show_bug.cgi?id=130955

Patch by Byungseon Shin <sun.shin@lge.com> on 2014-03-31
Reviewed by Dean Jackson.

To avoid aliasing issues when we render content to WebGL canvas,

we need to implement MSAA support.

  • Imagination OpenGLES GPU Driver already support MSAA, so we need a separate code path to enable it.
  • platform/graphics/Extensions3D.h:
  • platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:

(WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon):

  • platform/graphics/opengl/Extensions3DOpenGLCommon.h:

(WebCore::Extensions3DOpenGLCommon::isImagination):

  • platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:

(WebCore::GraphicsContext3D::reshapeFBOs):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r166551 r166563  
     12014-03-31  Byungseon Shin  <sun.shin@lge.com>
     2
     3        [WebGL][OpenGLES] Enable MSAA support for WebGL Canvas
     4        https://bugs.webkit.org/show_bug.cgi?id=130955
     5
     6        Reviewed by Dean Jackson.
     7
     8        To avoid aliasing issues when we render content to WebGL canvas,
     9         we need to implement MSAA support.
     10        - Imagination OpenGLES GPU Driver already support MSAA, so we
     11         need a separate code path to enable it.
     12
     13        * platform/graphics/Extensions3D.h:
     14        * platform/graphics/opengl/Extensions3DOpenGLCommon.cpp:
     15        (WebCore::Extensions3DOpenGLCommon::Extensions3DOpenGLCommon):
     16        * platform/graphics/opengl/Extensions3DOpenGLCommon.h:
     17        (WebCore::Extensions3DOpenGLCommon::isImagination):
     18        * platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp:
     19        (WebCore::GraphicsContext3D::reshapeFBOs):
     20
    1212014-03-31  Alexey Proskuryakov  <ap@apple.com>
    222
  • trunk/Source/WebCore/platform/graphics/Extensions3D.h

    r164468 r166563  
    5353    //   GL_EXT_packed_depth_stencil / GL_OES_packed_depth_stencil
    5454    //   GL_ANGLE_framebuffer_blit / GL_ANGLE_framebuffer_multisample
     55    //   GL_IMG_multisampled_render_to_texture
    5556    //   GL_OES_texture_float
    5657    //   GL_OES_texture_float_linear
     
    111112        FRAMEBUFFER_INCOMPLETE_MULTISAMPLE = 0x8D56,
    112113        MAX_SAMPLES = 0x8D57,
     114
     115        // GL_IMG_multisampled_render_to_texture
     116        RENDERBUFFER_SAMPLES_IMG = 0x9133,
     117        FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_IMG = 0x9134,
     118        MAX_SAMPLES_IMG = 0x9135,
     119        TEXTURE_SAMPLES_IMG = 0x9136,
    113120
    114121        // GL_OES_standard_derivatives names
     
    236243    virtual bool isAMD() = 0;
    237244    virtual bool isIntel() = 0;
     245    virtual bool isImagination() = 0;
    238246    virtual String vendor() = 0;
    239247
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.cpp

    r164574 r166563  
    5858    , m_isAMD(false)
    5959    , m_isIntel(false)
     60    , m_isImagination(false)
    6061    , m_maySupportMultisampling(true)
    6162    , m_requiresBuiltInFunctionEmulation(false)
     
    7172    if (vendorComponents.contains("intel"))
    7273        m_isIntel = true;
     74    if (vendorComponents.contains("imagination"))
     75        m_isImagination = true;
    7376
    7477#if PLATFORM(MAC)
  • trunk/Source/WebCore/platform/graphics/opengl/Extensions3DOpenGLCommon.h

    r144358 r166563  
    6363    virtual bool isAMD() { return m_isAMD; }
    6464    virtual bool isIntel() { return m_isIntel; }
     65    virtual bool isImagination() { return m_isImagination; }
    6566    virtual String vendor() { return m_vendor; }
    6667
     
    8586    bool m_isAMD;
    8687    bool m_isIntel;
     88    bool m_isImagination;
    8789    bool m_maySupportMultisampling;
    8890    bool m_requiresBuiltInFunctionEmulation;
  • trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLES.cpp

    r165676 r166563  
    111111    }
    112112
    113     // We don't support antialiasing yet. See GraphicsContext3D::validateAttributes.
    114     ASSERT(!m_attrs.antialias);
    115 
    116     if (m_attrs.stencil || m_attrs.depth) {
    117         // Use a 24 bit depth buffer where we know we have it.
    118         if (supportPackedDepthStencilBuffer) {
    119             ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
    120             ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height);
    121             if (m_attrs.stencil)
    122                 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
    123             if (m_attrs.depth)
    124                 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     113    if (extensions->isImagination() && m_attrs.antialias) {
     114        GLint maxSampleCount;
     115        ::glGetIntegerv(Extensions3D::MAX_SAMPLES_IMG, &maxSampleCount);
     116        GLint sampleCount = std::min(8, maxSampleCount);
     117
     118        extensions->framebufferTexture2DMultisampleIMG(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0, sampleCount);
     119
     120        if (m_attrs.stencil || m_attrs.depth) {
     121            // Use a 24 bit depth buffer where we know we have it.
     122            if (supportPackedDepthStencilBuffer) {
     123                ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
     124                extensions->renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH24_STENCIL8_OES, width, height);
     125                if (m_attrs.stencil)
     126                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     127                if (m_attrs.depth)
     128                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     129            } else {
     130                if (m_attrs.stencil) {
     131                    ::glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
     132                    extensions->renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_STENCIL_INDEX8, width, height);
     133                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer);
     134                }
     135                if (m_attrs.depth) {
     136                    ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
     137                    extensions->renderbufferStorageMultisample(GL_RENDERBUFFER, sampleCount, GL_DEPTH_COMPONENT16, width, height);
     138                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
     139                }
     140            }
    125141            ::glBindRenderbuffer(GL_RENDERBUFFER, 0);
    126         } else {
    127             if (m_attrs.stencil) {
    128                 ::glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
    129                 ::glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
    130                 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer);
    131             }
    132             if (m_attrs.depth) {
    133                 ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
    134                 ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
    135                 ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
     142        }
     143    } else {
     144        if (m_attrs.stencil || m_attrs.depth) {
     145            // Use a 24 bit depth buffer where we know we have it.
     146            if (supportPackedDepthStencilBuffer) {
     147                ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthStencilBuffer);
     148                ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8_OES, width, height);
     149                if (m_attrs.stencil)
     150                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     151                if (m_attrs.depth)
     152                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthStencilBuffer);
     153            } else {
     154                if (m_attrs.stencil) {
     155                    ::glBindRenderbuffer(GL_RENDERBUFFER, m_stencilBuffer);
     156                    ::glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, width, height);
     157                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, m_stencilBuffer);
     158                }
     159                if (m_attrs.depth) {
     160                    ::glBindRenderbuffer(GL_RENDERBUFFER, m_depthBuffer);
     161                    ::glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, width, height);
     162                    ::glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, m_depthBuffer);
     163                }
    136164            }
    137165            ::glBindRenderbuffer(GL_RENDERBUFFER, 0);
Note: See TracChangeset for help on using the changeset viewer.