mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 05:57:51 +00:00
transform/shader_io: Generate a wrapper function
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>
This commit is contained in:
committed by
Tint LUCI CQ
parent
3e92e9f8ba
commit
a5d73ce965
@@ -124,11 +124,16 @@ 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;
|
||||
main_out main_inner(float4 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_7 = {tint_symbol_3.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
const main_out tint_symbol_6 = {x_GLF_color};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
|
||||
const main_out inner_result = main_inner(tint_symbol.gl_FragCoord_param);
|
||||
tint_symbol_2 wrapper_result = (tint_symbol_2)0;
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ struct buf1 {
|
||||
struct main_out {
|
||||
float4 x_GLF_color_1;
|
||||
};
|
||||
struct tint_symbol_2 {
|
||||
struct tint_symbol_1 {
|
||||
float4 x_GLF_color_1 [[color(0)]];
|
||||
};
|
||||
|
||||
void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, thread float4x2* const tint_symbol_5) {
|
||||
void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, thread float4x2* const tint_symbol_3) {
|
||||
int i = 0;
|
||||
bool x_137 = false;
|
||||
bool x_138 = false;
|
||||
@@ -72,8 +72,8 @@ void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, th
|
||||
int const x_155 = clamp(x_154, 0, 3);
|
||||
int const x_156 = i;
|
||||
float const x_158 = x_12.x_GLF_uniform_float_values.arr[0].el;
|
||||
float const x_160 = (*(tint_symbol_5))[x_155][x_156];
|
||||
(*(tint_symbol_5))[x_155][x_156] = (x_160 + x_158);
|
||||
float const x_160 = (*(tint_symbol_3))[x_155][x_156];
|
||||
(*(tint_symbol_3))[x_155][x_156] = (x_160 + x_158);
|
||||
int const x_163 = i;
|
||||
i = as_type<int>((as_type<uint>(x_163) + as_type<uint>(1)));
|
||||
}
|
||||
@@ -82,22 +82,22 @@ void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, th
|
||||
return;
|
||||
}
|
||||
|
||||
void func1_(constant buf2& x_10, constant buf0& x_12, thread float4* const tint_symbol_6, thread float4x2* const tint_symbol_7) {
|
||||
void func1_(constant buf2& x_10, constant buf0& x_12, thread float4* const tint_symbol_4, thread float4x2* const tint_symbol_5) {
|
||||
int param = 0;
|
||||
float const x_167 = (*(tint_symbol_6)).y;
|
||||
float const x_167 = (*(tint_symbol_4)).y;
|
||||
if ((x_167 < 0.0f)) {
|
||||
return;
|
||||
}
|
||||
param = 1;
|
||||
func0_i1_(x_10, x_12, &(param), tint_symbol_7);
|
||||
func0_i1_(x_10, x_12, &(param), tint_symbol_5);
|
||||
return;
|
||||
}
|
||||
|
||||
void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, thread float4x2* const tint_symbol_8, thread float4* const tint_symbol_9, thread float4* const tint_symbol_10) {
|
||||
*(tint_symbol_8) = float4x2(float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f));
|
||||
func1_(x_10, x_12, tint_symbol_9, tint_symbol_8);
|
||||
func1_(x_10, x_12, tint_symbol_9, tint_symbol_8);
|
||||
float4x2 const x_54 = *(tint_symbol_8);
|
||||
void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, thread float4x2* const tint_symbol_6, thread float4* const tint_symbol_7, thread float4* const tint_symbol_8) {
|
||||
*(tint_symbol_6) = float4x2(float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f));
|
||||
func1_(x_10, x_12, tint_symbol_7, tint_symbol_6);
|
||||
func1_(x_10, x_12, tint_symbol_7, tint_symbol_6);
|
||||
float4x2 const x_54 = *(tint_symbol_6);
|
||||
int const x_56 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_59 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_62 = x_16.x_GLF_uniform_int_values.arr[1].el;
|
||||
@@ -112,23 +112,29 @@ void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, threa
|
||||
int const x_110 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_113 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_116 = x_16.x_GLF_uniform_int_values.arr[3].el;
|
||||
*(tint_symbol_10) = float4(float(x_107), float(x_110), float(x_113), float(x_116));
|
||||
*(tint_symbol_8) = float4(float(x_107), float(x_110), float(x_113), float(x_116));
|
||||
} else {
|
||||
int const x_120 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
float const x_121 = float(x_120);
|
||||
*(tint_symbol_10) = float4(x_121, x_121, x_121, x_121);
|
||||
*(tint_symbol_8) = float4(x_121, x_121, x_121, x_121);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fragment tint_symbol_2 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf2& x_10 [[buffer(2)]], constant buf0& x_12 [[buffer(0)]], constant buf1& x_16 [[buffer(1)]]) {
|
||||
thread float4 tint_symbol_11 = 0.0f;
|
||||
thread float4x2 tint_symbol_12 = float4x2(0.0f);
|
||||
thread float4 tint_symbol_13 = 0.0f;
|
||||
tint_symbol_11 = gl_FragCoord_param;
|
||||
main_1(x_10, x_12, x_16, &(tint_symbol_12), &(tint_symbol_11), &(tint_symbol_13));
|
||||
main_out const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_13};
|
||||
tint_symbol_2 const tint_symbol_4 = {.x_GLF_color_1=tint_symbol_3.x_GLF_color_1};
|
||||
return tint_symbol_4;
|
||||
main_out tint_symbol_inner(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, float4 gl_FragCoord_param, thread float4* const tint_symbol_9, thread float4x2* const tint_symbol_10, thread float4* const tint_symbol_11) {
|
||||
*(tint_symbol_9) = gl_FragCoord_param;
|
||||
main_1(x_10, x_12, x_16, tint_symbol_10, tint_symbol_9, tint_symbol_11);
|
||||
main_out const tint_symbol_2 = {.x_GLF_color_1=*(tint_symbol_11)};
|
||||
return tint_symbol_2;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf2& x_10 [[buffer(2)]], constant buf0& x_12 [[buffer(0)]], constant buf1& x_16 [[buffer(1)]]) {
|
||||
thread float4 tint_symbol_12 = 0.0f;
|
||||
thread float4x2 tint_symbol_13 = float4x2(0.0f);
|
||||
thread float4 tint_symbol_14 = 0.0f;
|
||||
main_out const inner_result = tint_symbol_inner(x_10, x_12, x_16, gl_FragCoord_param, &(tint_symbol_12), &(tint_symbol_13), &(tint_symbol_14));
|
||||
tint_symbol_1 wrapper_result = {};
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,11 +136,16 @@ 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;
|
||||
main_out main_inner(float4 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_7 = {tint_symbol_3.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
const main_out tint_symbol_6 = {x_GLF_color};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
tint_symbol_2 main(tint_symbol_1 tint_symbol) {
|
||||
const main_out inner_result = main_inner(tint_symbol.gl_FragCoord_param);
|
||||
tint_symbol_2 wrapper_result = (tint_symbol_2)0;
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ struct buf1 {
|
||||
struct main_out {
|
||||
float4 x_GLF_color_1;
|
||||
};
|
||||
struct tint_symbol_2 {
|
||||
struct tint_symbol_1 {
|
||||
float4 x_GLF_color_1 [[color(0)]];
|
||||
};
|
||||
|
||||
void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, thread float4x2* const tint_symbol_5) {
|
||||
void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, thread float4x2* const tint_symbol_3) {
|
||||
int i = 0;
|
||||
bool x_137 = false;
|
||||
bool x_138 = false;
|
||||
@@ -72,8 +72,8 @@ void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, th
|
||||
int const x_155 = clamp(x_154, 0, 3);
|
||||
int const x_156 = i;
|
||||
float const x_158 = x_12.x_GLF_uniform_float_values.arr[0].el;
|
||||
float const x_160 = (*(tint_symbol_5))[x_155][x_156];
|
||||
(*(tint_symbol_5))[x_155][x_156] = (x_160 + x_158);
|
||||
float const x_160 = (*(tint_symbol_3))[x_155][x_156];
|
||||
(*(tint_symbol_3))[x_155][x_156] = (x_160 + x_158);
|
||||
int const x_163 = i;
|
||||
i = as_type<int>((as_type<uint>(x_163) + as_type<uint>(1)));
|
||||
}
|
||||
@@ -82,22 +82,22 @@ void func0_i1_(constant buf2& x_10, constant buf0& x_12, thread int* const x, th
|
||||
return;
|
||||
}
|
||||
|
||||
void func1_(constant buf2& x_10, constant buf0& x_12, thread float4* const tint_symbol_6, thread float4x2* const tint_symbol_7) {
|
||||
void func1_(constant buf2& x_10, constant buf0& x_12, thread float4* const tint_symbol_4, thread float4x2* const tint_symbol_5) {
|
||||
int param = 0;
|
||||
float const x_167 = (*(tint_symbol_6)).y;
|
||||
float const x_167 = (*(tint_symbol_4)).y;
|
||||
if ((x_167 < 0.0f)) {
|
||||
return;
|
||||
}
|
||||
param = 1;
|
||||
func0_i1_(x_10, x_12, &(param), tint_symbol_7);
|
||||
func0_i1_(x_10, x_12, &(param), tint_symbol_5);
|
||||
return;
|
||||
}
|
||||
|
||||
void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, thread float4x2* const tint_symbol_8, thread float4* const tint_symbol_9, thread float4* const tint_symbol_10) {
|
||||
*(tint_symbol_8) = float4x2(float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f));
|
||||
func1_(x_10, x_12, tint_symbol_9, tint_symbol_8);
|
||||
func1_(x_10, x_12, tint_symbol_9, tint_symbol_8);
|
||||
float4x2 const x_54 = *(tint_symbol_8);
|
||||
void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, thread float4x2* const tint_symbol_6, thread float4* const tint_symbol_7, thread float4* const tint_symbol_8) {
|
||||
*(tint_symbol_6) = float4x2(float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f), float2(0.0f, 0.0f));
|
||||
func1_(x_10, x_12, tint_symbol_7, tint_symbol_6);
|
||||
func1_(x_10, x_12, tint_symbol_7, tint_symbol_6);
|
||||
float4x2 const x_54 = *(tint_symbol_6);
|
||||
int const x_56 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_59 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_62 = x_16.x_GLF_uniform_int_values.arr[1].el;
|
||||
@@ -112,23 +112,29 @@ void main_1(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, threa
|
||||
int const x_110 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_113 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_116 = x_16.x_GLF_uniform_int_values.arr[3].el;
|
||||
*(tint_symbol_10) = float4(float(x_107), float(x_110), float(x_113), float(x_116));
|
||||
*(tint_symbol_8) = float4(float(x_107), float(x_110), float(x_113), float(x_116));
|
||||
} else {
|
||||
int const x_120 = x_16.x_GLF_uniform_int_values.arr[0].el;
|
||||
float const x_121 = float(x_120);
|
||||
*(tint_symbol_10) = float4(x_121, x_121, x_121, x_121);
|
||||
*(tint_symbol_8) = float4(x_121, x_121, x_121, x_121);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
fragment tint_symbol_2 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf2& x_10 [[buffer(2)]], constant buf0& x_12 [[buffer(0)]], constant buf1& x_16 [[buffer(1)]]) {
|
||||
thread float4 tint_symbol_11 = 0.0f;
|
||||
thread float4x2 tint_symbol_12 = float4x2(0.0f);
|
||||
thread float4 tint_symbol_13 = 0.0f;
|
||||
tint_symbol_11 = gl_FragCoord_param;
|
||||
main_1(x_10, x_12, x_16, &(tint_symbol_12), &(tint_symbol_11), &(tint_symbol_13));
|
||||
main_out const tint_symbol_3 = {.x_GLF_color_1=tint_symbol_13};
|
||||
tint_symbol_2 const tint_symbol_4 = {.x_GLF_color_1=tint_symbol_3.x_GLF_color_1};
|
||||
return tint_symbol_4;
|
||||
main_out tint_symbol_inner(constant buf2& x_10, constant buf0& x_12, constant buf1& x_16, float4 gl_FragCoord_param, thread float4* const tint_symbol_9, thread float4x2* const tint_symbol_10, thread float4* const tint_symbol_11) {
|
||||
*(tint_symbol_9) = gl_FragCoord_param;
|
||||
main_1(x_10, x_12, x_16, tint_symbol_10, tint_symbol_9, tint_symbol_11);
|
||||
main_out const tint_symbol_2 = {.x_GLF_color_1=*(tint_symbol_11)};
|
||||
return tint_symbol_2;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(float4 gl_FragCoord_param [[position]], constant buf2& x_10 [[buffer(2)]], constant buf0& x_12 [[buffer(0)]], constant buf1& x_16 [[buffer(1)]]) {
|
||||
thread float4 tint_symbol_12 = 0.0f;
|
||||
thread float4x2 tint_symbol_13 = float4x2(0.0f);
|
||||
thread float4 tint_symbol_14 = 0.0f;
|
||||
main_out const inner_result = tint_symbol_inner(x_10, x_12, x_16, gl_FragCoord_param, &(tint_symbol_12), &(tint_symbol_13), &(tint_symbol_14));
|
||||
tint_symbol_1 wrapper_result = {};
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user