Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: gpu/command_buffer/service/program_manager.cc

Issue 2147663002: program_manager: detect interface block mismatches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "gpu/command_buffer/service/program_manager.h" 5 #include "gpu/command_buffer/service/program_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
(...skipping 1055 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 if (DetectUniformsMismatch(&conflicting_name)) { 1066 if (DetectUniformsMismatch(&conflicting_name)) {
1067 std::string info_log = "Uniforms with the same name but different " 1067 std::string info_log = "Uniforms with the same name but different "
1068 "type/precision: " + conflicting_name; 1068 "type/precision: " + conflicting_name;
1069 set_log_info(ProcessLogInfo(info_log).c_str()); 1069 set_log_info(ProcessLogInfo(info_log).c_str());
1070 return false; 1070 return false;
1071 } 1071 }
1072 if (DetectUniformLocationBindingConflicts()) { 1072 if (DetectUniformLocationBindingConflicts()) {
1073 set_log_info("glBindUniformLocationCHROMIUM() conflicts"); 1073 set_log_info("glBindUniformLocationCHROMIUM() conflicts");
1074 return false; 1074 return false;
1075 } 1075 }
1076 if (DetectInterfaceBlocksMismatch(&conflicting_name)) {
1077 std::string info_log =
1078 "Interface blocks with the same name but different"
1079 " fields/layout: " +
1080 conflicting_name;
1081 set_log_info(ProcessLogInfo(info_log).c_str());
1082 return false;
1083 }
1076 if (DetectVaryingsMismatch(&conflicting_name)) { 1084 if (DetectVaryingsMismatch(&conflicting_name)) {
1077 std::string info_log = "Varyings with the same name but different type, " 1085 std::string info_log = "Varyings with the same name but different type, "
1078 "or statically used varyings in fragment shader " 1086 "or statically used varyings in fragment shader "
1079 "are not declared in vertex shader: " + 1087 "are not declared in vertex shader: " +
1080 conflicting_name; 1088 conflicting_name;
1081 set_log_info(ProcessLogInfo(info_log).c_str()); 1089 set_log_info(ProcessLogInfo(info_log).c_str());
1082 return false; 1090 return false;
1083 } 1091 }
1084 if (DetectFragmentInputLocationBindingConflicts()) { 1092 if (DetectFragmentInputLocationBindingConflicts()) {
1085 set_log_info("glBindFragmentInputLocationCHROMIUM() conflicts"); 1093 set_log_info("glBindFragmentInputLocationCHROMIUM() conflicts");
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1613 if (hit->second->isSameUniformAtLinkTime(key_value.second)) 1621 if (hit->second->isSameUniformAtLinkTime(key_value.second))
1614 continue; 1622 continue;
1615 *conflicting_name = name; 1623 *conflicting_name = name;
1616 return true; 1624 return true;
1617 } 1625 }
1618 } 1626 }
1619 } 1627 }
1620 return false; 1628 return false;
1621 } 1629 }
1622 1630
1631 bool Program::DetectInterfaceBlocksMismatch(
1632 std::string* conflicting_name) const {
1633 std::map<std::string, const sh::InterfaceBlock*> interface_pointer_map;
1634 for (auto shader : attached_shaders_) {
1635 const InterfaceBlockMap& shader_interfaces = shader->interface_block_map();
1636 for (const auto& it : shader_interfaces) {
1637 const auto& name = it.first;
1638 auto hit = interface_pointer_map.find(name);
1639 if (hit == interface_pointer_map.end()) {
1640 interface_pointer_map[name] = &(it.second);
1641 } else {
1642 // If an interface is in the map, i.e., it has already been declared by
1643 // another shader, then the layout must match.
1644 if (hit->second->isSameInterfaceBlockAtLinkTime(it.second))
Ken Russell (switch to Gerrit) 2016/07/12 20:37:13 Is isSameInterfaceBlockAtLinkTime a new method in
1645 continue;
1646 *conflicting_name = name;
1647 return true;
1648 }
1649 }
1650 }
1651 return false;
1652 }
1653
1623 bool Program::DetectVaryingsMismatch(std::string* conflicting_name) const { 1654 bool Program::DetectVaryingsMismatch(std::string* conflicting_name) const {
1624 DCHECK(attached_shaders_[0].get() && 1655 DCHECK(attached_shaders_[0].get() &&
1625 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER && 1656 attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
1626 attached_shaders_[1].get() && 1657 attached_shaders_[1].get() &&
1627 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER); 1658 attached_shaders_[1]->shader_type() == GL_FRAGMENT_SHADER);
1628 const VaryingMap* vertex_varyings = &(attached_shaders_[0]->varying_map()); 1659 const VaryingMap* vertex_varyings = &(attached_shaders_[0]->varying_map());
1629 const VaryingMap* fragment_varyings = &(attached_shaders_[1]->varying_map()); 1660 const VaryingMap* fragment_varyings = &(attached_shaders_[1]->varying_map());
1630 1661
1631 int shader_version = attached_shaders_[0]->shader_version(); 1662 int shader_version = attached_shaders_[0]->shader_version();
1632 1663
(...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 DCHECK(program); 2397 DCHECK(program);
2367 program->ClearUniforms(&zero_); 2398 program->ClearUniforms(&zero_);
2368 } 2399 }
2369 2400
2370 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) { 2401 int32_t ProgramManager::MakeFakeLocation(int32_t index, int32_t element) {
2371 return index + element * 0x10000; 2402 return index + element * 0x10000;
2372 } 2403 }
2373 2404
2374 } // namespace gles2 2405 } // namespace gles2
2375 } // namespace gpu 2406 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/program_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698