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,132 @@
OpCapability Shader
%1 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %_GLF_color
OpExecutionMode %main OriginUpperLeft
OpSource ESSL 320
OpName %main "main"
OpName %arr "arr"
OpName %buf0 "buf0"
OpMemberName %buf0 0 "_GLF_uniform_float_values"
OpName %_ ""
OpName %i "i"
OpName %buf1 "buf1"
OpMemberName %buf1 0 "_GLF_uniform_int_values"
OpName %__0 ""
OpName %_GLF_color "_GLF_color"
OpDecorate %_arr_float_uint_4 ArrayStride 16
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %buf0 Block
OpDecorate %_ DescriptorSet 0
OpDecorate %_ Binding 0
OpDecorate %_arr_int_uint_3 ArrayStride 16
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %buf1 Block
OpDecorate %__0 DescriptorSet 0
OpDecorate %__0 Binding 1
OpDecorate %_GLF_color Location 0
%void = OpTypeVoid
%13 = OpTypeFunction %void
%float = OpTypeFloat 32
%uint = OpTypeInt 32 0
%uint_3 = OpConstant %uint 3
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%_ptr_Function__arr_float_uint_3 = OpTypePointer Function %_arr_float_uint_3
%uint_4 = OpConstant %uint 4
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%buf0 = OpTypeStruct %_arr_float_uint_4
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%_ = OpVariable %_ptr_Uniform_buf0 Uniform
%int = OpTypeInt 32 1
%int_0 = OpConstant %int 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Function_int = OpTypePointer Function %int
%_arr_int_uint_3 = OpTypeArray %int %uint_3
%buf1 = OpTypeStruct %_arr_int_uint_3
%_ptr_Uniform_buf1 = OpTypePointer Uniform %buf1
%__0 = OpVariable %_ptr_Uniform_buf1 Uniform
%_ptr_Uniform_int = OpTypePointer Uniform %int
%int_3 = OpConstant %int 3
%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 %13
%34 = OpLabel
%arr = OpVariable %_ptr_Function__arr_float_uint_3 Function
%i = OpVariable %_ptr_Function_int Function
%35 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0
%36 = OpLoad %float %35
%37 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_1
%38 = OpLoad %float %37
%39 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_2
%40 = OpLoad %float %39
%41 = OpCompositeConstruct %_arr_float_uint_3 %36 %38 %40
OpStore %arr %41
OpStore %i %int_1
OpBranch %42
%42 = OpLabel
OpLoopMerge %43 %44 None
OpBranch %45
%45 = OpLabel
%46 = OpLoad %int %i
%47 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_2
%48 = OpLoad %int %47
%49 = OpExtInst %int %1 SMin %48 %int_3
%50 = OpSLessThan %bool %46 %49
OpBranchConditional %50 %51 %43
%51 = OpLabel
%52 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_2
%53 = OpLoad %int %52
%54 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_0
%55 = OpLoad %float %54
%56 = OpAccessChain %_ptr_Function_float %arr %53
%57 = OpLoad %float %56
%58 = OpFAdd %float %57 %55
%59 = OpAccessChain %_ptr_Function_float %arr %53
OpStore %59 %58
OpBranch %44
%44 = OpLabel
%60 = OpLoad %int %i
%61 = OpIAdd %int %60 %int_1
OpStore %i %61
OpBranch %42
%43 = OpLabel
%62 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_2
%63 = OpLoad %int %62
%64 = OpAccessChain %_ptr_Function_float %arr %63
%65 = OpLoad %float %64
%66 = OpAccessChain %_ptr_Uniform_float %_ %int_0 %int_3
%67 = OpLoad %float %66
%68 = OpFOrdEqual %bool %65 %67
OpSelectionMerge %69 None
OpBranchConditional %68 %70 %71
%70 = OpLabel
%72 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_1
%73 = OpLoad %int %72
%74 = OpConvertSToF %float %73
%75 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_0
%76 = OpLoad %int %75
%77 = OpConvertSToF %float %76
%78 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_0
%79 = OpLoad %int %78
%80 = OpConvertSToF %float %79
%81 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_1
%82 = OpLoad %int %81
%83 = OpConvertSToF %float %82
%84 = OpCompositeConstruct %v4float %74 %77 %80 %83
OpStore %_GLF_color %84
OpBranch %69
%71 = OpLabel
%85 = OpAccessChain %_ptr_Uniform_int %__0 %int_0 %int_0
%86 = OpLoad %int %85
%87 = OpConvertSToF %float %86
%88 = OpCompositeConstruct %v4float %87 %87 %87 %87
OpStore %_GLF_color %88
OpBranch %69
%69 = OpLabel
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,67 @@
cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[4];
};
cbuffer cbuffer_x_9 : register(b1, space0) {
uint4 x_9[3];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
float arr[3] = (float[3])0;
int i = 0;
const uint scalar_offset = ((16u * uint(0))) / 4;
const float x_36 = asfloat(x_6[scalar_offset / 4][scalar_offset % 4]);
const float x_38 = asfloat(x_6[1].x);
const float x_40 = asfloat(x_6[2].x);
const float tint_symbol_4[3] = {x_36, x_38, x_40};
arr = tint_symbol_4;
i = 1;
while (true) {
const int x_46 = i;
const int x_48 = asint(x_9[2].x);
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
const int x_53 = asint(x_9[2].x);
const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const float x_55 = asfloat(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
const float x_57 = arr[x_53];
arr[x_53] = (x_57 + x_55);
{
i = (i + 1);
}
}
const int x_63 = asint(x_9[2].x);
const float x_65 = arr[x_63];
const float x_67 = asfloat(x_6[3].x);
if ((x_65 == x_67)) {
const int x_73 = asint(x_9[1].x);
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
const int x_76 = asint(x_9[scalar_offset_2 / 4][scalar_offset_2 % 4]);
const uint scalar_offset_3 = ((16u * uint(0))) / 4;
const int x_79 = asint(x_9[scalar_offset_3 / 4][scalar_offset_3 % 4]);
const int x_82 = asint(x_9[1].x);
x_GLF_color = float4(float(x_73), float(x_76), float(x_79), float(x_82));
} else {
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_86 = asint(x_9[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const float x_87 = float(x_86);
x_GLF_color = float4(x_87, x_87, x_87, x_87);
}
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_5 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_5;
}

View File

@@ -0,0 +1,83 @@
#include <metal_stdlib>
using namespace metal;
struct tint_padded_array_element {
/* 0x0000 */ float el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[4];
};
struct buf0 {
/* 0x0000 */ tint_array_wrapper x_GLF_uniform_float_values;
};
struct tint_padded_array_element_1 {
/* 0x0000 */ int el;
/* 0x0004 */ int8_t tint_pad_1[12];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_padded_array_element_1 arr[3];
};
struct buf1 {
/* 0x0000 */ tint_array_wrapper_1 x_GLF_uniform_int_values;
};
struct tint_array_wrapper_2 {
float 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 buf0& x_6, constant buf1& x_9, thread float4* const tint_symbol_5) {
tint_array_wrapper_2 arr = {};
int i = 0;
float const x_36 = x_6.x_GLF_uniform_float_values.arr[0].el;
float const x_38 = x_6.x_GLF_uniform_float_values.arr[1].el;
float const x_40 = x_6.x_GLF_uniform_float_values.arr[2].el;
tint_array_wrapper_2 const tint_symbol_3 = {.arr={x_36, x_38, x_40}};
arr = tint_symbol_3;
i = 1;
while (true) {
int const x_46 = i;
int const x_48 = x_9.x_GLF_uniform_int_values.arr[2].el;
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
int const x_53 = x_9.x_GLF_uniform_int_values.arr[2].el;
float const x_55 = x_6.x_GLF_uniform_float_values.arr[0].el;
float const x_57 = arr.arr[x_53];
arr.arr[x_53] = (x_57 + x_55);
{
int const x_60 = i;
i = (x_60 + 1);
}
}
int const x_63 = x_9.x_GLF_uniform_int_values.arr[2].el;
float const x_65 = arr.arr[x_63];
float const x_67 = x_6.x_GLF_uniform_float_values.arr[3].el;
if ((x_65 == x_67)) {
int const x_73 = x_9.x_GLF_uniform_int_values.arr[1].el;
int const x_76 = x_9.x_GLF_uniform_int_values.arr[0].el;
int const x_79 = x_9.x_GLF_uniform_int_values.arr[0].el;
int const x_82 = x_9.x_GLF_uniform_int_values.arr[1].el;
*(tint_symbol_5) = float4(float(x_73), float(x_76), float(x_79), float(x_82));
} else {
int const x_86 = x_9.x_GLF_uniform_int_values.arr[0].el;
float const x_87 = float(x_86);
*(tint_symbol_5) = float4(x_87, x_87, x_87, x_87);
}
return;
}
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]], constant buf1& x_9 [[buffer(1)]]) {
thread float4 tint_symbol_6 = 0.0f;
main_1(x_6, x_9, &(tint_symbol_6));
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_6};
tint_symbol_1 const tint_symbol_4 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
return tint_symbol_4;
}

