Tint: Support the translation of `clip_distances` on Vulkan

This patch adds the translation of `clip_distances` on Vulkan (SPIR-V)
backend.

Bug: chromium:358408571
Change-Id: Ia67f5bd0f5be529762d52e692a3f154d9c2e1e7d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/202774
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/tint/lang/spirv/writer/printer/printer.cc b/src/tint/lang/spirv/writer/printer/printer.cc
index 06a9fbd..d5cc327 100644
--- a/src/tint/lang/spirv/writer/printer/printer.cc
+++ b/src/tint/lang/spirv/writer/printer/printer.cc
@@ -362,8 +362,8 @@
             case core::BuiltinValue::kWorkgroupId:
                 return SpvBuiltInWorkgroupId;
             case core::BuiltinValue::kClipDistances:
-                // TODO(chromium:358408571): Implement `clip_distances` on SPIR-V
-                TINT_UNIMPLEMENTED();
+                module_.PushCapability(SpvCapabilityClipDistance);
+                return SpvBuiltInClipDistance;
             case core::BuiltinValue::kUndefined:
                 return SpvBuiltInMax;
         }
diff --git a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
index 9900ac3..c7847e8 100644
--- a/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
+++ b/src/tint/lang/wgsl/ast/transform/canonicalize_entry_point_io.cc
@@ -99,6 +99,8 @@
             return 12;
         case core::BuiltinValue::kPointSize:
             return 13;
+        case core::BuiltinValue::kClipDistances:
+            return 14;
         default:
             break;
     }
diff --git a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
index 38f03d3..0b520bc 100644
--- a/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
+++ b/src/tint/lang/wgsl/writer/ir_to_program/ir_to_program.cc
@@ -255,6 +255,10 @@
                         Enable(wgsl::Extension::kChromiumExperimentalSubgroups);
                         attrs.Push(b.Builtin(core::BuiltinValue::kSubgroupSize));
                         break;
+                    case core::BuiltinValue::kClipDistances:
+                        Enable(wgsl::Extension::kClipDistances);
+                        attrs.Push(b.Builtin(core::BuiltinValue::kClipDistances));
+                        break;
                     default:
                         TINT_UNIMPLEMENTED() << builtin.value();
                 }
