Workaround case with identical structs but different types.
With the current workarounds for SSBO type aliasing, we have no choice but to look at OpName in order to figure this out properly.
This commit is contained in:
parent
2eb6037ff3
commit
5ad4340976
47
reference/shaders/comp/type-alias.comp
Normal file
47
reference/shaders/comp/type-alias.comp
Normal file
@ -0,0 +1,47 @@
|
||||
#version 310 es
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
struct S0
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
struct S1
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer SSBO0
|
||||
{
|
||||
S0 s0s[];
|
||||
} _36;
|
||||
|
||||
layout(binding = 1, std430) buffer SSBO1
|
||||
{
|
||||
S1 s1s[];
|
||||
} _53;
|
||||
|
||||
layout(binding = 2, std430) buffer SSBO2
|
||||
{
|
||||
vec4 outputs[];
|
||||
} _62;
|
||||
|
||||
vec4 overload(S0 s0)
|
||||
{
|
||||
return s0.a;
|
||||
}
|
||||
|
||||
vec4 overload(S1 s1)
|
||||
{
|
||||
return s1.a;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
S0 s0 = _36.s0s[gl_GlobalInvocationID.x];
|
||||
S1 s1 = _53.s1s[gl_GlobalInvocationID.x];
|
||||
S0 param = s0;
|
||||
S1 param_1 = s1;
|
||||
_62.outputs[gl_GlobalInvocationID.x] = (overload(param) + overload(param_1));
|
||||
}
|
||||
|
45
shaders/comp/type-alias.comp
Normal file
45
shaders/comp/type-alias.comp
Normal file
@ -0,0 +1,45 @@
|
||||
#version 310 es
|
||||
layout(local_size_x = 1) in;
|
||||
|
||||
struct S0
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
struct S1
|
||||
{
|
||||
vec4 a;
|
||||
};
|
||||
|
||||
vec4 overload(S0 s0)
|
||||
{
|
||||
return s0.a;
|
||||
}
|
||||
|
||||
vec4 overload(S1 s1)
|
||||
{
|
||||
return s1.a;
|
||||
}
|
||||
|
||||
layout(std430, binding = 0) buffer SSBO0
|
||||
{
|
||||
S0 s0s[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 1) buffer SSBO1
|
||||
{
|
||||
S1 s1s[];
|
||||
};
|
||||
|
||||
layout(std430, binding = 2) buffer SSBO2
|
||||
{
|
||||
vec4 outputs[];
|
||||
};
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
S0 s0 = s0s[gl_GlobalInvocationID.x];
|
||||
S1 s1 = s1s[gl_GlobalInvocationID.x];
|
||||
outputs[gl_GlobalInvocationID.x] = overload(s0) + overload(s1);
|
||||
}
|
@ -1163,9 +1163,14 @@ void Compiler::parse(const Instruction &instruction)
|
||||
|
||||
// Check if we have seen this struct type before, with just different
|
||||
// decorations.
|
||||
//
|
||||
// Add workaround for issue #17 as well by looking at OpName for the struct
|
||||
// types, which we shouldn't normally do.
|
||||
// We should not normally have to consider type aliases like this to begin with
|
||||
// however ... glslang issues #304, #307 cover this.
|
||||
for (auto &other : global_struct_cache)
|
||||
{
|
||||
if (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;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user