Merge pull request #237 from KhronosGroup/fix-236

Fix spurious struct type aliasing in stripped binaries.
This commit is contained in:
Hans-Kristian Arntzen 2017-07-31 12:00:29 +02:00 committed by GitHub
commit 8f4bbdeb0c

View File

@ -1533,9 +1533,17 @@ void Compiler::parse(const Instruction &instruction)
// types, which we shouldn't normally do. // types, which we shouldn't normally do.
// We should not normally have to consider type aliases like this to begin with // We should not normally have to consider type aliases like this to begin with
// however ... glslang issues #304, #307 cover this. // however ... glslang issues #304, #307 cover this.
// For stripped names, never consider struct type aliasing.
// We risk declaring the same struct multiple times, but type-punning is not allowed
// so this is safe.
bool consider_aliasing = !get_name(type.self).empty();
if (consider_aliasing)
{
for (auto &other : global_struct_cache) for (auto &other : global_struct_cache)
{ {
if (get_name(type.self) == get_name(other) && types_are_logically_equivalent(type, get<SPIRType>(other))) if (get_name(type.self) == get_name(other) &&
types_are_logically_equivalent(type, get<SPIRType>(other)))
{ {
type.type_alias = other; type.type_alias = other;
break; break;
@ -1544,6 +1552,7 @@ void Compiler::parse(const Instruction &instruction)
if (type.type_alias == 0) if (type.type_alias == 0)
global_struct_cache.push_back(id); global_struct_cache.push_back(id);
}
break; break;
} }