View File

@@ -0,0 +1,174 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 109
; Schema: 0
OpCapability Shader
%52 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %buf0 "buf0"
OpMemberName %buf0 0 "x_GLF_uniform_float_values"
OpName %x_6 "x_6"
OpName %buf1 "buf1"
OpMemberName %buf1 0 "x_GLF_uniform_int_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 %arr "arr"
OpName %i "i"
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 %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %_arr_float_uint_4 ArrayStride 16
OpDecorate %x_6 NonWritable
OpDecorate %x_6 DescriptorSet 0
OpDecorate %x_6 Binding 0
OpDecorate %buf1 Block
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %_arr_int_uint_3 ArrayStride 16
OpDecorate %x_9 NonWritable
OpDecorate %x_9 DescriptorSet 0
OpDecorate %x_9 Binding 1
OpDecorate %tint_symbol_1 Location 0
OpDecorate %_arr_float_uint_3 ArrayStride 4
OpMemberDecorate %main_out 0 Offset 0
%float = OpTypeFloat 32
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%buf0 = OpTypeStruct %_arr_float_uint_4
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_6 = OpVariable %_ptr_Uniform_buf0 Uniform
%int = OpTypeInt 32 1
%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_9 = OpVariable %_ptr_Uniform_buf1 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%17 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %17
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %17
%void = OpTypeVoid
%20 = OpTypeFunction %void
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%_ptr_Function__arr_float_uint_3 = OpTypePointer Function %_arr_float_uint_3
%27 = OpConstantNull %_arr_float_uint_3
%_ptr_Function_int = OpTypePointer Function %int
%30 = OpConstantNull %int
%uint_0 = OpConstant %uint 0
%int_0 = OpConstant %int 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Uniform_int = OpTypePointer Uniform %int
%int_3 = OpConstant %int 3
%bool = OpTypeBool
%_ptr_Function_float = OpTypePointer Function %float
%main_out = OpTypeStruct %v4float
%97 = OpTypeFunction %void %main_out
%main_1 = OpFunction %void None %20
%23 = OpLabel
%arr = OpVariable %_ptr_Function__arr_float_uint_3 Function %27
%i = OpVariable %_ptr_Function_int Function %30
%34 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_0
%35 = OpLoad %float %34
%37 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_1
%38 = OpLoad %float %37
%40 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_2
%41 = OpLoad %float %40
%42 = OpCompositeConstruct %_arr_float_uint_3 %35 %38 %41
OpStore %arr %42
OpStore %i %int_1
OpBranch %43
%43 = OpLabel
OpLoopMerge %44 %45 None
OpBranch %46
%46 = OpLabel
%47 = OpLoad %int %i
%49 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%50 = OpLoad %int %49
%51 = OpExtInst %int %52 SMin %50 %int_3
%54 = OpSLessThan %bool %47 %51
OpSelectionMerge %56 None
OpBranchConditional %54 %57 %58
%57 = OpLabel
OpBranch %56
%58 = OpLabel
OpBranch %44
%56 = OpLabel
%59 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%60 = OpLoad %int %59
%61 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_0
%62 = OpLoad %float %61
%64 = OpAccessChain %_ptr_Function_float %arr %60
%65 = OpLoad %float %64
%66 = OpAccessChain %_ptr_Function_float %arr %60
%67 = OpFAdd %float %65 %62
OpStore %66 %67
OpBranch %45
%45 = OpLabel
%68 = OpLoad %int %i
%69 = OpIAdd %int %68 %int_1
OpStore %i %69
OpBranch %43
%44 = OpLabel
%70 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%71 = OpLoad %int %70
%72 = OpAccessChain %_ptr_Function_float %arr %71
%73 = OpLoad %float %72
%74 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_3
%75 = OpLoad %float %74
%76 = OpFOrdEqual %bool %73 %75
OpSelectionMerge %77 None
OpBranchConditional %76 %78 %79
%78 = OpLabel
%80 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_1
%81 = OpLoad %int %80
%82 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%83 = OpLoad %int %82
%84 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%85 = OpLoad %int %84
%86 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_1
%87 = OpLoad %int %86
%88 = OpConvertSToF %float %81
%89 = OpConvertSToF %float %83
%90 = OpConvertSToF %float %85
%91 = OpConvertSToF %float %87
%92 = OpCompositeConstruct %v4float %88 %89 %90 %91
OpStore %x_GLF_color %92
OpBranch %77
%79 = OpLabel
%93 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%94 = OpLoad %int %93
%95 = OpConvertSToF %float %94
%96 = OpCompositeConstruct %v4float %95 %95 %95 %95
OpStore %x_GLF_color %96
OpBranch %77
%77 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %97
%tint_symbol = OpFunctionParameter %main_out
%101 = OpLabel
%102 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %102
OpReturn
OpFunctionEnd
%main = OpFunction %void None %20
%104 = OpLabel
%105 = OpFunctionCall %void %main_1
%107 = OpLoad %v4float %x_GLF_color
%108 = OpCompositeConstruct %main_out %107
%106 = OpFunctionCall %void %tint_symbol_2 %108
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,72 @@
type Arr = [[stride(16)]] array<f32, 4>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr;
};
type Arr_1 = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr_1;
};
[[group(0), binding(0)]] var<uniform> x_6 : buf0;
[[group(0), binding(1)]] var<uniform> x_9 : buf1;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var arr : array<f32, 3>;
var i : i32;
let x_36 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_38 : f32 = x_6.x_GLF_uniform_float_values[1];
let x_40 : f32 = x_6.x_GLF_uniform_float_values[2];
arr = array<f32, 3>(x_36, x_38, x_40);
i = 1;
loop {
let x_46 : i32 = i;
let x_48 : i32 = x_9.x_GLF_uniform_int_values[2];
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
let x_53 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_55 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_57 : f32 = arr[x_53];
arr[x_53] = (x_57 + x_55);
continuing {
let x_60 : i32 = i;
i = (x_60 + 1);
}
}
let x_63 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_65 : f32 = arr[x_63];
let x_67 : f32 = x_6.x_GLF_uniform_float_values[3];
if ((x_65 == x_67)) {
let x_73 : i32 = x_9.x_GLF_uniform_int_values[1];
let x_76 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_79 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_82 : i32 = x_9.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_73), f32(x_76), f32(x_79), f32(x_82));
} else {
let x_86 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_87 : f32 = f32(x_86);
x_GLF_color = vec4<f32>(x_87, x_87, x_87, x_87);
}
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,72 @@
type Arr = [[stride(16)]] array<f32, 4>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr;
};
type Arr_1 = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr_1;
};
[[group(0), binding(0)]] var<uniform> x_6 : buf0;
[[group(0), binding(1)]] var<uniform> x_9 : buf1;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var arr : array<f32, 3>;
var i : i32;
let x_36 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_38 : f32 = x_6.x_GLF_uniform_float_values[1];
let x_40 : f32 = x_6.x_GLF_uniform_float_values[2];
arr = array<f32, 3>(x_36, x_38, x_40);
i = 1;
loop {
let x_46 : i32 = i;
let x_48 : i32 = x_9.x_GLF_uniform_int_values[2];
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
let x_53 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_55 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_57 : f32 = arr[x_53];
arr[x_53] = (x_57 + x_55);
continuing {
let x_60 : i32 = i;
i = (x_60 + 1);
}
}
let x_63 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_65 : f32 = arr[x_63];
let x_67 : f32 = x_6.x_GLF_uniform_float_values[3];
if ((x_65 == x_67)) {
let x_73 : i32 = x_9.x_GLF_uniform_int_values[1];
let x_76 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_79 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_82 : i32 = x_9.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_73), f32(x_76), f32(x_79), f32(x_82));
} else {
let x_86 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_87 : f32 = f32(x_86);
x_GLF_color = vec4<f32>(x_87, x_87, x_87, x_87);
}
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 @@
cbuffer cbuffer_x_6 : register(b0, space0) {
uint4 x_6[4];
};
cbuffer cbuffer_x_9 : register(b1, space0) {
uint4 x_9[3];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
void main_1() {
float arr[3] = (float[3])0;
int i = 0;
const uint scalar_offset = ((16u * uint(0))) / 4;
const float x_36 = asfloat(x_6[scalar_offset / 4][scalar_offset % 4]);
const float x_38 = asfloat(x_6[1].x);
const float x_40 = asfloat(x_6[2].x);
const float tint_symbol_4[3] = {x_36, x_38, x_40};
arr = tint_symbol_4;
i = 1;
while (true) {
const int x_46 = i;
const int x_48 = asint(x_9[2].x);
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
const int x_53 = asint(x_9[2].x);
const uint scalar_offset_1 = ((16u * uint(0))) / 4;
const float x_55 = asfloat(x_6[scalar_offset_1 / 4][scalar_offset_1 % 4]);
const float x_57 = arr[x_53];
arr[x_53] = (x_57 + x_55);
{
i = (i + 1);
}
}
const int x_63 = asint(x_9[2].x);
const float x_65 = arr[x_63];
const float x_67 = asfloat(x_6[3].x);
if ((x_65 == x_67)) {
const int x_73 = asint(x_9[1].x);
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
const int x_76 = asint(x_9[scalar_offset_2 / 4][scalar_offset_2 % 4]);
const uint scalar_offset_3 = ((16u * uint(0))) / 4;
const int x_79 = asint(x_9[scalar_offset_3 / 4][scalar_offset_3 % 4]);
const int x_82 = asint(x_9[1].x);
x_GLF_color = float4(float(x_73), float(x_76), float(x_79), float(x_82));
} else {
const uint scalar_offset_4 = ((16u * uint(0))) / 4;
const int x_86 = asint(x_9[scalar_offset_4 / 4][scalar_offset_4 % 4]);
const float x_87 = float(x_86);
x_GLF_color = float4(x_87, x_87, x_87, x_87);
}
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_5 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_5;
}

View File

@@ -0,0 +1,83 @@
#include <metal_stdlib>
using namespace metal;
struct tint_padded_array_element {
/* 0x0000 */ float el;
/* 0x0004 */ int8_t tint_pad[12];
};
struct tint_array_wrapper {
/* 0x0000 */ tint_padded_array_element arr[4];
};
struct buf0 {
/* 0x0000 */ tint_array_wrapper x_GLF_uniform_float_values;
};
struct tint_padded_array_element_1 {
/* 0x0000 */ int el;
/* 0x0004 */ int8_t tint_pad_1[12];
};
struct tint_array_wrapper_1 {
/* 0x0000 */ tint_padded_array_element_1 arr[3];
};
struct buf1 {
/* 0x0000 */ tint_array_wrapper_1 x_GLF_uniform_int_values;
};
struct tint_array_wrapper_2 {
float 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 buf0& x_6, constant buf1& x_9, thread float4* const tint_symbol_5) {
tint_array_wrapper_2 arr = {};
int i = 0;
float const x_36 = x_6.x_GLF_uniform_float_values.arr[0].el;
float const x_38 = x_6.x_GLF_uniform_float_values.arr[1].el;
float const x_40 = x_6.x_GLF_uniform_float_values.arr[2].el;
tint_array_wrapper_2 const tint_symbol_3 = {.arr={x_36, x_38, x_40}};
arr = tint_symbol_3;
i = 1;
while (true) {
int const x_46 = i;
int const x_48 = x_9.x_GLF_uniform_int_values.arr[2].el;
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
int const x_53 = x_9.x_GLF_uniform_int_values.arr[2].el;
float const x_55 = x_6.x_GLF_uniform_float_values.arr[0].el;
float const x_57 = arr.arr[x_53];
arr.arr[x_53] = (x_57 + x_55);
{
int const x_60 = i;
i = (x_60 + 1);
}
}
int const x_63 = x_9.x_GLF_uniform_int_values.arr[2].el;
float const x_65 = arr.arr[x_63];
float const x_67 = x_6.x_GLF_uniform_float_values.arr[3].el;
if ((x_65 == x_67)) {
int const x_73 = x_9.x_GLF_uniform_int_values.arr[1].el;
int const x_76 = x_9.x_GLF_uniform_int_values.arr[0].el;
int const x_79 = x_9.x_GLF_uniform_int_values.arr[0].el;
int const x_82 = x_9.x_GLF_uniform_int_values.arr[1].el;
*(tint_symbol_5) = float4(float(x_73), float(x_76), float(x_79), float(x_82));
} else {
int const x_86 = x_9.x_GLF_uniform_int_values.arr[0].el;
float const x_87 = float(x_86);
*(tint_symbol_5) = float4(x_87, x_87, x_87, x_87);
}
return;
}
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]], constant buf1& x_9 [[buffer(1)]]) {
thread float4 tint_symbol_6 = 0.0f;
main_1(x_6, x_9, &(tint_symbol_6));
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_6};
tint_symbol_1 const tint_symbol_4 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
return tint_symbol_4;
}

