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

120 lines
4.5 KiB
HLSL

static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_20 : register(b0, space0) {
uint4 x_20[1];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
bool collision_vf2_vf4_(inout float2 pos, inout float4 quad) {
const float x_110 = pos.x;
const float x_112 = quad.x;
if ((x_110 < x_112)) {
return false;
}
const float x_117 = pos.y;
const float x_119 = quad.y;
if ((x_117 < x_119)) {
return false;
}
const float x_124 = pos.x;
const float x_126 = quad.x;
const float x_128 = quad.z;
if ((x_124 > (x_126 + x_128))) {
return false;
}
const float x_134 = pos.y;
const float x_136 = quad.y;
const float x_138 = quad.w;
if ((x_134 > (x_136 + x_138))) {
return false;
}
return true;
}
float4 match_vf2_(inout float2 pos_1) {
float4 res = float4(0.0f, 0.0f, 0.0f, 0.0f);
float x_144 = 0.0f;
float x_145 = 0.0f;
int i = 0;
float2 param = float2(0.0f, 0.0f);
float4 param_1 = float4(0.0f, 0.0f, 0.0f, 0.0f);
float4 indexable[8] = (float4[8])0;
float4 indexable_1[8] = (float4[8])0;
float4 indexable_2[8] = (float4[8])0;
float4 indexable_3[16] = (float4[16])0;
const float x_147 = gl_FragCoord.x;
if ((x_147 < 0.0f)) {
x_144 = -1.0f;
} else {
const float x_153 = gl_FragCoord.x;
if ((x_153 >= 0.0f)) {
const float x_159 = gl_FragCoord.x;
x_145 = ((x_159 >= 0.0f) ? 0.5f : 1.0f);
} else {
x_145 = 1.0f;
}
x_144 = min(x_145, 0.5f);
}
res = float4(clamp(0.5f, 0.5f, x_144), 0.5f, 1.0f, 1.0f);
i = 0;
{
for(; (i < 8); i = (i + 1)) {
const int x_174 = i;
const float2 x_175 = pos_1;
param = x_175;
const float4 tint_symbol_5[8] = {float4(4.0f, 4.0f, 20.0f, 4.0f), float4(4.0f, 4.0f, 4.0f, 20.0f), float4(4.0f, 20.0f, 20.0f, 4.0f), float4(20.0f, 4.0f, 4.0f, 8.0f), float4(8.0f, 6.0f, 4.0f, 2.0f), float4(2.0f, 12.0f, 2.0f, 4.0f), float4(16.0f, 2.0f, 4.0f, 4.0f), float4(12.0f, 22.0f, 4.0f, 4.0f)};
indexable = tint_symbol_5;
const float4 x_177 = indexable[x_174];
param_1 = x_177;
const bool x_178 = collision_vf2_vf4_(param, param_1);
if (x_178) {
const int x_181 = i;
const float4 tint_symbol_6[8] = {float4(4.0f, 4.0f, 20.0f, 4.0f), float4(4.0f, 4.0f, 4.0f, 20.0f), float4(4.0f, 20.0f, 20.0f, 4.0f), float4(20.0f, 4.0f, 4.0f, 8.0f), float4(8.0f, 6.0f, 4.0f, 2.0f), float4(2.0f, 12.0f, 2.0f, 4.0f), float4(16.0f, 2.0f, 4.0f, 4.0f), float4(12.0f, 22.0f, 4.0f, 4.0f)};
indexable_1 = tint_symbol_6;
const float x_183 = indexable_1[x_181].x;
const int x_185 = i;
const float4 tint_symbol_7[8] = {float4(4.0f, 4.0f, 20.0f, 4.0f), float4(4.0f, 4.0f, 4.0f, 20.0f), float4(4.0f, 20.0f, 20.0f, 4.0f), float4(20.0f, 4.0f, 4.0f, 8.0f), float4(8.0f, 6.0f, 4.0f, 2.0f), float4(2.0f, 12.0f, 2.0f, 4.0f), float4(16.0f, 2.0f, 4.0f, 4.0f), float4(12.0f, 22.0f, 4.0f, 4.0f)};
indexable_2 = tint_symbol_7;
const float x_187 = indexable_2[x_185].y;
const int x_190 = i;
const float4 tint_symbol_8[16] = {float4(0.0f, 0.0f, 0.0f, 1.0f), float4(0.5f, 0.0f, 0.0f, 1.0f), float4(0.0f, 0.5f, 0.0f, 1.0f), float4(0.5f, 0.5f, 0.0f, 1.0f), float4(0.0f, 0.0f, 0.5f, 1.0f), float4(0.5f, 0.0f, 0.5f, 1.0f), float4(0.0f, 0.5f, 0.5f, 1.0f), float4(0.5f, 0.5f, 0.5f, 1.0f), float4(0.0f, 0.0f, 0.0f, 1.0f), float4(1.0f, 0.0f, 0.0f, 1.0f), float4(0.0f, 1.0f, 0.0f, 1.0f), float4(1.0f, 1.0f, 0.0f, 1.0f), float4(0.0f, 0.0f, 1.0f, 1.0f), float4(1.0f, 0.0f, 1.0f, 1.0f), float4(0.0f, 1.0f, 1.0f, 1.0f), float4(1.0f, 1.0f, 1.0f, 1.0f)};
indexable_3 = tint_symbol_8;
const float4 x_196 = indexable_3[((((int(x_183) * int(x_187)) + (x_190 * 9)) + 11) % 16)];
res = x_196;
}
}
}
return res;
}
void main_1() {
float2 lin = float2(0.0f, 0.0f);
float2 param_2 = float2(0.0f, 0.0f);
const float4 x_98 = gl_FragCoord;
const float2 x_101 = asfloat(x_20[0].xy);
lin = (float2(x_98.x, x_98.y) / x_101);
lin = floor((lin * 32.0f));
param_2 = lin;
const float4 x_107 = match_vf2_(param_2);
x_GLF_color = x_107;
return;
}
struct main_out {
float4 x_GLF_color_1;
};
struct tint_symbol_1 {
float4 gl_FragCoord_param : SV_Position;
};
struct tint_symbol_2 {
float4 x_GLF_color_1 : SV_Target0;
};
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
const float4 gl_FragCoord_param = tint_symbol.gl_FragCoord_param;
gl_FragCoord = gl_FragCoord_param;
main_1();
const main_out tint_symbol_3 = {x_GLF_color};
const tint_symbol_2 tint_symbol_9 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_9;
}