mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-10 22:17: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
@@ -60,10 +60,13 @@ struct tint_symbol_1 {
|
||||
uint3 gl_WorkGroupID_param : SV_GroupID;
|
||||
};
|
||||
|
||||
[numthreads(4, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint3 gl_WorkGroupID_param = tint_symbol.gl_WorkGroupID_param;
|
||||
void main_inner(uint3 gl_WorkGroupID_param) {
|
||||
gl_WorkGroupID = gl_WorkGroupID_param;
|
||||
main_1();
|
||||
}
|
||||
|
||||
[numthreads(4, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
main_inner(tint_symbol.gl_WorkGroupID_param);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ struct In0 {
|
||||
/* 0x0000 */ tint_array_wrapper_2 data_in0;
|
||||
};
|
||||
|
||||
void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, thread uint3* const tint_symbol_2) {
|
||||
void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, thread uint3* const tint_symbol_1) {
|
||||
uint base_index_in = 0u;
|
||||
uint base_index_out = 0u;
|
||||
int index_in0 = 0;
|
||||
@@ -34,9 +34,9 @@ void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, c
|
||||
int i = 0;
|
||||
int temp0 = 0;
|
||||
int temp1 = 0;
|
||||
uint const x_58 = (*(tint_symbol_2)).x;
|
||||
uint const x_58 = (*(tint_symbol_1)).x;
|
||||
base_index_in = (128u * x_58);
|
||||
uint const x_61 = (*(tint_symbol_2)).x;
|
||||
uint const x_61 = (*(tint_symbol_1)).x;
|
||||
base_index_out = (256u * x_61);
|
||||
index_in0 = 127;
|
||||
index_in1 = 383;
|
||||
@@ -99,10 +99,14 @@ void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, c
|
||||
return;
|
||||
}
|
||||
|
||||
void tint_symbol_inner(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, uint3 gl_WorkGroupID_param, thread uint3* const tint_symbol_2) {
|
||||
*(tint_symbol_2) = gl_WorkGroupID_param;
|
||||
main_1(x_13, x_17, x_15, x_19, tint_symbol_2);
|
||||
}
|
||||
|
||||
kernel void tint_symbol(uint3 gl_WorkGroupID_param [[threadgroup_position_in_grid]], const device In2& x_13 [[buffer(2)]], const device In1& x_17 [[buffer(1)]], device Out0& x_15 [[buffer(3)]], const device In0& x_19 [[buffer(0)]]) {
|
||||
thread uint3 tint_symbol_3 = 0u;
|
||||
tint_symbol_3 = gl_WorkGroupID_param;
|
||||
main_1(x_13, x_17, x_15, x_19, &(tint_symbol_3));
|
||||
tint_symbol_inner(x_13, x_17, x_15, x_19, gl_WorkGroupID_param, &(tint_symbol_3));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,13 @@ struct tint_symbol_1 {
|
||||
uint3 gl_WorkGroupID_param : SV_GroupID;
|
||||
};
|
||||
|
||||
[numthreads(4, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint3 gl_WorkGroupID_param = tint_symbol.gl_WorkGroupID_param;
|
||||
void main_inner(uint3 gl_WorkGroupID_param) {
|
||||
gl_WorkGroupID = gl_WorkGroupID_param;
|
||||
main_1();
|
||||
}
|
||||
|
||||
[numthreads(4, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
main_inner(tint_symbol.gl_WorkGroupID_param);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ struct In0 {
|
||||
/* 0x0000 */ tint_array_wrapper_2 data_in0;
|
||||
};
|
||||
|
||||
void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, thread uint3* const tint_symbol_2) {
|
||||
void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, thread uint3* const tint_symbol_1) {
|
||||
uint base_index_in = 0u;
|
||||
uint base_index_out = 0u;
|
||||
int index_in0 = 0;
|
||||
@@ -34,9 +34,9 @@ void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, c
|
||||
int i = 0;
|
||||
int temp0 = 0;
|
||||
int temp1 = 0;
|
||||
uint const x_58 = (*(tint_symbol_2)).x;
|
||||
uint const x_58 = (*(tint_symbol_1)).x;
|
||||
base_index_in = (128u * x_58);
|
||||
uint const x_61 = (*(tint_symbol_2)).x;
|
||||
uint const x_61 = (*(tint_symbol_1)).x;
|
||||
base_index_out = (256u * x_61);
|
||||
index_in0 = 127;
|
||||
index_in1 = 383;
|
||||
@@ -99,10 +99,14 @@ void main_1(const device In2& x_13, const device In1& x_17, device Out0& x_15, c
|
||||
return;
|
||||
}
|
||||
|
||||
void tint_symbol_inner(const device In2& x_13, const device In1& x_17, device Out0& x_15, const device In0& x_19, uint3 gl_WorkGroupID_param, thread uint3* const tint_symbol_2) {
|
||||
*(tint_symbol_2) = gl_WorkGroupID_param;
|
||||
main_1(x_13, x_17, x_15, x_19, tint_symbol_2);
|
||||
}
|
||||
|
||||
kernel void tint_symbol(uint3 gl_WorkGroupID_param [[threadgroup_position_in_grid]], const device In2& x_13 [[buffer(2)]], const device In1& x_17 [[buffer(1)]], device Out0& x_15 [[buffer(3)]], const device In0& x_19 [[buffer(0)]]) {
|
||||
thread uint3 tint_symbol_3 = 0u;
|
||||
tint_symbol_3 = gl_WorkGroupID_param;
|
||||
main_1(x_13, x_17, x_15, x_19, &(tint_symbol_3));
|
||||
tint_symbol_inner(x_13, x_17, x_15, x_19, gl_WorkGroupID_param, &(tint_symbol_3));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user