View File

@@ -0,0 +1,174 @@
; SPIR-V
; Version: 1.3
; Generator: Google Tint Compiler; 0
; Bound: 109
; Schema: 0
OpCapability Shader
%52 = OpExtInstImport "GLSL.std.450"
OpMemoryModel Logical GLSL450
OpEntryPoint Fragment %main "main" %tint_symbol_1
OpExecutionMode %main OriginUpperLeft
OpName %buf0 "buf0"
OpMemberName %buf0 0 "x_GLF_uniform_float_values"
OpName %x_6 "x_6"
OpName %buf1 "buf1"
OpMemberName %buf1 0 "x_GLF_uniform_int_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 %arr "arr"
OpName %i "i"
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 %buf0 Block
OpMemberDecorate %buf0 0 Offset 0
OpDecorate %_arr_float_uint_4 ArrayStride 16
OpDecorate %x_6 NonWritable
OpDecorate %x_6 DescriptorSet 0
OpDecorate %x_6 Binding 0
OpDecorate %buf1 Block
OpMemberDecorate %buf1 0 Offset 0
OpDecorate %_arr_int_uint_3 ArrayStride 16
OpDecorate %x_9 NonWritable
OpDecorate %x_9 DescriptorSet 0
OpDecorate %x_9 Binding 1
OpDecorate %tint_symbol_1 Location 0
OpDecorate %_arr_float_uint_3 ArrayStride 4
OpMemberDecorate %main_out 0 Offset 0
%float = OpTypeFloat 32
%uint = OpTypeInt 32 0
%uint_4 = OpConstant %uint 4
%_arr_float_uint_4 = OpTypeArray %float %uint_4
%buf0 = OpTypeStruct %_arr_float_uint_4
%_ptr_Uniform_buf0 = OpTypePointer Uniform %buf0
%x_6 = OpVariable %_ptr_Uniform_buf0 Uniform
%int = OpTypeInt 32 1
%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_9 = OpVariable %_ptr_Uniform_buf1 Uniform
%v4float = OpTypeVector %float 4
%_ptr_Private_v4float = OpTypePointer Private %v4float
%17 = OpConstantNull %v4float
%x_GLF_color = OpVariable %_ptr_Private_v4float Private %17
%_ptr_Output_v4float = OpTypePointer Output %v4float
%tint_symbol_1 = OpVariable %_ptr_Output_v4float Output %17
%void = OpTypeVoid
%20 = OpTypeFunction %void
%_arr_float_uint_3 = OpTypeArray %float %uint_3
%_ptr_Function__arr_float_uint_3 = OpTypePointer Function %_arr_float_uint_3
%27 = OpConstantNull %_arr_float_uint_3
%_ptr_Function_int = OpTypePointer Function %int
%30 = OpConstantNull %int
%uint_0 = OpConstant %uint 0
%int_0 = OpConstant %int 0
%_ptr_Uniform_float = OpTypePointer Uniform %float
%int_1 = OpConstant %int 1
%int_2 = OpConstant %int 2
%_ptr_Uniform_int = OpTypePointer Uniform %int
%int_3 = OpConstant %int 3
%bool = OpTypeBool
%_ptr_Function_float = OpTypePointer Function %float
%main_out = OpTypeStruct %v4float
%97 = OpTypeFunction %void %main_out
%main_1 = OpFunction %void None %20
%23 = OpLabel
%arr = OpVariable %_ptr_Function__arr_float_uint_3 Function %27
%i = OpVariable %_ptr_Function_int Function %30
%34 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_0
%35 = OpLoad %float %34
%37 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_1
%38 = OpLoad %float %37
%40 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_2
%41 = OpLoad %float %40
%42 = OpCompositeConstruct %_arr_float_uint_3 %35 %38 %41
OpStore %arr %42
OpStore %i %int_1
OpBranch %43
%43 = OpLabel
OpLoopMerge %44 %45 None
OpBranch %46
%46 = OpLabel
%47 = OpLoad %int %i
%49 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%50 = OpLoad %int %49
%51 = OpExtInst %int %52 SMin %50 %int_3
%54 = OpSLessThan %bool %47 %51
OpSelectionMerge %56 None
OpBranchConditional %54 %57 %58
%57 = OpLabel
OpBranch %56
%58 = OpLabel
OpBranch %44
%56 = OpLabel
%59 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%60 = OpLoad %int %59
%61 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_0
%62 = OpLoad %float %61
%64 = OpAccessChain %_ptr_Function_float %arr %60
%65 = OpLoad %float %64
%66 = OpAccessChain %_ptr_Function_float %arr %60
%67 = OpFAdd %float %65 %62
OpStore %66 %67
OpBranch %45
%45 = OpLabel
%68 = OpLoad %int %i
%69 = OpIAdd %int %68 %int_1
OpStore %i %69
OpBranch %43
%44 = OpLabel
%70 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_2
%71 = OpLoad %int %70
%72 = OpAccessChain %_ptr_Function_float %arr %71
%73 = OpLoad %float %72
%74 = OpAccessChain %_ptr_Uniform_float %x_6 %uint_0 %int_3
%75 = OpLoad %float %74
%76 = OpFOrdEqual %bool %73 %75
OpSelectionMerge %77 None
OpBranchConditional %76 %78 %79
%78 = OpLabel
%80 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_1
%81 = OpLoad %int %80
%82 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%83 = OpLoad %int %82
%84 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%85 = OpLoad %int %84
%86 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_1
%87 = OpLoad %int %86
%88 = OpConvertSToF %float %81
%89 = OpConvertSToF %float %83
%90 = OpConvertSToF %float %85
%91 = OpConvertSToF %float %87
%92 = OpCompositeConstruct %v4float %88 %89 %90 %91
OpStore %x_GLF_color %92
OpBranch %77
%79 = OpLabel
%93 = OpAccessChain %_ptr_Uniform_int %x_9 %uint_0 %int_0
%94 = OpLoad %int %93
%95 = OpConvertSToF %float %94
%96 = OpCompositeConstruct %v4float %95 %95 %95 %95
OpStore %x_GLF_color %96
OpBranch %77
%77 = OpLabel
OpReturn
OpFunctionEnd
%tint_symbol_2 = OpFunction %void None %97
%tint_symbol = OpFunctionParameter %main_out
%101 = OpLabel
%102 = OpCompositeExtract %v4float %tint_symbol 0
OpStore %tint_symbol_1 %102
OpReturn
OpFunctionEnd
%main = OpFunction %void None %20
%104 = OpLabel
%105 = OpFunctionCall %void %main_1
%107 = OpLoad %v4float %x_GLF_color
%108 = OpCompositeConstruct %main_out %107
%106 = OpFunctionCall %void %tint_symbol_2 %108
OpReturn
OpFunctionEnd

