SPV: Reduce spurious type generation by removing intermediate types in the middle of access chains.

This generally simplifies access chain generation, with far fewer  type conversions.
It is particularly important to future SPIR-V changes where there is less aggregate
type uniqueness due to carrying different layout information with the type.
This commit is contained in:
John Kessenich
2015-09-13 14:46:30 -06:00
parent c9a808319a
commit fa668dad99
8 changed files with 144 additions and 137 deletions

View File

@@ -7,7 +7,7 @@ Linked compute stage:
// Module Version 99
// Generated by (magic number): 51a00bb
// Id's are bound by 72
// Id's are bound by 68
Source ESSL 310
Capability Shader
@@ -26,21 +26,21 @@ Linked compute stage:
MemberName 25(outbna) 0 "k"
MemberName 25(outbna) 1 "na"
Name 27 "outbnamena"
Name 47 "i"
Name 53 "outs"
MemberName 53(outs) 0 "s"
MemberName 53(outs) 1 "va"
Name 55 "outnames"
Name 59 "gl_LocalInvocationID"
Name 44 "i"
Name 50 "outs"
MemberName 50(outs) 0 "s"
MemberName 50(outs) 1 "va"
Name 52 "outnames"
Name 55 "gl_LocalInvocationID"
Decorate 14(outb) GLSLShared
Decorate 14(outb) BufferBlock
Decorate 25(outbna) GLSLShared
Decorate 25(outbna) BufferBlock
Decorate 53(outs) GLSLShared
Decorate 53(outs) BufferBlock
Decorate 59(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 71 BuiltIn WorkgroupSize
Decorate 71 NoStaticUse
Decorate 50(outs) GLSLShared
Decorate 50(outs) BufferBlock
Decorate 55(gl_LocalInvocationID) BuiltIn LocalInvocationId
Decorate 67 BuiltIn WorkgroupSize
Decorate 67 NoStaticUse
2: TypeVoid
3: TypeFunction 2
7: TypeInt 32 0
@@ -64,30 +64,26 @@ Linked compute stage:
27(outbnamena): 26(ptr) Variable Uniform
28: 17(int) Constant 1
31: TypePointer Uniform 24(fvec4)
33: TypeRuntimeArray 12(fvec3)
34: 17(int) Constant 3
35: 17(int) Constant 18
36: TypePointer Uniform 12(fvec3)
40: TypeRuntimeArray 12(fvec3)
41: 17(int) Constant 17
42: 11(float) Constant 1077936128
43: 12(fvec3) ConstantComposite 42 42 42
45: TypeRuntimeArray 12(fvec3)
46: TypePointer WorkgroupLocal 17(int)
47(i): 46(ptr) Variable WorkgroupLocal
52: TypeRuntimeArray 24(fvec4)
53(outs): TypeStruct 17(int) 52
54: TypePointer Uniform 53(outs)
55(outnames): 54(ptr) Variable Uniform
56: TypeRuntimeArray 24(fvec4)
57: TypeVector 7(int) 3
58: TypePointer Input 57(ivec3)
59(gl_LocalInvocationID): 58(ptr) Variable Input
66: TypePointer Uniform 17(int)
68: 7(int) Constant 16
69: 7(int) Constant 32
70: 7(int) Constant 4
71: 57(ivec3) ConstantComposite 68 69 70
33: 17(int) Constant 3
34: 17(int) Constant 18
35: TypePointer Uniform 12(fvec3)
39: 17(int) Constant 17
40: 11(float) Constant 1077936128
41: 12(fvec3) ConstantComposite 40 40 40
43: TypePointer WorkgroupLocal 17(int)
44(i): 43(ptr) Variable WorkgroupLocal
49: TypeRuntimeArray 24(fvec4)
50(outs): TypeStruct 17(int) 49
51: TypePointer Uniform 50(outs)
52(outnames): 51(ptr) Variable Uniform
53: TypeVector 7(int) 3
54: TypePointer Input 53(ivec3)
55(gl_LocalInvocationID): 54(ptr) Variable Input
62: TypePointer Uniform 17(int)
64: 7(int) Constant 16
65: 7(int) Constant 32
66: 7(int) Constant 4
67: 53(ivec3) ConstantComposite 64 65 66
4(main): 2 Function None 3
5: Label
MemoryBarrier 8 9
@@ -99,26 +95,26 @@ Linked compute stage:
30: 24(fvec4) CompositeConstruct 29 29 29 29
32: 31(ptr) AccessChain 27(outbnamena) 28
Store 32 30
37: 36(ptr) AccessChain 16(outbname) 34 35
38: 12(fvec3) Load 37
39: 11(float) CompositeExtract 38 0
Store 20(s) 39
44: 36(ptr) AccessChain 16(outbname) 34 41
Store 44 43
48: 17(int) Load 47(i)
49: 11(float) Load 20(s)
50: 12(fvec3) CompositeConstruct 49 49 49
51: 36(ptr) AccessChain 16(outbname) 34 48
Store 51 50
60: 57(ivec3) Load 59(gl_LocalInvocationID)
61: 7(int) CompositeExtract 60 0
62: 11(float) Load 20(s)
63: 24(fvec4) CompositeConstruct 62 62 62 62
64: 31(ptr) AccessChain 55(outnames) 28 61
Store 64 63
65: 17(int) ArrayLength 16(outbname)
67: 66(ptr) AccessChain 55(outnames) 18
Store 67 65
36: 35(ptr) AccessChain 16(outbname) 33 34
37: 12(fvec3) Load 36
38: 11(float) CompositeExtract 37 0
Store 20(s) 38
42: 35(ptr) AccessChain 16(outbname) 33 39
Store 42 41
45: 17(int) Load 44(i)
46: 11(float) Load 20(s)
47: 12(fvec3) CompositeConstruct 46 46 46
48: 35(ptr) AccessChain 16(outbname) 33 45
Store 48 47
56: 53(ivec3) Load 55(gl_LocalInvocationID)
57: 7(int) CompositeExtract 56 0
58: 11(float) Load 20(s)
59: 24(fvec4) CompositeConstruct 58 58 58 58
60: 31(ptr) AccessChain 52(outnames) 28 57
Store 60 59
61: 17(int) ArrayLength 16(outbname)
63: 62(ptr) AccessChain 52(outnames) 18
Store 63 61
Branch 6
6: Label
Return

View File

@@ -51,7 +51,7 @@ Linked fragment stage:
292: 19(int) Constant 2
299: 19(int) Constant 1
301: TypePointer Function 7(float)
332: TypeVector 7(float) 3
331: TypeVector 7(float) 3
347: 7(float) Constant 1073741824
354: 7(float) Constant 1065353216
359: 19(int) Constant 66
@@ -434,11 +434,11 @@ Linked fragment stage:
329: 7(float) Load 302(f)
330: 7(float) FAdd 329 328
Store 302(f) 330
331: 8(fvec4) Load 10(v)
333: 332(fvec3) VectorShuffle 331 331 0 1 2
332: 8(fvec4) Load 10(v)
333: 331(fvec3) VectorShuffle 332 332 0 1 2
334: 8(fvec4) Load 10(v)
335: 332(fvec3) VectorShuffle 334 334 0 1 2
336: 332(fvec3) ExtInst 1(GLSL.std.450) 67(Cross) 333 335
335: 331(fvec3) VectorShuffle 334 334 0 1 2
336: 331(fvec3) ExtInst 1(GLSL.std.450) 67(Cross) 333 335
337: 7(float) CompositeExtract 336 0
338: 7(float) Load 302(f)
339: 7(float) FAdd 338 337

View File

@@ -86,7 +86,7 @@ Linked fragment stage:
67: 14(int) Constant 0
68: TypeInt 32 0
69: 68(int) Constant 0
97: TypeVector 7(float) 2
96: TypeVector 7(float) 2
110: 68(int) Constant 2
142: 7(float) Constant 0
143: 8(fvec3) ConstantComposite 142 142 142
@@ -227,8 +227,8 @@ Linked fragment stage:
34(comp): 15(ptr) FunctionParameter
36: Label
95: 14(int) Load 34(comp)
96: 8(fvec3) CompositeExtract 33(i) 0
98: 97(fvec2) VectorShuffle 96 96 1 0
97: 8(fvec3) CompositeExtract 33(i) 0
98: 96(fvec2) VectorShuffle 97 97 1 0
99: 7(float) VectorExtractDynamic 98 95
100: 8(fvec3) Load 66(OutColor)
101: 8(fvec3) CompositeConstruct 99 99 99
@@ -241,10 +241,10 @@ Linked fragment stage:
38(comp): 15(ptr) FunctionParameter
40: Label
103: 8(fvec3) CompositeExtract 37(i) 0
104: 97(fvec2) VectorShuffle 103 103 0 1
104: 96(fvec2) VectorShuffle 103 103 0 1
105: 8(fvec3) Load 66(OutColor)
106: 97(fvec2) VectorShuffle 105 105 0 1
107: 97(fvec2) FAdd 106 104
106: 96(fvec2) VectorShuffle 105 105 0 1
107: 96(fvec2) FAdd 106 104
108: 8(fvec3) Load 66(OutColor)
109: 8(fvec3) VectorShuffle 108 107 3 4 2
Store 66(OutColor) 109
@@ -279,10 +279,10 @@ Linked fragment stage:
50(comp): 15(ptr) FunctionParameter
52: Label
121: 8(fvec3) CompositeExtract 49(i) 0
122: 97(fvec2) VectorShuffle 121 121 0 1
122: 96(fvec2) VectorShuffle 121 121 0 1
123: 8(fvec3) Load 66(OutColor)
124: 97(fvec2) VectorShuffle 123 123 2 1
125: 97(fvec2) FAdd 124 122
124: 96(fvec2) VectorShuffle 123 123 2 1
125: 96(fvec2) FAdd 124 122
126: 8(fvec3) Load 66(OutColor)
127: 8(fvec3) VectorShuffle 126 125 0 4 3
Store 66(OutColor) 127
@@ -293,10 +293,10 @@ Linked fragment stage:
54(comp): 15(ptr) FunctionParameter
56: Label
128: 8(fvec3) CompositeExtract 53(i) 0
129: 97(fvec2) VectorShuffle 128 128 0 1
129: 96(fvec2) VectorShuffle 128 128 0 1
130: 8(fvec3) Load 66(OutColor)
131: 97(fvec2) VectorShuffle 130 130 0 2
132: 97(fvec2) FAdd 131 129
131: 96(fvec2) VectorShuffle 130 130 0 2
132: 96(fvec2) FAdd 131 129
133: 8(fvec3) Load 66(OutColor)
134: 8(fvec3) VectorShuffle 133 132 3 1 4
Store 66(OutColor) 134

View File

@@ -57,7 +57,7 @@ Linked compute stage:
25: TypeVector 24(int) 3
26: TypePointer Input 25(ivec3)
27(gl_GlobalInvocationID): 26(ptr) Variable Input
29: TypeVector 24(int) 2
28: TypeVector 24(int) 2
32: TypePointer Function 8(float)
34(gl_LocalInvocationID): 26(ptr) Variable Input
38: 12(int) Constant 8
@@ -86,12 +86,12 @@ Linked compute stage:
Store 16 14
20: 19(ptr) AccessChain 11(bufInst) 17
Store 20 18
28: 25(ivec3) Load 27(gl_GlobalInvocationID)
30: 29(ivec2) VectorShuffle 28 28 0 1
29: 25(ivec3) Load 27(gl_GlobalInvocationID)
30: 28(ivec2) VectorShuffle 29 29 0 1
31: 21(ivec2) Bitcast 30
Store 23(storePos) 31
35: 25(ivec3) Load 34(gl_LocalInvocationID)
36: 29(ivec2) VectorShuffle 35 35 0 1
36: 28(ivec2) VectorShuffle 35 35 0 1
37: 21(ivec2) Bitcast 36
39: 21(ivec2) CompositeConstruct 38 38
40: 21(ivec2) ISub 37 39

View File

@@ -58,7 +58,7 @@ Linked fragment stage:
50: TypePointer UniformConstant 49(ivec4)
51(v4): 50(ptr) Variable UniformConstant
71: 48(int) Constant 4
86: TypeVector 7(float) 3
85: TypeVector 7(float) 3
97: TypePointer Input 7(float)
98(f): 97(ptr) Variable Input
116: 14(int) Constant 16
@@ -145,8 +145,8 @@ Linked fragment stage:
82: 8(fvec4) Load 36(gl_FragColor)
83: 8(fvec4) FAdd 82 81
Store 36(gl_FragColor) 83
85: 8(fvec4) Load 12(BaseColor)
87: 86(fvec3) VectorShuffle 85 85 0 1 2
86: 8(fvec4) Load 12(BaseColor)
87: 85(fvec3) VectorShuffle 86 86 0 1 2
88: 8(fvec4) Load 84(r)
89: 8(fvec4) VectorShuffle 88 87 4 5 6 3
Store 84(r) 89
@@ -169,10 +169,10 @@ Linked fragment stage:
Branch 91
92: Label
104: 8(fvec4) Load 84(r)
105: 86(fvec3) VectorShuffle 104 104 0 1 2
105: 85(fvec3) VectorShuffle 104 104 0 1 2
106: 8(fvec4) Load 36(gl_FragColor)
107: 86(fvec3) VectorShuffle 106 106 0 1 2
108: 86(fvec3) FAdd 107 105
107: 85(fvec3) VectorShuffle 106 106 0 1 2
108: 85(fvec3) FAdd 107 105
109: 8(fvec4) Load 36(gl_FragColor)
110: 8(fvec4) VectorShuffle 109 108 4 5 6 3
Store 36(gl_FragColor) 110