HLSL: fix qualifier propagation from user struct types to block definitions.

The HLSL FE tracks four versions of a declared type to avoid losing information, since it
is not (at type-decl time) known how the type will be used downstream.  If such a type
was used in a cbuffer declaration, the cbuffer type's members should have been using
the uniform form of the original user structure type, but were not.

This would manifest as matrix qualifiers (and other things, such as pack offsets) on user struct
members going missing in the SPIR-V module if the struct type was a member of a cbuffer, like so:

    struct MyBuffer
    {
        row_major float4x4 mat1;
        column_major float4x4 mat2;
    };

    cbuffer Example
    {
        MyBuffer g_MyBuffer;
    };

Fixes: #789
This commit is contained in:
LoopDawg 2017-08-04 15:40:53 -06:00
parent 2b4f77f2dc
commit 898f5fbef7
5 changed files with 230 additions and 25 deletions

View file

@ -68,7 +68,7 @@ using depth_greater
0:15 3 (const int)
0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} s})
0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{ temp float f, temp float g, temp float d, temp 4-component vector of float normal} t})
0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} t})
0:? 'f' (layout( location=0) out float)
0:? 'g' (layout( location=1) out float)
0:? 'd' ( out float FragDepth)
@ -151,7 +151,7 @@ using depth_greater
0:15 3 (const int)
0:? Linker Objects
0:? 'anon@0' (layout( row_major std140) uniform block{ uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} s})
0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{ temp float f, temp float g, temp float d, temp 4-component vector of float normal} t})
0:? 'anon@1' (layout( row_major std140) uniform block{layout( row_major std140 offset=88) uniform structure{layout( offset=68) temp float f, temp float g, temp float d, temp 4-component vector of float normal} t})
0:? 'f' (layout( location=0) out float)
0:? 'g' (layout( location=1) out float)
0:? 'd' ( out float FragDepth)
@ -163,7 +163,7 @@ using depth_greater
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 66
// Id's are bound by 65
Capability Shader
1: ExtInstImport "GLSL.std.450"
@ -200,14 +200,9 @@ using depth_greater
Name 59 "$Global"
MemberName 59($Global) 0 "s"
Name 61 ""
Name 62 "T"
MemberName 62(T) 0 "f"
MemberName 62(T) 1 "g"
MemberName 62(T) 2 "d"
MemberName 62(T) 3 "normal"
Name 63 "buff"
MemberName 63(buff) 0 "t"
Name 65 ""
Name 62 "buff"
MemberName 62(buff) 0 "t"
Name 64 ""
Decorate 22(f) Location 0
Decorate 27(g) Centroid
Decorate 27(g) Location 1
@ -224,13 +219,9 @@ using depth_greater
MemberDecorate 59($Global) 0 Offset 0
Decorate 59($Global) Block
Decorate 61 DescriptorSet 0
MemberDecorate 62(T) 0 Offset 0
MemberDecorate 62(T) 1 Offset 4
MemberDecorate 62(T) 2 Offset 8
MemberDecorate 62(T) 3 Offset 16
MemberDecorate 63(buff) 0 Offset 96
Decorate 63(buff) Block
Decorate 65 DescriptorSet 0
MemberDecorate 62(buff) 0 Offset 96
Decorate 62(buff) Block
Decorate 64 DescriptorSet 0
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
@ -261,10 +252,9 @@ using depth_greater
59($Global): TypeStruct 58(T)
60: TypePointer Uniform 59($Global)
61: 60(ptr) Variable Uniform
62(T): TypeStruct 6(float) 6(float) 6(float) 7(fvec4)
63(buff): TypeStruct 62(T)
64: TypePointer Uniform 63(buff)
65: 64(ptr) Variable Uniform
62(buff): TypeStruct 58(T)
63: TypePointer Uniform 62(buff)
64: 63(ptr) Variable Uniform
4(main): 2 Function None 3
5: Label
18(t): 9(ptr) Variable Function