Bug 681835: fixed a series of object deletion conformance issues r=bjacob

The bindX() commands were erroring with INVALID_VALUE when they're instead supposed to simply fail silently when they're given a deleted object. Additionally, the getParameter() function was failing after its associated variable was deleted, sometimes returning values when it should return null.
* * *
Bug 681835: WebGL fix for previous patch which introduced a bug with deletion

DeleteRenderbuffer and DeleteFramebuffer weren't checking if the deleted buffer was the currently bound buffer before deleting them. This patch implements this functionality. A separate test case patch was also submitted to Khronos:
http://www.khronos.org/bugzilla/show_bug.cgi?id=518
This commit is contained in:
Doug Sherk 2011-09-01 15:28:34 -04:00
parent a32b0c9e31
commit b3837749e5
4 changed files with 34 additions and 16 deletions

View File

@ -201,8 +201,13 @@ WebGLContext::BindBuffer(WebGLenum target, nsIWebGLBuffer *bobj)
{ {
WebGLuint bufname; WebGLuint bufname;
WebGLBuffer* buf; WebGLBuffer* buf;
PRBool isNull; PRBool isNull; // allow null objects
if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull)) PRBool isDeleted; // allow deleted objects
if (!GetConcreteObjectAndGLName("bindBuffer", bobj, &buf, &bufname, &isNull, &isDeleted))
return NS_OK;
// silently ignore a deleted buffer
if (isDeleted)
return NS_OK; return NS_OK;
if (target != LOCAL_GL_ARRAY_BUFFER && if (target != LOCAL_GL_ARRAY_BUFFER &&
@ -237,13 +242,18 @@ NS_IMETHODIMP
WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj) WebGLContext::BindFramebuffer(WebGLenum target, nsIWebGLFramebuffer *fbobj)
{ {
WebGLuint framebuffername; WebGLuint framebuffername;
PRBool isNull; PRBool isNull; // allow null objects
PRBool isDeleted; // allow deleted objects
WebGLFramebuffer *wfb; WebGLFramebuffer *wfb;
if (target != LOCAL_GL_FRAMEBUFFER) if (target != LOCAL_GL_FRAMEBUFFER)
return ErrorInvalidEnum("BindFramebuffer: target must be GL_FRAMEBUFFER"); return ErrorInvalidEnum("BindFramebuffer: target must be GL_FRAMEBUFFER");
if (!GetConcreteObjectAndGLName("bindFramebuffer", fbobj, &wfb, &framebuffername, &isNull)) if (!GetConcreteObjectAndGLName("bindFramebuffer", fbobj, &wfb, &framebuffername, &isNull, &isDeleted))
return NS_OK;
// silently ignore a deleted frame buffer
if (isDeleted)
return NS_OK; return NS_OK;
MakeContextCurrent(); MakeContextCurrent();
@ -264,13 +274,18 @@ NS_IMETHODIMP
WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj) WebGLContext::BindRenderbuffer(WebGLenum target, nsIWebGLRenderbuffer *rbobj)
{ {
WebGLuint renderbuffername; WebGLuint renderbuffername;
PRBool isNull; PRBool isNull; // allow null objects
PRBool isDeleted; // allow deleted objects
WebGLRenderbuffer *wrb; WebGLRenderbuffer *wrb;
if (target != LOCAL_GL_RENDERBUFFER) if (target != LOCAL_GL_RENDERBUFFER)
return ErrorInvalidEnumInfo("bindRenderbuffer: target", target); return ErrorInvalidEnumInfo("bindRenderbuffer: target", target);
if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull)) if (!GetConcreteObjectAndGLName("bindRenderBuffer", rbobj, &wrb, &renderbuffername, &isNull, &isDeleted))
return NS_OK;
// silently ignore a deleted buffer
if (isDeleted)
return NS_OK; return NS_OK;
if (!isNull) if (!isNull)
@ -290,8 +305,13 @@ WebGLContext::BindTexture(WebGLenum target, nsIWebGLTexture *tobj)
{ {
WebGLuint texturename; WebGLuint texturename;
WebGLTexture *tex; WebGLTexture *tex;
PRBool isNull; // allow null object PRBool isNull; // allow null objects
if (!GetConcreteObjectAndGLName("bindTexture", tobj, &tex, &texturename, &isNull)) PRBool isDeleted; // allow deleted objects
if (!GetConcreteObjectAndGLName("bindTexture", tobj, &tex, &texturename, &isNull, &isDeleted))
return NS_OK;
// silently ignore a deleted texture
if (isDeleted)
return NS_OK; return NS_OK;
if (target == LOCAL_GL_TEXTURE_2D) { if (target == LOCAL_GL_TEXTURE_2D) {
@ -1063,6 +1083,9 @@ WebGLContext::DeleteFramebuffer(nsIWebGLFramebuffer *fbobj)
fbuf->Delete(); fbuf->Delete();
mMapFramebuffers.Remove(fbufname); mMapFramebuffers.Remove(fbufname);
if (mBoundFramebuffer && mBoundFramebuffer->GLName() == fbufname)
mBoundFramebuffer = NULL;
return NS_OK; return NS_OK;
} }
@ -1093,10 +1116,12 @@ WebGLContext::DeleteRenderbuffer(nsIWebGLRenderbuffer *rbobj)
*/ */
gl->fDeleteRenderbuffers(1, &rbufname); gl->fDeleteRenderbuffers(1, &rbufname);
rbuf->Delete(); rbuf->Delete();
mMapRenderbuffers.Remove(rbufname); mMapRenderbuffers.Remove(rbufname);
if (mBoundRenderbuffer && mBoundRenderbuffer->GLName() == rbufname)
mBoundRenderbuffer = NULL;
return NS_OK; return NS_OK;
} }
@ -2197,10 +2222,6 @@ WebGLContext::GetFramebufferAttachmentParameter(WebGLenum target, WebGLenum atta
wrval->SetAsInt32(LOCAL_GL_NONE); wrval->SetAsInt32(LOCAL_GL_NONE);
break; break;
case LOCAL_GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME:
wrval->SetAsEmpty();
break;
default: default:
return ErrorInvalidEnumInfo("GetFramebufferAttachmentParameter: pname", pname); return ErrorInvalidEnumInfo("GetFramebufferAttachmentParameter: pname", pname);
} }

View File

@ -12,7 +12,6 @@ conformance/gl-getshadersource.html
conformance/gl-uniform-bool.html conformance/gl-uniform-bool.html
conformance/glsl-conformance.html conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html conformance/glsl-long-variable-names.html
conformance/object-deletion-behaviour.html
conformance/premultiplyalpha-test.html conformance/premultiplyalpha-test.html
conformance/read-pixels-test.html conformance/read-pixels-test.html
conformance/uninitialized-test.html conformance/uninitialized-test.html

View File

@ -6,7 +6,6 @@ conformance/gl-getshadersource.html
conformance/gl-object-get-calls.html conformance/gl-object-get-calls.html
conformance/glsl-conformance.html conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html conformance/glsl-long-variable-names.html
conformance/object-deletion-behaviour.html
conformance/premultiplyalpha-test.html conformance/premultiplyalpha-test.html
conformance/program-test.html conformance/program-test.html
conformance/read-pixels-test.html conformance/read-pixels-test.html

View File

@ -4,7 +4,6 @@ conformance/framebuffer-object-attachment.html
conformance/gl-getshadersource.html conformance/gl-getshadersource.html
conformance/glsl-conformance.html conformance/glsl-conformance.html
conformance/glsl-long-variable-names.html conformance/glsl-long-variable-names.html
conformance/object-deletion-behaviour.html
conformance/premultiplyalpha-test.html conformance/premultiplyalpha-test.html
conformance/read-pixels-test.html conformance/read-pixels-test.html
conformance/more/conformance/quickCheckAPI.html conformance/more/conformance/quickCheckAPI.html