Bug 682496: fixed program-test.html test failures

Fixed programs and shaders so that when they're marked for deletion and then detached completely, are deleted.
This commit is contained in:
Doug Sherk 2011-10-26 16:00:44 -04:00
Родитель c116f6ed5d
Коммит f8179e8309
3 изменённых файлов: 53 добавлений и 21 удалений

Просмотреть файл

@ -700,6 +700,7 @@ public:
friend class WebGLTexture;
friend class WebGLFramebuffer;
friend class WebGLProgram;
};
// this class is a mixin for the named type wrappers, and is used
@ -1388,21 +1389,36 @@ public:
WebGLShader(WebGLContext *context, WebGLuint name, WebGLenum stype) :
WebGLContextBoundObject(context),
mName(name), mDeleted(false), mType(stype),
mNeedsTranslation(true), mAttachCount(0)
mNeedsTranslation(true), mAttachCount(0),
mDeletePending(false)
{ }
void DetachedFromProgram() {
DecrementAttachCount();
if (mDeletePending && AttachCount() <= 0) {
Delete();
}
}
void Delete() {
if (mDeleted)
return;
ZeroOwners();
mDeleted = true;
if (AttachCount() > 0) {
mDeletePending = true;
return;
}
bool Deleted() { return mDeleted && mAttachCount == 0; }
ZeroOwners();
mDeleted = true;
mDeletePending = false;
}
bool Deleted() { return mDeleted; }
WebGLuint GLName() { return mName; }
WebGLenum ShaderType() { return mType; }
PRUint32 AttachCount() { return mAttachCount; }
PRInt32 AttachCount() { return mAttachCount; }
void IncrementAttachCount() { mAttachCount++; }
void DecrementAttachCount() { mAttachCount--; }
@ -1436,7 +1452,8 @@ protected:
nsString mSource;
nsCString mTranslationLog;
bool mNeedsTranslation;
PRUint32 mAttachCount;
PRInt32 mAttachCount;
bool mDeletePending;
};
NS_DEFINE_STATIC_IID_ACCESSOR(WebGLShader, WEBGLSHADER_PRIVATE_IID)
@ -1466,19 +1483,35 @@ public:
void Delete() {
if (mDeleted)
return;
if (mContext->mCurrentProgram == this) {
mDeletePending = true;
return;
}
DetachShaders();
ZeroOwners();
mDeleted = true;
mDeletePending = false;
}
void DetachShaders() {
for (PRUint32 i = 0; i < mAttachedShaders.Length(); ++i) {
if (mAttachedShaders[i])
mAttachedShaders[i]->DecrementAttachCount();
WebGLShader* shader = mAttachedShaders[i];
if (shader)
shader->DetachedFromProgram();
}
mAttachedShaders.Clear();
}
bool Deleted() { return mDeleted && !mDeletePending; }
void NoLongerCurrent() {
if (mDeletePending) {
DetachShaders();
Delete();
}
}
bool Deleted() { return mDeleted; }
void SetDeletePending() { mDeletePending = true; }
void ClearDeletePending() { mDeletePending = false; }
bool HasDeletePending() { return mDeletePending; }
@ -1505,7 +1538,7 @@ public:
// return true if the shader was found and removed
bool DetachShader(WebGLShader *shader) {
if (mAttachedShaders.RemoveElement(shader)) {
shader->DecrementAttachCount();
shader->DetachedFromProgram();
return true;
}
return false;

Просмотреть файл

@ -1159,12 +1159,6 @@ WebGLContext::DeleteProgram(nsIWebGLProgram *pobj)
gl->fDeleteProgram(progname);
if (prog == mCurrentProgram) {
prog->SetDeletePending();
} else {
prog->DetachShaders();
}
prog->Delete();
mMapPrograms.Remove(progname);
@ -1212,6 +1206,8 @@ WebGLContext::DetachShader(nsIWebGLProgram *pobj, nsIWebGLShader *shobj)
gl->fDetachShader(progname, shadername);
shader->DetachedFromProgram();
return NS_OK;
}
@ -2438,6 +2434,12 @@ WebGLContext::GetProgramParameter(nsIWebGLProgram *pobj, PRUint32 pname, nsIVari
break;
case LOCAL_GL_DELETE_STATUS:
case LOCAL_GL_LINK_STATUS:
{
GLint i = 0;
gl->fGetProgramiv(progname, pname, &i);
wrval->SetAsBool(bool(i));
}
break;
case LOCAL_GL_VALIDATE_STATUS:
{
GLint i = 0;
@ -3967,13 +3969,12 @@ WebGLContext::UseProgram(nsIWebGLProgram *pobj)
gl->fUseProgram(progname);
if (mCurrentProgram && mCurrentProgram->HasDeletePending()) {
mCurrentProgram->DetachShaders();
mCurrentProgram->ClearDeletePending();
}
WebGLProgram* previous = mCurrentProgram;
mCurrentProgram = prog;
if (previous)
previous->NoLongerCurrent();
return NS_OK;
}
@ -4191,7 +4192,6 @@ WebGLContext::GetShaderParameter(nsIWebGLShader *sobj, WebGLenum pname, nsIVaria
wrval->SetAsBool(bool(i));
}
break;
default:
return NS_ERROR_NOT_IMPLEMENTED;
}

Просмотреть файл

@ -5,7 +5,6 @@ conformance/glsl/misc/glsl-function-nodes.html
conformance/glsl/misc/glsl-long-variable-names.html
conformance/glsl/misc/shader-with-256-character-identifier.frag.html
conformance/glsl/misc/shader-with-long-line.html
conformance/programs/program-test.html
conformance/reading/read-pixels-test.html
conformance/renderbuffers/framebuffer-object-attachment.html
conformance/state/gl-object-get-calls.html