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

142 lines
3.9 KiB
HLSL

static float4 gl_FragCoord = float4(0.0f, 0.0f, 0.0f, 0.0f);
cbuffer cbuffer_x_24 : register(b0, space0) {
uint4 x_24[1];
};
static float4 x_GLF_color = float4(0.0f, 0.0f, 0.0f, 0.0f);
float cross2d_vf2_vf2_(inout float2 a, inout float2 b) {
const float x_76 = a.x;
const float x_78 = b.y;
const float x_81 = b.x;
const float x_83 = a.y;
return ((x_76 * x_78) - (x_81 * x_83));
}
int pointInTriangle_vf2_vf2_vf2_vf2_(inout float2 p, inout float2 a_1, inout float2 b_1, inout float2 c) {
float pab = 0.0f;
float2 param = float2(0.0f, 0.0f);
float2 param_1 = float2(0.0f, 0.0f);
float pbc = 0.0f;
float2 param_2 = float2(0.0f, 0.0f);
float2 param_3 = float2(0.0f, 0.0f);
float pca = 0.0f;
float2 param_4 = float2(0.0f, 0.0f);
float2 param_5 = float2(0.0f, 0.0f);
bool x_137 = false;
bool x_169 = false;
bool x_138_phi = false;
bool x_170_phi = false;
const float x_88 = p.x;
const float x_90 = a_1.x;
const float x_93 = p.y;
const float x_95 = a_1.y;
const float x_99 = b_1.x;
const float x_100 = a_1.x;
const float x_103 = b_1.y;
const float x_104 = a_1.y;
param = float2((x_88 - x_90), (x_93 - x_95));
param_1 = float2((x_99 - x_100), (x_103 - x_104));
const float x_107 = cross2d_vf2_vf2_(param, param_1);
pab = x_107;
const float x_108 = p.x;
const float x_109 = b_1.x;
const float x_111 = p.y;
const float x_112 = b_1.y;
const float x_116 = c.x;
const float x_117 = b_1.x;
const float x_120 = c.y;
const float x_121 = b_1.y;
param_2 = float2((x_108 - x_109), (x_111 - x_112));
param_3 = float2((x_116 - x_117), (x_120 - x_121));
const float x_124 = cross2d_vf2_vf2_(param_2, param_3);
pbc = x_124;
bool tint_tmp = (pab < 0.0f);
if (tint_tmp) {
tint_tmp = (pbc < 0.0f);
}
const bool x_129 = (tint_tmp);
x_138_phi = x_129;
if (!(x_129)) {
bool tint_tmp_1 = (pab >= 0.0f);
if (tint_tmp_1) {
tint_tmp_1 = (pbc >= 0.0f);
}
x_137 = (tint_tmp_1);
x_138_phi = x_137;
}
if (!(x_138_phi)) {
return 0;
}
const float x_142 = p.x;
const float x_143 = c.x;
const float x_145 = p.y;
const float x_146 = c.y;
const float x_149 = a_1.x;
const float x_150 = c.x;
const float x_152 = a_1.y;
const float x_153 = c.y;
param_4 = float2((x_142 - x_143), (x_145 - x_146));
param_5 = float2((x_149 - x_150), (x_152 - x_153));
const float x_156 = cross2d_vf2_vf2_(param_4, param_5);
pca = x_156;
bool tint_tmp_2 = (pab < 0.0f);
if (tint_tmp_2) {
tint_tmp_2 = (pca < 0.0f);
}
const bool x_161 = (tint_tmp_2);
x_170_phi = x_161;
if (!(x_161)) {
bool tint_tmp_3 = (pab >= 0.0f);
if (tint_tmp_3) {
tint_tmp_3 = (pca >= 0.0f);
}
x_169 = (tint_tmp_3);
x_170_phi = x_169;
}
if (!(x_170_phi)) {
return 0;
}
return 1;
}
void main_1() {
float2 pos = float2(0.0f, 0.0f);
float2 param_6 = float2(0.0f, 0.0f);
float2 param_7 = float2(0.0f, 0.0f);
float2 param_8 = float2(0.0f, 0.0f);
float2 param_9 = float2(0.0f, 0.0f);
const float4 x_63 = gl_FragCoord;
const float2 x_66 = asfloat(x_24[0].xy);
pos = (float2(x_63.x, x_63.y) / x_66);
param_6 = pos;
param_7 = float2(0.699999988f, 0.300000012f);
param_8 = float2(0.5f, 0.899999976f);
param_9 = float2(0.100000001f, 0.400000006f);
const int x_69 = pointInTriangle_vf2_vf2_vf2_vf2_(param_6, param_7, param_8, param_9);
if ((x_69 == 1)) {
x_GLF_color = float4(1.0f, 0.0f, 0.0f, 1.0f);
} else {
x_GLF_color = float4(0.0f, 0.0f, 0.0f, 1.0f);
}
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_5 = {tint_symbol_3.x_GLF_color_1};
return tint_symbol_5;
}