Changeset 145280 in webkit


Ignore:
Timestamp:
Mar 8, 2013 3:47:16 PM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Check to ensure MultisampleRenderbuffer creation succeeds
https://bugs.webkit.org/show_bug.cgi?id=111780

Patch by Brandon Jones <bajones@google.com> on 2013-03-08
Reviewed by Dean Jackson.

On OSX systems using AMD graphics chips the allocation of large
Multisample Renderbuffers in Chromium would fail without any indication
of failure. Attempting to draw to the buffer resulted in garbage being
rendered onscreen. This could be reproduced by opening a full-page
WebGL app and pressing (Command + "-") several times. This patch adds an
additional check during DrawingBuffer resize to verify that the resized
buffer is valid.

  • platform/graphics/gpu/DrawingBuffer.cpp:

(WebCore):
(WebCore::DrawingBuffer::checkBufferIntegrity):
(WebCore::DrawingBuffer::reset):

  • platform/graphics/gpu/DrawingBuffer.h:

(DrawingBuffer):

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r145279 r145280  
     12013-03-08  Brandon Jones  <bajones@google.com>
     2
     3        Check to ensure MultisampleRenderbuffer creation succeeds
     4        https://bugs.webkit.org/show_bug.cgi?id=111780
     5
     6        Reviewed by Dean Jackson.
     7
     8        On OSX systems using AMD graphics chips the allocation of large
     9        Multisample Renderbuffers in Chromium would fail without any indication
     10        of failure. Attempting to draw to the buffer resulted in garbage being
     11        rendered onscreen. This could be reproduced by opening a full-page
     12        WebGL app and pressing (Command + "-") several times. This patch adds an
     13        additional check during DrawingBuffer resize to verify that the resized
     14        buffer is valid.
     15
     16        * platform/graphics/gpu/DrawingBuffer.cpp:
     17        (WebCore):
     18        (WebCore::DrawingBuffer::checkBufferIntegrity):
     19        (WebCore::DrawingBuffer::reset):
     20        * platform/graphics/gpu/DrawingBuffer.h:
     21        (DrawingBuffer):
     22
    1232013-03-08  Harald Alvestrand  <hta@chromium.org>
    224
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp

    r139142 r145280  
    190190}
    191191
     192// Only way to ensure that we're not getting a bad framebuffer on some AMD/OSX devices.
     193// FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly.
     194bool DrawingBuffer::checkBufferIntegrity()
     195{
     196    if (!m_multisampleFBO)
     197        return true;
     198
     199    m_context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_multisampleFBO);
     200    m_context->clearColor(1.0f, 0.0f, 1.0f, 1.0f);
     201    m_context->clear(GraphicsContext3D::COLOR_BUFFER_BIT);
     202
     203    commit(0, 0, 1, 1);
     204
     205    unsigned char pixel[4] = {0, 0, 0, 0};
     206    m_context->readPixels(0, 0, 1, 1, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE, &pixel);
     207
     208    return (pixel[0] == 0xFF && pixel[1] == 0x00 && pixel[2] == 0xFF && pixel[3] == 0xFF);
     209}
     210
    192211bool DrawingBuffer::reset(const IntSize& newSize)
    193212{
     
    239258        }
    240259
    241 
    242260        do {
    243261            m_size = adjustedSize;
     
    253271                m_context->bindRenderbuffer(GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
    254272                m_context->getExtensions()->renderbufferStorageMultisample(GraphicsContext3D::RENDERBUFFER, sampleCount, internalRenderbufferFormat, m_size.width(), m_size.height());
     273
     274                if (m_context->getError() == GraphicsContext3D::OUT_OF_MEMORY) {
     275                    adjustedSize.scale(s_resourceAdjustedRatio);
     276                    continue;
     277                }
     278
    255279                m_context->framebufferRenderbuffer(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::RENDERBUFFER, m_multisampleColorBuffer);
    256280                resizeDepthStencil(sampleCount);
     
    279303            if (!multisample())
    280304                resizeDepthStencil(0);
    281             if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) == GraphicsContext3D::FRAMEBUFFER_COMPLETE)
    282                 break;
    283             adjustedSize.scale(s_resourceAdjustedRatio);
     305            if (m_context->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     306                adjustedSize.scale(s_resourceAdjustedRatio);
     307                continue;
     308            }
     309
     310#if OS(DARWIN)
     311            // FIXME: This can be removed once renderbufferStorageMultisample starts reporting GL_OUT_OF_MEMORY properly on OSX.
     312            if (!checkBufferIntegrity()) {
     313                adjustedSize.scale(s_resourceAdjustedRatio);
     314                continue;
     315            }
     316#endif
     317
     318            break;
    284319
    285320        } while (!adjustedSize.isEmpty());
  • trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h

    r139142 r145280  
    141141    void initialize(const IntSize&);
    142142
     143    bool checkBufferIntegrity();
     144
    143145    PreserveDrawingBuffer m_preserveDrawingBuffer;
    144146    AlphaRequirement m_alpha;
Note: See TracChangeset for help on using the changeset viewer.