Skip to content

Commit 04f0de6

Browse files
jimblandyErichDonGubler
authored andcommitted
[naga] Add some tests to in/abstract-types-var.wgsl.
Fill out a few more cases for variable type inference and automatic conversions of initializers.
1 parent 2876012 commit 04f0de6

File tree

4 files changed

+186
-168
lines changed

4 files changed

+186
-168
lines changed

naga/tests/in/abstract-types-var.wgsl

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var<private> ivfs_af = vec2<f32>(1.0);
5353
var<private> iafafaf = array<f32, 2>(1.0, 2.0);
5454
var<private> iafaiai = array<f32, 2>(1, 2);
5555

56+
var<private> iaipaiai = array(1, 2);
5657
var<private> iafpafaf = array(1.0, 2.0);
5758
var<private> iafpaiaf = array(1, 2.0);
5859
var<private> iafpafai = array(1.0, 2);
@@ -93,13 +94,16 @@ fn all_constant_arguments() {
9394
var xai_iai: array<i32, 2> = array<i32, 2>(1i, 2);
9495
var xaiai_i: array<i32, 2> = array<i32, 2>(1, 2i);
9596

96-
// Ideally these would infer the var type from the initializer,
97-
// but we don't support that yet.
9897
var xaipaiai: array<i32, 2> = array(1, 2);
9998
var xafpaiai: array<f32, 2> = array(1, 2);
10099
var xafpaiaf: array<f32, 2> = array(1, 2.0);
101100
var xafpafai: array<f32, 2> = array(1.0, 2);
102101
var xafpafaf: array<f32, 2> = array(1.0, 2.0);
102+
103+
var iaipaiai = array(1, 2);
104+
var iafpaiaf = array(1, 2.0);
105+
var iafpafai = array(1.0, 2);
106+
var iafpafaf = array(1.0, 2.0);
103107
}
104108

