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

146 lines
4.4 KiB
Plaintext

#include <metal_stdlib>
using namespace metal;
struct buf0 {
/* 0x0000 */ packed_float2 resolution;
};
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_2 {
float4 x_GLF_color_1 [[color(0)]];
};
float cross2d_vf2_vf2_(thread float2* const a, thread float2* const b) {
float const x_79 = (*(a)).x;
float const x_81 = (*(b)).y;
float const x_84 = (*(b)).x;
float const x_86 = (*(a)).y;
return ((x_79 * x_81) - (x_84 * x_86));
}
int pointInTriangle_vf2_vf2_vf2_vf2_(thread float2* const p, thread float2* const a_1, thread float2* const b_1, thread float2* const c) {
bool x_90 = false;
int x_91 = 0;
float pab = 0.0f;
float2 param = 0.0f;
float2 param_1 = 0.0f;
float pbc = 0.0f;
float2 param_2 = 0.0f;
float2 param_3 = 0.0f;
float pca = 0.0f;
float2 param_4 = 0.0f;
float2 param_5 = 0.0f;
bool x_140 = false;
bool x_168 = false;
bool x_141_phi = false;
bool x_169_phi = false;
int x_173_phi = 0;
switch(0u) {
default: {
float const x_95 = (*(p)).x;
float const x_97 = (*(a_1)).x;
float const x_100 = (*(p)).y;
float const x_102 = (*(a_1)).y;
float const x_106 = (*(b_1)).x;
float const x_107 = (*(a_1)).x;
float const x_110 = (*(b_1)).y;
float const x_111 = (*(a_1)).y;
param = float2((x_95 - x_97), (x_100 - x_102));
param_1 = float2((x_106 - x_107), (x_110 - x_111));
float const x_114 = cross2d_vf2_vf2_(&(param), &(param_1));
pab = x_114;
float const x_115 = (*(p)).x;
float const x_116 = (*(b_1)).x;
float const x_118 = (*(p)).y;
float const x_119 = (*(b_1)).y;
float const x_123 = (*(c)).x;
float const x_124 = (*(b_1)).x;
float const x_127 = (*(c)).y;
float const x_128 = (*(b_1)).y;
param_2 = float2((x_115 - x_116), (x_118 - x_119));
param_3 = float2((x_123 - x_124), (x_127 - x_128));
float const x_131 = cross2d_vf2_vf2_(&(param_2), &(param_3));
pbc = x_131;
bool const x_134 = ((x_114 < 0.0f) && (x_131 < 0.0f));
x_141_phi = x_134;
if (!(x_134)) {
x_140 = ((x_114 >= 0.0f) && (x_131 >= 0.0f));
x_141_phi = x_140;
}
bool const x_141 = x_141_phi;
if (!(x_141)) {
x_90 = true;
x_91 = 0;
x_173_phi = 0;
break;
}
float const x_145 = (*(p)).x;
float const x_146 = (*(c)).x;
float const x_148 = (*(p)).y;
float const x_149 = (*(c)).y;
float const x_152 = (*(a_1)).x;
float const x_153 = (*(c)).x;
float const x_155 = (*(a_1)).y;
float const x_156 = (*(c)).y;
param_4 = float2((x_145 - x_146), (x_148 - x_149));
param_5 = float2((x_152 - x_153), (x_155 - x_156));
float const x_159 = cross2d_vf2_vf2_(&(param_4), &(param_5));
pca = x_159;
bool const x_162 = ((x_114 < 0.0f) && (x_159 < 0.0f));
x_169_phi = x_162;
if (!(x_162)) {
x_168 = ((x_114 >= 0.0f) && (x_159 >= 0.0f));
x_169_phi = x_168;
}
bool const x_169 = x_169_phi;
if (!(x_169)) {
x_90 = true;
x_91 = 0;
x_173_phi = 0;
break;
}
x_90 = true;
x_91 = 1;
x_173_phi = 1;
break;
}
}
int const x_173 = x_173_phi;
return x_173;
}
void main_1(constant buf0& x_24, thread float4* const tint_symbol_5, thread float4* const tint_symbol_6) {
float2 pos = 0.0f;
float2 param_6 = 0.0f;
float2 param_7 = 0.0f;
float2 param_8 = 0.0f;
float2 param_9 = 0.0f;
float4 const x_67 = *(tint_symbol_5);
float2 const x_70 = x_24.resolution;
float2 const x_71 = (float2(x_67.x, x_67.y) / x_70);
pos = x_71;
param_6 = x_71;
param_7 = float2(0.699999988f, 0.300000012f);
param_8 = float2(0.5f, 0.899999976f);
param_9 = float2(0.100000001f, 0.400000006f);
int const x_72 = pointInTriangle_vf2_vf2_vf2_vf2_(&(param_6), &(param_7), &(param_8), &(param_9));
if ((x_72 == 1)) {
*(tint_symbol_6) = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
*(tint_symbol_6) = float4(0.0f, 0.0f, 0.0f, 1.0f);
}
return;
}
fragment tint_symbol_2 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf0& x_24 [[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_24, &(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;
}