Add tests derived from VK-GL-CTS

This adds SPIR-V assembly and WGSL tests derived from VK-GL-CTS commit
571256871c2e2f03995373e1e4a02958d8cd8cf5. The following procedure was
followed:

- Those .amber files in VK-GL-CTS wholly owned by Google were
  identified

- All GLSL and SPIR-V shaders were extracted from the Amber files and
  converted into SPIR-V binaries

- The compact-ids pass of spirv-opt was applied to each binary

- Duplicate binaries were removed

- spirv-opt -O was used to obtain an optimized version of each remaining
  binary, with duplicates discarded

- Binaries that failed validation using spirv-val with target
  environment SPIR-V 1.3 were discarded

- Those binaries that tint could not successfully convert into WGSL were
  put aside for further investigation

- SPIR-V assembly versions of the remaining binaries are included in
  this CL

- test-runner with -generate-expected and -generate-skip was used to
  generate expected .spvasm, .msl, .hlsl and .wgsl outputs for these
  SPIR-V assembly tests

- Each successfully-generated .expected.wgsl is included in this CL
  again, as a WGLSL test

- test-runner with -generate-expected and -generate-skip was used again,
  to generate expected outputs for these WGSL tests

Change-Id: Ibe9baf2729cf97e0b633db9a426f53362a5de540
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/58842
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
Alastair Donaldson
2021-07-23 13:10:12 +00:00
committed by Tint LUCI CQ
parent bd3edb564f
commit f7e73d4ee3
5160 changed files with 621458 additions and 0 deletions

View File

