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

152 lines
4.5 KiB
WebGPU Shading Language

[[block]]
struct buf0 {
resolution : vec2<f32>;
};
var<private> gl_FragCoord : vec4<f32>;
[[group(0), binding(0)]] var<uniform> x_24 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn cross2d_vf2_vf2_(a : ptr<function, vec2<f32>>, b : ptr<function, vec2<f32>>) -> f32 {
let x_79 : f32 = (*(a)).x;
let x_81 : f32 = (*(b)).y;
let x_84 : f32 = (*(b)).x;
let x_86 : f32 = (*(a)).y;
return ((x_79 * x_81) - (x_84 * x_86));
}
fn pointInTriangle_vf2_vf2_vf2_vf2_(p : ptr<function, vec2<f32>>, a_1 : ptr<function, vec2<f32>>, b_1 : ptr<function, vec2<f32>>, c : ptr<function, vec2<f32>>) -> i32 {
var x_90 : bool = false;
var x_91 : i32;
var pab : f32;
var param : vec2<f32>;
var param_1 : vec2<f32>;
var pbc : f32;
var param_2 : vec2<f32>;
var param_3 : vec2<f32>;
var pca : f32;
var param_4 : vec2<f32>;
var param_5 : vec2<f32>;
var x_140 : bool;
var x_168 : bool;
var x_141_phi : bool;
var x_169_phi : bool;
var x_173_phi : i32;
switch(0u) {
default: {
let x_94 : ptr<function, f32> = &((*(p)).x);
let x_95 : f32 = *(x_94);
let x_96 : ptr<function, f32> = &((*(a_1)).x);
let x_97 : f32 = *(x_96);
let x_99 : ptr<function, f32> = &((*(p)).y);
let x_100 : f32 = *(x_99);
let x_101 : ptr<function, f32> = &((*(a_1)).y);
let x_102 : f32 = *(x_101);
let x_105 : ptr<function, f32> = &((*(b_1)).x);
let x_106 : f32 = *(x_105);
let x_107 : f32 = *(x_96);
let x_109 : ptr<function, f32> = &((*(b_1)).y);
let x_110 : f32 = *(x_109);
let x_111 : f32 = *(x_101);
param = vec2<f32>((x_95 - x_97), (x_100 - x_102));
param_1 = vec2<f32>((x_106 - x_107), (x_110 - x_111));
let x_114 : f32 = cross2d_vf2_vf2_(&(param), &(param_1));
pab = x_114;
let x_115 : f32 = *(x_94);
let x_116 : f32 = *(x_105);
let x_118 : f32 = *(x_99);
let x_119 : f32 = *(x_109);
let x_122 : ptr<function, f32> = &((*(c)).x);
let x_123 : f32 = *(x_122);
let x_124 : f32 = *(x_105);
let x_126 : ptr<function, f32> = &((*(c)).y);
let x_127 : f32 = *(x_126);
let x_128 : f32 = *(x_109);
param_2 = vec2<f32>((x_115 - x_116), (x_118 - x_119));
param_3 = vec2<f32>((x_123 - x_124), (x_127 - x_128));
let x_131 : f32 = cross2d_vf2_vf2_(&(param_2), &(param_3));
pbc = x_131;
let x_134 : bool = ((x_114 < 0.0) && (x_131 < 0.0));
x_141_phi = x_134;
if (!(x_134)) {
x_140 = ((x_114 >= 0.0) && (x_131 >= 0.0));
x_141_phi = x_140;
}
let x_141 : bool = x_141_phi;
if (!(x_141)) {
x_90 = true;
x_91 = 0;
x_173_phi = 0;
break;
}
let x_145 : f32 = *(x_94);
let x_146 : f32 = *(x_122);
let x_148 : f32 = *(x_99);
let x_149 : f32 = *(x_126);
let x_152 : f32 = *(x_96);
let x_153 : f32 = *(x_122);
let x_155 : f32 = *(x_101);
let x_156 : f32 = *(x_126);
param_4 = vec2<f32>((x_145 - x_146), (x_148 - x_149));
param_5 = vec2<f32>((x_152 - x_153), (x_155 - x_156));
let x_159 : f32 = cross2d_vf2_vf2_(&(param_4), &(param_5));
pca = x_159;
let x_162 : bool = ((x_114 < 0.0) && (x_159 < 0.0));
x_169_phi = x_162;
if (!(x_162)) {
x_168 = ((x_114 >= 0.0) && (x_159 >= 0.0));
x_169_phi = x_168;
}
let x_169 : bool = 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;
}
}
let x_173 : i32 = x_173_phi;
return x_173;
}
fn main_1() {
var pos : vec2<f32>;
var param_6 : vec2<f32>;
var param_7 : vec2<f32>;
var param_8 : vec2<f32>;
var param_9 : vec2<f32>;
let x_67 : vec4<f32> = gl_FragCoord;
let x_70 : vec2<f32> = x_24.resolution;
let x_71 : vec2<f32> = (vec2<f32>(x_67.x, x_67.y) / x_70);
pos = x_71;
param_6 = x_71;
param_7 = vec2<f32>(0.699999988, 0.300000012);
param_8 = vec2<f32>(0.5, 0.899999976);
param_9 = vec2<f32>(0.100000001, 0.400000006);
let x_72 : i32 = pointInTriangle_vf2_vf2_vf2_vf2_(&(param_6), &(param_7), &(param_8), &(param_9));
if ((x_72 == 1)) {
x_GLF_color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
} else {
x_GLF_color = vec4<f32>(0.0, 0.0, 0.0, 1.0);
}
return;
}
struct main_out {
[[location(0)]]
x_GLF_color_1 : vec4<f32>;
};
[[stage(fragment)]]
fn main([[builtin(position)]] gl_FragCoord_param : vec4<f32>) -> main_out {
gl_FragCoord = gl_FragCoord_param;
main_1();
return main_out(x_GLF_color);
}