Skip to content
Permalink
Browse files
2010-10-14 Zhenyao Mo <zmo@google.com>
        Reviewed by Kenneth Russell.

        Cache link status at linkProgram and use it in useProgram instead of querying GPU
        https://bugs.webkit.org/show_bug.cgi?id=47685

        * html/canvas/WebGLProgram.cpp: Always cache link status at linkStatus and use it upon query.
        (WebCore::WebGLProgram::WebGLProgram):
        * html/canvas/WebGLProgram.h: Ditto.
        (WebCore::WebGLProgram::getLinkStatus):
        (WebCore::WebGLProgram::setLinkStatus):
        * html/canvas/WebGLRenderingContext.cpp: Ditto.
        (WebCore::WebGLRenderingContext::getProgramParameter):
        (WebCore::WebGLRenderingContext::linkProgram):
        (WebCore::WebGLRenderingContext::useProgram):


Canonical link: https://commits.webkit.org/60389@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69804 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Zhenyao Mo committed Oct 14, 2010
1 parent 7ee56ff commit 6dee5877ba5ac93e71421b2c62ccbc7188d693e9
Showing 4 changed files with 29 additions and 14 deletions.
@@ -1,3 +1,20 @@
2010-10-14 Zhenyao Mo <zmo@google.com>

Reviewed by Kenneth Russell.

Cache link status at linkProgram and use it in useProgram instead of querying GPU
https://bugs.webkit.org/show_bug.cgi?id=47685

* html/canvas/WebGLProgram.cpp: Always cache link status at linkStatus and use it upon query.
(WebCore::WebGLProgram::WebGLProgram):
* html/canvas/WebGLProgram.h: Ditto.
(WebCore::WebGLProgram::getLinkStatus):
(WebCore::WebGLProgram::setLinkStatus):
* html/canvas/WebGLRenderingContext.cpp: Ditto.
(WebCore::WebGLRenderingContext::getProgramParameter):
(WebCore::WebGLRenderingContext::linkProgram):
(WebCore::WebGLRenderingContext::useProgram):

2010-10-14 Justin Schuh <jschuh@chromium.org>

Reviewed by James Robinson.
@@ -40,7 +40,7 @@ PassRefPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContext* ctx)

WebGLProgram::WebGLProgram(WebGLRenderingContext* ctx)
: WebGLObject(ctx)
, m_linkFailure(false)
, m_linkStatus(false)
{
setObject(context()->graphicsContext3D()->createProgram());
}
@@ -50,11 +50,8 @@ class WebGLProgram : public WebGLObject {

bool isUsingVertexAttrib0() const;

// Return true means getProgramParameter(LINK_STATUS) should return
// false; return false means we should actually call
// getProgramParameter(LINK_STATUS) to find out.
bool isLinkFailureFlagSet() const { return m_linkFailure; }
void setLinkFailureFlag(bool failed) { m_linkFailure = failed; }
bool getLinkStatus() const { return m_linkStatus; }
void setLinkStatus(bool status) { m_linkStatus = status; }

WebGLShader* getAttachedShader(GraphicsContext3D::WebGLEnumType);
bool attachShader(WebGLShader*);
@@ -70,7 +67,7 @@ class WebGLProgram : public WebGLObject {

Vector<int> m_activeAttribLocations;

bool m_linkFailure;
bool m_linkStatus;

RefPtr<WebGLShader> m_vertexShader;
RefPtr<WebGLShader> m_fragmentShader;
@@ -1484,10 +1484,7 @@ WebGLGetInfo WebGLRenderingContext::getProgramParameter(WebGLProgram* program, u
m_context->getProgramiv(objectOrZero(program), pname, &value);
return WebGLGetInfo(static_cast<bool>(value));
case GraphicsContext3D::LINK_STATUS:
if (program->isLinkFailureFlagSet())
return WebGLGetInfo(false);
m_context->getProgramiv(objectOrZero(program), pname, &value);
return WebGLGetInfo(static_cast<bool>(value));
return WebGLGetInfo(program->getLinkStatus());
case GraphicsContext3D::INFO_LOG_LENGTH:
case GraphicsContext3D::ATTACHED_SHADERS:
case GraphicsContext3D::ACTIVE_ATTRIBUTES:
@@ -1897,14 +1894,17 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
return;
if (!isGLES2Compliant()) {
if (!program->getAttachedShader(GraphicsContext3D::VERTEX_SHADER) || !program->getAttachedShader(GraphicsContext3D::FRAGMENT_SHADER)) {
program->setLinkFailureFlag(true);
program->setLinkStatus(false);
return;
}
program->setLinkFailureFlag(false);
}

m_context->linkProgram(objectOrZero(program));
program->cacheActiveAttribLocations();
// cache link status
int value = 0;
m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::LINK_STATUS, &value);
program->setLinkStatus(static_cast<bool>(value));
cleanupAfterGraphicsCall(false);
}

@@ -2714,11 +2714,12 @@ void WebGLRenderingContext::uniformMatrix4fv(const WebGLUniformLocation* locatio

void WebGLRenderingContext::useProgram(WebGLProgram* program, ExceptionCode& ec)
{
UNUSED_PARAM(ec);
if (program && program->context() != this) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return;
}
if (program && program->object() && !getProgramParameter(program, GraphicsContext3D::LINK_STATUS, ec).getBool()) {
if (program && program->object() && !program->getLinkStatus()) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
cleanupAfterGraphicsCall(false);
return;

0 comments on commit 6dee587

Please sign in to comment.