Commit e4feb0d4 authored by cwallez's avatar cwallez Committed by Commit bot

program_manager: detect interface block mismatches

This fixes the deqp/data/gles3/shaders/linkage.html tests that were
checking that compilation fail if interface blocks have different
layouts.

BUG=621031
CQ_INCLUDE_TRYBOTS=tryserver.chromium.linux:linux_optional_gpu_tests_rel;tryserver.chromium.mac:mac_optional_gpu_tests_rel;tryserver.chromium.win:win_optional_gpu_tests_rel

Review-Url: https://codereview.chromium.org/2147663002
Cr-Commit-Position: refs/heads/master@{#405256}
parent e49e995e
......@@ -1073,6 +1073,14 @@ bool Program::Link(ShaderManager* manager,
set_log_info("glBindUniformLocationCHROMIUM() conflicts");
return false;
}
if (DetectInterfaceBlocksMismatch(&conflicting_name)) {
std::string info_log =
"Interface blocks with the same name but different"
" fields/layout: " +
conflicting_name;
set_log_info(ProcessLogInfo(info_log).c_str());
return false;
}
if (DetectVaryingsMismatch(&conflicting_name)) {
std::string info_log = "Varyings with the same name but different type, "
"or statically used varyings in fragment shader "
......@@ -1620,6 +1628,29 @@ bool Program::DetectUniformsMismatch(std::string* conflicting_name) const {
return false;
}
bool Program::DetectInterfaceBlocksMismatch(
std::string* conflicting_name) const {
std::map<std::string, const sh::InterfaceBlock*> interface_pointer_map;
for (auto shader : attached_shaders_) {
const InterfaceBlockMap& shader_interfaces = shader->interface_block_map();
for (const auto& it : shader_interfaces) {
const auto& name = it.first;
auto hit = interface_pointer_map.find(name);
if (hit == interface_pointer_map.end()) {
interface_pointer_map[name] = &(it.second);
} else {
// If an interface is in the map, i.e., it has already been declared by
// another shader, then the layout must match.
if (hit->second->isSameInterfaceBlockAtLinkTime(it.second))
continue;
*conflicting_name = name;
return true;
}
}
}
return false;
}
bool Program::DetectVaryingsMismatch(std::string* conflicting_name) const {
DCHECK(attached_shaders_[0].get() &&
attached_shaders_[0]->shader_type() == GL_VERTEX_SHADER &&
......
......@@ -345,6 +345,10 @@ class GPU_EXPORT Program : public base::RefCounted<Program> {
// conflicting_name if such cases are detected.
bool DetectUniformsMismatch(std::string* conflicting_name) const;
// Detects if there are interface blocks of the same name but different
// layouts.
bool DetectInterfaceBlocksMismatch(std::string* conflicting_name) const;
// Return true if a varying is statically used in fragment shader, but it
// is not declared in vertex shader.
bool DetectVaryingsMismatch(std::string* conflicting_name) const;
......
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