HLSL: Stop flattening non-IO structs containing opaques.

This makes struct returns from functions work, but breaks
structs containing arrays, due to limitations in subsequent
transforms in spirv-opt. This is expected to be fixed soon.
This commit is contained in:
John Kessenich
2017-11-16 16:03:18 -07:00
parent 471bfed062
commit dc005fb083
18 changed files with 1610 additions and 1419 deletions

View File

@@ -9,13 +9,19 @@ Shader version: 500
0:13 Sequence
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 membTex: direct index for structure ( temp 2-element array of texture2D)
0:13 'packed' ( temp structure{ temp int a, temp 2-element array of texture2D membTex, temp int b})
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 0 (const int)
0:? 'tex[0]' ( uniform texture2D)
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 membTex: direct index for structure ( temp 2-element array of texture2D)
0:13 'packed' ( temp structure{ temp int a, temp 2-element array of texture2D membTex, temp int b})
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 1 (const int)
0:? 'tex[1]' ( uniform texture2D)
@@ -50,13 +56,19 @@ Shader version: 500
0:13 Sequence
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 membTex: direct index for structure ( temp 2-element array of texture2D)
0:13 'packed' ( temp structure{ temp int a, temp 2-element array of texture2D membTex, temp int b})
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 0 (const int)
0:? 'tex[0]' ( uniform texture2D)
0:13 move second child to first child ( temp texture2D)
0:13 direct index ( temp texture2D)
0:? 'packed.membTex' ( temp 2-element array of texture2D)
0:13 membTex: direct index for structure ( temp 2-element array of texture2D)
0:13 'packed' ( temp structure{ temp int a, temp 2-element array of texture2D membTex, temp int b})
0:13 Constant:
0:13 1 (const int)
0:13 Constant:
0:13 1 (const int)
0:? 'tex[1]' ( uniform texture2D)
@@ -80,71 +92,76 @@ Shader version: 500
// Module Version 10000
// Generated by (magic number): 80002
// Id's are bound by 42
// Id's are bound by 43
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Vertex 4 "main" 35 38
EntryPoint Vertex 4 "main" 36 39
Source HLSL 500
Name 4 "main"
Name 11 "@main(vf4;"
Name 10 "pos"
Name 18 "packed.membTex"
Name 22 "tex[0]"
Name 27 "tex[1]"
Name 33 "pos"
Name 35 "pos"
Name 38 "@entryPointOutput"
Name 39 "param"
Decorate 22(tex[0]) DescriptorSet 0
Decorate 27(tex[1]) DescriptorSet 0
Decorate 35(pos) Location 0
Decorate 38(@entryPointOutput) BuiltIn Position
Name 18 "Packed"
MemberName 18(Packed) 0 "a"
MemberName 18(Packed) 1 "membTex"
MemberName 18(Packed) 2 "b"
Name 20 "packed"
Name 24 "tex[0]"
Name 28 "tex[1]"
Name 34 "pos"
Name 36 "pos"
Name 39 "@entryPointOutput"
Name 40 "param"
Decorate 24(tex[0]) DescriptorSet 0
Decorate 28(tex[1]) DescriptorSet 0
Decorate 36(pos) Location 0
Decorate 39(@entryPointOutput) BuiltIn Position
2: TypeVoid
3: TypeFunction 2
6: TypeFloat 32
7: TypeVector 6(float) 4
8: TypePointer Function 7(fvec4)
9: TypeFunction 7(fvec4) 8(ptr)
13: TypeImage 6(float) 2D sampled format:Unknown
14: TypeInt 32 0
15: 14(int) Constant 2
16: TypeArray 13 15
17: TypePointer Function 16
19: TypeInt 32 1
20: 19(int) Constant 0
21: TypePointer UniformConstant 13
22(tex[0]): 21(ptr) Variable UniformConstant
24: TypePointer Function 13
26: 19(int) Constant 1
27(tex[1]): 21(ptr) Variable UniformConstant
34: TypePointer Input 7(fvec4)
35(pos): 34(ptr) Variable Input
37: TypePointer Output 7(fvec4)
38(@entryPointOutput): 37(ptr) Variable Output
13: TypeInt 32 1
14: TypeImage 6(float) 2D sampled format:Unknown
15: TypeInt 32 0
16: 15(int) Constant 2
17: TypeArray 14 16
18(Packed): TypeStruct 13(int) 17 13(int)
19: TypePointer Function 18(Packed)
21: 13(int) Constant 1
22: 13(int) Constant 0
23: TypePointer UniformConstant 14
24(tex[0]): 23(ptr) Variable UniformConstant
26: TypePointer Function 14
28(tex[1]): 23(ptr) Variable UniformConstant
35: TypePointer Input 7(fvec4)
36(pos): 35(ptr) Variable Input
38: TypePointer Output 7(fvec4)
39(@entryPointOutput): 38(ptr) Variable Output
4(main): 2 Function None 3
5: Label
33(pos): 8(ptr) Variable Function
39(param): 8(ptr) Variable Function
36: 7(fvec4) Load 35(pos)
Store 33(pos) 36
40: 7(fvec4) Load 33(pos)
Store 39(param) 40
41: 7(fvec4) FunctionCall 11(@main(vf4;) 39(param)
Store 38(@entryPointOutput) 41
34(pos): 8(ptr) Variable Function
40(param): 8(ptr) Variable Function
37: 7(fvec4) Load 36(pos)
Store 34(pos) 37
41: 7(fvec4) Load 34(pos)
Store 40(param) 41
42: 7(fvec4) FunctionCall 11(@main(vf4;) 40(param)
Store 39(@entryPointOutput) 42
Return
FunctionEnd
11(@main(vf4;): 7(fvec4) Function None 9
10(pos): 8(ptr) FunctionParameter
12: Label
18(packed.membTex): 17(ptr) Variable Function
23: 13 Load 22(tex[0])
25: 24(ptr) AccessChain 18(packed.membTex) 20
Store 25 23
28: 13 Load 27(tex[1])
29: 24(ptr) AccessChain 18(packed.membTex) 26
Store 29 28
30: 7(fvec4) Load 10(pos)
ReturnValue 30
20(packed): 19(ptr) Variable Function
25: 14 Load 24(tex[0])
27: 26(ptr) AccessChain 20(packed) 21 22
Store 27 25
29: 14 Load 28(tex[1])
30: 26(ptr) AccessChain 20(packed) 21 21
Store 30 29
31: 7(fvec4) Load 10(pos)
ReturnValue 31
FunctionEnd