@@ -1068,6 +1072,8 @@
                 if (auto builtin = ir_attrs.builtin) {
                     if (RequiresSubgroups(*builtin)) {
                         Enable(wgsl::Extension::kChromiumExperimentalSubgroups);
+                    } else if (*builtin == core::BuiltinValue::kClipDistances) {
+                        Enable(wgsl::Extension::kClipDistances);
                     }
                     ast_attrs.Push(b.Builtin(*builtin));
                 }
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl
new file mode 100644
index 0000000..932338e
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.dxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..f677823
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.dxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.fxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..f677823
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.fxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.glsl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.glsl
new file mode 100644
index 0000000..7d7ee00
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.glsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl:1:8 error: GLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.msl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.msl
new file mode 100644
index 0000000..557ef30
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.msl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl:1:8 error: MSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.spvasm b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.spvasm
new file mode 100644
index 0000000..558066c
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.spvasm
@@ -0,0 +1,59 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 1
+; Bound: 30
+; Schema: 0
+               OpCapability Shader
+               OpCapability ClipDistance
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %main "main" %main_position_Output %main_clip_distances_Output %main___point_size_Output
+               OpName %main_position_Output "main_position_Output"
+               OpName %main_clip_distances_Output "main_clip_distances_Output"
+               OpName %main___point_size_Output "main___point_size_Output"
+               OpName %main_inner "main_inner"
+               OpMemberName %VertexOutputs 0 "position"
+               OpMemberName %VertexOutputs 1 "clipDistance"
+               OpName %VertexOutputs "VertexOutputs"
+               OpName %main "main"
+               OpDecorate %main_position_Output BuiltIn Position
+               OpDecorate %_arr_float_uint_1 ArrayStride 4
+               OpDecorate %main_clip_distances_Output BuiltIn ClipDistance
+               OpDecorate %main___point_size_Output BuiltIn PointSize
+               OpMemberDecorate %VertexOutputs 0 Offset 0
+               OpMemberDecorate %VertexOutputs 1 Offset 16
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%main_position_Output = OpVariable %_ptr_Output_v4float Output
+       %uint = OpTypeInt 32 0
+     %uint_1 = OpConstant %uint 1
+%_arr_float_uint_1 = OpTypeArray %float %uint_1
+%_ptr_Output__arr_float_uint_1 = OpTypePointer Output %_arr_float_uint_1
+%main_clip_distances_Output = OpVariable %_ptr_Output__arr_float_uint_1 Output
+%_ptr_Output_float = OpTypePointer Output %float
+%main___point_size_Output = OpVariable %_ptr_Output_float Output
+%VertexOutputs = OpTypeStruct %v4float %_arr_float_uint_1
+         %14 = OpTypeFunction %VertexOutputs
+    %float_1 = OpConstant %float 1
+    %float_2 = OpConstant %float 2
+    %float_3 = OpConstant %float 3
+    %float_4 = OpConstant %float 4
+         %17 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
+         %22 = OpConstantNull %_arr_float_uint_1
+         %16 = OpConstantComposite %VertexOutputs %17 %22
+       %void = OpTypeVoid
+         %25 = OpTypeFunction %void
+ %main_inner = OpFunction %VertexOutputs None %14
+         %15 = OpLabel
+               OpReturnValue %16
+               OpFunctionEnd
+       %main = OpFunction %void None %25
+         %26 = OpLabel
+         %27 = OpFunctionCall %VertexOutputs %main_inner
+         %28 = OpCompositeExtract %v4float %27 0
+               OpStore %main_position_Output %28
+         %29 = OpCompositeExtract %_arr_float_uint_1 %27 1
+               OpStore %main_clip_distances_Output %29
+               OpStore %main___point_size_Output %float_1
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.wgsl
new file mode 100644
index 0000000..932338e
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_1.wgsl.expected.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 1>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 1>(0.0));
+}
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl
new file mode 100644
index 0000000..d3f9113c
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.dxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..0c242636
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.dxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.fxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..0c242636
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.fxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.glsl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.glsl
new file mode 100644
index 0000000..88551af
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.glsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl:1:8 error: GLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.msl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.msl
new file mode 100644
index 0000000..668fc1f
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.msl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl:1:8 error: MSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.spvasm b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.spvasm
new file mode 100644
index 0000000..8c87a3e
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.spvasm
@@ -0,0 +1,59 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 1
+; Bound: 30
+; Schema: 0
+               OpCapability Shader
+               OpCapability ClipDistance
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %main "main" %main_position_Output %main_clip_distances_Output %main___point_size_Output
+               OpName %main_position_Output "main_position_Output"
+               OpName %main_clip_distances_Output "main_clip_distances_Output"
+               OpName %main___point_size_Output "main___point_size_Output"
+               OpName %main_inner "main_inner"
+               OpMemberName %VertexOutputs 0 "position"
+               OpMemberName %VertexOutputs 1 "clipDistance"
+               OpName %VertexOutputs "VertexOutputs"
+               OpName %main "main"
+               OpDecorate %main_position_Output BuiltIn Position
+               OpDecorate %_arr_float_uint_4 ArrayStride 4
+               OpDecorate %main_clip_distances_Output BuiltIn ClipDistance
+               OpDecorate %main___point_size_Output BuiltIn PointSize
+               OpMemberDecorate %VertexOutputs 0 Offset 0
+               OpMemberDecorate %VertexOutputs 1 Offset 16
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%main_position_Output = OpVariable %_ptr_Output_v4float Output
+       %uint = OpTypeInt 32 0
+     %uint_4 = OpConstant %uint 4
+%_arr_float_uint_4 = OpTypeArray %float %uint_4
+%_ptr_Output__arr_float_uint_4 = OpTypePointer Output %_arr_float_uint_4
+%main_clip_distances_Output = OpVariable %_ptr_Output__arr_float_uint_4 Output
+%_ptr_Output_float = OpTypePointer Output %float
+%main___point_size_Output = OpVariable %_ptr_Output_float Output
+%VertexOutputs = OpTypeStruct %v4float %_arr_float_uint_4
+         %14 = OpTypeFunction %VertexOutputs
+    %float_1 = OpConstant %float 1
+    %float_2 = OpConstant %float 2
+    %float_3 = OpConstant %float 3
+    %float_4 = OpConstant %float 4
+         %17 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
+         %22 = OpConstantNull %_arr_float_uint_4
+         %16 = OpConstantComposite %VertexOutputs %17 %22
+       %void = OpTypeVoid
+         %25 = OpTypeFunction %void
+ %main_inner = OpFunction %VertexOutputs None %14
+         %15 = OpLabel
+               OpReturnValue %16
+               OpFunctionEnd
+       %main = OpFunction %void None %25
+         %26 = OpLabel
+         %27 = OpFunctionCall %VertexOutputs %main_inner
+         %28 = OpCompositeExtract %v4float %27 0
+               OpStore %main_position_Output %28
+         %29 = OpCompositeExtract %_arr_float_uint_4 %27 1
+               OpStore %main_clip_distances_Output %29
+               OpStore %main___point_size_Output %float_1
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.wgsl
new file mode 100644
index 0000000..d3f9113c
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_4.wgsl.expected.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 4>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 4>(0.0, 0.0, 0.0, 0.0));
+}
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl
new file mode 100644
index 0000000..61d4f06
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.dxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.dxc.hlsl
new file mode 100644
index 0000000..19f146d
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.dxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.fxc.hlsl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.fxc.hlsl
new file mode 100644
index 0000000..19f146d
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.fxc.hlsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl:1:8 error: HLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.glsl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.glsl
new file mode 100644
index 0000000..4eaae78
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.glsl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl:1:8 error: GLSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.msl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.msl
new file mode 100644
index 0000000..2592985
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.msl
@@ -0,0 +1,21 @@
+SKIP: FAILED
+
+
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn tint_symbol() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}
+
+Failed to generate: <dawn>/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl:1:8 error: MSL backend does not support extension 'clip_distances'
+enable clip_distances;
+       ^^^^^^^^^^^^^^
+
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.spvasm b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.spvasm
new file mode 100644
index 0000000..10365f8
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.spvasm
@@ -0,0 +1,59 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 1
+; Bound: 30
+; Schema: 0
+               OpCapability Shader
+               OpCapability ClipDistance
+               OpMemoryModel Logical GLSL450
+               OpEntryPoint Vertex %main "main" %main_position_Output %main_clip_distances_Output %main___point_size_Output
+               OpName %main_position_Output "main_position_Output"
+               OpName %main_clip_distances_Output "main_clip_distances_Output"
+               OpName %main___point_size_Output "main___point_size_Output"
+               OpName %main_inner "main_inner"
+               OpMemberName %VertexOutputs 0 "position"
+               OpMemberName %VertexOutputs 1 "clipDistance"
+               OpName %VertexOutputs "VertexOutputs"
+               OpName %main "main"
+               OpDecorate %main_position_Output BuiltIn Position
+               OpDecorate %_arr_float_uint_8 ArrayStride 4
+               OpDecorate %main_clip_distances_Output BuiltIn ClipDistance
+               OpDecorate %main___point_size_Output BuiltIn PointSize
+               OpMemberDecorate %VertexOutputs 0 Offset 0
+               OpMemberDecorate %VertexOutputs 1 Offset 16
+      %float = OpTypeFloat 32
+    %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+%main_position_Output = OpVariable %_ptr_Output_v4float Output
+       %uint = OpTypeInt 32 0
+     %uint_8 = OpConstant %uint 8
+%_arr_float_uint_8 = OpTypeArray %float %uint_8
+%_ptr_Output__arr_float_uint_8 = OpTypePointer Output %_arr_float_uint_8
+%main_clip_distances_Output = OpVariable %_ptr_Output__arr_float_uint_8 Output
+%_ptr_Output_float = OpTypePointer Output %float
+%main___point_size_Output = OpVariable %_ptr_Output_float Output
+%VertexOutputs = OpTypeStruct %v4float %_arr_float_uint_8
+         %14 = OpTypeFunction %VertexOutputs
+    %float_1 = OpConstant %float 1
+    %float_2 = OpConstant %float 2
+    %float_3 = OpConstant %float 3
+    %float_4 = OpConstant %float 4
+         %17 = OpConstantComposite %v4float %float_1 %float_2 %float_3 %float_4
+         %22 = OpConstantNull %_arr_float_uint_8
+         %16 = OpConstantComposite %VertexOutputs %17 %22
+       %void = OpTypeVoid
+         %25 = OpTypeFunction %void
+ %main_inner = OpFunction %VertexOutputs None %14
+         %15 = OpLabel
+               OpReturnValue %16
+               OpFunctionEnd
+       %main = OpFunction %void None %25
+         %26 = OpLabel
+         %27 = OpFunctionCall %VertexOutputs %main_inner
+         %28 = OpCompositeExtract %v4float %27 0
+               OpStore %main_position_Output %28
+         %29 = OpCompositeExtract %_arr_float_uint_8 %27 1
+               OpStore %main_clip_distances_Output %29
+               OpStore %main___point_size_Output %float_1
+               OpReturn
+               OpFunctionEnd
diff --git a/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.wgsl b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.wgsl
new file mode 100644
index 0000000..61d4f06
--- /dev/null
+++ b/test/tint/extensions/clip_distances/clip_distances_size_8.wgsl.expected.wgsl
@@ -0,0 +1,13 @@
+enable clip_distances;
+
+struct VertexOutputs {
+  @builtin(position)
+  position : vec4<f32>,
+  @builtin(clip_distances)
+  clipDistance : array<f32, 8>,
+}
+
+@vertex
+fn main() -> VertexOutputs {
+  return VertexOutputs(vec4<f32>(1.0, 2.0, 3.0, 4.0), array<f32, 8>(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
+}