Commit 05afda1f authored by gman@chromium.org's avatar gman@chromium.org

Fix for gl programs. An unsuccessful link should report

the link is unsuccessful but not replace the old program.

TEST=webgl conformance tests pass
BUG=none

Review URL: http://codereview.chromium.org/6242006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@71882 0039d316-1c4b-4281-b951-d872f2087c98
parent 9277111a
......@@ -3607,16 +3607,17 @@ void GLES2DecoderImpl::DoLinkProgram(GLuint program) {
if (!info) {
return;
}
info->ClearLinkStatus();
if (!info->CanLink()) {
return;
}
glLinkProgram(info->service_id());
GLint success = 0;
glGetProgramiv(info->service_id(), GL_LINK_STATUS, &success);
if (success) {
info->Update();
} else {
info->Reset();
}
};
......
......@@ -48,11 +48,13 @@ ProgramManager::ProgramInfo::ProgramInfo(GLuint service_id)
max_attrib_name_length_(0),
max_uniform_name_length_(0),
service_id_(service_id),
valid_(false) {
valid_(false),
link_status_(false) {
}
void ProgramManager::ProgramInfo::Reset() {
valid_ = false;
link_status_ = false;
max_uniform_name_length_ = 0;
max_attrib_name_length_ = 0;
attrib_infos_.clear();
......@@ -76,6 +78,7 @@ void ProgramManager::ProgramInfo::UpdateLogInfo() {
void ProgramManager::ProgramInfo::Update() {
Reset();
link_status_ = true;
GLint num_attribs = 0;
GLint max_len = 0;
GLint max_location = -1;
......@@ -337,7 +340,7 @@ void ProgramManager::ProgramInfo::GetProgramiv(GLenum pname, GLint* params) {
*params = max_uniform_name_length_ + 1;
break;
case GL_LINK_STATUS:
*params = valid_;
*params = link_status_;
break;
case GL_INFO_LOG_LENGTH:
// Notice +1 to accomodate NULL terminator.
......
......@@ -75,9 +75,6 @@ class ProgramManager {
return sampler_indices_;
}
// Resets the program after an unsuccessful link.
void Reset();
// Updates the program info after a successful link.
void Update();
......@@ -131,6 +128,10 @@ class ProgramManager {
return valid_;
}
void ClearLinkStatus() {
link_status_ = false;
}
bool AttachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info);
void DetachShader(ShaderManager* manager, ShaderManager::ShaderInfo* info);
......@@ -169,6 +170,9 @@ class ProgramManager {
service_id_ = 0;
}
// Resets the program.
void Reset();
const UniformInfo* AddUniformInfo(
GLsizei size, GLenum type, GLint location, const std::string& name);
......@@ -205,9 +209,12 @@ class ProgramManager {
// Shaders by type of shader.
ShaderManager::ShaderInfo::Ref attached_shaders_[kMaxAttachedShaders];
// This is true if glLinkProgram was successful.
// This is true if glLinkProgram was successful at least once.
bool valid_;
// This is true if glLinkProgram was successful last time it was called.
bool link_status_;
// Log info
std::string log_info_;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment