HLSL: fix copies between arrays of structs of builtins, and arrayed builtins.

Structs are split to remove builtin members to create valid SPIR-V.  In this
process, an outer structure array dimension may be propegated onto the
now-removed builtin variables.  For example, a mystruct[3].position ->
position[3].  The copy between the split and unsplit forms would handle
this in some cases, but not if the array dimension was at different levels
of aggregate.

It now does this, but may not handle arbitrary composite types.  Unclear if
that has any semantic meaning for builtins though.
This commit is contained in:
steve-lunarg
2017-02-02 16:32:02 -07:00
committed by John Kessenich
parent abd8dca86d
commit ec712ebea1
5 changed files with 473 additions and 174 deletions

View File

@@ -37,6 +37,18 @@ gl_FragCoord origin is upper left
0:7 0 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 0 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp float)
0:7 f: direct index for structure (temp float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
@@ -52,6 +64,18 @@ gl_FragCoord origin is upper left
0:7 1 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 1 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 1 (const int)
0:7 move second child to first child (temp float)
0:7 f: direct index for structure (temp float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
@@ -67,6 +91,18 @@ gl_FragCoord origin is upper left
0:7 2 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 2 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 2 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:7 Function Call: @main(i1;struct-S-f1-vf41[3]; (temp 4-component vector of float)
@@ -120,6 +156,18 @@ gl_FragCoord origin is upper left
0:7 0 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 0 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp float)
0:7 f: direct index for structure (temp float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
@@ -135,6 +183,18 @@ gl_FragCoord origin is upper left
0:7 1 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 1 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 1 (const int)
0:7 move second child to first child (temp float)
0:7 f: direct index for structure (temp float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
@@ -150,6 +210,18 @@ gl_FragCoord origin is upper left
0:7 2 (const int)
0:7 Constant:
0:7 0 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:7 pos: direct index for structure (temp 4-component vector of float)
0:7 direct index (temp structure{temp float f, temp 4-component vector of float pos})
0:? 'input' (temp 3-element array of structure{temp float f, temp 4-component vector of float pos})
0:7 Constant:
0:7 2 (const int)
0:7 Constant:
0:7 1 (const int)
0:7 direct index (in 4-component vector of float FragCoord)
0:? 'input_pos' (in 3-element array of 4-component vector of float FragCoord)
0:7 Constant:
0:7 2 (const int)
0:7 move second child to first child (temp 4-component vector of float)
0:? '@entryPointOutput' (layout(location=0 ) out 4-component vector of float)
0:7 Function Call: @main(i1;struct-S-f1-vf41[3]; (temp 4-component vector of float)
@@ -163,12 +235,12 @@ gl_FragCoord origin is upper left
// Module Version 10000
// Generated by (magic number): 80001
// Id's are bound by 63
// Id's are bound by 73
Capability Shader
1: ExtInstImport "GLSL.std.450"
MemoryModel Logical GLSL450
EntryPoint Fragment 4 "main" 32 39 54 62
EntryPoint Fragment 4 "main" 32 39 48 67
ExecutionMode 4 OriginUpperLeft
Name 4 "main"
Name 10 "S"
@@ -184,14 +256,14 @@ gl_FragCoord origin is upper left
Name 36 "S"
MemberName 36(S) 0 "f"
Name 39 "input"
Name 54 "@entryPointOutput"
Name 55 "param"
Name 57 "param"
Name 62 "input_pos"
Name 48 "input_pos"
Name 67 "@entryPointOutput"
Name 68 "param"
Name 70 "param"
Decorate 32(i) Location 0
Decorate 39(input) Location 1
Decorate 54(@entryPointOutput) Location 0
Decorate 62(input_pos) BuiltIn FragCoord
Decorate 48(input_pos) BuiltIn FragCoord
Decorate 67(@entryPointOutput) Location 0
2: TypeVoid
3: TypeFunction 2
6: TypeInt 32 1
@@ -218,38 +290,51 @@ gl_FragCoord origin is upper left
40: TypePointer Input 8(float)
43: TypePointer Function 8(float)
45: 6(int) Constant 1
49: 6(int) Constant 2
53: TypePointer Output 9(fvec4)
54(@entryPointOutput): 53(ptr) Variable Output
60: TypeArray 9(fvec4) 12
61: TypePointer Input 60
62(input_pos): 61(ptr) Variable Input
46: TypeArray 9(fvec4) 12
47: TypePointer Input 46
48(input_pos): 47(ptr) Variable Input
49: TypePointer Input 9(fvec4)
59: 6(int) Constant 2
66: TypePointer Output 9(fvec4)
67(@entryPointOutput): 66(ptr) Variable Output
4(main): 2 Function None 3
5: Label
30(i): 7(ptr) Variable Function
34(input): 14(ptr) Variable Function
55(param): 7(ptr) Variable Function
57(param): 14(ptr) Variable Function
68(param): 7(ptr) Variable Function
70(param): 14(ptr) Variable Function
33: 6(int) Load 32(i)
Store 30(i) 33
41: 40(ptr) AccessChain 39(input) 35 35
42: 8(float) Load 41
44: 43(ptr) AccessChain 34(input) 35 35
Store 44 42
46: 40(ptr) AccessChain 39(input) 45 35
47: 8(float) Load 46
48: 43(ptr) AccessChain 34(input) 45 35
Store 48 47
50: 40(ptr) AccessChain 39(input) 49 35
51: 8(float) Load 50
52: 43(ptr) AccessChain 34(input) 49 35
50: 49(ptr) AccessChain 48(input_pos) 35
51: 9(fvec4) Load 50
52: 25(ptr) AccessChain 34(input) 35 45
Store 52 51
56: 6(int) Load 30(i)
Store 55(param) 56
58: 13 Load 34(input)
Store 57(param) 58
59: 9(fvec4) FunctionCall 18(@main(i1;struct-S-f1-vf41[3];) 55(param) 57(param)
Store 54(@entryPointOutput) 59
53: 40(ptr) AccessChain 39(input) 45 35
54: 8(float) Load 53
55: 43(ptr) AccessChain 34(input) 45 35
Store 55 54
56: 49(ptr) AccessChain 48(input_pos) 45
57: 9(fvec4) Load 56
58: 25(ptr) AccessChain 34(input) 45 45
Store 58 57
60: 40(ptr) AccessChain 39(input) 59 35
61: 8(float) Load 60
62: 43(ptr) AccessChain 34(input) 59 35
Store 62 61
63: 49(ptr) AccessChain 48(input_pos) 59
64: 9(fvec4) Load 63
65: 25(ptr) AccessChain 34(input) 59 45
Store 65 64
69: 6(int) Load 30(i)
Store 68(param) 69
71: 13 Load 34(input)
Store 70(param) 71
72: 9(fvec4) FunctionCall 18(@main(i1;struct-S-f1-vf41[3];) 68(param) 70(param)
Store 67(@entryPointOutput) 72
Return
FunctionEnd
18(@main(i1;struct-S-f1-vf41[3];): 9(fvec4) Function None 15