mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-06-03 05:01:27 +00:00
This is a major reworking of this transform. The old transform code was getting unwieldy, with part of the complication coming from the handling of multiple return statements. By generating a wrapper function instead, we can avoid a lot of this complexity. The original entry point function is stripped of all shader IO attributes (as well as `stage` and `workgroup_size`), but the body is left unmodified. A new entry point wrapper function is introduced which calls the original function, packing/unpacking the shader inputs as necessary, and propagates the result to the corresponding shader outputs. The new code has been refactored to use a state object with the different parts of the transform split into separate functions, which makes it much more manageable. Fixed: tint:1076 Bug: tint:920 Change-Id: I3490a0ea7a3509a4e198ce730e476516649d8d96 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/60521 Auto-Submit: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@google.com>
133 lines
2.8 KiB
Plaintext
133 lines
2.8 KiB
Plaintext
#include <metal_stdlib>
|
|
|
|
using namespace metal;
|
|
struct tint_array_wrapper {
|
|
int arr[2];
|
|
};
|
|
struct Array {
|
|
tint_array_wrapper values;
|
|
};
|
|
struct buf0 {
|
|
/* 0x0000 */ int zero;
|
|
};
|
|
struct main_out {
|
|
float4 x_GLF_color_1;
|
|
};
|
|
struct tint_symbol_1 {
|
|
float4 x_GLF_color_1 [[color(0)]];
|
|
};
|
|
|
|
void main_1(constant buf0& x_8, thread float4* const tint_symbol_5) {
|
|
bool x_50 = false;
|
|
int x_15 = 0;
|
|
int x_16 = 0;
|
|
Array param = {};
|
|
int x_19 = 0;
|
|
int x_20_phi = 0;
|
|
tint_array_wrapper const tint_symbol_2 = {.arr={0, 0}};
|
|
Array const tint_symbol_3 = {.values=tint_symbol_2};
|
|
param = tint_symbol_3;
|
|
x_50 = false;
|
|
while (true) {
|
|
int x_19_phi = 0;
|
|
bool x_63_phi = false;
|
|
while (true) {
|
|
int const x_17 = x_8.zero;
|
|
int const x_18 = param.values.arr[x_17];
|
|
if ((x_18 == 1)) {
|
|
x_50 = true;
|
|
x_15 = 1;
|
|
x_19_phi = 1;
|
|
x_63_phi = true;
|
|
break;
|
|
}
|
|
x_19_phi = 0;
|
|
x_63_phi = false;
|
|
break;
|
|
}
|
|
x_19 = x_19_phi;
|
|
bool const x_63 = x_63_phi;
|
|
x_20_phi = x_19;
|
|
if (x_63) {
|
|
break;
|
|
}
|
|
x_50 = true;
|
|
x_15 = 1;
|
|
x_20_phi = 1;
|
|
break;
|
|
}
|
|
int const x_20 = x_20_phi;
|
|
x_16 = x_20;
|
|
if ((x_20 == 1)) {
|
|
*(tint_symbol_5) = float4(1.0f, 0.0f, 0.0f, 1.0f);
|
|
} else {
|
|
*(tint_symbol_5) = float4(0.0f, 0.0f, 0.0f, 0.0f);
|
|
}
|
|
return;
|
|
}
|
|
|
|
main_out tint_symbol_inner(constant buf0& x_8, thread float4* const tint_symbol_6) {
|
|
main_1(x_8, tint_symbol_6);
|
|
main_out const tint_symbol_4 = {.x_GLF_color_1=*(tint_symbol_6)};
|
|
return tint_symbol_4;
|
|
}
|
|
|
|
fragment tint_symbol_1 tint_symbol(constant buf0& x_8 [[buffer(0)]]) {
|
|
thread float4 tint_symbol_7 = 0.0f;
|
|
main_out const inner_result = tint_symbol_inner(x_8, &(tint_symbol_7));
|
|
tint_symbol_1 wrapper_result = {};
|
|
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
|
return wrapper_result;
|
|
}
|
|
|
|
int func_struct_Array_i1_2_1_(constant buf0& x_8, thread Array* const a) {
|
|
bool x_70 = false;
|
|
int x_12 = 0;
|
|
int x_13 = 0;
|
|
bool x_72_phi = false;
|
|
int x_14_phi = 0;
|
|
x_72_phi = false;
|
|
while (true) {
|
|
bool x_77 = false;
|
|
bool x_77_phi = false;
|
|
int x_13_phi = 0;
|
|
bool x_87_phi = false;
|
|
bool const x_72 = x_72_phi;
|
|
x_77_phi = x_72;
|
|
while (true) {
|
|
x_77 = x_77_phi;
|
|
int const x_10 = x_8.zero;
|
|
int const x_11 = (*(a)).values.arr[x_10];
|
|
if ((x_11 == 1)) {
|
|
x_70 = true;
|
|
x_12 = 1;
|
|
x_13_phi = 1;
|
|
x_87_phi = true;
|
|
break;
|
|
}
|
|
x_13_phi = 0;
|
|
x_87_phi = x_77;
|
|
break;
|
|
{
|
|
x_77_phi = false;
|
|
}
|
|
}
|
|
x_13 = x_13_phi;
|
|
bool const x_87 = x_87_phi;
|
|
x_14_phi = x_13;
|
|
if (x_87) {
|
|
break;
|
|
}
|
|
x_70 = true;
|
|
x_12 = 1;
|
|
x_14_phi = 1;
|
|
break;
|
|
{
|
|
x_72_phi = false;
|
|
}
|
|
}
|
|
int const x_14 = x_14_phi;
|
|
return x_14;
|
|
}
|
|
|