Bug 1263018 - Only update active prog info if linking active prog. - r=jrmuizel

This commit is contained in:
Jeff Gilbert 2016-04-20 12:02:07 -07:00
Родитель 5024e050fd
Коммит 9c3993e371
4 изменённых файлов: 26 добавлений и 25 удалений

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

@ -360,8 +360,10 @@ WebGLContext::DrawElements_check(GLsizei count, GLenum type,
return false;
}
// Any checks below this depend on a program being available.
if (!mCurrentProgram) {
// Any checks below this depend on mActiveProgramLinkInfo being available.
if (!mActiveProgramLinkInfo) {
// Technically, this will only be null iff CURRENT_PROGRAM is null.
// But it's better to branch on what we actually care about.
ErrorInvalidOperation("%s: null CURRENT_PROGRAM", info);
return false;
}

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

@ -1088,14 +1088,19 @@ WebGLContext::LinkProgram(WebGLProgram* prog)
prog->LinkProgram();
if (prog->IsLinked()) {
if (!prog->IsLinked()) {
// If we failed to link, but `prog == mCurrentProgram`, we are *not* supposed to
// null out mActiveProgramLinkInfo.
return;
}
if (prog == mCurrentProgram) {
mActiveProgramLinkInfo = prog->LinkInfo();
if (gl->WorkAroundDriverBugs() &&
gl->Vendor() == gl::GLVendor::NVIDIA)
{
if (mCurrentProgram == prog)
gl->fUseProgram(prog->mGLName);
gl->fUseProgram(prog->mGLName);
}
}
}

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

@ -885,7 +885,7 @@ WebGLProgram::UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockB
gl->fUniformBlockBinding(mGLName, uniformBlockIndex, uniformBlockBinding);
}
bool
void
WebGLProgram::LinkProgram()
{
mContext->InvalidateBufferFetching(); // we do it early in this function
@ -897,18 +897,18 @@ WebGLProgram::LinkProgram()
if (!mVertShader || !mVertShader->IsCompiled()) {
mLinkLog.AssignLiteral("Must have a compiled vertex shader attached.");
mContext->GenerateWarning("linkProgram: %s", mLinkLog.BeginReading());
return false;
return;
}
if (!mFragShader || !mFragShader->IsCompiled()) {
mLinkLog.AssignLiteral("Must have an compiled fragment shader attached.");
mContext->GenerateWarning("linkProgram: %s", mLinkLog.BeginReading());
return false;
return;
}
if (!mFragShader->CanLinkTo(mVertShader, &mLinkLog)) {
mContext->GenerateWarning("linkProgram: %s", mLinkLog.BeginReading());
return false;
return;
}
gl::GLContext* gl = mContext->gl;
@ -925,14 +925,14 @@ WebGLProgram::LinkProgram()
mLinkLog.AssignLiteral("Programs with more than 16 samplers are disallowed on"
" Mesa drivers to avoid crashing.");
mContext->GenerateWarning("linkProgram: %s", mLinkLog.BeginReading());
return false;
return;
}
// Bug 1203135: Mesa crashes internally if we exceed the reported maximum attribute count.
if (mVertShader->NumAttributes() > mContext->MaxVertexAttribs()) {
mLinkLog.AssignLiteral("Number of attributes exceeds Mesa's reported max attribute count.");
mContext->GenerateWarning("linkProgram: %s", mLinkLog.BeginReading());
return false;
return;
}
}
@ -954,8 +954,9 @@ WebGLProgram::LinkProgram()
&mTempMappedVaryings);
}
if (LinkAndUpdate())
return true;
LinkAndUpdate();
if (IsLinked())
return;
// Failed link.
if (mContext->ShouldGenerateWarnings()) {
@ -970,8 +971,6 @@ WebGLProgram::LinkProgram()
mLinkLog.BeginReading());
}
}
return false;
}
bool
@ -1013,7 +1012,7 @@ WebGLProgram::ValidateProgram() const
////////////////////////////////////////////////////////////////////////////////
bool
void
WebGLProgram::LinkAndUpdate()
{
mMostRecentLinkInfo = nullptr;
@ -1039,15 +1038,10 @@ WebGLProgram::LinkAndUpdate()
GLint ok = 0;
gl->fGetProgramiv(mGLName, LOCAL_GL_LINK_STATUS, &ok);
if (!ok)
return false;
return;
mMostRecentLinkInfo = QueryProgramInfo(this, gl);
MOZ_ASSERT(mMostRecentLinkInfo);
if (!mMostRecentLinkInfo)
mLinkLog.AssignLiteral("Failed to gather program info.");
return mMostRecentLinkInfo;
MOZ_RELEASE_ASSERT(mMostRecentLinkInfo);
}
bool

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

@ -156,7 +156,7 @@ public:
dom::Nullable< nsTArray<GLuint> >& retval) const;
void UniformBlockBinding(GLuint uniformBlockIndex, GLuint uniformBlockBinding) const;
bool LinkProgram();
void LinkProgram();
bool UseProgram() const;
void ValidateProgram() const;
@ -195,7 +195,7 @@ public:
private:
~WebGLProgram();
bool LinkAndUpdate();
void LinkAndUpdate();
public:
const GLuint mGLName;