105109
fn mixed_constant_and_runtime_arguments() {

naga/tests/out/msl/abstract-types-var.msl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ void all_constant_arguments(
4646
type_7 xafpaiaf = type_7 {1.0, 2.0};
4747
type_7 xafpafai = type_7 {1.0, 2.0};
4848
type_7 xafpafaf = type_7 {1.0, 2.0};
49+
type_8 iaipaiai = type_8 {1, 2};
50+
type_7 iafpaiaf = type_7 {1.0, 2.0};
51+
type_7 iafpafai = type_7 {1.0, 2.0};
52+
type_7 iafpafaf = type_7 {1.0, 2.0};
4953
}
5054

5155
void mixed_constant_and_runtime_arguments(
Lines changed: 168 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
; SPIR-V
22
; Version: 1.1
33
; Generator: rspirv
4-
; Bound: 220
4+
; Bound: 225
55
OpCapability Shader
66
OpCapability Linkage
77
%1 = OpExtInstImport "GLSL.std.450"
@@ -84,171 +84,176 @@ OpDecorate %12 ArrayStride 4
8484
%75 = OpVariable %45 Private %34
8585
%76 = OpVariable %63 Private %37
8686
%77 = OpVariable %63 Private %37
87-
%78 = OpVariable %63 Private %37
87+
%78 = OpVariable %66 Private %39
8888
%79 = OpVariable %63 Private %37
8989
%80 = OpVariable %63 Private %37
90-
%83 = OpTypeFunction %2
91-
%85 = OpTypePointer Function %4
92-
%87 = OpTypePointer Function %6
93-
%89 = OpTypePointer Function %8
94-
%95 = OpTypePointer Function %9
95-
%111 = OpTypePointer Function %10
96-
%116 = OpTypePointer Function %12
97-
%127 = OpTypePointer Function %5
98-
%128 = OpConstantNull %5
99-
%130 = OpTypePointer Function %3
100-
%131 = OpConstantNull %3
101-
%133 = OpTypePointer Function %7
102-
%134 = OpConstantNull %7
103-
%136 = OpConstantNull %6
104-
%138 = OpConstantNull %6
105-
%140 = OpConstantNull %6
106-
%142 = OpConstantNull %6
107-
%144 = OpConstantNull %9
108-
%146 = OpConstantNull %9
109-
%148 = OpConstantNull %9
110-
%150 = OpConstantNull %9
111-
%152 = OpConstantNull %10
112-
%154 = OpConstantNull %10
113-
%156 = OpConstantNull %10
114-
%158 = OpConstantNull %10
115-
%160 = OpConstantNull %12
116-
%162 = OpConstantNull %12
117-
%164 = OpConstantNull %10
118-
%166 = OpConstantNull %10
119-
%168 = OpConstantNull %10
120-
%170 = OpConstantNull %10
121-
%172 = OpConstantNull %12
122-
%174 = OpConstantNull %12
123-
%82 = OpFunction %2 None %83
124-
%81 = OpLabel
125-
%120 = OpVariable %111 Function %37
126-
%117 = OpVariable %116 Function %39
127-
%113 = OpVariable %111 Function %37
128-
%109 = OpVariable %89 Function %34
129-
%106 = OpVariable %85 Function %33
130-
%103 = OpVariable %95 Function %31
131-
%100 = OpVariable %95 Function %31
132-
%97 = OpVariable %95 Function %31
133-
%93 = OpVariable %87 Function %24
134-
%90 = OpVariable %87 Function %24
135-
%84 = OpVariable %85 Function %15
136-
%121 = OpVariable %111 Function %37
137-
%118 = OpVariable %116 Function %39
138-
%114 = OpVariable %111 Function %37
139-
%110 = OpVariable %111 Function %37
140-
%107 = OpVariable %87 Function %36
141-
%104 = OpVariable %85 Function %33
142-
%101 = OpVariable %95 Function %31
143-
%98 = OpVariable %95 Function %31
144-
%94 = OpVariable %95 Function %31
145-
%91 = OpVariable %87 Function %24
146-
%86 = OpVariable %87 Function %18
147-
%122 = OpVariable %111 Function %37
148-
%119 = OpVariable %111 Function %37
149-
%115 = OpVariable %116 Function %39
150-
%112 = OpVariable %111 Function %37
151-
%108 = OpVariable %89 Function %34
152-
%105 = OpVariable %89 Function %34
153-
%102 = OpVariable %95 Function %31
154-
%99 = OpVariable %95 Function %31
155-
%96 = OpVariable %95 Function %31
156-
%92 = OpVariable %87 Function %24
157-
%88 = OpVariable %89 Function %21
158-
OpBranch %123
159-
%123 = OpLabel
90+
%81 = OpVariable %63 Private %37
91+
%84 = OpTypeFunction %2
92+
%86 = OpTypePointer Function %4
93+
%88 = OpTypePointer Function %6
94+
%90 = OpTypePointer Function %8
95+
%96 = OpTypePointer Function %9
96+
%112 = OpTypePointer Function %10
97+
%117 = OpTypePointer Function %12
98+
%132 = OpTypePointer Function %5
99+
%133 = OpConstantNull %5
100+
%135 = OpTypePointer Function %3
101+
%136 = OpConstantNull %3
102+
%138 = OpTypePointer Function %7
103+
%139 = OpConstantNull %7
104+
%141 = OpConstantNull %6
105+
%143 = OpConstantNull %6
106+
%145 = OpConstantNull %6
107+
%147 = OpConstantNull %6
108+
%149 = OpConstantNull %9
109+
%151 = OpConstantNull %9
110+
%153 = OpConstantNull %9
111+
%155 = OpConstantNull %9
112+
%157 = OpConstantNull %10
113+
%159 = OpConstantNull %10
114+
%161 = OpConstantNull %10
115+
%163 = OpConstantNull %10
116+
%165 = OpConstantNull %12
117+
%167 = OpConstantNull %12
118+
%169 = OpConstantNull %10
119+
%171 = OpConstantNull %10
120+
%173 = OpConstantNull %10
121+
%175 = OpConstantNull %10
122+
%177 = OpConstantNull %12
123+
%179 = OpConstantNull %12
124+
%83 = OpFunction %2 None %84
125+
%82 = OpLabel
126+
%127 = OpVariable %112 Function %37
127+
%124 = OpVariable %117 Function %39
128+
%121 = OpVariable %112 Function %37
129+
%118 = OpVariable %117 Function %39
130+
%114 = OpVariable %112 Function %37
131+
%110 = OpVariable %90 Function %34
132+
%107 = OpVariable %86 Function %33
133+
%104 = OpVariable %96 Function %31
134+
%101 = OpVariable %96 Function %31
135+
%98 = OpVariable %96 Function %31
136+
%94 = OpVariable %88 Function %24
137+
%91 = OpVariable %88 Function %24
138+
%85 = OpVariable %86 Function %15
139+
%125 = OpVariable %112 Function %37
140+
%122 = OpVariable %112 Function %37
141+
%119 = OpVariable %117 Function %39
142+
%115 = OpVariable %112 Function %37
143+
%111 = OpVariable %112 Function %37
144+
%108 = OpVariable %88 Function %36
145+
%105 = OpVariable %86 Function %33
146+
%102 = OpVariable %96 Function %31
147+
%99 = OpVariable %96 Function %31
148+
%95 = OpVariable %96 Function %31
149+
%92 = OpVariable %88 Function %24
150+
%87 = OpVariable %88 Function %18
151+
%126 = OpVariable %112 Function %37
152+
%123 = OpVariable %112 Function %37
153+
%120 = OpVariable %112 Function %37
154+
%116 = OpVariable %117 Function %39
155+
%113 = OpVariable %112 Function %37
156+
%109 = OpVariable %90 Function %34
157+
%106 = OpVariable %90 Function %34
158+
%103 = OpVariable %96 Function %31
159+
%100 = OpVariable %96 Function %31
160+
%97 = OpVariable %96 Function %31
161+
%93 = OpVariable %88 Function %24
162+
%89 = OpVariable %90 Function %21
163+
OpBranch %128
164+
%128 = OpLabel
160165
OpReturn
161166
OpFunctionEnd
162-
%125 = OpFunction %2 None %83
163-
%124 = OpLabel
164-
%173 = OpVariable %116 Function %174
165-
%167 = OpVariable %111 Function %168
166-
%161 = OpVariable %116 Function %162
167-
%155 = OpVariable %111 Function %156
168-
%149 = OpVariable %95 Function %150
169-
%143 = OpVariable %95 Function %144
170-
%137 = OpVariable %87 Function %138
171-
%129 = OpVariable %130 Function %131
172-
%171 = OpVariable %116 Function %172
173-
%165 = OpVariable %111 Function %166
174-
%159 = OpVariable %116 Function %160
175-
%153 = OpVariable %111 Function %154
176-
%147 = OpVariable %95 Function %148
177-
%141 = OpVariable %87 Function %142
178-
%135 = OpVariable %87 Function %136
179-
%126 = OpVariable %127 Function %128
180-
%169 = OpVariable %111 Function %170
181-
%163 = OpVariable %111 Function %164
182-
%157 = OpVariable %111 Function %158
183-
%151 = OpVariable %111 Function %152
184-
%145 = OpVariable %95 Function %146
185-
%139 = OpVariable %87 Function %140
186-
%132 = OpVariable %133 Function %134
187-
OpBranch %175
188-
%175 = OpLabel
189-
%176 = OpLoad %5 %126
190-
%177 = OpCompositeConstruct %6 %176 %23
191-
OpStore %135 %177
192-
%178 = OpLoad %5 %126
193-
%179 = OpCompositeConstruct %6 %22 %178
194-
OpStore %137 %179
195-
%180 = OpLoad %5 %126
196-
%181 = OpCompositeConstruct %6 %180 %23
197-
OpStore %139 %181
198-
%182 = OpLoad %5 %126
199-
%183 = OpCompositeConstruct %6 %22 %182
200-
OpStore %141 %183
201-
%184 = OpLoad %7 %132
202-
%185 = OpCompositeConstruct %8 %184 %26
203-
%186 = OpCompositeConstruct %9 %185 %30
204-
OpStore %143 %186
205-
%187 = OpLoad %7 %132
206-
%188 = OpCompositeConstruct %8 %25 %187
207-
%189 = OpCompositeConstruct %9 %188 %30
208-
OpStore %145 %189
209-
%190 = OpLoad %7 %132
210-
%191 = OpCompositeConstruct %8 %190 %29
211-
%192 = OpCompositeConstruct %9 %27 %191
212-
OpStore %147 %192
213-
%193 = OpLoad %7 %132
214-
%194 = OpCompositeConstruct %8 %28 %193
215-
%195 = OpCompositeConstruct %9 %27 %194
216-
OpStore %149 %195
217-
%196 = OpLoad %7 %132
218-
%197 = OpCompositeConstruct %10 %196 %26
219-
OpStore %151 %197
220-
%198 = OpLoad %7 %132
221-
%199 = OpCompositeConstruct %10 %25 %198
222-
OpStore %153 %199
223-
%200 = OpLoad %7 %132
224-
%201 = OpCompositeConstruct %10 %200 %26
225-
OpStore %155 %201
226-
%202 = OpLoad %7 %132
227-
%203 = OpCompositeConstruct %10 %25 %202
228-
OpStore %157 %203
229-
%204 = OpLoad %3 %129
230-
%205 = OpCompositeConstruct %12 %204 %38
231-
OpStore %159 %205
232-
%206 = OpLoad %3 %129
233-
%207 = OpCompositeConstruct %12 %32 %206
234-
OpStore %161 %207
235-
%208 = OpLoad %7 %132
236-
%209 = OpCompositeConstruct %10 %208 %26
237-
OpStore %163 %209
238-
%210 = OpLoad %7 %132
239-
%211 = OpCompositeConstruct %10 %25 %210
240-
OpStore %165 %211
241-
%212 = OpLoad %7 %132
242-
%213 = OpCompositeConstruct %10 %212 %26
243-
OpStore %167 %213
244-
%214 = OpLoad %7 %132
245-
%215 = OpCompositeConstruct %10 %25 %214
246-
OpStore %169 %215
247-
%216 = OpLoad %3 %129
248-
%217 = OpCompositeConstruct %12 %216 %38
249-
OpStore %171 %217
250-
%218 = OpLoad %3 %129
251-
%219 = OpCompositeConstruct %12 %32 %218
252-
OpStore %173 %219
167+
%130 = OpFunction %2 None %84
168+
%129 = OpLabel
169+
%178 = OpVariable %117 Function %179
170+
%172 = OpVariable %112 Function %173
171+
%166 = OpVariable %117 Function %167
172+
%160 = OpVariable %112 Function %161
173+
%154 = OpVariable %96 Function %155
174+
%148 = OpVariable %96 Function %149
175+
%142 = OpVariable %88 Function %143
176+
%134 = OpVariable %135 Function %136
177+
%176 = OpVariable %117 Function %177
178+
%170 = OpVariable %112 Function %171
179+
%164 = OpVariable %117 Function %165
180+
%158 = OpVariable %112 Function %159
181+
%152 = OpVariable %96 Function %153
182+
%146 = OpVariable %88 Function %147
183+
%140 = OpVariable %88 Function %141
184+
%131 = OpVariable %132 Function %133
185+
%174 = OpVariable %112 Function %175
186+
%168 = OpVariable %112 Function %169
187+
%162 = OpVariable %112 Function %163
188+
%156 = OpVariable %112 Function %157
189+
%150 = OpVariable %96 Function %151
190+
%144 = OpVariable %88 Function %145
191+
%137 = OpVariable %138 Function %139
192+
OpBranch %180
193+
%180 = OpLabel
194+
%181 = OpLoad %5 %131
195+
%182 = OpCompositeConstruct %6 %181 %23
196+
OpStore %140 %182
197+
%183 = OpLoad %5 %131
198+
%184 = OpCompositeConstruct %6 %22 %183
199+
OpStore %142 %184
200+
%185 = OpLoad %5 %131
201+
%186 = OpCompositeConstruct %6 %185 %23
202+
OpStore %144 %186
203+
%187 = OpLoad %5 %131
204+
%188 = OpCompositeConstruct %6 %22 %187
205+
OpStore %146 %188
206+
%189 = OpLoad %7 %137
207+
%190 = OpCompositeConstruct %8 %189 %26
208+
%191 = OpCompositeConstruct %9 %190 %30
209+
OpStore %148 %191
210+
%192 = OpLoad %7 %137
211+
%193 = OpCompositeConstruct %8 %25 %192
212+
%194 = OpCompositeConstruct %9 %193 %30
213+
OpStore %150 %194
214+
%195 = OpLoad %7 %137
215+
%196 = OpCompositeConstruct %8 %195 %29
216+
%197 = OpCompositeConstruct %9 %27 %196
217+
OpStore %152 %197
218+
%198 = OpLoad %7 %137
219+
%199 = OpCompositeConstruct %8 %28 %198
220+
%200 = OpCompositeConstruct %9 %27 %199
221+
OpStore %154 %200
222+
%201 = OpLoad %7 %137
223+
%202 = OpCompositeConstruct %10 %201 %26
224+
OpStore %156 %202
225+
%203 = OpLoad %7 %137
226+
%204 = OpCompositeConstruct %10 %25 %203
227+
OpStore %158 %204
228+
%205 = OpLoad %7 %137
229+
%206 = OpCompositeConstruct %10 %205 %26
230+
OpStore %160 %206
231+
%207 = OpLoad %7 %137
232+
%208 = OpCompositeConstruct %10 %25 %207
233+
OpStore %162 %208
234+
%209 = OpLoad %3 %134
235+
%210 = OpCompositeConstruct %12 %209 %38
236+
OpStore %164 %210
237+
%211 = OpLoad %3 %134
238+
%212 = OpCompositeConstruct %12 %32 %211
239+
OpStore %166 %212
240+
%213 = OpLoad %7 %137
241+
%214 = OpCompositeConstruct %10 %213 %26
242+
OpStore %168 %214
243+
%215 = OpLoad %7 %137
244+
%216 = OpCompositeConstruct %10 %25 %215
245+
OpStore %170 %216
246+
%217 = OpLoad %7 %137
247+
%218 = OpCompositeConstruct %10 %217 %26
248+
OpStore %172 %218
249+
%219 = OpLoad %7 %137
250+
%220 = OpCompositeConstruct %10 %25 %219
251+
OpStore %174 %220
252+
%221 = OpLoad %3 %134
253+
%222 = OpCompositeConstruct %12 %221 %38
254+
OpStore %176 %222
255+
%223 = OpLoad %3 %134
256+
%224 = OpCompositeConstruct %12 %32 %223
257+
OpStore %178 %224
253258
OpReturn
254259
OpFunctionEnd

0 commit comments

Comments
 (0)