Alastair Donaldson f7e73d4ee3 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>
2021-07-23 13:10:12 +00:00

113 lines
2.8 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
struct buf0 {
/* 0x0000 */ packed_float2 injectionSwitch;
};
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_2 {
float4 x_GLF_color_1 [[color(0)]];
};
void main_1(constant buf0& x_9, thread float4* const tint_symbol_5, thread float4* const tint_symbol_6) {
float x_43 = 0.0f;
float x_44 = 0.0f;
float x_45 = 0.0f;
int x_46 = 0;
int zero = 0;
float2 param = 0.0f;
float2 temp = 0.0f;
float4 const x_47 = *(tint_symbol_5);
param = float2(x_47.x, x_47.y);
while (true) {
float const x_54 = param.y;
if ((x_54 < 50.0f)) {
float const x_60 = x_9.injectionSwitch.y;
x_44 = x_60;
} else {
x_44 = 0.0f;
}
float const x_61 = x_44;
x_43 = x_61;
float const x_63 = (*(tint_symbol_5)).y;
float const x_65 = select(0.0f, 1.0f, (x_63 < 50.0f));
x_45 = x_65;
if (((x_61 - x_65) < 1.0f)) {
x_46 = 0;
break;
}
x_46 = 1;
break;
{
if (false) {
} else {
break;
}
}
}
int const x_70 = x_46;
zero = x_70;
if ((x_70 == 1)) {
return;
}
*(tint_symbol_6) = float4(0.0f, 1.0f, 1.0f, 1.0f);
float const x_75 = (*(tint_symbol_5)).x;
float const x_77 = x_9.injectionSwitch.x;
if ((x_75 >= x_77)) {
float const x_82 = (*(tint_symbol_5)).y;
if ((x_82 >= 0.0f)) {
float const x_87 = x_9.injectionSwitch.y;
(*(tint_symbol_6)).x = x_87;
}
}
float const x_90 = (*(tint_symbol_5)).y;
if ((x_90 >= 0.0f)) {
float const x_95 = x_9.injectionSwitch.x;
(*(tint_symbol_6)).y = x_95;
}
float4 const x_97 = *(tint_symbol_5);
float2 const x_98 = float2(x_97.x, x_97.y);
float2 const x_101 = float2(x_98.x, x_98.y);
temp = x_101;
if ((x_101.y >= 0.0f)) {
float const x_107 = x_9.injectionSwitch.x;
(*(tint_symbol_6)).z = x_107;
}
return;
}
fragment tint_symbol_2 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf0& x_9 [[buffer(0)]]) {
thread float4 tint_symbol_7 = 0.0f;
thread float4 tint_symbol_8 = 0.0f;
tint_symbol_7 = gl_FragCoord_param;
main_1(x_9, &(tint_symbol_7), &(tint_symbol_8));
main_out const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_8};
tint_symbol_2 const tint_symbol_4 = {.x_GLF_color_1=tint_symbol_3.x_GLF_color_1};
return tint_symbol_4;
}
int alwaysZero_vf2_(constant buf0& x_9, thread float2* const coord, thread float4* const tint_symbol_9) {
float a = 0.0f;
float x_110 = 0.0f;
float b = 0.0f;
float const x_112 = (*(coord)).y;
if ((x_112 < 50.0f)) {
float const x_118 = x_9.injectionSwitch.y;
x_110 = x_118;
} else {
x_110 = 0.0f;
}
float const x_119 = x_110;
a = x_119;
float const x_121 = (*(tint_symbol_9)).y;
float const x_123 = select(0.0f, 1.0f, (x_121 < 50.0f));
b = x_123;
if (((x_119 - x_123) < 1.0f)) {
return 0;
}
return 1;
}