@@ -0,0 +1,133 @@
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_GLF_color
OpExecutionMode %main OriginUpperLeft
OpSource ESSL 310
OpName %main "main"
OpName %numbers "numbers"
OpName %buf1 "buf1"
OpMemberName %buf1 0 "_GLF_uniform_int_values"
OpName %_ ""
OpName %a "a"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "_GLF_uniform_float_values"
OpName %__0 ""
OpName %b "b"
OpName %_GLF_color "_GLF_color"
OpDecorate %_arr_int_uint_3_0 ArrayStride 16
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %buf1 Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 1
OpDecorate %_arr_float_uint_3 ArrayStride 16
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %buf0 Block
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 0
OpDecorate %_GLF_color Location 0
%void = OpTypeVoid
%14 = OpTypeFunction %void
%int = OpTypeInt 32 1
%uint = OpTypeInt 32 0
%uint_3 = OpConstant %uint 3
%_arr_int_uint_3 = OpTypeArray %int %uint_3
%_ptr_Function__arr_int_uint_3 = OpTypePointer Function %_arr_int_uint_3
%_arr_int_uint_3_0 = OpTypeArray %int %uint_3
%buf1 = OpTypeStruct %_arr_int_uint_3_0
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
%_ = OpVariable %_ptr_Uniform_buf1 Uniform
%int_0 = OpConstant %int 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Function_int = OpTypePointer Function %int
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%float = OpTypeFloat 32
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%float_0 = OpConstant %float 0
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%buf0 = OpTypeStruct %_arr_float_uint_3
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%__0 = OpVariable %_ptr_Uniform_buf0 Uniform
%_ptr_Uniform_float = OpTypePointer Uniform %float
%bool = OpTypeBool
%_ptr_Function_float = OpTypePointer Function %float
%v4float = OpTypeVector %float 4
%_ptr_Output_v4float = OpTypePointer Output %v4float
%_GLF_color = OpVariable %_ptr_Output_v4float Output
%main = OpFunction %void None %14
%36 = OpLabel
%numbers = OpVariable %_ptr_Function__arr_int_uint_3 Function
%a = OpVariable %_ptr_Function_v2float Function
%b = OpVariable %_ptr_Function_float Function
%37 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%38 = OpLoad %int %37
%39 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%40 = OpLoad %int %39
%41 = OpAccessChain %_ptr_Function_int %numbers %38
OpStore %41 %40
%42 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_1
%43 = OpLoad %int %42
%44 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_1
%45 = OpLoad %int %44
%46 = OpAccessChain %_ptr_Function_int %numbers %43
OpStore %46 %45
%47 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_2
%48 = OpLoad %int %47
%49 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_2
%50 = OpLoad %int %49
%51 = OpAccessChain %_ptr_Function_int %numbers %48
OpStore %51 %50
%52 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%53 = OpLoad %int %52
%54 = OpConvertSToF %float %53
%55 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %int_2
%56 = OpLoad %float %55
%57 = OpFOrdLessThan %bool %float_0 %56
%58 = OpSelect %int %57 %int_1 %int_2
%59 = OpAccessChain %_ptr_Function_int %numbers %58
%60 = OpLoad %int %59
%61 = OpConvertSToF %float %60
%62 = OpCompositeConstruct %v2float %54 %61
OpStore %a %62
%63 = OpLoad %v2float %a
%64 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %int_1
%65 = OpLoad %float %64
%66 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %int_1
%67 = OpLoad %float %66
%68 = OpCompositeConstruct %v2float %65 %67
%69 = OpDot %float %63 %68
OpStore %b %69
%70 = OpLoad %float %b
%71 = OpAccessChain %_ptr_Uniform_float %__0 %int_0 %int_0
%72 = OpLoad %float %71
%73 = OpFOrdEqual %bool %70 %72
OpSelectionMerge %74 None
OpBranchConditional %73 %75 %76
%75 = OpLabel
%77 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_1
%78 = OpLoad %int %77
%79 = OpConvertSToF %float %78
%80 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%81 = OpLoad %int %80
%82 = OpConvertSToF %float %81
%83 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%84 = OpLoad %int %83
%85 = OpConvertSToF %float %84
%86 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_1
%87 = OpLoad %int %86
%88 = OpConvertSToF %float %87
%89 = OpCompositeConstruct %v4float %79 %82 %85 %88
OpStore %_GLF_color %89
OpBranch %74
%76 = OpLabel
%90 = OpAccessChain %_ptr_Uniform_int %_ %int_0 %int_0
%91 = OpLoad %int %90
%92 = OpConvertSToF %float %91
%93 = OpCompositeConstruct %v4float %92 %92 %92 %92
OpStore %_GLF_color %93
OpBranch %74
%74 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,65 @@
cbuffer cbuffer_x_6 : register(b1, space0) {
uint4 x_6[3];
};
cbuffer cbuffer_x_9 : register(b0, space0) {
uint4 x_9[3];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
int numbers[3] = (int[3])0;
float2 a = float2(0.0f, 0.0f);
float b = 0.0f;
const uint scalar_offset = ((16u * uint(0))) / 4;
const int x_38 = asint(x_6[scalar_offset / 4][scalar_offset % 4]);
const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
numbers[x_38] = x_40;
const int x_43 = asint(x_6[1].x);
const int x_45 = asint(x_6[1].x);
numbers[x_43] = x_45;
const int x_48 = asint(x_6[2].x);
const int x_50 = asint(x_6[2].x);
numbers[x_48] = x_50;
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
const int x_53 = asint(x_6[scalar_offset_2 / 4][scalar_offset_2 % 4]);
const float x_56 = asfloat(x_9[2].x);
const int x_60 = numbers[((0.0f < x_56) ? 1 : 2)];
a = float2(float(x_53), float(x_60));
const float2 x_63 = a;
const float x_65 = asfloat(x_9[1].x);
const float x_67 = asfloat(x_9[1].x);
b = dot(x_63, float2(x_65, x_67));
const float x_70 = b;
const uint scalar_offset_3 = ((16u * uint(0))) / 4;
const float x_72 = asfloat(x_9[scalar_offset_3 / 4][scalar_offset_3 % 4]);
if ((x_70 == x_72)) {
const int x_78 = asint(x_6[1].x);
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_81 = asint(x_6[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const uint scalar_offset_5 = ((16u * uint(0))) / 4;
const int x_84 = asint(x_6[scalar_offset_5 / 4][scalar_offset_5 % 4]);
const int x_87 = asint(x_6[1].x);
x_GLF_color = float4(float(x_78), float(x_81), float(x_84), float(x_87));
} else {
const uint scalar_offset_6 = ((16u * uint(0))) / 4;
const int x_91 = asint(x_6[scalar_offset_6 / 4][scalar_offset_6 % 4]);
const float x_92 = float(x_91);
x_GLF_color = float4(x_92, x_92, x_92, x_92);
}
return;
}
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol {
float4 x_GLF_color_1 : SV_Target0;
};
tint_symbol main() {
main_1();
const main_out tint_symbol_1 = {x_GLF_color};
const tint_symbol tint_symbol_4 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_4;
}

View File

@@ -0,0 +1,78 @@
#include <metal_stdlib>
using namespace metal;
struct tint_padded_array_element {
/* 0x0000 */ int el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[3];
};
struct buf1 {
/* 0x0000 */ tint_array_wrapper x_GLF_uniform_int_values;
};
struct tint_padded_array_element_1 {
/* 0x0000 */ float el;
/* 0x0004 */ int8_t tint_pad_1[12];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_padded_array_element_1 arr[3];
};
struct buf0 {
/* 0x0000 */ tint_array_wrapper_1 x_GLF_uniform_float_values;
};
struct tint_array_wrapper_2 {
int arr[3];
};
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_1 {
float4 x_GLF_color_1 [[color(0)]];
};
void main_1(constant buf1& x_6, constant buf0& x_9, thread float4* const tint_symbol_4) {
tint_array_wrapper_2 numbers = {};
float2 a = 0.0f;
float b = 0.0f;
int const x_38 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_40 = x_6.x_GLF_uniform_int_values.arr[0].el;
numbers.arr[x_38] = x_40;
int const x_43 = x_6.x_GLF_uniform_int_values.arr[1].el;
int const x_45 = x_6.x_GLF_uniform_int_values.arr[1].el;
numbers.arr[x_43] = x_45;
int const x_48 = x_6.x_GLF_uniform_int_values.arr[2].el;
int const x_50 = x_6.x_GLF_uniform_int_values.arr[2].el;
numbers.arr[x_48] = x_50;
int const x_53 = x_6.x_GLF_uniform_int_values.arr[0].el;
float const x_56 = x_9.x_GLF_uniform_float_values.arr[2].el;
int const x_60 = numbers.arr[select(2, 1, (0.0f < x_56))];
a = float2(float(x_53), float(x_60));
float2 const x_63 = a;
float const x_65 = x_9.x_GLF_uniform_float_values.arr[1].el;
float const x_67 = x_9.x_GLF_uniform_float_values.arr[1].el;
b = dot(x_63, float2(x_65, x_67));
float const x_70 = b;
float const x_72 = x_9.x_GLF_uniform_float_values.arr[0].el;
if ((x_70 == x_72)) {
int const x_78 = x_6.x_GLF_uniform_int_values.arr[1].el;
int const x_81 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_84 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_87 = x_6.x_GLF_uniform_int_values.arr[1].el;
*(tint_symbol_4) = float4(float(x_78), float(x_81), float(x_84), float(x_87));
} else {
int const x_91 = x_6.x_GLF_uniform_int_values.arr[0].el;
float const x_92 = float(x_91);
*(tint_symbol_4) = float4(x_92, x_92, x_92, x_92);
}
return;
}
fragment tint_symbol_1 tint_symbol(constant buf1& x_6 [[buffer(1)]], constant buf0& x_9 [[buffer(0)]]) {
thread float4 tint_symbol_5 = 0.0f;
main_1(x_6, x_9, &(tint_symbol_5));
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_5};
tint_symbol_1 const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
return tint_symbol_3;
}

View File

@@ -0,0 +1,170 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 112
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %buf1 "buf1"
OpMemberName %buf1 0 "x_GLF_uniform_int_values"
OpName %x_6 "x_6"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "x_GLF_uniform_float_values"
OpName %x_9 "x_9"
OpName %x_GLF_color "x_GLF_color"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %main_1 "main_1"
OpName %numbers "numbers"
OpName %a "a"
OpName %b "b"
OpName %main_out "main_out"
OpMemberName %main_out 0 "x_GLF_color_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpDecorate %buf1 Block
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %_arr_int_uint_3 ArrayStride 16
OpDecorate %x_6 NonWritable
OpDecorate %x_6 DescriptorSet 0
OpDecorate %x_6 Binding 1
OpDecorate %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %_arr_float_uint_3 ArrayStride 16
OpDecorate %x_9 NonWritable
OpDecorate %x_9 DescriptorSet 0
OpDecorate %x_9 Binding 0
OpDecorate %tint_symbol_1 Location 0
OpDecorate %_arr_int_uint_3_0 ArrayStride 4
OpMemberDecorate %main_out 0 Offset 0
%int = OpTypeInt 32 1
%uint = OpTypeInt 32 0
%uint_3 = OpConstant %uint 3
%_arr_int_uint_3 = OpTypeArray %int %uint_3
%buf1 = OpTypeStruct %_arr_int_uint_3
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
%x_6 = OpVariable %_ptr_Uniform_buf1 Uniform
%float = OpTypeFloat 32
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%buf0 = OpTypeStruct %_arr_float_uint_3
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_9 = OpVariable %_ptr_Uniform_buf0 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%16 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %16
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %16
%void = OpTypeVoid
%19 = OpTypeFunction %void
%_arr_int_uint_3_0 = OpTypeArray %int %uint_3
%_ptr_Function__arr_int_uint_3_0 = OpTypePointer Function %_arr_int_uint_3_0
%26 = OpConstantNull %_arr_int_uint_3_0
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%30 = OpConstantNull %v2float
%_ptr_Function_float = OpTypePointer Function %float
%33 = OpConstantNull %float
%uint_0 = OpConstant %uint 0
%int_0 = OpConstant %int 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Function_int = OpTypePointer Function %int
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Uniform_float = OpTypePointer Uniform %float
%float_0 = OpConstant %float 0
%bool = OpTypeBool
%main_out = OpTypeStruct %v4float
%100 = OpTypeFunction %void %main_out
%main_1 = OpFunction %void None %19
%22 = OpLabel
%numbers = OpVariable %_ptr_Function__arr_int_uint_3_0 Function %26
%a = OpVariable %_ptr_Function_v2float Function %30
%b = OpVariable %_ptr_Function_float Function %33
%37 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%38 = OpLoad %int %37
%39 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%40 = OpLoad %int %39
%42 = OpAccessChain %_ptr_Function_int %numbers %38
OpStore %42 %40
%44 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%45 = OpLoad %int %44
%46 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%47 = OpLoad %int %46
%48 = OpAccessChain %_ptr_Function_int %numbers %45
OpStore %48 %47
%50 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_2
%51 = OpLoad %int %50
%52 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_2
%53 = OpLoad %int %52
%54 = OpAccessChain %_ptr_Function_int %numbers %51
OpStore %54 %53
%55 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%56 = OpLoad %int %55
%58 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_2
%59 = OpLoad %float %58
%62 = OpFOrdLessThan %bool %float_0 %59
%60 = OpSelect %int %62 %int_1 %int_2
%64 = OpAccessChain %_ptr_Function_int %numbers %60
%65 = OpLoad %int %64
%66 = OpConvertSToF %float %56
%67 = OpConvertSToF %float %65
%68 = OpCompositeConstruct %v2float %66 %67
OpStore %a %68
%69 = OpLoad %v2float %a
%70 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_1
%71 = OpLoad %float %70
%72 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_1
%73 = OpLoad %float %72
%75 = OpCompositeConstruct %v2float %71 %73
%74 = OpDot %float %69 %75
OpStore %b %74
%76 = OpLoad %float %b
%77 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_0
%78 = OpLoad %float %77
%79 = OpFOrdEqual %bool %76 %78
OpSelectionMerge %80 None
OpBranchConditional %79 %81 %82
%81 = OpLabel
%83 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%84 = OpLoad %int %83
%85 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%86 = OpLoad %int %85
%87 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%88 = OpLoad %int %87
%89 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%90 = OpLoad %int %89
%91 = OpConvertSToF %float %84
%92 = OpConvertSToF %float %86
%93 = OpConvertSToF %float %88
%94 = OpConvertSToF %float %90
%95 = OpCompositeConstruct %v4float %91 %92 %93 %94
OpStore %x_GLF_color %95
OpBranch %80
%82 = OpLabel
%96 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%97 = OpLoad %int %96
%98 = OpConvertSToF %float %97
%99 = OpCompositeConstruct %v4float %98 %98 %98 %98
OpStore %x_GLF_color %99
OpBranch %80
%80 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %100
%tint_symbol = OpFunctionParameter %main_out
%104 = OpLabel
%105 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %105
OpReturn
OpFunctionEnd
%main = OpFunction %void None %19
%107 = OpLabel
%108 = OpFunctionCall %void %main_1
%110 = OpLoad %v4float %x_GLF_color
%111 = OpCompositeConstruct %main_out %110
%109 = OpFunctionCall %void %tint_symbol_2 %111
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,67 @@
type Arr = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr;
};
type Arr_1 = [[stride(16)]] array<f32, 3>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr_1;
};
[[group(0), binding(1)]] var<uniform> x_6 : buf1;
[[group(0), binding(0)]] var<uniform> x_9 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var numbers : array<i32, 3>;
var a : vec2<f32>;
var b : f32;
let x_38 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_40 : i32 = x_6.x_GLF_uniform_int_values[0];
numbers[x_38] = x_40;
let x_43 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_45 : i32 = x_6.x_GLF_uniform_int_values[1];
numbers[x_43] = x_45;
let x_48 : i32 = x_6.x_GLF_uniform_int_values[2];
let x_50 : i32 = x_6.x_GLF_uniform_int_values[2];
numbers[x_48] = x_50;
let x_53 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_56 : f32 = x_9.x_GLF_uniform_float_values[2];
let x_60 : i32 = numbers[select(2, 1, (0.0 < x_56))];
a = vec2<f32>(f32(x_53), f32(x_60));
let x_63 : vec2<f32> = a;
let x_65 : f32 = x_9.x_GLF_uniform_float_values[1];
let x_67 : f32 = x_9.x_GLF_uniform_float_values[1];
b = dot(x_63, vec2<f32>(x_65, x_67));
let x_70 : f32 = b;
let x_72 : f32 = x_9.x_GLF_uniform_float_values[0];
if ((x_70 == x_72)) {
let x_78 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_81 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_84 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_87 : i32 = x_6.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_78), f32(x_81), f32(x_84), f32(x_87));
} else {
let x_91 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_92 : f32 = f32(x_91);
x_GLF_color = vec4<f32>(x_92, x_92, x_92, x_92);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}

