diff options
Diffstat (limited to 'chromium/gpu/command_buffer/service/program_manager.cc')
-rw-r--r-- | chromium/gpu/command_buffer/service/program_manager.cc | 134 |
1 files changed, 104 insertions, 30 deletions
diff --git a/chromium/gpu/command_buffer/service/program_manager.cc b/chromium/gpu/command_buffer/service/program_manager.cc index d6e121a5da6..44169b8e197 100644 --- a/chromium/gpu/command_buffer/service/program_manager.cc +++ b/chromium/gpu/command_buffer/service/program_manager.cc @@ -125,16 +125,77 @@ Program::UniformInfo::UniformInfo() is_array(false) { } -Program::UniformInfo::UniformInfo( - GLsizei _size, - GLenum _type, - int _fake_location_base, - const std::string& _name) +Program::UniformInfo::UniformInfo(GLsizei _size, + GLenum _type, + int _fake_location_base, + const std::string& _name) : size(_size), type(_type), + accepts_api_type(0), fake_location_base(_fake_location_base), is_array(false), name(_name) { + switch (type) { + case GL_INT: + accepts_api_type = kUniform1i; + break; + case GL_INT_VEC2: + accepts_api_type = kUniform2i; + break; + case GL_INT_VEC3: + accepts_api_type = kUniform3i; + break; + case GL_INT_VEC4: + accepts_api_type = kUniform4i; + break; + + case GL_BOOL: + accepts_api_type = kUniform1i | kUniform1f; + break; + case GL_BOOL_VEC2: + accepts_api_type = kUniform2i | kUniform2f; + break; + case GL_BOOL_VEC3: + accepts_api_type = kUniform3i | kUniform3f; + break; + case GL_BOOL_VEC4: + accepts_api_type = kUniform4i | kUniform4f; + break; + + case GL_FLOAT: + accepts_api_type = kUniform1f; + break; + case GL_FLOAT_VEC2: + accepts_api_type = kUniform2f; + break; + case GL_FLOAT_VEC3: + accepts_api_type = kUniform3f; + break; + case GL_FLOAT_VEC4: + accepts_api_type = kUniform4f; + break; + + case GL_FLOAT_MAT2: + accepts_api_type = kUniformMatrix2f; + break; + case GL_FLOAT_MAT3: + accepts_api_type = kUniformMatrix3f; + break; + case GL_FLOAT_MAT4: + accepts_api_type = kUniformMatrix4f; + break; + + case GL_SAMPLER_2D: + case GL_SAMPLER_2D_RECT_ARB: + case GL_SAMPLER_CUBE: + case GL_SAMPLER_3D_OES: + case GL_SAMPLER_EXTERNAL_OES: + accepts_api_type = kUniform1i; + break; + default: + NOTREACHED() << "Unhandled UniformInfo type " << type; + break; + } } Program::UniformInfo::~UniformInfo() {} @@ -179,7 +240,7 @@ std::string Program::ProcessLogInfo( std::string prior_log; std::string hashed_name; while (RE2::Consume(&input, - "(.*)(webgl_[0123456789abcdefABCDEF]+)", + "(.*?)(webgl_[0123456789abcdefABCDEF]+)", &prior_log, &hashed_name)) { output += prior_log; @@ -357,13 +418,13 @@ void Program::Update() { #if !defined(NDEBUG) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableGPUServiceLoggingGPU)) { - DLOG(INFO) << "----: attribs for service_id: " << service_id(); + DVLOG(1) << "----: attribs for service_id: " << service_id(); for (size_t ii = 0; ii < attrib_infos_.size(); ++ii) { const VertexAttrib& info = attrib_infos_[ii]; - DLOG(INFO) << ii << ": loc = " << info.location - << ", size = " << info.size - << ", type = " << GLES2Util::GetStringEnum(info.type) - << ", name = " << info.name; + DVLOG(1) << ii << ": loc = " << info.location + << ", size = " << info.size + << ", type = " << GLES2Util::GetStringEnum(info.type) + << ", name = " << info.name; } } #endif @@ -435,14 +496,14 @@ void Program::Update() { #if !defined(NDEBUG) if (CommandLine::ForCurrentProcess()->HasSwitch( switches::kEnableGPUServiceLoggingGPU)) { - DLOG(INFO) << "----: uniforms for service_id: " << service_id(); + DVLOG(1) << "----: uniforms for service_id: " << service_id(); for (size_t ii = 0; ii < uniform_infos_.size(); ++ii) { const UniformInfo& info = uniform_infos_[ii]; if (info.IsValid()) { - DLOG(INFO) << ii << ": loc = " << info.element_locations[0] - << ", size = " << info.size - << ", type = " << GLES2Util::GetStringEnum(info.type) - << ", name = " << info.name; + DVLOG(1) << ii << ": loc = " << info.element_locations[0] + << ", size = " << info.size + << ", type = " << GLES2Util::GetStringEnum(info.type) + << ", name = " << info.name; } } } @@ -533,18 +594,24 @@ bool Program::Link(ShaderManager* manager, set_log_info("glBindAttribLocation() conflicts"); return false; } - if (DetectUniformsMismatch()) { - set_log_info("Uniforms with the same name but different type/precision"); + std::string conflicting_name; + if (DetectUniformsMismatch(&conflicting_name)) { + std::string info_log = "Uniforms with the same name but different " + "type/precision: " + conflicting_name; + set_log_info(ProcessLogInfo(info_log).c_str()); return false; } - if (DetectVaryingsMismatch()) { - set_log_info("Varyings with the same name but different type, " - "or statically used varyings in fragment shader are not " - "declared in vertex shader"); + if (DetectVaryingsMismatch(&conflicting_name)) { + std::string info_log = "Varyings with the same name but different type, " + "or statically used varyings in fragment shader are " + "not declared in vertex shader: " + conflicting_name; + set_log_info(ProcessLogInfo(info_log).c_str()); return false; } - if (DetectGlobalNameConflicts()) { - set_log_info("Name conflicts between an uniform and an attribute"); + if (DetectGlobalNameConflicts(&conflicting_name)) { + std::string info_log = "Name conflicts between an uniform and an " + "attribute: " + conflicting_name; + set_log_info(ProcessLogInfo(info_log).c_str()); return false; } if (!CheckVaryingsPacking(varyings_packing_option)) { @@ -1005,7 +1072,7 @@ bool Program::DetectAttribLocationBindingConflicts() const { return false; } -bool Program::DetectUniformsMismatch() const { +bool Program::DetectUniformsMismatch(std::string* conflicting_name) const { typedef std::map<std::string, UniformType> UniformMap; UniformMap uniform_map; for (int ii = 0; ii < kMaxAttachedShaders; ++ii) { @@ -1024,6 +1091,7 @@ bool Program::DetectUniformsMismatch() const { // declared by other shader, then the type and precision must match. if (map_entry->second == type) continue; + *conflicting_name = name; return true; } } @@ -1031,7 +1099,7 @@ bool Program::DetectUniformsMismatch() const { return false; } -bool Program::DetectVaryingsMismatch() const { +bool Program::DetectVaryingsMismatch(std::string* conflicting_name) const { DCHECK(attached_shaders_[0] && attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && attached_shaders_[1] && @@ -1051,20 +1119,24 @@ bool Program::DetectVaryingsMismatch() const { ShaderTranslator::VariableMap::const_iterator hit = vertex_varyings->find(name); if (hit == vertex_varyings->end()) { - if (iter->second.static_use) + if (iter->second.static_use) { + *conflicting_name = name; return true; + } continue; } if (hit->second.type != iter->second.type || - hit->second.size != iter->second.size) + hit->second.size != iter->second.size) { + *conflicting_name = name; return true; + } } return false; } -bool Program::DetectGlobalNameConflicts() const { +bool Program::DetectGlobalNameConflicts(std::string* conflicting_name) const { DCHECK(attached_shaders_[0] && attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && attached_shaders_[1] && @@ -1078,8 +1150,10 @@ bool Program::DetectGlobalNameConflicts() const { for (ShaderTranslator::VariableMap::const_iterator iter = attribs->begin(); iter != attribs->end(); ++iter) { for (int ii = 0; ii < 2; ++ii) { - if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) + if (uniforms[ii]->find(iter->first) != uniforms[ii]->end()) { + *conflicting_name = iter->first; return true; + } } } return false; |