View File

@@ -0,0 +1,72 @@
type Arr = [[stride(16)]] array<f32, 4>;
[[block]]
struct buf0 {
x_GLF_uniform_float_values : Arr;
};
type Arr_1 = [[stride(16)]] array<i32, 3>;
[[block]]
struct buf1 {
x_GLF_uniform_int_values : Arr_1;
};
[[group(0), binding(0)]] var<uniform> x_6 : buf0;
[[group(0), binding(1)]] var<uniform> x_9 : buf1;
var<private> x_GLF_color : vec4<f32>;
fn main_1() {
var arr : array<f32, 3>;
var i : i32;
let x_36 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_38 : f32 = x_6.x_GLF_uniform_float_values[1];
let x_40 : f32 = x_6.x_GLF_uniform_float_values[2];
arr = array<f32, 3>(x_36, x_38, x_40);
i = 1;
loop {
let x_46 : i32 = i;
let x_48 : i32 = x_9.x_GLF_uniform_int_values[2];
if ((x_46 < min(x_48, 3))) {
} else {
break;
}
let x_53 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_55 : f32 = x_6.x_GLF_uniform_float_values[0];
let x_57 : f32 = arr[x_53];
arr[x_53] = (x_57 + x_55);
continuing {
let x_60 : i32 = i;
i = (x_60 + 1);
}
}
let x_63 : i32 = x_9.x_GLF_uniform_int_values[2];
let x_65 : f32 = arr[x_63];
let x_67 : f32 = x_6.x_GLF_uniform_float_values[3];
if ((x_65 == x_67)) {
let x_73 : i32 = x_9.x_GLF_uniform_int_values[1];
let x_76 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_79 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_82 : i32 = x_9.x_GLF_uniform_int_values[1];
x_GLF_color = vec4<f32>(f32(x_73), f32(x_76), f32(x_79), f32(x_82));
} else {
let x_86 : i32 = x_9.x_GLF_uniform_int_values[0];
let x_87 : f32 = f32(x_86);
x_GLF_color = vec4<f32>(x_87, x_87, x_87, x_87);
}
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);
}