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

155 lines
3.2 KiB
HLSL

struct QuicksortObject {
int numbers[10];
};
static QuicksortObject obj = (QuicksortObject)0;
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_30 : register(b0, space0) {
uint4 x_30[1];
};
void swap_i1_i1_(inout int i, inout int j) {
int temp = 0;
const int x_92 = i;
const int x_94 = obj.numbers[x_92];
temp = x_94;
const int x_95 = i;
const int x_96 = j;
const int x_98 = obj.numbers[x_96];
obj.numbers[x_95] = x_98;
const int x_100 = j;
obj.numbers[x_100] = temp;
return;
}
int performPartition_i1_i1_(inout int l, inout int h) {
int pivot = 0;
int i_1 = 0;
int j_1 = 0;
int param = 0;
int param_1 = 0;
int param_2 = 0;
int param_3 = 0;
const int x_104 = h;
const int x_106 = obj.numbers[x_104];
pivot = x_106;
const int x_107 = l;
i_1 = (x_107 - 1);
const int x_109 = l;
j_1 = x_109;
while (true) {
const int x_114 = j_1;
const int x_115 = h;
if ((x_114 <= (x_115 - 1))) {
} else {
break;
}
const int x_121 = obj.numbers[j_1];
if ((x_121 <= pivot)) {
i_1 = (i_1 + 1);
param = i_1;
param_1 = j_1;
swap_i1_i1_(param, param_1);
}
{
j_1 = (j_1 + 1);
}
}
param_2 = (i_1 + 1);
const int x_135 = h;
param_3 = x_135;
swap_i1_i1_(param_2, param_3);
return (i_1 + 1);
}
void quicksort_() {
int l_1 = 0;
int h_1 = 0;
int top = 0;
int stack[10] = (int[10])0;
int p = 0;
int param_4 = 0;
int param_5 = 0;
l_1 = 0;
h_1 = 9;
top = -1;
const int x_141 = (top + 1);
top = x_141;
stack[x_141] = l_1;
const int x_145 = (top + 1);
top = x_145;
stack[x_145] = h_1;
while (true) {
if ((top >= 0)) {
} else {
break;
}
const int x_155 = top;
top = (x_155 - 1);
const int x_158 = stack[x_155];
h_1 = x_158;
const int x_159 = top;
top = (x_159 - 1);
const int x_162 = stack[x_159];
l_1 = x_162;
param_4 = l_1;
param_5 = h_1;
const int x_165 = performPartition_i1_i1_(param_4, param_5);
p = x_165;
if (((p - 1) > l_1)) {
const int x_173 = (top + 1);
top = x_173;
stack[x_173] = l_1;
const int x_177 = (top + 1);
top = x_177;
stack[x_177] = (p - 1);
}
if (((p + 1) < h_1)) {
const int x_188 = (top + 1);
top = x_188;
stack[x_188] = (p + 1);
const int x_193 = (top + 1);
top = x_193;
stack[x_193] = h_1;
}
}
return;
}
void main_1() {
int i_2 = 0;
i_2 = 0;
{
for(; (i_2 < 10); i_2 = (i_2 + 1)) {
obj.numbers[i_2] = (10 - i_2);
const int x_71 = i_2;
const int x_74 = obj.numbers[i_2];
const int x_77 = obj.numbers[i_2];
obj.numbers[x_71] = (x_74 * x_77);
}
}
quicksort_();
const int x_84 = obj.numbers[0];
const int x_86 = obj.numbers[4];
if ((x_84 < x_86)) {
x_GLF_color = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
x_GLF_color = float4(0.0f, 1.0f, 0.0f, 1.0f);
}
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_2 = {tint_symbol_1.x_GLF_color_1};
return tint_symbol_2;
}