[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.
This commit is contained in:
Jim Blandy
2024-12-24 11:56:33 -08:00
committed by Erich Gubler
parent 28760125a7
commit 04f0de6d64
4 changed files with 186 additions and 168 deletions

View File

@@ -53,6 +53,7 @@ var<private> ivfs_af = vec2<f32>(1.0);
var<private> iafafaf = array<f32, 2>(1.0, 2.0);
var<private> iafaiai = array<f32, 2>(1, 2);
var<private> iaipaiai = array(1, 2);
var<private> iafpafaf = array(1.0, 2.0);
var<private> iafpaiaf = array(1, 2.0);
var<private> iafpafai = array(1.0, 2);
@@ -93,13 +94,16 @@ fn all_constant_arguments() {
var xai_iai: array<i32, 2> = array<i32, 2>(1i, 2);
var xaiai_i: array<i32, 2> = array<i32, 2>(1, 2i);
// Ideally these would infer the var type from the initializer,
// but we don't support that yet.
var xaipaiai: array<i32, 2> = array(1, 2);
var xafpaiai: array<f32, 2> = array(1, 2);
var xafpaiaf: array<f32, 2> = array(1, 2.0);
var xafpafai: array<f32, 2> = array(1.0, 2);
var xafpafaf: array<f32, 2> = array(1.0, 2.0);
var iaipaiai = array(1, 2);
var iafpaiaf = array(1, 2.0);
var iafpafai = array(1.0, 2);
var iafpafaf = array(1.0, 2.0);
}
fn mixed_constant_and_runtime_arguments() {

View File

@@ -46,6 +46,10 @@ void all_constant_arguments(
type_7 xafpaiaf = type_7 {1.0, 2.0};
type_7 xafpafai = type_7 {1.0, 2.0};
type_7 xafpafaf = type_7 {1.0, 2.0};
type_8 iaipaiai = type_8 {1, 2};
type_7 iafpaiaf = type_7 {1.0, 2.0};
type_7 iafpafai = type_7 {1.0, 2.0};
type_7 iafpafaf = type_7 {1.0, 2.0};
}
void mixed_constant_and_runtime_arguments(

View File

@@ -1,7 +1,7 @@
; SPIR-V
; Version: 1.1
; Generator: rspirv
; Bound: 220
; Bound: 225
OpCapability Shader
OpCapability Linkage
%1 = OpExtInstImport "GLSL.std.450"
@@ -84,171 +84,176 @@ OpDecorate %12 ArrayStride 4
%75 = OpVariable %45 Private %34
%76 = OpVariable %63 Private %37
%77 = OpVariable %63 Private %37
%78 = OpVariable %63 Private %37
%78 = OpVariable %66 Private %39
%79 = OpVariable %63 Private %37
%80 = OpVariable %63 Private %37
%83 = OpTypeFunction %2
%85 = OpTypePointer Function %4
%87 = OpTypePointer Function %6
%89 = OpTypePointer Function %8
%95 = OpTypePointer Function %9
%111 = OpTypePointer Function %10
%116 = OpTypePointer Function %12
%127 = OpTypePointer Function %5
%128 = OpConstantNull %5
%130 = OpTypePointer Function %3
%131 = OpConstantNull %3
%133 = OpTypePointer Function %7
%134 = OpConstantNull %7
%136 = OpConstantNull %6
%138 = OpConstantNull %6
%140 = OpConstantNull %6
%142 = OpConstantNull %6
%144 = OpConstantNull %9
%146 = OpConstantNull %9
%148 = OpConstantNull %9
%150 = OpConstantNull %9
%152 = OpConstantNull %10
%154 = OpConstantNull %10
%156 = OpConstantNull %10
%158 = OpConstantNull %10
%160 = OpConstantNull %12
%162 = OpConstantNull %12
%164 = OpConstantNull %10
%166 = OpConstantNull %10
%168 = OpConstantNull %10
%170 = OpConstantNull %10
%172 = OpConstantNull %12
%174 = OpConstantNull %12
%82 = OpFunction %2 None %83
%81 = OpLabel
%120 = OpVariable %111 Function %37
%117 = OpVariable %116 Function %39
%113 = OpVariable %111 Function %37
%109 = OpVariable %89 Function %34
%106 = OpVariable %85 Function %33
%103 = OpVariable %95 Function %31
%100 = OpVariable %95 Function %31
%97 = OpVariable %95 Function %31
%93 = OpVariable %87 Function %24
%90 = OpVariable %87 Function %24
%84 = OpVariable %85 Function %15
%121 = OpVariable %111 Function %37
%118 = OpVariable %116 Function %39
%114 = OpVariable %111 Function %37
%110 = OpVariable %111 Function %37
%107 = OpVariable %87 Function %36
%104 = OpVariable %85 Function %33
%101 = OpVariable %95 Function %31
%98 = OpVariable %95 Function %31
%94 = OpVariable %95 Function %31
%91 = OpVariable %87 Function %24
%86 = OpVariable %87 Function %18
%122 = OpVariable %111 Function %37
%119 = OpVariable %111 Function %37
%115 = OpVariable %116 Function %39
%112 = OpVariable %111 Function %37
%108 = OpVariable %89 Function %34
%105 = OpVariable %89 Function %34
%102 = OpVariable %95 Function %31
%99 = OpVariable %95 Function %31
%96 = OpVariable %95 Function %31
%92 = OpVariable %87 Function %24
%88 = OpVariable %89 Function %21
OpBranch %123
%123 = OpLabel
%81 = OpVariable %63 Private %37
%84 = OpTypeFunction %2
%86 = OpTypePointer Function %4
%88 = OpTypePointer Function %6
%90 = OpTypePointer Function %8
%96 = OpTypePointer Function %9
%112 = OpTypePointer Function %10
%117 = OpTypePointer Function %12
%132 = OpTypePointer Function %5
%133 = OpConstantNull %5
%135 = OpTypePointer Function %3
%136 = OpConstantNull %3
%138 = OpTypePointer Function %7
%139 = OpConstantNull %7
%141 = OpConstantNull %6
%143 = OpConstantNull %6
%145 = OpConstantNull %6
%147 = OpConstantNull %6
%149 = OpConstantNull %9
%151 = OpConstantNull %9
%153 = OpConstantNull %9
%155 = OpConstantNull %9
%157 = OpConstantNull %10
%159 = OpConstantNull %10
%161 = OpConstantNull %10
%163 = OpConstantNull %10
%165 = OpConstantNull %12
%167 = OpConstantNull %12
%169 = OpConstantNull %10
%171 = OpConstantNull %10
%173 = OpConstantNull %10
%175 = OpConstantNull %10
%177 = OpConstantNull %12
%179 = OpConstantNull %12
%83 = OpFunction %2 None %84
%82 = OpLabel
%127 = OpVariable %112 Function %37
%124 = OpVariable %117 Function %39
%121 = OpVariable %112 Function %37
%118 = OpVariable %117 Function %39
%114 = OpVariable %112 Function %37
%110 = OpVariable %90 Function %34
%107 = OpVariable %86 Function %33
%104 = OpVariable %96 Function %31
%101 = OpVariable %96 Function %31
%98 = OpVariable %96 Function %31
%94 = OpVariable %88 Function %24
%91 = OpVariable %88 Function %24
%85 = OpVariable %86 Function %15
%125 = OpVariable %112 Function %37
%122 = OpVariable %112 Function %37
%119 = OpVariable %117 Function %39
%115 = OpVariable %112 Function %37
%111 = OpVariable %112 Function %37
%108 = OpVariable %88 Function %36
%105 = OpVariable %86 Function %33
%102 = OpVariable %96 Function %31
%99 = OpVariable %96 Function %31
%95 = OpVariable %96 Function %31
%92 = OpVariable %88 Function %24
%87 = OpVariable %88 Function %18
%126 = OpVariable %112 Function %37
%123 = OpVariable %112 Function %37
%120 = OpVariable %112 Function %37
%116 = OpVariable %117 Function %39
%113 = OpVariable %112 Function %37
%109 = OpVariable %90 Function %34
%106 = OpVariable %90 Function %34
%103 = OpVariable %96 Function %31
%100 = OpVariable %96 Function %31
%97 = OpVariable %96 Function %31
%93 = OpVariable %88 Function %24
%89 = OpVariable %90 Function %21
OpBranch %128
%128 = OpLabel
OpReturn
OpFunctionEnd
%125 = OpFunction %2 None %83
%124 = OpLabel
%173 = OpVariable %116 Function %174
%167 = OpVariable %111 Function %168
%161 = OpVariable %116 Function %162
%155 = OpVariable %111 Function %156
%149 = OpVariable %95 Function %150
%143 = OpVariable %95 Function %144
%137 = OpVariable %87 Function %138
%129 = OpVariable %130 Function %131
%171 = OpVariable %116 Function %172
%165 = OpVariable %111 Function %166
%159 = OpVariable %116 Function %160
%153 = OpVariable %111 Function %154
%147 = OpVariable %95 Function %148
%141 = OpVariable %87 Function %142
%135 = OpVariable %87 Function %136
%126 = OpVariable %127 Function %128
%169 = OpVariable %111 Function %170
%163 = OpVariable %111 Function %164
%157 = OpVariable %111 Function %158
%151 = OpVariable %111 Function %152
%145 = OpVariable %95 Function %146
%139 = OpVariable %87 Function %140
%132 = OpVariable %133 Function %134
OpBranch %175
%175 = OpLabel
%176 = OpLoad %5 %126
%177 = OpCompositeConstruct %6 %176 %23
OpStore %135 %177
%178 = OpLoad %5 %126
%179 = OpCompositeConstruct %6 %22 %178
OpStore %137 %179
%180 = OpLoad %5 %126
%181 = OpCompositeConstruct %6 %180 %23
OpStore %139 %181
%182 = OpLoad %5 %126
%183 = OpCompositeConstruct %6 %22 %182
OpStore %141 %183
%184 = OpLoad %7 %132
%185 = OpCompositeConstruct %8 %184 %26
%186 = OpCompositeConstruct %9 %185 %30
OpStore %143 %186
%187 = OpLoad %7 %132
%188 = OpCompositeConstruct %8 %25 %187
%189 = OpCompositeConstruct %9 %188 %30
OpStore %145 %189
%190 = OpLoad %7 %132
%191 = OpCompositeConstruct %8 %190 %29
%192 = OpCompositeConstruct %9 %27 %191
OpStore %147 %192
%193 = OpLoad %7 %132
%194 = OpCompositeConstruct %8 %28 %193
%195 = OpCompositeConstruct %9 %27 %194
OpStore %149 %195
%196 = OpLoad %7 %132
%197 = OpCompositeConstruct %10 %196 %26
OpStore %151 %197
%198 = OpLoad %7 %132
%199 = OpCompositeConstruct %10 %25 %198
OpStore %153 %199
%200 = OpLoad %7 %132
%201 = OpCompositeConstruct %10 %200 %26
OpStore %155 %201
%202 = OpLoad %7 %132
%203 = OpCompositeConstruct %10 %25 %202
OpStore %157 %203
%204 = OpLoad %3 %129
%205 = OpCompositeConstruct %12 %204 %38
OpStore %159 %205
%206 = OpLoad %3 %129
%207 = OpCompositeConstruct %12 %32 %206
OpStore %161 %207
%208 = OpLoad %7 %132
%209 = OpCompositeConstruct %10 %208 %26
OpStore %163 %209
%210 = OpLoad %7 %132
%211 = OpCompositeConstruct %10 %25 %210
OpStore %165 %211
%212 = OpLoad %7 %132
%213 = OpCompositeConstruct %10 %212 %26
OpStore %167 %213
%214 = OpLoad %7 %132
%215 = OpCompositeConstruct %10 %25 %214
OpStore %169 %215
%216 = OpLoad %3 %129
%217 = OpCompositeConstruct %12 %216 %38
OpStore %171 %217
%218 = OpLoad %3 %129
%219 = OpCompositeConstruct %12 %32 %218
OpStore %173 %219
%130 = OpFunction %2 None %84
%129 = OpLabel
%178 = OpVariable %117 Function %179
%172 = OpVariable %112 Function %173
%166 = OpVariable %117 Function %167
%160 = OpVariable %112 Function %161
%154 = OpVariable %96 Function %155
%148 = OpVariable %96 Function %149
%142 = OpVariable %88 Function %143
%134 = OpVariable %135 Function %136
%176 = OpVariable %117 Function %177
%170 = OpVariable %112 Function %171
%164 = OpVariable %117 Function %165
%158 = OpVariable %112 Function %159
%152 = OpVariable %96 Function %153
%146 = OpVariable %88 Function %147
%140 = OpVariable %88 Function %141
%131 = OpVariable %132 Function %133
%174 = OpVariable %112 Function %175
%168 = OpVariable %112 Function %169
%162 = OpVariable %112 Function %163
%156 = OpVariable %112 Function %157
%150 = OpVariable %96 Function %151
%144 = OpVariable %88 Function %145
%137 = OpVariable %138 Function %139
OpBranch %180
%180 = OpLabel
%181 = OpLoad %5 %131
%182 = OpCompositeConstruct %6 %181 %23
OpStore %140 %182
%183 = OpLoad %5 %131
%184 = OpCompositeConstruct %6 %22 %183
OpStore %142 %184
%185 = OpLoad %5 %131
%186 = OpCompositeConstruct %6 %185 %23
OpStore %144 %186
%187 = OpLoad %5 %131
%188 = OpCompositeConstruct %6 %22 %187
OpStore %146 %188
%189 = OpLoad %7 %137
%190 = OpCompositeConstruct %8 %189 %26
%191 = OpCompositeConstruct %9 %190 %30
OpStore %148 %191
%192 = OpLoad %7 %137
%193 = OpCompositeConstruct %8 %25 %192
%194 = OpCompositeConstruct %9 %193 %30
OpStore %150 %194
%195 = OpLoad %7 %137
%196 = OpCompositeConstruct %8 %195 %29
%197 = OpCompositeConstruct %9 %27 %196
OpStore %152 %197
%198 = OpLoad %7 %137
%199 = OpCompositeConstruct %8 %28 %198
%200 = OpCompositeConstruct %9 %27 %199
OpStore %154 %200
%201 = OpLoad %7 %137
%202 = OpCompositeConstruct %10 %201 %26
OpStore %156 %202
%203 = OpLoad %7 %137
%204 = OpCompositeConstruct %10 %25 %203
OpStore %158 %204
%205 = OpLoad %7 %137
%206 = OpCompositeConstruct %10 %205 %26
OpStore %160 %206
%207 = OpLoad %7 %137
%208 = OpCompositeConstruct %10 %25 %207
OpStore %162 %208
%209 = OpLoad %3 %134
%210 = OpCompositeConstruct %12 %209 %38
OpStore %164 %210
%211 = OpLoad %3 %134
%212 = OpCompositeConstruct %12 %32 %211
OpStore %166 %212
%213 = OpLoad %7 %137
%214 = OpCompositeConstruct %10 %213 %26
OpStore %168 %214
%215 = OpLoad %7 %137
%216 = OpCompositeConstruct %10 %25 %215
OpStore %170 %216
%217 = OpLoad %7 %137
%218 = OpCompositeConstruct %10 %217 %26
OpStore %172 %218
%219 = OpLoad %7 %137
%220 = OpCompositeConstruct %10 %25 %219
OpStore %174 %220
%221 = OpLoad %3 %134
%222 = OpCompositeConstruct %12 %221 %38
OpStore %176 %222
%223 = OpLoad %3 %134
%224 = OpCompositeConstruct %12 %32 %223
OpStore %178 %224
OpReturn
OpFunctionEnd

View File

@@ -30,9 +30,10 @@ var<private> ivfs_ai: vec2<f32> = vec2(1f);
var<private> ivfs_af: vec2<f32> = vec2(1f);
var<private> iafafaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafaiai: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafpafaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafpaiaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafpafai: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iaipaiai_1: array<i32, 2> = array<i32, 2>(1i, 2i);
var<private> iafpafaf_1: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafpaiaf_1: array<f32, 2> = array<f32, 2>(1f, 2f);
var<private> iafpafai_1: array<f32, 2> = array<f32, 2>(1f, 2f);
fn all_constant_arguments() {
var xvipaiai: vec2<i32> = vec2<i32>(42i, 43i);
@@ -68,6 +69,10 @@ fn all_constant_arguments() {
var xafpaiaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var xafpafai: array<f32, 2> = array<f32, 2>(1f, 2f);
var xafpafaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var iaipaiai: array<i32, 2> = array<i32, 2>(1i, 2i);
var iafpaiaf: array<f32, 2> = array<f32, 2>(1f, 2f);
var iafpafai: array<f32, 2> = array<f32, 2>(1f, 2f);
var iafpafaf: array<f32, 2> = array<f32, 2>(1f, 2f);
}