Changeset 117506 in webkit


Ignore:
Timestamp:
May 17, 2012 3:27:48 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

Add more descriptive warnings for framebuffer incomplete conditions
https://bugs.webkit.org/show_bug.cgi?id=86774

Patch by Gregg Tavares <gman@google.com> on 2012-05-17
Reviewed by Kenneth Russell.

No new tests as there is no new functionality

  • html/canvas/WebGLFramebuffer.cpp:

(WebCore::WebGLFramebuffer::checkStatus):
(WebCore::WebGLFramebuffer::onAccess):
(WebCore::WebGLFramebuffer::initializeRenderbuffers):

  • html/canvas/WebGLFramebuffer.h:

(WebGLFramebuffer):

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore):
(WebCore::WebGLRenderingContext::checkFramebufferStatus):
(WebCore::WebGLRenderingContext::clear):
(WebCore::WebGLRenderingContext::copyTexImage2D):
(WebCore::WebGLRenderingContext::copyTexSubImage2D):
(WebCore::WebGLRenderingContext::drawArrays):
(WebCore::WebGLRenderingContext::drawElements):
(WebCore::WebGLRenderingContext::readPixels):
(WebCore::WebGLRenderingContext::printGLWarningToConsole):

  • html/canvas/WebGLRenderingContext.h:
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r117504 r117506  
     12012-05-17  Gregg Tavares  <gman@google.com>
     2
     3        Add more descriptive warnings for framebuffer incomplete conditions
     4        https://bugs.webkit.org/show_bug.cgi?id=86774
     5
     6        Reviewed by Kenneth Russell.
     7
     8        No new tests as there is no new functionality
     9
     10        * html/canvas/WebGLFramebuffer.cpp:
     11        (WebCore::WebGLFramebuffer::checkStatus):
     12        (WebCore::WebGLFramebuffer::onAccess):
     13        (WebCore::WebGLFramebuffer::initializeRenderbuffers):
     14        * html/canvas/WebGLFramebuffer.h:
     15        (WebGLFramebuffer):
     16        * html/canvas/WebGLRenderingContext.cpp:
     17        (WebCore):
     18        (WebCore::WebGLRenderingContext::checkFramebufferStatus):
     19        (WebCore::WebGLRenderingContext::clear):
     20        (WebCore::WebGLRenderingContext::copyTexImage2D):
     21        (WebCore::WebGLRenderingContext::copyTexSubImage2D):
     22        (WebCore::WebGLRenderingContext::drawArrays):
     23        (WebCore::WebGLRenderingContext::drawElements):
     24        (WebCore::WebGLRenderingContext::readPixels):
     25        (WebCore::WebGLRenderingContext::printGLWarningToConsole):
     26        * html/canvas/WebGLRenderingContext.h:
     27
    1282012-05-17  Oliver Hunt  <oliver@apple.com>
    229
  • trunk/Source/WebCore/html/canvas/WebGLFramebuffer.cpp

    r115870 r117506  
    3737namespace {
    3838
    39     bool isAttachmentComplete(WebGLSharedObject* attachedObject, GC3Denum attachment)
     39    bool isAttachmentComplete(WebGLSharedObject* attachedObject, GC3Denum attachment, const char** reason)
    4040    {
    4141        ASSERT(attachedObject && attachedObject->object());
    4242        ASSERT(attachedObject->isRenderbuffer());
     43        ASSERT(reason);
    4344        WebGLRenderbuffer* buffer = reinterpret_cast<WebGLRenderbuffer*>(attachedObject);
    4445        switch (attachment) {
    4546        case GraphicsContext3D::DEPTH_ATTACHMENT:
    46             if (buffer->getInternalFormat() != GraphicsContext3D::DEPTH_COMPONENT16)
     47            if (buffer->getInternalFormat() != GraphicsContext3D::DEPTH_COMPONENT16) {
     48                *reason = "DEPTH_ATTACHMENT is not a depth format";
    4749                return false;
     50            }
    4851            break;
    4952        case GraphicsContext3D::STENCIL_ATTACHMENT:
    50             if (buffer->getInternalFormat() != GraphicsContext3D::STENCIL_INDEX8)
     53            if (buffer->getInternalFormat() != GraphicsContext3D::STENCIL_INDEX8) {
     54                *reason = "STENCIL_ATTACHMENT is not a stencil format";
    5155                return false;
     56            }
    5257            break;
    5358        case GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT:
    54             if (buffer->getInternalFormat() != GraphicsContext3D::DEPTH_STENCIL)
     59            if (buffer->getInternalFormat() != GraphicsContext3D::DEPTH_STENCIL) {
     60                *reason = "DEPTH_STENCIL_ATTACHMENT is not a depth-stencil format";
    5561                return false;
     62            }
    5663            break;
    5764        default:
     
    5966            return false;
    6067        }
    61         if (!buffer->getWidth() || !buffer->getHeight())
     68        if (!buffer->getWidth() || !buffer->getHeight()) {
     69            *reason = "attachment has a 0 dimension";
    6270            return false;
     71        }
    6372        return true;
    6473    }
     
    320329}
    321330
    322 GC3Denum WebGLFramebuffer::checkStatus() const
     331GC3Denum WebGLFramebuffer::checkStatus(const char** reason) const
    323332{
    324333    unsigned int count = 0;
    325334    GC3Dsizei width = 0, height = 0;
    326335    if (isDepthAttached()) {
    327         if (!isAttachmentComplete(m_depthAttachment.get(), GraphicsContext3D::DEPTH_ATTACHMENT))
     336        if (!isAttachmentComplete(m_depthAttachment.get(), GraphicsContext3D::DEPTH_ATTACHMENT, reason))
    328337            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
    329338        width = getImageWidth(m_depthAttachment.get());
     
    332341    }
    333342    if (isStencilAttached()) {
    334         if (!isAttachmentComplete(m_stencilAttachment.get(), GraphicsContext3D::STENCIL_ATTACHMENT))
     343        if (!isAttachmentComplete(m_stencilAttachment.get(), GraphicsContext3D::STENCIL_ATTACHMENT, reason))
    335344            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
    336345        if (!count) {
     
    338347            height = getImageHeight(m_stencilAttachment.get());
    339348        } else {
    340             if (width != getImageWidth(m_stencilAttachment.get()) || height != getImageHeight(m_stencilAttachment.get()))
     349            if (width != getImageWidth(m_stencilAttachment.get()) || height != getImageHeight(m_stencilAttachment.get())) {
     350                *reason = "STENCIL_ATTACHMENT has different dimensions than DEPTH_ATTACHMENT";
    341351                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
     352            }
    342353        }
    343354        count++;
    344355    }
    345356    if (isDepthStencilAttached()) {
    346         if (!isAttachmentComplete(m_depthStencilAttachment.get(), GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT))
     357        if (!isAttachmentComplete(m_depthStencilAttachment.get(), GraphicsContext3D::DEPTH_STENCIL_ATTACHMENT, reason))
    347358            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
    348         if (!isValidRenderbuffer(m_depthStencilAttachment.get()))
     359        if (!isValidRenderbuffer(m_depthStencilAttachment.get())) {
     360            *reason = "DEPTH_STENCIL_ATTACHMENT is not valid";
    349361            return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
     362        }
    350363        if (!count) {
    351364            width = getImageWidth(m_depthStencilAttachment.get());
    352365            height = getImageHeight(m_depthStencilAttachment.get());
    353366        } else {
    354             if (width != getImageWidth(m_depthStencilAttachment.get()) || height != getImageHeight(m_depthStencilAttachment.get()))
     367            if (width != getImageWidth(m_depthStencilAttachment.get()) || height != getImageHeight(m_depthStencilAttachment.get())) {
     368                *reason = "DEPTH_STENCIL_ATTACHMENT has different dimensions than other attachments";
    355369                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
     370            }
    356371        }
    357372        count++;
    358373    }
    359374    // WebGL specific: no conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments.
    360     if (count > 1)
     375    if (count > 1) {
     376        *reason = "conflicting DEPTH/STENCIL/DEPTH_STENCIL attachments";
    361377        return GraphicsContext3D::FRAMEBUFFER_UNSUPPORTED;
     378    }
    362379    if (isColorAttached()) {
    363380        // FIXME: if color buffer is texture, is ALPHA, LUMINANCE or LUMINANCE_ALPHA valid?
    364         if (!getColorBufferFormat())
     381        if (!getColorBufferFormat()) {
     382            *reason = "COLOR_ATTACHMENT0 is an unsupported format";
    365383            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
     384        }
    366385        if (!count) {
    367             if (!getColorBufferWidth() || !getColorBufferHeight())
     386            if (!getColorBufferWidth() || !getColorBufferHeight())  {
     387                *reason = "COLOR_ATTACHMENT0 has a 0 dimension";
    368388                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_ATTACHMENT;
     389            }
    369390        } else {
    370             if (width != getColorBufferWidth() || height != getColorBufferHeight())
     391            if (width != getColorBufferWidth() || height != getColorBufferHeight())  {
     392                *reason = "COLOR_ATTACHMENT0 has different dimensions than other attachments";
    371393                return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_DIMENSIONS;
    372         }
     394            }
     395        }
     396
    373397    } else {
    374         if (!count)
     398        if (!count) {
     399            *reason = "no attachments";
    375400            return GraphicsContext3D::FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT;
     401        }
    376402    }
    377403    return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
    378404}
    379405
    380 bool WebGLFramebuffer::onAccess(GraphicsContext3D* context3d, bool needToInitializeRenderbuffers)
    381 {
    382     if (checkStatus() != GraphicsContext3D::FRAMEBUFFER_COMPLETE)
     406bool WebGLFramebuffer::onAccess(GraphicsContext3D* context3d, bool needToInitializeRenderbuffers, const char** reason)
     407{
     408    if (checkStatus(reason) != GraphicsContext3D::FRAMEBUFFER_COMPLETE)
    383409        return false;
    384410    if (needToInitializeRenderbuffers)
    385         return initializeRenderbuffers(context3d);
     411        return initializeRenderbuffers(context3d, reason);
    386412    return true;
    387413}
     
    405431}
    406432
    407 bool WebGLFramebuffer::initializeRenderbuffers(GraphicsContext3D* g3d)
     433bool WebGLFramebuffer::initializeRenderbuffers(GraphicsContext3D* g3d, const char** reason)
    408434{
    409435    ASSERT(object());
     
    432458    // We only clear un-initialized renderbuffers when they are ready to be
    433459    // read, i.e., when the framebuffer is complete.
    434     if (g3d->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE)
     460    if (g3d->checkFramebufferStatus(GraphicsContext3D::FRAMEBUFFER) != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     461        *reason = "framebuffer not complete";
    435462        return false;
     463    }
    436464
    437465    GC3Dfloat colorClearValue[] = {0, 0, 0, 0}, depthClearValue = 0;
  • trunk/Source/WebCore/html/canvas/WebGLFramebuffer.h

    r115870 r117506  
    6262    // the buffers if they haven't been initialized and
    6363    // needToInitializeRenderbuffers is true.
    64     bool onAccess(GraphicsContext3D*, bool needToInitializeRenderbuffers);
     64    bool onAccess(GraphicsContext3D*, bool needToInitializeRenderbuffers, const char** reason);
    6565
    6666    // Software version of glCheckFramebufferStatus(), except that when
     
    6868    // glCheckFramebufferStatus() to return FRAMEBUFFER_UNSUPPORTED,
    6969    // depending on hardware implementation.
    70     GC3Denum checkStatus() const;
     70    GC3Denum checkStatus(const char** reason) const;
    7171
    7272    bool hasEverBeenBound() const { return object() && m_hasEverBeenBound; }
     
    8585
    8686    // Return false if framebuffer is incomplete.
    87     bool initializeRenderbuffers(GraphicsContext3D*);
     87    bool initializeRenderbuffers(GraphicsContext3D*, const char** reason);
    8888
    8989    // Check if the framebuffer is currently bound.
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r117379 r117506  
    11661166    if (!m_framebufferBinding || !m_framebufferBinding->object())
    11671167        return GraphicsContext3D::FRAMEBUFFER_COMPLETE;
    1168     GC3Denum result = m_framebufferBinding->checkStatus();
    1169     if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE)
     1168    const char* reason = "framebuffer incomplete";
     1169    GC3Denum result = m_framebufferBinding->checkStatus(&reason);
     1170    if (result != GraphicsContext3D::FRAMEBUFFER_COMPLETE) {
     1171        printGLWarningToConsole("checkFramebufferStatus", reason);
    11701172        return result;
     1173    }
    11711174    result = m_context->checkFramebufferStatus(target);
    11721175    cleanupAfterGraphicsCall(false);
     
    11821185        return;
    11831186    }
    1184     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    1185         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "clear", "can not render to framebuffer");
     1187    const char* reason = "framebuffer incomplete";
     1188    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     1189        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "clear", reason);
    11861190        return;
    11871191    }
     
    13341338        return;
    13351339    }
    1336     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    1337         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", "framebuffer not readable");
     1340    const char* reason = "framebuffer incomplete";
     1341    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     1342        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexImage2D", reason);
    13381343        return;
    13391344    }
     
    13801385        return;
    13811386    }
    1382     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    1383         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", "framebuffer not readable");
     1387    const char* reason = "framebuffer incomplete";
     1388    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     1389        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "copyTexSubImage2D", reason);
    13841390        return;
    13851391    }
     
    18791885    }
    18801886
    1881     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    1882         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawArrays", "framebuffer can not be rendered to");
     1887    const char* reason = "framebuffer incomplete";
     1888    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     1889        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawArrays", reason);
    18831890        return;
    18841891    }
     
    19531960    }
    19541961
    1955     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    1956         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawElements", "framebuffer can not be rendered to");
     1962    const char* reason = "framebuffer incomplete";
     1963    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     1964        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "drawElements", reason);
    19571965        return;
    19581966    }
     
    32563264        return;
    32573265    }
    3258     if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe())) {
    3259         synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "readPixels", "framebuffer not readable");
     3266    const char* reason = "framebuffer incomplete";
     3267    if (m_framebufferBinding && !m_framebufferBinding->onAccess(graphicsContext3D(), !isResourceSafe(), &reason)) {
     3268        synthesizeGLError(GraphicsContext3D::INVALID_FRAMEBUFFER_OPERATION, "readPixels", reason);
    32603269        return;
    32613270    }
     
    55335542
    55345543
     5544void WebGLRenderingContext::printGLWarningToConsole(const char* functionName, const char* description)
     5545{
     5546    if (m_synthesizedErrorsToConsole) {
     5547        String str = String("WebGL: ") + String(functionName) + ": " + String(description);
     5548        printGLErrorToConsole(str);
     5549    }
     5550}
     5551
    55355552void WebGLRenderingContext::applyStencilTest()
    55365553{
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.h

    r116374 r117506  
    635635    // Helper function to print GL errors to console.
    636636    void printGLErrorToConsole(const String&);
     637    void printGLWarningToConsole(const char* function, const char* reason);
    637638
    638639    // Helper function to print warnings to console. Currently
Note: See TracChangeset for help on using the changeset viewer.