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

198 lines
4.0 KiB
WebGPU Shading Language

[[block]]
struct buf1 {
resolution : vec2<f32>;
};
[[block]]
struct buf0 {
injectionSwitch : vec2<f32>;
};
var<private> gl_FragCoord : vec4<f32>;
[[group(0), binding(1)]] var<uniform> x_9 : buf1;
[[group(0), binding(0)]] var<uniform> x_13 : buf0;
var<private> x_GLF_color : vec4<f32>;
fn checkSwap_f1_f1_(a : ptr<function, f32>, b : ptr<function, f32>) -> bool {
var x_147 : bool;
var x_158 : f32;
var x_159 : f32;
var x_179 : f32;
var x_178 : f32;
var x_185 : f32;
var x_184 : f32;
var x_160_phi : f32;
var x_180_phi : f32;
var x_186_phi : f32;
let x_149 : f32 = gl_FragCoord.y;
let x_151 : f32 = x_9.resolution.y;
let x_153 : bool = (x_149 < (x_151 / 2.0));
if (x_153) {
x_158 = *(a);
x_160_phi = x_158;
} else {
x_159 = 0.0;
x_160_phi = x_159;
}
var x_166 : f32;
var x_167 : f32;
var x_168_phi : f32;
let x_160 : f32 = x_160_phi;
var guard155 : bool = true;
if (false) {
} else {
if (guard155) {
if (x_153) {
x_166 = *(b);
x_168_phi = x_166;
} else {
x_167 = 0.0;
x_168_phi = x_167;
}
let x_168 : f32 = x_168_phi;
let x_169 : bool = (x_160 > x_168);
if (x_153) {
x_147 = x_169;
}
if (true) {
} else {
guard155 = false;
}
if (guard155) {
guard155 = false;
}
}
}
if (x_153) {
x_179 = 0.0;
x_180_phi = x_179;
} else {
x_178 = *(a);
x_180_phi = x_178;
}
let x_180 : f32 = x_180_phi;
if (x_153) {
x_185 = 0.0;
x_186_phi = x_185;
} else {
x_184 = *(b);
x_186_phi = x_184;
}
let x_186 : f32 = x_186_phi;
if (x_153) {
} else {
x_147 = (x_180 < x_186);
}
let x_191 : bool = x_147;
return x_191;
}
fn main_1() {
var i : i32;
var data : array<f32, 10>;
var i_1 : i32;
var j : i32;
var doSwap : bool;
var param : f32;
var param_1 : f32;
var temp : f32;
i = 0;
loop {
let x_59 : i32 = i;
if ((x_59 < 10)) {
} else {
break;
}
let x_62 : i32 = i;
let x_63 : i32 = i;
let x_67 : f32 = x_13.injectionSwitch.y;
data[x_62] = (f32((10 - x_63)) * x_67);
continuing {
let x_70 : i32 = i;
i = (x_70 + 1);
}
}
i_1 = 0;
loop {
let x_76 : i32 = i_1;
if ((x_76 < 9)) {
} else {
break;
}
j = 0;
loop {
let x_83 : i32 = j;
if ((x_83 < 10)) {
} else {
break;
}
let x_86 : i32 = j;
let x_87 : i32 = i_1;
if ((x_86 < (x_87 + 1))) {
continue;
}
let x_92 : i32 = i_1;
let x_93 : i32 = j;
let x_95 : f32 = data[x_92];
param = x_95;
let x_97 : f32 = data[x_93];
param_1 = x_97;
let x_98 : bool = checkSwap_f1_f1_(&(param), &(param_1));
doSwap = x_98;
let x_99 : bool = doSwap;
if (x_99) {
let x_102 : i32 = i_1;
let x_104 : f32 = data[x_102];
temp = x_104;
let x_105 : i32 = i_1;
let x_106 : i32 = j;
let x_108 : f32 = data[x_106];
data[x_105] = x_108;
let x_110 : i32 = j;
let x_111 : f32 = temp;
data[x_110] = x_111;
}
continuing {
let x_113 : i32 = j;
j = (x_113 + 1);
}
}
continuing {
let x_115 : i32 = i_1;
i_1 = (x_115 + 1);
}
}
let x_118 : f32 = gl_FragCoord.x;
let x_120 : f32 = x_9.resolution.x;
if ((x_118 < (x_120 / 2.0))) {
let x_127 : f32 = data[0];
let x_130 : f32 = data[5];
let x_133 : f32 = data[9];
x_GLF_color = vec4<f32>((x_127 / 10.0), (x_130 / 10.0), (x_133 / 10.0), 1.0);
} else {
let x_137 : f32 = data[5];
let x_140 : f32 = data[9];
let x_143 : f32 = data[0];
x_GLF_color = vec4<f32>((x_137 / 10.0), (x_140 / 10.0), (x_143 / 10.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);
}