[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-10851-g50815da
zmo at google.com
zmo at google.com
Wed Dec 22 18:14:33 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit 32c2739e0adbfbd49e2778b11e380d8ee3c59c74
Author: zmo at google.com <zmo at google.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Thu Dec 9 01:38:56 2010 +0000
2010-12-07 Zhenyao Mo <zmo at google.com>
Reviewed by Kenneth Russell.
WebGLUniformLocation objects must be invalidated during linkProgram
https://bugs.webkit.org/show_bug.cgi?id=37118
* html/canvas/WebGLProgram.cpp:
(WebCore::WebGLProgram::WebGLProgram): Initialize link count to 0.
(WebCore::WebGLProgram::cacheActiveAttribLocations): Don't check link status through gl call; use the cached status instead.
* html/canvas/WebGLProgram.h:
(WebCore::WebGLProgram::getLinkCount): Get link count.
(WebCore::WebGLProgram::increaseLinkCount): Increase link count by 1.
* html/canvas/WebGLRenderingContext.cpp:
(WebCore::WebGLRenderingContext::getUniform): Fix a bug where wrong error is generated.
(WebCore::WebGLRenderingContext::linkProgram): call increaseLinkCount after linkProgram.
* html/canvas/WebGLUniformLocation.cpp:
(WebCore::WebGLUniformLocation::WebGLUniformLocation): Set program's link count upon creation.
(WebCore::WebGLUniformLocation::program): Return null if count doesn't match the program's.
(WebCore::WebGLUniformLocation::location): Return -1 if count doesn't match the program's.
* html/canvas/WebGLUniformLocation.h:
2010-12-07 Zhenyao Mo <zmo at google.com>
Reviewed by Kenneth Russell.
WebGLUniformLocation objects must be invalidated during linkProgram
https://bugs.webkit.org/show_bug.cgi?id=37118
* fast/canvas/webgl/uniform-location-expected.txt:
* fast/canvas/webgl/uniform-location.html: Check that after linkProgram, all previous uniform locations become invalid.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73573 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 3cb9146..8680be2 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,13 @@
+2010-12-07 Zhenyao Mo <zmo at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ WebGLUniformLocation objects must be invalidated during linkProgram
+ https://bugs.webkit.org/show_bug.cgi?id=37118
+
+ * fast/canvas/webgl/uniform-location-expected.txt:
+ * fast/canvas/webgl/uniform-location.html: Check that after linkProgram, all previous uniform locations become invalid.
+
2010-12-08 Adele Peterson <adele at apple.com>
Reviewed by Darin Adler.
diff --git a/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt b/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
index 8077f00..8006db3 100644
--- a/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
+++ b/LayoutTests/fast/canvas/webgl/uniform-location-expected.txt
@@ -10,14 +10,22 @@ PASS contextA.uniformMatrix4fv(null, false, mat) generated expected GL error: NO
PASS contextA.useProgram(programS) generated expected GL error: NO_ERROR.
PASS contextA.uniform1i(locationSx, 3) generated expected GL error: NO_ERROR.
PASS contextA.uniform1f(locationArray0, 4.0) generated expected GL error: NO_ERROR.
+PASS contextA.uniform1f(locationArray1, 5.0) generated expected GL error: NO_ERROR.
PASS contextA.getUniform(programS, locationSx) is 3
PASS contextA.getUniform(programS, locationArray0) is 4.0
+PASS contextA.getUniform(programS, locationArray1) is 5.0
PASS contextA.useProgram(programV) generated expected GL error: NO_ERROR.
PASS contextA.uniform4fv(locationVec4, vec) generated expected GL error: NO_ERROR.
PASS contextA.getUniform(programV, locationVec4) is vec
PASS contextA.getUniformLocation(programV, "IDontExist") is null
PASS contextA.linkProgram(programA1) generated expected GL error: NO_ERROR.
PASS contextA.uniformMatrix4fv(locationA, false, mat) generated expected GL error: INVALID_OPERATION.
+PASS contextA.useProgram(programS) generated expected GL error: NO_ERROR.
+PASS contextA.linkProgram(programS) generated expected GL error: NO_ERROR.
+PASS contextA.uniform1i(locationSx, 3) generated expected GL error: INVALID_OPERATION.
+PASS contextA.getUniform(programS, locationSx) generated expected GL error: INVALID_OPERATION.
+PASS contextA.uniform1i(locationSx, 3) generated expected GL error: NO_ERROR.
+PASS contextA.getUniform(programS, locationSx) is 3
PASS successfullyParsed is true
TEST COMPLETE
diff --git a/LayoutTests/fast/canvas/webgl/uniform-location.html b/LayoutTests/fast/canvas/webgl/uniform-location.html
index f055ad0..060d43f 100644
--- a/LayoutTests/fast/canvas/webgl/uniform-location.html
+++ b/LayoutTests/fast/canvas/webgl/uniform-location.html
@@ -22,6 +22,7 @@ var locationA = contextA.getUniformLocation(programA1, 'u_modelViewProjMatrix');
var locationB = contextB.getUniformLocation(programB, 'u_modelViewProjMatrix');
var locationSx = contextA.getUniformLocation(programS, "u_struct.x");
var locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
+var locationArray1 = contextA.getUniformLocation(programS, "u_array[1]");
var locationVec4 = contextA.getUniformLocation(programV, "fval4");
var vec = [1, 2, 3, 4];
@@ -36,9 +37,11 @@ shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniformMatrix4fv(nu
shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray0, 4.0)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1f(locationArray1, 5.0)");
shouldBe("contextA.getUniform(programS, locationSx)", "3");
shouldBe("contextA.getUniform(programS, locationArray0)", "4.0");
+shouldBe("contextA.getUniform(programS, locationArray1)", "5.0");
shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programV)");
shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform4fv(locationVec4, vec)");
@@ -49,6 +52,18 @@ shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(program
// After linking all boxes are bad.
shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniformMatrix4fv(locationA, false, mat)");
+// after re-linking the same program, all uniform locations become invalid.
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.useProgram(programS)");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.linkProgram(programS)");
+shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.uniform1i(locationSx, 3)");
+shouldGenerateGLError(contextA, contextA.INVALID_OPERATION, "contextA.getUniform(programS, locationSx)");
+
+// Retrieve the locations again, and they should be good.
+locationSx = contextA.getUniformLocation(programS, "u_struct.x");
+locationArray0 = contextA.getUniformLocation(programS, "u_array[0]");
+shouldGenerateGLError(contextA, contextA.NO_ERROR, "contextA.uniform1i(locationSx, 3)");
+shouldBe("contextA.getUniform(programS, locationSx)", "3");
+
successfullyParsed = true;
</script>
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index f498138..f2977b4 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,25 @@
+2010-12-07 Zhenyao Mo <zmo at google.com>
+
+ Reviewed by Kenneth Russell.
+
+ WebGLUniformLocation objects must be invalidated during linkProgram
+ https://bugs.webkit.org/show_bug.cgi?id=37118
+
+ * html/canvas/WebGLProgram.cpp:
+ (WebCore::WebGLProgram::WebGLProgram): Initialize link count to 0.
+ (WebCore::WebGLProgram::cacheActiveAttribLocations): Don't check link status through gl call; use the cached status instead.
+ * html/canvas/WebGLProgram.h:
+ (WebCore::WebGLProgram::getLinkCount): Get link count.
+ (WebCore::WebGLProgram::increaseLinkCount): Increase link count by 1.
+ * html/canvas/WebGLRenderingContext.cpp:
+ (WebCore::WebGLRenderingContext::getUniform): Fix a bug where wrong error is generated.
+ (WebCore::WebGLRenderingContext::linkProgram): call increaseLinkCount after linkProgram.
+ * html/canvas/WebGLUniformLocation.cpp:
+ (WebCore::WebGLUniformLocation::WebGLUniformLocation): Set program's link count upon creation.
+ (WebCore::WebGLUniformLocation::program): Return null if count doesn't match the program's.
+ (WebCore::WebGLUniformLocation::location): Return -1 if count doesn't match the program's.
+ * html/canvas/WebGLUniformLocation.h:
+
2010-12-08 Adele Peterson <adele at apple.com>
Reviewed by Darin Adler.
diff --git a/WebCore/html/canvas/WebGLProgram.cpp b/WebCore/html/canvas/WebGLProgram.cpp
index 53706fe..b2c2086 100644
--- a/WebCore/html/canvas/WebGLProgram.cpp
+++ b/WebCore/html/canvas/WebGLProgram.cpp
@@ -41,6 +41,7 @@ PassRefPtr<WebGLProgram> WebGLProgram::create(WebGLRenderingContext* ctx)
WebGLProgram::WebGLProgram(WebGLRenderingContext* ctx)
: WebGLObject(ctx)
, m_linkStatus(false)
+ , m_linkCount(0)
{
setObject(context()->graphicsContext3D()->createProgram());
}
@@ -64,9 +65,9 @@ bool WebGLProgram::cacheActiveAttribLocations()
if (!object())
return false;
GraphicsContext3D* context3d = context()->graphicsContext3D();
- int linkStatus = 0;
- context3d->getProgramiv(object(), GraphicsContext3D::LINK_STATUS, &linkStatus);
- if (!linkStatus)
+
+ // Assume link status has already been cached.
+ if (!m_linkStatus)
return false;
int numAttribs = 0;
diff --git a/WebCore/html/canvas/WebGLProgram.h b/WebCore/html/canvas/WebGLProgram.h
index 3b88fdd..6b89ae5 100644
--- a/WebCore/html/canvas/WebGLProgram.h
+++ b/WebCore/html/canvas/WebGLProgram.h
@@ -53,6 +53,13 @@ public:
bool getLinkStatus() const { return m_linkStatus; }
void setLinkStatus(bool status) { m_linkStatus = status; }
+ unsigned long getLinkCount() const { return m_linkCount; }
+
+ // This is to be called everytime after the program is successfully linked.
+ // We don't deal with integer overflow here, assuming in reality a program
+ // will never be linked so many times.
+ void increaseLinkCount() { ++m_linkCount; }
+
WebGLShader* getAttachedShader(GraphicsContext3D::WebGLEnumType);
bool attachShader(WebGLShader*);
bool detachShader(WebGLShader*);
@@ -69,6 +76,10 @@ private:
bool m_linkStatus;
+ // This is used to track whether a WebGLUniformLocation belongs to this
+ // program or not.
+ unsigned long m_linkCount;
+
RefPtr<WebGLShader> m_vertexShader;
RefPtr<WebGLShader> m_fragmentShader;
};
diff --git a/WebCore/html/canvas/WebGLRenderingContext.cpp b/WebCore/html/canvas/WebGLRenderingContext.cpp
index 90e8833..08e9ba8 100644
--- a/WebCore/html/canvas/WebGLRenderingContext.cpp
+++ b/WebCore/html/canvas/WebGLRenderingContext.cpp
@@ -1885,11 +1885,7 @@ WebGLGetInfo WebGLRenderingContext::getUniform(WebGLProgram* program, const WebG
UNUSED_PARAM(ec);
if (isContextLost() || !validateWebGLObject(program))
return WebGLGetInfo();
- if (!uniformLocation) {
- m_context->synthesizeGLError(GraphicsContext3D::INVALID_VALUE);
- return WebGLGetInfo();
- }
- if (uniformLocation->program() != program) {
+ if (!uniformLocation || uniformLocation->program() != program) {
m_context->synthesizeGLError(GraphicsContext3D::INVALID_OPERATION);
return WebGLGetInfo();
}
@@ -2208,11 +2204,13 @@ void WebGLRenderingContext::linkProgram(WebGLProgram* program, ExceptionCode& ec
}
m_context->linkProgram(objectOrZero(program));
- program->cacheActiveAttribLocations();
+ program->increaseLinkCount();
// cache link status
int value = 0;
m_context->getProgramiv(objectOrZero(program), GraphicsContext3D::LINK_STATUS, &value);
program->setLinkStatus(static_cast<bool>(value));
+ // Need to cache link status before caching active attribute locations.
+ program->cacheActiveAttribLocations();
cleanupAfterGraphicsCall(false);
}
diff --git a/WebCore/html/canvas/WebGLUniformLocation.cpp b/WebCore/html/canvas/WebGLUniformLocation.cpp
index 2157470..e67b09a 100644
--- a/WebCore/html/canvas/WebGLUniformLocation.cpp
+++ b/WebCore/html/canvas/WebGLUniformLocation.cpp
@@ -41,6 +41,25 @@ WebGLUniformLocation::WebGLUniformLocation(WebGLProgram* program, long location)
: m_program(program)
, m_location(location)
{
+ ASSERT(m_program);
+ m_linkCount = m_program->getLinkCount();
+}
+
+WebGLProgram* WebGLUniformLocation::program() const
+{
+ // If the program has been linked again, then this UniformLocation is no
+ // longer valid.
+ if (m_program->getLinkCount() != m_linkCount)
+ return 0;
+ return m_program.get();
+}
+
+long WebGLUniformLocation::location() const
+{
+ // If the program has been linked again, then this UniformLocation is no
+ // longer valid.
+ ASSERT(m_program->getLinkCount() == m_linkCount);
+ return m_location;
}
}
diff --git a/WebCore/html/canvas/WebGLUniformLocation.h b/WebCore/html/canvas/WebGLUniformLocation.h
index 66647c5..f8ce699 100644
--- a/WebCore/html/canvas/WebGLUniformLocation.h
+++ b/WebCore/html/canvas/WebGLUniformLocation.h
@@ -41,9 +41,9 @@ public:
static PassRefPtr<WebGLUniformLocation> create(WebGLProgram* program, long location);
- WebGLProgram* program() const { return m_program.get(); }
+ WebGLProgram* program() const;
- long location() const { return m_location; }
+ long location() const;
protected:
WebGLUniformLocation(WebGLProgram* program, long location);
@@ -51,6 +51,7 @@ protected:
private:
RefPtr<WebGLProgram> m_program;
long m_location;
+ unsigned long m_linkCount;
};
} // namespace WebCore
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list