View File

@@ -0,0 +1,67 @@
type Arr = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr;
};
type Arr_1 = [[stride(16)]] array<f32, 3>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr_1;
};
[[group(0), binding(1)]] var<uniform> x_6 : buf1;
[[group(0), binding(0)]] var<uniform> x_9 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var numbers : array<i32, 3>;
var a : vec2<f32>;
var b : f32;
let x_38 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_40 : i32 = x_6.x_GLF_uniform_int_values[0];
numbers[x_38] = x_40;
let x_43 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_45 : i32 = x_6.x_GLF_uniform_int_values[1];
numbers[x_43] = x_45;
let x_48 : i32 = x_6.x_GLF_uniform_int_values[2];
let x_50 : i32 = x_6.x_GLF_uniform_int_values[2];
numbers[x_48] = x_50;
let x_53 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_56 : f32 = x_9.x_GLF_uniform_float_values[2];
let x_60 : i32 = numbers[select(2, 1, (0.0 < x_56))];
a = vec2<f32>(f32(x_53), f32(x_60));
let x_63 : vec2<f32> = a;
let x_65 : f32 = x_9.x_GLF_uniform_float_values[1];
let x_67 : f32 = x_9.x_GLF_uniform_float_values[1];
b = dot(x_63, vec2<f32>(x_65, x_67));
let x_70 : f32 = b;
let x_72 : f32 = x_9.x_GLF_uniform_float_values[0];
if ((x_70 == x_72)) {
let x_78 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_81 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_84 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_87 : i32 = x_6.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_78), f32(x_81), f32(x_84), f32(x_87));
} else {
let x_91 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_92 : f32 = f32(x_91);
x_GLF_color = vec4<f32>(x_92, x_92, x_92, x_92);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}

