mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-18 01:15:39 +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
@@ -30,8 +30,8 @@ void main_1() {
|
||||
const uint scalar_offset = ((16u * uint(0))) / 4;
|
||||
const int x_75 = asint(x_6[scalar_offset / 4][scalar_offset % 4]);
|
||||
const int x_77 = asint(x_6[10].x);
|
||||
const int tint_symbol_3[10] = {x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77};
|
||||
arr0 = tint_symbol_3;
|
||||
const int tint_symbol_2[10] = {x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77};
|
||||
arr0 = tint_symbol_2;
|
||||
const int x_80 = asint(x_6[1].x);
|
||||
const int x_82 = asint(x_6[12].x);
|
||||
const int x_84 = asint(x_6[15].x);
|
||||
@@ -42,8 +42,8 @@ void main_1() {
|
||||
const int x_94 = asint(x_6[11].x);
|
||||
const int x_96 = asint(x_6[18].x);
|
||||
const int x_98 = asint(x_6[19].x);
|
||||
const int tint_symbol_4[10] = {x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98};
|
||||
arr1 = tint_symbol_4;
|
||||
const int tint_symbol_3[10] = {x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98};
|
||||
arr1 = tint_symbol_3;
|
||||
const int x_101 = asint(x_6[8].x);
|
||||
a = x_101;
|
||||
while (true) {
|
||||
@@ -137,8 +137,8 @@ void main_1() {
|
||||
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
|
||||
const int x_212 = asint(x_6[scalar_offset_2 / 4][scalar_offset_2 % 4]);
|
||||
const int x_214 = asint(x_6[10].x);
|
||||
const int tint_symbol_5[10] = {x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214};
|
||||
ref0 = tint_symbol_5;
|
||||
const int tint_symbol_4[10] = {x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214};
|
||||
ref0 = tint_symbol_4;
|
||||
const int x_217 = asint(x_6[11].x);
|
||||
const int x_219 = asint(x_6[12].x);
|
||||
const int x_221 = asint(x_6[11].x);
|
||||
@@ -149,8 +149,8 @@ void main_1() {
|
||||
const int x_231 = asint(x_6[11].x);
|
||||
const int x_233 = asint(x_6[18].x);
|
||||
const int x_235 = asint(x_6[19].x);
|
||||
const int tint_symbol_6[10] = {x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235};
|
||||
ref1 = tint_symbol_6;
|
||||
const int tint_symbol_5[10] = {x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235};
|
||||
ref1 = tint_symbol_5;
|
||||
const int x_238 = asint(x_6[2].x);
|
||||
const int x_241 = asint(x_6[3].x);
|
||||
const int x_244 = asint(x_6[3].x);
|
||||
@@ -196,9 +196,15 @@ struct tint_symbol {
|
||||
float4 x_GLF_color_1 : SV_Target0;
|
||||
};
|
||||
|
||||
tint_symbol main() {
|
||||
main_out main_inner() {
|
||||
main_1();
|
||||
const main_out tint_symbol_1 = {x_GLF_color};
|
||||
const tint_symbol tint_symbol_7 = {tint_symbol_1.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
const main_out tint_symbol_6 = {x_GLF_color};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
tint_symbol main() {
|
||||
const main_out inner_result = main_inner();
|
||||
tint_symbol wrapper_result = (tint_symbol)0;
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ struct tint_symbol_1 {
|
||||
float4 x_GLF_color_1 [[color(0)]];
|
||||
};
|
||||
|
||||
void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
void main_1(constant buf0& x_6, thread float4* const tint_symbol_7) {
|
||||
tint_array_wrapper_1 arr0 = {};
|
||||
tint_array_wrapper_1 arr1 = {};
|
||||
int a = 0;
|
||||
@@ -47,8 +47,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_73 = x_6.x_GLF_uniform_int_values.arr[9].el;
|
||||
int const x_75 = x_6.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_77 = x_6.x_GLF_uniform_int_values.arr[10].el;
|
||||
tint_array_wrapper_1 const tint_symbol_3 = {.arr={x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77}};
|
||||
arr0 = tint_symbol_3;
|
||||
tint_array_wrapper_1 const tint_symbol_2 = {.arr={x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77}};
|
||||
arr0 = tint_symbol_2;
|
||||
int const x_80 = x_6.x_GLF_uniform_int_values.arr[1].el;
|
||||
int const x_82 = x_6.x_GLF_uniform_int_values.arr[12].el;
|
||||
int const x_84 = x_6.x_GLF_uniform_int_values.arr[15].el;
|
||||
@@ -59,8 +59,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_94 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_96 = x_6.x_GLF_uniform_int_values.arr[18].el;
|
||||
int const x_98 = x_6.x_GLF_uniform_int_values.arr[19].el;
|
||||
tint_array_wrapper_1 const tint_symbol_4 = {.arr={x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98}};
|
||||
arr1 = tint_symbol_4;
|
||||
tint_array_wrapper_1 const tint_symbol_3 = {.arr={x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98}};
|
||||
arr1 = tint_symbol_3;
|
||||
int const x_101 = x_6.x_GLF_uniform_int_values.arr[8].el;
|
||||
a = x_101;
|
||||
while (true) {
|
||||
@@ -169,8 +169,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_210 = x_6.x_GLF_uniform_int_values.arr[9].el;
|
||||
int const x_212 = x_6.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_214 = x_6.x_GLF_uniform_int_values.arr[10].el;
|
||||
tint_array_wrapper_1 const tint_symbol_5 = {.arr={x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214}};
|
||||
ref0 = tint_symbol_5;
|
||||
tint_array_wrapper_1 const tint_symbol_4 = {.arr={x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214}};
|
||||
ref0 = tint_symbol_4;
|
||||
int const x_217 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_219 = x_6.x_GLF_uniform_int_values.arr[12].el;
|
||||
int const x_221 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
@@ -181,13 +181,13 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_231 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_233 = x_6.x_GLF_uniform_int_values.arr[18].el;
|
||||
int const x_235 = x_6.x_GLF_uniform_int_values.arr[19].el;
|
||||
tint_array_wrapper_1 const tint_symbol_6 = {.arr={x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235}};
|
||||
ref1 = tint_symbol_6;
|
||||
tint_array_wrapper_1 const tint_symbol_5 = {.arr={x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235}};
|
||||
ref1 = tint_symbol_5;
|
||||
int const x_238 = x_6.x_GLF_uniform_int_values.arr[2].el;
|
||||
int const x_241 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
int const x_244 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
int const x_247 = x_6.x_GLF_uniform_int_values.arr[2].el;
|
||||
*(tint_symbol_8) = float4(float(x_238), float(x_241), float(x_244), float(x_247));
|
||||
*(tint_symbol_7) = float4(float(x_238), float(x_241), float(x_244), float(x_247));
|
||||
int const x_251 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
i = x_251;
|
||||
while (true) {
|
||||
@@ -217,7 +217,7 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
if (x_278) {
|
||||
int const x_282 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
float const x_283 = float(x_282);
|
||||
*(tint_symbol_8) = float4(x_283, x_283, x_283, x_283);
|
||||
*(tint_symbol_7) = float4(x_283, x_283, x_283, x_283);
|
||||
}
|
||||
{
|
||||
int const x_285 = i;
|
||||
@@ -227,11 +227,17 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
return;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]]) {
|
||||
thread float4 tint_symbol_9 = 0.0f;
|
||||
main_1(x_6, &(tint_symbol_9));
|
||||
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_9};
|
||||
tint_symbol_1 const tint_symbol_7 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
main_out tint_symbol_inner(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
main_1(x_6, tint_symbol_8);
|
||||
main_out const tint_symbol_6 = {.x_GLF_color_1=*(tint_symbol_8)};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]]) {
|
||||
thread float4 tint_symbol_9 = 0.0f;
|
||||
main_out const inner_result = tint_symbol_inner(x_6, &(tint_symbol_9));
|
||||
tint_symbol_1 wrapper_result = {};
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@ void main_1() {
|
||||
const uint scalar_offset = ((16u * uint(0))) / 4;
|
||||
const int x_75 = asint(x_6[scalar_offset / 4][scalar_offset % 4]);
|
||||
const int x_77 = asint(x_6[10].x);
|
||||
const int tint_symbol_3[10] = {x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77};
|
||||
arr0 = tint_symbol_3;
|
||||
const int tint_symbol_2[10] = {x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77};
|
||||
arr0 = tint_symbol_2;
|
||||
const int x_80 = asint(x_6[1].x);
|
||||
const int x_82 = asint(x_6[12].x);
|
||||
const int x_84 = asint(x_6[15].x);
|
||||
@@ -42,8 +42,8 @@ void main_1() {
|
||||
const int x_94 = asint(x_6[11].x);
|
||||
const int x_96 = asint(x_6[18].x);
|
||||
const int x_98 = asint(x_6[19].x);
|
||||
const int tint_symbol_4[10] = {x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98};
|
||||
arr1 = tint_symbol_4;
|
||||
const int tint_symbol_3[10] = {x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98};
|
||||
arr1 = tint_symbol_3;
|
||||
const int x_101 = asint(x_6[8].x);
|
||||
a = x_101;
|
||||
while (true) {
|
||||
@@ -137,8 +137,8 @@ void main_1() {
|
||||
const uint scalar_offset_2 = ((16u * uint(0))) / 4;
|
||||
const int x_212 = asint(x_6[scalar_offset_2 / 4][scalar_offset_2 % 4]);
|
||||
const int x_214 = asint(x_6[10].x);
|
||||
const int tint_symbol_5[10] = {x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214};
|
||||
ref0 = tint_symbol_5;
|
||||
const int tint_symbol_4[10] = {x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214};
|
||||
ref0 = tint_symbol_4;
|
||||
const int x_217 = asint(x_6[11].x);
|
||||
const int x_219 = asint(x_6[12].x);
|
||||
const int x_221 = asint(x_6[11].x);
|
||||
@@ -149,8 +149,8 @@ void main_1() {
|
||||
const int x_231 = asint(x_6[11].x);
|
||||
const int x_233 = asint(x_6[18].x);
|
||||
const int x_235 = asint(x_6[19].x);
|
||||
const int tint_symbol_6[10] = {x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235};
|
||||
ref1 = tint_symbol_6;
|
||||
const int tint_symbol_5[10] = {x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235};
|
||||
ref1 = tint_symbol_5;
|
||||
const int x_238 = asint(x_6[2].x);
|
||||
const int x_241 = asint(x_6[3].x);
|
||||
const int x_244 = asint(x_6[3].x);
|
||||
@@ -196,9 +196,15 @@ struct tint_symbol {
|
||||
float4 x_GLF_color_1 : SV_Target0;
|
||||
};
|
||||
|
||||
tint_symbol main() {
|
||||
main_out main_inner() {
|
||||
main_1();
|
||||
const main_out tint_symbol_1 = {x_GLF_color};
|
||||
const tint_symbol tint_symbol_7 = {tint_symbol_1.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
const main_out tint_symbol_6 = {x_GLF_color};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
tint_symbol main() {
|
||||
const main_out inner_result = main_inner();
|
||||
tint_symbol wrapper_result = (tint_symbol)0;
|
||||
wrapper_result.x_GLF_color_1 = inner_result.x_GLF_color_1;
|
||||
return wrapper_result;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ struct tint_symbol_1 {
|
||||
float4 x_GLF_color_1 [[color(0)]];
|
||||
};
|
||||
|
||||
void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
void main_1(constant buf0& x_6, thread float4* const tint_symbol_7) {
|
||||
tint_array_wrapper_1 arr0 = {};
|
||||
tint_array_wrapper_1 arr1 = {};
|
||||
int a = 0;
|
||||
@@ -47,8 +47,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_73 = x_6.x_GLF_uniform_int_values.arr[9].el;
|
||||
int const x_75 = x_6.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_77 = x_6.x_GLF_uniform_int_values.arr[10].el;
|
||||
tint_array_wrapper_1 const tint_symbol_3 = {.arr={x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77}};
|
||||
arr0 = tint_symbol_3;
|
||||
tint_array_wrapper_1 const tint_symbol_2 = {.arr={x_59, x_61, x_63, x_65, x_67, x_69, x_71, x_73, x_75, x_77}};
|
||||
arr0 = tint_symbol_2;
|
||||
int const x_80 = x_6.x_GLF_uniform_int_values.arr[1].el;
|
||||
int const x_82 = x_6.x_GLF_uniform_int_values.arr[12].el;
|
||||
int const x_84 = x_6.x_GLF_uniform_int_values.arr[15].el;
|
||||
@@ -59,8 +59,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_94 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_96 = x_6.x_GLF_uniform_int_values.arr[18].el;
|
||||
int const x_98 = x_6.x_GLF_uniform_int_values.arr[19].el;
|
||||
tint_array_wrapper_1 const tint_symbol_4 = {.arr={x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98}};
|
||||
arr1 = tint_symbol_4;
|
||||
tint_array_wrapper_1 const tint_symbol_3 = {.arr={x_80, x_82, x_84, x_86, x_88, x_90, x_92, x_94, x_96, x_98}};
|
||||
arr1 = tint_symbol_3;
|
||||
int const x_101 = x_6.x_GLF_uniform_int_values.arr[8].el;
|
||||
a = x_101;
|
||||
while (true) {
|
||||
@@ -169,8 +169,8 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_210 = x_6.x_GLF_uniform_int_values.arr[9].el;
|
||||
int const x_212 = x_6.x_GLF_uniform_int_values.arr[0].el;
|
||||
int const x_214 = x_6.x_GLF_uniform_int_values.arr[10].el;
|
||||
tint_array_wrapper_1 const tint_symbol_5 = {.arr={x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214}};
|
||||
ref0 = tint_symbol_5;
|
||||
tint_array_wrapper_1 const tint_symbol_4 = {.arr={x_196, x_198, x_200, x_202, x_204, x_206, x_208, x_210, x_212, x_214}};
|
||||
ref0 = tint_symbol_4;
|
||||
int const x_217 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_219 = x_6.x_GLF_uniform_int_values.arr[12].el;
|
||||
int const x_221 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
@@ -181,13 +181,13 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
int const x_231 = x_6.x_GLF_uniform_int_values.arr[11].el;
|
||||
int const x_233 = x_6.x_GLF_uniform_int_values.arr[18].el;
|
||||
int const x_235 = x_6.x_GLF_uniform_int_values.arr[19].el;
|
||||
tint_array_wrapper_1 const tint_symbol_6 = {.arr={x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235}};
|
||||
ref1 = tint_symbol_6;
|
||||
tint_array_wrapper_1 const tint_symbol_5 = {.arr={x_217, x_219, x_221, x_223, x_225, x_227, x_229, x_231, x_233, x_235}};
|
||||
ref1 = tint_symbol_5;
|
||||
int const x_238 = x_6.x_GLF_uniform_int_values.arr[2].el;
|
||||
int const x_241 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
int const x_244 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
int const x_247 = x_6.x_GLF_uniform_int_values.arr[2].el;
|
||||
*(tint_symbol_8) = float4(float(x_238), float(x_241), float(x_244), float(x_247));
|
||||
*(tint_symbol_7) = float4(float(x_238), float(x_241), float(x_244), float(x_247));
|
||||
int const x_251 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
i = x_251;
|
||||
while (true) {
|
||||
@@ -217,7 +217,7 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
if (x_278) {
|
||||
int const x_282 = x_6.x_GLF_uniform_int_values.arr[3].el;
|
||||
float const x_283 = float(x_282);
|
||||
*(tint_symbol_8) = float4(x_283, x_283, x_283, x_283);
|
||||
*(tint_symbol_7) = float4(x_283, x_283, x_283, x_283);
|
||||
}
|
||||
{
|
||||
int const x_285 = i;
|
||||
@@ -227,11 +227,17 @@ void main_1(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
return;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]]) {
|
||||
thread float4 tint_symbol_9 = 0.0f;
|
||||
main_1(x_6, &(tint_symbol_9));
|
||||
main_out const tint_symbol_2 = {.x_GLF_color_1=tint_symbol_9};
|
||||
tint_symbol_1 const tint_symbol_7 = {.x_GLF_color_1=tint_symbol_2.x_GLF_color_1};
|
||||
return tint_symbol_7;
|
||||
main_out tint_symbol_inner(constant buf0& x_6, thread float4* const tint_symbol_8) {
|
||||
main_1(x_6, tint_symbol_8);
|
||||
main_out const tint_symbol_6 = {.x_GLF_color_1=*(tint_symbol_8)};
|
||||
return tint_symbol_6;
|
||||
}
|
||||
|
||||
fragment tint_symbol_1 tint_symbol(constant buf0& x_6 [[buffer(0)]]) {
|
||||
thread float4 tint_symbol_9 = 0.0f;
|
||||
main_out const inner_result = tint_symbol_inner(x_6, &(tint_symbol_9));
|
||||
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