GLSL: implement textureNumLayers(), and update expectations.

Bug: tint:1426
Change-Id: I609a34be458c14deef866ab66d7b57b8ee6316f2
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/80580
Reviewed-by: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Stephen White <senorblanco@chromium.org>
diff --git a/src/writer/glsl/generator_impl.cc b/src/writer/glsl/generator_impl.cc
index 66bf4da..022ade2 100644
--- a/src/writer/glsl/generator_impl.cc
+++ b/src/writer/glsl/generator_impl.cc
@@ -1279,8 +1279,34 @@
       }
       return true;
     }
-    // TODO(senorblanco): determine if this works for array textures
-    case sem::BuiltinType::kTextureNumLayers:
+    case sem::BuiltinType::kTextureNumLayers: {
+      if (texture_type->Is<sem::StorageTexture>()) {
+        out << "imageSize(";
+      } else {
+        out << "textureSize(";
+      }
+      // textureSize() on sampler2dArray returns the array size in the
+      // final component, so return it
+      if (!EmitExpression(out, texture)) {
+        return false;
+      }
+      // The LOD parameter is mandatory on textureSize() for non-multisampled
+      // textures.
+      if (!texture_type->Is<sem::StorageTexture>() &&
+          !texture_type->Is<sem::MultisampledTexture>() &&
+          !texture_type->Is<sem::DepthMultisampledTexture>()) {
+        out << ", ";
+        if (auto* level_arg = arg(Usage::kLevel)) {
+          if (!EmitExpression(out, level_arg)) {
+            return false;
+          }
+        } else {
+          out << "0";
+        }
+      }
+      out << ").z";
+      return true;
+    }
     case sem::BuiltinType::kTextureNumLevels: {
       out << "textureQueryLevels(";
       if (!EmitExpression(out, texture)) {
diff --git a/src/writer/glsl/generator_impl_builtin_texture_test.cc b/src/writer/glsl/generator_impl_builtin_texture_test.cc
index 8ec2019..180119c 100644
--- a/src/writer/glsl/generator_impl_builtin_texture_test.cc
+++ b/src/writer/glsl/generator_impl_builtin_texture_test.cc
@@ -103,7 +103,9 @@
     case ValidTextureOverload::kNumLayersDepth2dArray:
     case ValidTextureOverload::kNumLayersCubeArray:
     case ValidTextureOverload::kNumLayersDepthCubeArray:
+      return {"textureSize"};
     case ValidTextureOverload::kNumLayersStorageWO2dArray:
+      return {"imageSize"};
     case ValidTextureOverload::kNumLevels2d:
     case ValidTextureOverload::kNumLevelsCube:
     case ValidTextureOverload::kNumLevelsDepth2d:
diff --git a/test/builtins/gen/textureNumLayers/024820.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/024820.wgsl.expected.glsl
index 9aaedbf..1f9bd05 100644
--- a/test/builtins/gen/textureNumLayers/024820.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/024820.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_024820() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_024820() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_024820() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/053df7.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/053df7.wgsl.expected.glsl
index a413d26..5fe042f 100644
--- a/test/builtins/gen/textureNumLayers/053df7.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/053df7.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 uniform highp usamplerCubeArray arg_0_1;
 void textureNumLayers_053df7() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 uniform highp usamplerCubeArray arg_0_1;
 void textureNumLayers_053df7() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 uniform highp usamplerCubeArray arg_0_1;
 void textureNumLayers_053df7() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/058cc3.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/058cc3.wgsl.expected.glsl
index 6470356..44df962 100644
--- a/test/builtins/gen/textureNumLayers/058cc3.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/058cc3.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 layout(rg32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_058cc3() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 layout(rg32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_058cc3() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 layout(rg32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_058cc3() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/09d05d.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/09d05d.wgsl.expected.glsl
index 703e836..c86d2fb 100644
--- a/test/builtins/gen/textureNumLayers/09d05d.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/09d05d.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba8) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_09d05d() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba8) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_09d05d() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba8) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_09d05d() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/13b4ce.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/13b4ce.wgsl.expected.glsl
index 43a852b..3c9a7f2 100644
--- a/test/builtins/gen/textureNumLayers/13b4ce.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/13b4ce.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_13b4ce() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_13b4ce() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_13b4ce() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/22e53b.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/22e53b.wgsl.expected.glsl
index 3ca623d..5c54b7e 100644
--- a/test/builtins/gen/textureNumLayers/22e53b.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/22e53b.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(r32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_22e53b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(r32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_22e53b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(r32i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_22e53b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/562013.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/562013.wgsl.expected.glsl
index d01feaa..1a2892c 100644
--- a/test/builtins/gen/textureNumLayers/562013.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/562013.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba16f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_562013() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba16f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_562013() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba16f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_562013() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/5d59cd.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/5d59cd.wgsl.expected.glsl
index dbd8565..279b3d8 100644
--- a/test/builtins/gen/textureNumLayers/5d59cd.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/5d59cd.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_5d59cd() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_5d59cd() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_5d59cd() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/68a65b.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/68a65b.wgsl.expected.glsl
index 452dfdc..5a0f0f5 100644
--- a/test/builtins/gen/textureNumLayers/68a65b.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/68a65b.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_68a65b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_68a65b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_68a65b() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/778bd1.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/778bd1.wgsl.expected.glsl
index 125cf2d..ea1d024 100644
--- a/test/builtins/gen/textureNumLayers/778bd1.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/778bd1.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_778bd1() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_778bd1() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 uniform highp samplerCubeArray arg_0_1;
 void textureNumLayers_778bd1() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/7f1937.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/7f1937.wgsl.expected.glsl
index 28b99e8..ff4ca80 100644
--- a/test/builtins/gen/textureNumLayers/7f1937.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/7f1937.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 layout(rg32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_7f1937() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 layout(rg32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_7f1937() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 layout(rg32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_7f1937() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/85f980.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/85f980.wgsl.expected.glsl
index 399cdf3..c050f36 100644
--- a/test/builtins/gen/textureNumLayers/85f980.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/85f980.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 uniform highp isamplerCubeArray arg_0_1;
 void textureNumLayers_85f980() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 uniform highp isamplerCubeArray arg_0_1;
 void textureNumLayers_85f980() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 uniform highp isamplerCubeArray arg_0_1;
 void textureNumLayers_85f980() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/87953e.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/87953e.wgsl.expected.glsl
index c010813..6783694 100644
--- a/test/builtins/gen/textureNumLayers/87953e.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/87953e.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 uniform highp usampler2DArray arg_0_1;
 void textureNumLayers_87953e() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 uniform highp usampler2DArray arg_0_1;
 void textureNumLayers_87953e() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 uniform highp usampler2DArray arg_0_1;
 void textureNumLayers_87953e() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/893e7c.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/893e7c.wgsl.expected.glsl
index 8f091a4..9382cfb 100644
--- a/test/builtins/gen/textureNumLayers/893e7c.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/893e7c.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 uniform highp isampler2DArray arg_0_1;
 void textureNumLayers_893e7c() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 uniform highp isampler2DArray arg_0_1;
 void textureNumLayers_893e7c() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 uniform highp isampler2DArray arg_0_1;
 void textureNumLayers_893e7c() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/9700fb.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/9700fb.wgsl.expected.glsl
index 92e6b9f..a911859 100644
--- a/test/builtins/gen/textureNumLayers/9700fb.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/9700fb.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba16ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_9700fb() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba16ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_9700fb() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba16ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_9700fb() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/a216d2.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/a216d2.wgsl.expected.glsl
index bb9a35d..42d5859 100644
--- a/test/builtins/gen/textureNumLayers/a216d2.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/a216d2.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba8i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_a216d2() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba8i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_a216d2() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba8i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_a216d2() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/cd5dc8.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/cd5dc8.wgsl.expected.glsl
index 0dbc40b..56c729c 100644
--- a/test/builtins/gen/textureNumLayers/cd5dc8.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/cd5dc8.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_cd5dc8() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_cd5dc8() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_cd5dc8() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/d5b228.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/d5b228.wgsl.expected.glsl
index 1c335a5..3264a39 100644
--- a/test/builtins/gen/textureNumLayers/d5b228.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/d5b228.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(r32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_d5b228() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(r32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_d5b228() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(r32f) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_d5b228() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/e31be1.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/e31be1.wgsl.expected.glsl
index caf4bee..5f39ba1 100644
--- a/test/builtins/gen/textureNumLayers/e31be1.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/e31be1.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba8_snorm) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_e31be1() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba8_snorm) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_e31be1() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba8_snorm) uniform highp writeonly image2DArray arg_0;
 void textureNumLayers_e31be1() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/e653c0.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/e653c0.wgsl.expected.glsl
index ba34f64..bca9bd4 100644
--- a/test/builtins/gen/textureNumLayers/e653c0.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/e653c0.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_e653c0() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_e653c0() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 uniform highp sampler2DArray arg_0_1;
 void textureNumLayers_e653c0() {
-  int res = textureQueryLevels(arg_0_1);;
+  int res = textureSize(arg_0_1, 0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/ee942f.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/ee942f.wgsl.expected.glsl
index 03aa7e9..6dedd6e 100644
--- a/test/builtins/gen/textureNumLayers/ee942f.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/ee942f.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(r32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ee942f() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(r32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ee942f() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(r32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ee942f() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/f33005.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/f33005.wgsl.expected.glsl
index c2d1263..75841f8 100644
--- a/test/builtins/gen/textureNumLayers/f33005.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/f33005.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba16i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_f33005() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba16i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_f33005() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba16i) uniform highp writeonly iimage2DArray arg_0;
 void textureNumLayers_f33005() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/builtins/gen/textureNumLayers/fcec98.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/fcec98.wgsl.expected.glsl
index cf93720..5457d1e 100644
--- a/test/builtins/gen/textureNumLayers/fcec98.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/fcec98.wgsl.expected.glsl
@@ -4,7 +4,7 @@
 
 layout(rg32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_fcec98() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -31,7 +31,7 @@
 
 layout(rg32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_fcec98() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -53,7 +53,7 @@
 
 layout(rg32ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_fcec98() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
diff --git a/test/builtins/gen/textureNumLayers/ff5e89.wgsl.expected.glsl b/test/builtins/gen/textureNumLayers/ff5e89.wgsl.expected.glsl
index f08c258..dc4d434 100644
--- a/test/builtins/gen/textureNumLayers/ff5e89.wgsl.expected.glsl
+++ b/test/builtins/gen/textureNumLayers/ff5e89.wgsl.expected.glsl
@@ -1,10 +1,8 @@
-SKIP: FAILED
-
 #version 310 es
 
 layout(rgba8ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ff5e89() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 vec4 vertex_main() {
@@ -19,20 +17,12 @@
   gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 precision mediump float;
 
 layout(rgba8ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ff5e89() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void fragment_main() {
@@ -43,19 +33,11 @@
   fragment_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:6: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:6: '=' :  cannot convert from ' const float' to ' temp mediump int'
-ERROR: 0:6: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
 #version 310 es
 
 layout(rgba8ui) uniform highp writeonly uimage2DArray arg_0;
 void textureNumLayers_ff5e89() {
-  int res = textureQueryLevels(arg_0);;
+  int res = imageSize(arg_0).z;
 }
 
 void compute_main() {
@@ -67,11 +49,3 @@
   compute_main();
   return;
 }
-Error parsing GLSL shader:
-ERROR: 0:5: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:5: '=' :  cannot convert from ' const float' to ' temp highp int'
-ERROR: 0:5: '' : compilation terminated 
-ERROR: 3 compilation errors.  No code generated.
-
-
-
diff --git a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl
deleted file mode 100644
index 9a35a8e..0000000
--- a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl
+++ /dev/null
@@ -1,43 +0,0 @@
-SKIP: FAILED
-
-#version 310 es
-precision mediump float;
-
-uniform highp sampler2DArray x_20_1;
-void main_1() {
-  float f1 = 1.0f;
-  vec2 vf12 = vec2(1.0f, 2.0f);
-  vec2 vf21 = vec2(2.0f, 1.0f);
-  vec3 vf123 = vec3(1.0f, 2.0f, 3.0f);
-  vec4 vf1234 = vec4(1.0f, 2.0f, 3.0f, 4.0f);
-  int i1 = 1;
-  ivec2 vi12 = ivec2(1, 2);
-  ivec3 vi123 = ivec3(1, 2, 3);
-  ivec4 vi1234 = ivec4(1, 2, 3, 4);
-  uint u1 = 1u;
-  uvec2 vu12 = uvec2(1u, 2u);
-  uvec3 vu123 = uvec3(1u, 2u, 3u);
-  uvec4 vu1234 = uvec4(1u, 2u, 3u, 4u);
-  float coords1 = 1.0f;
-  vec2 coords12 = vf12;
-  vec3 coords123 = vf123;
-  vec4 coords1234 = vf1234;
-  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureQueryLevels(x_20_1););
-  return;
-}
-
-void tint_symbol() {
-  main_1();
-}
-
-void main() {
-  tint_symbol();
-  return;
-}
-Error parsing GLSL shader:
-ERROR: 0:23: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:23: '' : compilation terminated 
-ERROR: 2 compilation errors.  No code generated.
-
-
-
diff --git a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_1.spvasm.expected.glsl b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_1.spvasm.expected.glsl
index 4ad3ddc..8c3d294 100644
--- a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_1.spvasm.expected.glsl
+++ b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_1.spvasm.expected.glsl
@@ -22,7 +22,7 @@
   vec2 coords12 = vf12;
   vec3 coords123 = vf123;
   vec4 coords1234 = vf1234;
-  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureQueryLevels(x_20_1););
+  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureSize(x_20_1, 0).z);
   return;
 }
 
diff --git a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_2.spvasm.expected.glsl b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_2.spvasm.expected.glsl
deleted file mode 100644
index 9a35a8e..0000000
--- a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_2.spvasm.expected.glsl
+++ /dev/null
@@ -1,43 +0,0 @@
-SKIP: FAILED
-
-#version 310 es
-precision mediump float;
-
-uniform highp sampler2DArray x_20_1;
-void main_1() {
-  float f1 = 1.0f;
-  vec2 vf12 = vec2(1.0f, 2.0f);
-  vec2 vf21 = vec2(2.0f, 1.0f);
-  vec3 vf123 = vec3(1.0f, 2.0f, 3.0f);
-  vec4 vf1234 = vec4(1.0f, 2.0f, 3.0f, 4.0f);
-  int i1 = 1;
-  ivec2 vi12 = ivec2(1, 2);
-  ivec3 vi123 = ivec3(1, 2, 3);
-  ivec4 vi1234 = ivec4(1, 2, 3, 4);
-  uint u1 = 1u;
-  uvec2 vu12 = uvec2(1u, 2u);
-  uvec3 vu123 = uvec3(1u, 2u, 3u);
-  uvec4 vu1234 = uvec4(1u, 2u, 3u, 4u);
-  float coords1 = 1.0f;
-  vec2 coords12 = vf12;
-  vec3 coords123 = vf123;
-  vec4 coords1234 = vf1234;
-  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureQueryLevels(x_20_1););
-  return;
-}
-
-void tint_symbol() {
-  main_1();
-}
-
-void main() {
-  tint_symbol();
-  return;
-}
-Error parsing GLSL shader:
-ERROR: 0:23: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:23: '' : compilation terminated 
-ERROR: 2 compilation errors.  No code generated.
-
-
-
diff --git a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_3.spvasm.expected.glsl b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_3.spvasm.expected.glsl
index 4ad3ddc..8c3d294 100644
--- a/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_3.spvasm.expected.glsl
+++ b/test/unittest/reader/spirv/ImageQuerySizeLod_Arrayed_SignedResult_SignedLevel_SpvParserHandleTest_SampledImageAccessTest_Variable_3.spvasm.expected.glsl
@@ -22,7 +22,7 @@
   vec2 coords12 = vf12;
   vec3 coords123 = vf123;
   vec4 coords1234 = vf1234;
-  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureQueryLevels(x_20_1););
+  ivec3 x_99 = ivec3(textureSize(x_20_1, i1).xy, textureSize(x_20_1, 0).z);
   return;
 }
 
diff --git a/test/unittest/reader/spirv/ImageQuerySize_Arrayed_SignedResult_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl b/test/unittest/reader/spirv/ImageQuerySize_Arrayed_SignedResult_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl
deleted file mode 100644
index 649714b..0000000
--- a/test/unittest/reader/spirv/ImageQuerySize_Arrayed_SignedResult_SpvParserHandleTest_SampledImageAccessTest_Variable_0.spvasm.expected.glsl
+++ /dev/null
@@ -1,44 +0,0 @@
-SKIP: FAILED
-
-#version 310 es
-precision mediump float;
-
-uniform highp sampler2DArray x_20_1;
-void main_1() {
-  float f1 = 1.0f;
-  vec2 vf12 = vec2(1.0f, 2.0f);
-  vec2 vf21 = vec2(2.0f, 1.0f);
-  vec3 vf123 = vec3(1.0f, 2.0f, 3.0f);
-  vec4 vf1234 = vec4(1.0f, 2.0f, 3.0f, 4.0f);
-  int i1 = 1;
-  ivec2 vi12 = ivec2(1, 2);
-  ivec3 vi123 = ivec3(1, 2, 3);
-  ivec4 vi1234 = ivec4(1, 2, 3, 4);
-  uint u1 = 1u;
-  uvec2 vu12 = uvec2(1u, 2u);
-  uvec3 vu123 = uvec3(1u, 2u, 3u);
-  uvec4 vu1234 = uvec4(1u, 2u, 3u, 4u);
-  float coords1 = 1.0f;
-  vec2 coords12 = vf12;
-  vec3 coords123 = vf123;
-  vec4 coords1234 = vf1234;
-  ivec3 x_99 = ivec3(textureSize(x_20_1, 0).xy, textureQueryLevels(x_20_1););
-  vec4 x_98 = texelFetch(x_20_1, ivec3(vi123.xy, vi123.z), 0);
-  return;
-}
-
-void tint_symbol() {
-  main_1();
-}
-
-void main() {
-  tint_symbol();
-  return;
-}
-Error parsing GLSL shader:
-ERROR: 0:23: 'textureQueryLevels' : no matching overloaded function found 
-ERROR: 0:23: '' : compilation terminated 
-ERROR: 2 compilation errors.  No code generated.
-
-
-