View File

@@ -0,0 +1,65 @@
cbuffer cbuffer_x_6 : register(b1, space0) {
uint4 x_6[3];
};
cbuffer cbuffer_x_9 : register(b0, space0) {
uint4 x_9[3];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
int numbers[3] = (int[3])0;
float2 a = float2(0.0f, 0.0f);
float b = 0.0f;
const uint scalar_offset = ((16u * uint(0))) / 4;
const int x_38 = asint(x_6[scalar_offset / 4][scalar_offset % 4]);
const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const int x_40 = asint(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
numbers[x_38] = x_40;
const int x_43 = asint(x_6[1].x);
const int x_45 = asint(x_6[1].x);
numbers[x_43] = x_45;
const int x_48 = asint(x_6[2].x);
const int x_50 = asint(x_6[2].x);
numbers[x_48] = x_50;
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
const int x_53 = asint(x_6[scalar_offset_2 / 4][scalar_offset_2 % 4]);
const float x_56 = asfloat(x_9[2].x);
const int x_60 = numbers[((0.0f < x_56) ? 1 : 2)];
a = float2(float(x_53), float(x_60));
const float2 x_63 = a;
const float x_65 = asfloat(x_9[1].x);
const float x_67 = asfloat(x_9[1].x);
b = dot(x_63, float2(x_65, x_67));
const float x_70 = b;
const uint scalar_offset_3 = ((16u * uint(0))) / 4;
const float x_72 = asfloat(x_9[scalar_offset_3 / 4][scalar_offset_3 % 4]);
if ((x_70 == x_72)) {
const int x_78 = asint(x_6[1].x);
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_81 = asint(x_6[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const uint scalar_offset_5 = ((16u * uint(0))) / 4;
const int x_84 = asint(x_6[scalar_offset_5 / 4][scalar_offset_5 % 4]);
const int x_87 = asint(x_6[1].x);
x_GLF_color = float4(float(x_78), float(x_81), float(x_84), float(x_87));
} else {
const uint scalar_offset_6 = ((16u * uint(0))) / 4;
const int x_91 = asint(x_6[scalar_offset_6 / 4][scalar_offset_6 % 4]);
const float x_92 = float(x_91);
x_GLF_color = float4(x_92, x_92, x_92, x_92);
}
return;
}
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol {
float4 x_GLF_color_1 : SV_Target0;
};
tint_symbol main() {
main_1();
const main_out tint_symbol_1 = {x_GLF_color};
const tint_symbol tint_symbol_4 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_4;
}

View File

@@ -0,0 +1,78 @@
#include <metal_stdlib>
using namespace metal;
struct tint_padded_array_element {
/* 0x0000 */ int el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[3];
};
struct buf1 {
/* 0x0000 */ tint_array_wrapper x_GLF_uniform_int_values;
};
struct tint_padded_array_element_1 {
/* 0x0000 */ float el;
/* 0x0004 */ int8_t tint_pad_1[12];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_padded_array_element_1 arr[3];
};
struct buf0 {
/* 0x0000 */ tint_array_wrapper_1 x_GLF_uniform_float_values;
};
struct tint_array_wrapper_2 {
int arr[3];
};
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_1 {
float4 x_GLF_color_1 [[color(0)]];
};
void main_1(constant buf1& x_6, constant buf0& x_9, thread float4* const tint_symbol_4) {
tint_array_wrapper_2 numbers = {};
float2 a = 0.0f;
float b = 0.0f;
int const x_38 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_40 = x_6.x_GLF_uniform_int_values.arr[0].el;
numbers.arr[x_38] = x_40;
int const x_43 = x_6.x_GLF_uniform_int_values.arr[1].el;
int const x_45 = x_6.x_GLF_uniform_int_values.arr[1].el;
numbers.arr[x_43] = x_45;
int const x_48 = x_6.x_GLF_uniform_int_values.arr[2].el;
int const x_50 = x_6.x_GLF_uniform_int_values.arr[2].el;
numbers.arr[x_48] = x_50;
int const x_53 = x_6.x_GLF_uniform_int_values.arr[0].el;
float const x_56 = x_9.x_GLF_uniform_float_values.arr[2].el;
int const x_60 = numbers.arr[select(2, 1, (0.0f < x_56))];
a = float2(float(x_53), float(x_60));
float2 const x_63 = a;
float const x_65 = x_9.x_GLF_uniform_float_values.arr[1].el;
float const x_67 = x_9.x_GLF_uniform_float_values.arr[1].el;
b = dot(x_63, float2(x_65, x_67));
float const x_70 = b;
float const x_72 = x_9.x_GLF_uniform_float_values.arr[0].el;
if ((x_70 == x_72)) {
int const x_78 = x_6.x_GLF_uniform_int_values.arr[1].el;
int const x_81 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_84 = x_6.x_GLF_uniform_int_values.arr[0].el;
int const x_87 = x_6.x_GLF_uniform_int_values.arr[1].el;
*(tint_symbol_4) = float4(float(x_78), float(x_81), float(x_84), float(x_87));
} else {
int const x_91 = x_6.x_GLF_uniform_int_values.arr[0].el;
float const x_92 = float(x_91);
*(tint_symbol_4) = float4(x_92, x_92, x_92, x_92);
}
return;
}
fragment tint_symbol_1 tint_symbol(constant buf1& x_6 [[buffer(1)]], constant buf0& x_9 [[buffer(0)]]) {
thread float4 tint_symbol_5 = 0.0f;
main_1(x_6, x_9, &(tint_symbol_5));
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_5};
tint_symbol_1 const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
return tint_symbol_3;
}

View File

@@ -0,0 +1,170 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 112
; Schema: 0
OpCapability Shader
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %buf1 "buf1"
OpMemberName %buf1 0 "x_GLF_uniform_int_values"
OpName %x_6 "x_6"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "x_GLF_uniform_float_values"
OpName %x_9 "x_9"
OpName %x_GLF_color "x_GLF_color"
OpName %tint_symbol_1 "tint_symbol_1"
OpName %main_1 "main_1"
OpName %numbers "numbers"
OpName %a "a"
OpName %b "b"
OpName %main_out "main_out"
OpMemberName %main_out 0 "x_GLF_color_1"
OpName %tint_symbol_2 "tint_symbol_2"
OpName %tint_symbol "tint_symbol"
OpName %main "main"
OpDecorate %buf1 Block
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %_arr_int_uint_3 ArrayStride 16
OpDecorate %x_6 NonWritable
OpDecorate %x_6 DescriptorSet 0
OpDecorate %x_6 Binding 1
OpDecorate %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %_arr_float_uint_3 ArrayStride 16
OpDecorate %x_9 NonWritable
OpDecorate %x_9 DescriptorSet 0
OpDecorate %x_9 Binding 0
OpDecorate %tint_symbol_1 Location 0
OpDecorate %_arr_int_uint_3_0 ArrayStride 4
OpMemberDecorate %main_out 0 Offset 0
%int = OpTypeInt 32 1
%uint = OpTypeInt 32 0
%uint_3 = OpConstant %uint 3
%_arr_int_uint_3 = OpTypeArray %int %uint_3
%buf1 = OpTypeStruct %_arr_int_uint_3
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
%x_6 = OpVariable %_ptr_Uniform_buf1 Uniform
%float = OpTypeFloat 32
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%buf0 = OpTypeStruct %_arr_float_uint_3
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_9 = OpVariable %_ptr_Uniform_buf0 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%16 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %16
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %16
%void = OpTypeVoid
%19 = OpTypeFunction %void
%_arr_int_uint_3_0 = OpTypeArray %int %uint_3
%_ptr_Function__arr_int_uint_3_0 = OpTypePointer Function %_arr_int_uint_3_0
%26 = OpConstantNull %_arr_int_uint_3_0
%v2float = OpTypeVector %float 2
%_ptr_Function_v2float = OpTypePointer Function %v2float
%30 = OpConstantNull %v2float
%_ptr_Function_float = OpTypePointer Function %float
%33 = OpConstantNull %float
%uint_0 = OpConstant %uint 0
%int_0 = OpConstant %int 0
%_ptr_Uniform_int = OpTypePointer Uniform %int
%_ptr_Function_int = OpTypePointer Function %int
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Uniform_float = OpTypePointer Uniform %float
%float_0 = OpConstant %float 0
%bool = OpTypeBool
%main_out = OpTypeStruct %v4float
%100 = OpTypeFunction %void %main_out
%main_1 = OpFunction %void None %19
%22 = OpLabel
%numbers = OpVariable %_ptr_Function__arr_int_uint_3_0 Function %26
%a = OpVariable %_ptr_Function_v2float Function %30
%b = OpVariable %_ptr_Function_float Function %33
%37 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%38 = OpLoad %int %37
%39 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%40 = OpLoad %int %39
%42 = OpAccessChain %_ptr_Function_int %numbers %38
OpStore %42 %40
%44 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%45 = OpLoad %int %44
%46 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%47 = OpLoad %int %46
%48 = OpAccessChain %_ptr_Function_int %numbers %45
OpStore %48 %47
%50 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_2
%51 = OpLoad %int %50
%52 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_2
%53 = OpLoad %int %52
%54 = OpAccessChain %_ptr_Function_int %numbers %51
OpStore %54 %53
%55 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%56 = OpLoad %int %55
%58 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_2
%59 = OpLoad %float %58
%62 = OpFOrdLessThan %bool %float_0 %59
%60 = OpSelect %int %62 %int_1 %int_2
%64 = OpAccessChain %_ptr_Function_int %numbers %60
%65 = OpLoad %int %64
%66 = OpConvertSToF %float %56
%67 = OpConvertSToF %float %65
%68 = OpCompositeConstruct %v2float %66 %67
OpStore %a %68
%69 = OpLoad %v2float %a
%70 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_1
%71 = OpLoad %float %70
%72 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_1
%73 = OpLoad %float %72
%75 = OpCompositeConstruct %v2float %71 %73
%74 = OpDot %float %69 %75
OpStore %b %74
%76 = OpLoad %float %b
%77 = OpAccessChain %_ptr_Uniform_float %x_9 %uint_0 %int_0
%78 = OpLoad %float %77
%79 = OpFOrdEqual %bool %76 %78
OpSelectionMerge %80 None
OpBranchConditional %79 %81 %82
%81 = OpLabel
%83 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%84 = OpLoad %int %83
%85 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%86 = OpLoad %int %85
%87 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%88 = OpLoad %int %87
%89 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_1
%90 = OpLoad %int %89
%91 = OpConvertSToF %float %84
%92 = OpConvertSToF %float %86
%93 = OpConvertSToF %float %88
%94 = OpConvertSToF %float %90
%95 = OpCompositeConstruct %v4float %91 %92 %93 %94
OpStore %x_GLF_color %95
OpBranch %80
%82 = OpLabel
%96 = OpAccessChain %_ptr_Uniform_int %x_6 %uint_0 %int_0
%97 = OpLoad %int %96
%98 = OpConvertSToF %float %97
%99 = OpCompositeConstruct %v4float %98 %98 %98 %98
OpStore %x_GLF_color %99
OpBranch %80
%80 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %100
%tint_symbol = OpFunctionParameter %main_out
%104 = OpLabel
%105 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %105
OpReturn
OpFunctionEnd
%main = OpFunction %void None %19
%107 = OpLabel
%108 = OpFunctionCall %void %main_1
%110 = OpLoad %v4float %x_GLF_color
%111 = OpCompositeConstruct %main_out %110
%109 = OpFunctionCall %void %tint_symbol_2 %111
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,67 @@
type Arr = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr;
};
type Arr_1 = [[stride(16)]] array<f32, 3>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr_1;
};
[[group(0), binding(1)]] var<uniform> x_6 : buf1;
[[group(0), binding(0)]] var<uniform> x_9 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var numbers : array<i32, 3>;
var a : vec2<f32>;
var b : f32;
let x_38 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_40 : i32 = x_6.x_GLF_uniform_int_values[0];
numbers[x_38] = x_40;
let x_43 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_45 : i32 = x_6.x_GLF_uniform_int_values[1];
numbers[x_43] = x_45;
let x_48 : i32 = x_6.x_GLF_uniform_int_values[2];
let x_50 : i32 = x_6.x_GLF_uniform_int_values[2];
numbers[x_48] = x_50;
let x_53 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_56 : f32 = x_9.x_GLF_uniform_float_values[2];
let x_60 : i32 = numbers[select(2, 1, (0.0 < x_56))];
a = vec2<f32>(f32(x_53), f32(x_60));
let x_63 : vec2<f32> = a;
let x_65 : f32 = x_9.x_GLF_uniform_float_values[1];
let x_67 : f32 = x_9.x_GLF_uniform_float_values[1];
b = dot(x_63, vec2<f32>(x_65, x_67));
let x_70 : f32 = b;
let x_72 : f32 = x_9.x_GLF_uniform_float_values[0];
if ((x_70 == x_72)) {
let x_78 : i32 = x_6.x_GLF_uniform_int_values[1];
let x_81 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_84 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_87 : i32 = x_6.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_78), f32(x_81), f32(x_84), f32(x_87));
} else {
let x_91 : i32 = x_6.x_GLF_uniform_int_values[0];
let x_92 : f32 = f32(x_91);
x_GLF_color = vec4<f32>(x_92, x_92, x_92, x_92);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main() -> main_out {
main_1();
return main_out(x_GLF_color);
}