Changeset 156971 in webkit


Ignore:
Timestamp:
Oct 5, 2013, 12:27:35 PM (12 years ago)
Author:
dino@apple.com
Message:

[WebGL] program should not be able to link if a bad shader is attached
https://bugs.webkit.org/show_bug.cgi?id=94036

Reviewed by Darin Adler.

If you attempt to link a program when bad shaders are attached, the
link should fail. WebGL also requires that the previously linked
program should remain intact. We were doing the former, but not
the latter.

Fix this by not calling glLinkProgram if we know we have bad
shaders, and synthesize a bad link status instead.

Test: WebGL conformance test conformance/programs/program-test.html
(found in LayoutTests/webgl)

  • html/canvas/WebGLRenderingContext.cpp:

(WebCore::WebGLRenderingContext::compileShader): Mark a shader as valid
if it compiled ok.
(WebCore::WebGLRenderingContext::linkProgram): Don't call into GraphicsContext3D::linkProgram
if we know that we don't have valid shaders.

  • html/canvas/WebGLShader.cpp:

(WebCore::WebGLShader::WebGLShader): Initialize m_isValid.

  • html/canvas/WebGLShader.h:

(WebCore::WebGLShader::isValid): New member variable getter and setter.
(WebCore::WebGLShader::setValid):

Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r156970 r156971  
     12013-10-04  Dean Jackson  <dino@apple.com>
     2
     3        [WebGL] program should not be able to link if a bad shader is attached
     4        https://bugs.webkit.org/show_bug.cgi?id=94036
     5
     6        Reviewed by Darin Adler.
     7
     8        If you attempt to link a program when bad shaders are attached, the
     9        link should fail. WebGL also requires that the previously linked
     10        program should remain intact. We were doing the former, but not
     11        the latter.
     12
     13        Fix this by not calling glLinkProgram if we know we have bad
     14        shaders, and synthesize a bad link status instead.
     15
     16        Test: WebGL conformance test conformance/programs/program-test.html
     17        (found in LayoutTests/webgl)
     18
     19        * html/canvas/WebGLRenderingContext.cpp:
     20        (WebCore::WebGLRenderingContext::compileShader): Mark a shader as valid
     21        if it compiled ok.
     22        (WebCore::WebGLRenderingContext::linkProgram): Don't call into GraphicsContext3D::linkProgram
     23        if we know that we don't have valid shaders.
     24        * html/canvas/WebGLShader.cpp:
     25        (WebCore::WebGLShader::WebGLShader): Initialize m_isValid.
     26        * html/canvas/WebGLShader.h:
     27        (WebCore::WebGLShader::isValid): New member variable getter and setter.
     28        (WebCore::WebGLShader::setValid):
     29
    1302013-10-05  Dean Jackson  <dino@apple.com>
    231
  • trunk/Source/WebCore/html/canvas/WebGLRenderingContext.cpp

    r156970 r156971  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    12991299        return;
    13001300    m_context->compileShader(objectOrZero(shader));
     1301    GC3Dint value;
     1302    m_context->getShaderiv(objectOrZero(shader), GraphicsContext3D::COMPILE_STATUS, &value);
     1303    shader->setValid(value);
    13011304    cleanupAfterGraphicsCall(false);
    13021305}
     
    33233326        return;
    33243327    if (!isGLES2Compliant()) {
    3325         if (!program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER) || !program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER)) {
     3328        WebGLShader* vertexShader = program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER);
     3329        WebGLShader* fragmentShader = program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER);
     3330        if (!vertexShader || !vertexShader->isValid() || !fragmentShader || !fragmentShader->isValid()) {
    33263331            program->setLinkStatus(false);
    33273332            return;
  • trunk/Source/WebCore/html/canvas/WebGLShader.cpp

    r104954 r156971  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444    , m_type(type)
    4545    , m_source("")
     46    , m_isValid(false)
    4647{
    4748    setObject(ctx->graphicsContext3D()->createShader(type));
  • trunk/Source/WebCore/html/canvas/WebGLShader.h

    r151947 r156971  
    11/*
    2  * Copyright (C) 2009 Apple Inc. All rights reserved.
     2 * Copyright (C) 2009, 2013 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    4444    void setSource(const String& source) { m_source = source; }
    4545
     46    bool isValid() const { return m_isValid; }
     47    void setValid(bool valid) { m_isValid = valid; }
     48
    4649private:
    4750    WebGLShader(WebGLRenderingContext*, GC3Denum);
     
    5356    GC3Denum m_type;
    5457    String m_source;
     58    bool m_isValid;
    5559};
    5660
Note: See TracChangeset for help on using the changeset viewer.