tint: Add builtin tests for arguments passed by var
Change-Id: I81b69d23e40675d7f525e6369afec9aa0659d043
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/92321
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl
new file mode 100644
index 0000000..f027dfd
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl
@@ -0,0 +1,46 @@
+// Copyright 2021 The Tint Authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+////////////////////////////////////////////////////////////////////////////////
+// File generated by tools/intrinsic-gen
+// using the template:
+// test/tint/builtins/gen/gen.wgsl.tmpl
+// and the intrinsic defintion file:
+// src/tint/intrinsics.def
+//
+// Do not modify this file directly
+////////////////////////////////////////////////////////////////////////////////
+
+
+// fn pack4x8snorm(vec4<f32>) -> u32
+fn pack4x8snorm_4d22e7() {
+ var arg_0 = vec4<f32>();
+ var res: u32 = pack4x8snorm(arg_0);
+}
+
+@stage(vertex)
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ pack4x8snorm_4d22e7();
+ return vec4<f32>();
+}
+
+@stage(fragment)
+fn fragment_main() {
+ pack4x8snorm_4d22e7();
+}
+
+@stage(compute) @workgroup_size(1)
+fn compute_main() {
+ pack4x8snorm_4d22e7();
+}
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.glsl b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.glsl
new file mode 100644
index 0000000..d7f6483
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.glsl
@@ -0,0 +1,52 @@
+#version 310 es
+
+void pack4x8snorm_4d22e7() {
+ vec4 arg_0 = vec4(0.0f);
+ uint res = packSnorm4x8(arg_0);
+}
+
+vec4 vertex_main() {
+ pack4x8snorm_4d22e7();
+ return vec4(0.0f);
+}
+
+void main() {
+ gl_PointSize = 1.0;
+ vec4 inner_result = vertex_main();
+ gl_Position = inner_result;
+ gl_Position.y = -(gl_Position.y);
+ gl_Position.z = ((2.0f * gl_Position.z) - gl_Position.w);
+ return;
+}
+#version 310 es
+precision mediump float;
+
+void pack4x8snorm_4d22e7() {
+ vec4 arg_0 = vec4(0.0f);
+ uint res = packSnorm4x8(arg_0);
+}
+
+void fragment_main() {
+ pack4x8snorm_4d22e7();
+}
+
+void main() {
+ fragment_main();
+ return;
+}
+#version 310 es
+
+void pack4x8snorm_4d22e7() {
+ vec4 arg_0 = vec4(0.0f);
+ uint res = packSnorm4x8(arg_0);
+}
+
+void compute_main() {
+ pack4x8snorm_4d22e7();
+}
+
+layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
+void main() {
+ compute_main();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.hlsl b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.hlsl
new file mode 100644
index 0000000..bdf414b
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.hlsl
@@ -0,0 +1,36 @@
+uint tint_pack4x8snorm(float4 param_0) {
+ int4 i = int4(round(clamp(param_0, -1.0, 1.0) * 127.0)) & 0xff;
+ return asuint(i.x | i.y << 8 | i.z << 16 | i.w << 24);
+}
+
+void pack4x8snorm_4d22e7() {
+ float4 arg_0 = (0.0f).xxxx;
+ uint res = tint_pack4x8snorm(arg_0);
+}
+
+struct tint_symbol {
+ float4 value : SV_Position;
+};
+
+float4 vertex_main_inner() {
+ pack4x8snorm_4d22e7();
+ return (0.0f).xxxx;
+}
+
+tint_symbol vertex_main() {
+ const float4 inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = (tint_symbol)0;
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+void fragment_main() {
+ pack4x8snorm_4d22e7();
+ return;
+}
+
+[numthreads(1, 1, 1)]
+void compute_main() {
+ pack4x8snorm_4d22e7();
+ return;
+}
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.msl b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.msl
new file mode 100644
index 0000000..5463f99
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.msl
@@ -0,0 +1,34 @@
+#include <metal_stdlib>
+
+using namespace metal;
+void pack4x8snorm_4d22e7() {
+ float4 arg_0 = float4(0.0f);
+ uint res = pack_float_to_snorm4x8(arg_0);
+}
+
+struct tint_symbol {
+ float4 value [[position]];
+};
+
+float4 vertex_main_inner() {
+ pack4x8snorm_4d22e7();
+ return float4(0.0f);
+}
+
+vertex tint_symbol vertex_main() {
+ float4 const inner_result = vertex_main_inner();
+ tint_symbol wrapper_result = {};
+ wrapper_result.value = inner_result;
+ return wrapper_result;
+}
+
+fragment void fragment_main() {
+ pack4x8snorm_4d22e7();
+ return;
+}
+
+kernel void compute_main() {
+ pack4x8snorm_4d22e7();
+ return;
+}
+
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.spvasm b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.spvasm
new file mode 100644
index 0000000..74247cd
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.spvasm
@@ -0,0 +1,72 @@
+; SPIR-V
+; Version: 1.3
+; Generator: Google Tint Compiler; 0
+; Bound: 36
+; Schema: 0
+ OpCapability Shader
+ %17 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Vertex %vertex_main "vertex_main" %value %vertex_point_size
+ OpEntryPoint Fragment %fragment_main "fragment_main"
+ OpEntryPoint GLCompute %compute_main "compute_main"
+ OpExecutionMode %fragment_main OriginUpperLeft
+ OpExecutionMode %compute_main LocalSize 1 1 1
+ OpName %value "value"
+ OpName %vertex_point_size "vertex_point_size"
+ OpName %pack4x8snorm_4d22e7 "pack4x8snorm_4d22e7"
+ OpName %arg_0 "arg_0"
+ OpName %res "res"
+ OpName %vertex_main_inner "vertex_main_inner"
+ OpName %vertex_main "vertex_main"
+ OpName %fragment_main "fragment_main"
+ OpName %compute_main "compute_main"
+ OpDecorate %value BuiltIn Position
+ OpDecorate %vertex_point_size BuiltIn PointSize
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %5 = OpConstantNull %v4float
+ %value = OpVariable %_ptr_Output_v4float Output %5
+%_ptr_Output_float = OpTypePointer Output %float
+ %8 = OpConstantNull %float
+%vertex_point_size = OpVariable %_ptr_Output_float Output %8
+ %void = OpTypeVoid
+ %9 = OpTypeFunction %void
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+ %uint = OpTypeInt 32 0
+%_ptr_Function_uint = OpTypePointer Function %uint
+ %21 = OpConstantNull %uint
+ %22 = OpTypeFunction %v4float
+ %float_1 = OpConstant %float 1
+%pack4x8snorm_4d22e7 = OpFunction %void None %9
+ %12 = OpLabel
+ %arg_0 = OpVariable %_ptr_Function_v4float Function %5
+ %res = OpVariable %_ptr_Function_uint Function %21
+ OpStore %arg_0 %5
+ %18 = OpLoad %v4float %arg_0
+ %15 = OpExtInst %uint %17 PackSnorm4x8 %18
+ OpStore %res %15
+ OpReturn
+ OpFunctionEnd
+%vertex_main_inner = OpFunction %v4float None %22
+ %24 = OpLabel
+ %25 = OpFunctionCall %void %pack4x8snorm_4d22e7
+ OpReturnValue %5
+ OpFunctionEnd
+%vertex_main = OpFunction %void None %9
+ %27 = OpLabel
+ %28 = OpFunctionCall %v4float %vertex_main_inner
+ OpStore %value %28
+ OpStore %vertex_point_size %float_1
+ OpReturn
+ OpFunctionEnd
+%fragment_main = OpFunction %void None %9
+ %31 = OpLabel
+ %32 = OpFunctionCall %void %pack4x8snorm_4d22e7
+ OpReturn
+ OpFunctionEnd
+%compute_main = OpFunction %void None %9
+ %34 = OpLabel
+ %35 = OpFunctionCall %void %pack4x8snorm_4d22e7
+ OpReturn
+ OpFunctionEnd
diff --git a/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.wgsl b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.wgsl
new file mode 100644
index 0000000..18df3db
--- /dev/null
+++ b/test/tint/builtins/gen/var/pack4x8snorm/4d22e7.wgsl.expected.wgsl
@@ -0,0 +1,20 @@
+fn pack4x8snorm_4d22e7() {
+ var arg_0 = vec4<f32>();
+ var res : u32 = pack4x8snorm(arg_0);
+}
+
+@stage(vertex)
+fn vertex_main() -> @builtin(position) vec4<f32> {
+ pack4x8snorm_4d22e7();
+ return vec4<f32>();
+}
+
+@stage(fragment)
+fn fragment_main() {
+ pack4x8snorm_4d22e7();
+}
+
+@stage(compute) @workgroup_size(1)
+fn compute_main() {
+ pack4x8snorm_4d22e7();
+}