mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-09 13:38:00 +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
@@ -23,9 +23,7 @@ tint_symbol_11_ret tint_symbol_11(ByteAddressBuffer buffer, uint offset) {
|
||||
return arr_1;
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint idx = tint_symbol.idx;
|
||||
void main_inner(uint idx) {
|
||||
const int3 a = asint(s.Load3((176u * idx)));
|
||||
const int b = asint(s.Load(((176u * idx) + 12u)));
|
||||
const uint3 c = s.Load3(((176u * idx) + 16u));
|
||||
@@ -35,5 +33,10 @@ void main(tint_symbol_1 tint_symbol) {
|
||||
const float2x3 g = tint_symbol_8(s, ((176u * idx) + 48u));
|
||||
const float3x2 h = tint_symbol_9(s, ((176u * idx) + 80u));
|
||||
const int4 i[4] = tint_symbol_11(s, ((176u * idx) + 112u));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
main_inner(tint_symbol.idx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct S {
|
||||
/* 0x0000 */ Inner arr[1];
|
||||
};
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], const device S& s [[buffer(0)]]) {
|
||||
void tint_symbol_inner(const device S& s, uint idx) {
|
||||
int3 const a = s.arr[idx].a;
|
||||
int const b = s.arr[idx].b;
|
||||
uint3 const c = s.arr[idx].c;
|
||||
@@ -30,6 +30,10 @@ kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], const device S
|
||||
float2x3 const g = s.arr[idx].g;
|
||||
float3x2 const h = s.arr[idx].h;
|
||||
tint_array_wrapper const i = s.arr[idx].i;
|
||||
}
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], const device S& s [[buffer(0)]]) {
|
||||
tint_symbol_inner(s, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,7 @@ void tint_symbol_11(RWByteAddressBuffer buffer, uint offset, int4 value[4]) {
|
||||
}
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint idx = tint_symbol.idx;
|
||||
void main_inner(uint idx) {
|
||||
s.Store3((176u * idx), asuint(int3(0, 0, 0)));
|
||||
s.Store(((176u * idx) + 12u), asuint(0));
|
||||
s.Store3(((176u * idx) + 16u), asuint(uint3(0u, 0u, 0u)));
|
||||
@@ -37,5 +35,10 @@ void main(tint_symbol_1 tint_symbol) {
|
||||
tint_symbol_9(s, ((176u * idx) + 80u), float3x2(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f));
|
||||
const int4 tint_symbol_13[4] = (int4[4])0;
|
||||
tint_symbol_11(s, ((176u * idx) + 112u), tint_symbol_13);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
main_inner(tint_symbol.idx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ struct S {
|
||||
/* 0x0000 */ Inner arr[1];
|
||||
};
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], device S& s [[buffer(0)]]) {
|
||||
void tint_symbol_inner(device S& s, uint idx) {
|
||||
s.arr[idx].a = int3();
|
||||
s.arr[idx].b = int();
|
||||
s.arr[idx].c = uint3();
|
||||
@@ -29,8 +29,12 @@ kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], device S& s [[
|
||||
s.arr[idx].f = float();
|
||||
s.arr[idx].g = float2x3();
|
||||
s.arr[idx].h = float3x2();
|
||||
tint_array_wrapper const tint_symbol_2 = {.arr={}};
|
||||
s.arr[idx].i = tint_symbol_2;
|
||||
tint_array_wrapper const tint_symbol_1 = {.arr={}};
|
||||
s.arr[idx].i = tint_symbol_1;
|
||||
}
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], device S& s [[buffer(0)]]) {
|
||||
tint_symbol_inner(s, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,9 +12,7 @@ float2x3 tint_symbol_9(uint4 buffer[96], uint offset) {
|
||||
return float2x3(asfloat(buffer[scalar_offset / 4].xyz), asfloat(buffer[scalar_offset_1 / 4].xyz));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
const uint idx = tint_symbol.idx;
|
||||
void main_inner(uint idx) {
|
||||
const uint scalar_offset_2 = ((192u * idx)) / 4;
|
||||
const int3 a = asint(s[scalar_offset_2 / 4].xyz);
|
||||
const uint scalar_offset_3 = (((192u * idx) + 12u)) / 4;
|
||||
@@ -34,5 +32,10 @@ void main(tint_symbol_1 tint_symbol) {
|
||||
uint4 ubo_load_1 = s[scalar_offset_9 / 4];
|
||||
const int2 h = asint(((scalar_offset_9 & 2) ? ubo_load_1.zw : ubo_load_1.xy));
|
||||
const float2x3 i = tint_symbol_9(s, ((192u * idx) + 64u));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main(tint_symbol_1 tint_symbol) {
|
||||
main_inner(tint_symbol.idx);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ struct S {
|
||||
/* 0x0000 */ tint_array_wrapper_1 arr;
|
||||
};
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], constant S& s [[buffer(0)]]) {
|
||||
void tint_symbol_inner(constant S& s, uint idx) {
|
||||
int3 const a = s.arr.arr[idx].a;
|
||||
int const b = s.arr.arr[idx].b;
|
||||
uint3 const c = s.arr.arr[idx].c;
|
||||
@@ -35,6 +35,10 @@ kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], constant S& s
|
||||
int2 const g = s.arr.arr[idx].g;
|
||||
int2 const h = s.arr.arr[idx].h;
|
||||
float2x3 const i = s.arr.arr[idx].i;
|
||||
}
|
||||
|
||||
kernel void tint_symbol(uint idx [[thread_index_in_threadgroup]], constant S& s [[buffer(0)]]) {
|
||||
tint_symbol_inner(s, idx);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user