hlsl: Pointer support

Add `transform::InlinePointerLets` - a Transform that moves all usage of function-scope  `let` statements of a pointer type into their places of usage.

Make the HLSL writer transform pointer parameters to `inout`.

Fixed: tint:183
Change-Id: I0a7552fa6cd31c7b7691e64feae3170a81cc6c49
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/51281
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
Ben Clayton
2021-05-19 19:16:32 +00:00
committed by Tint LUCI CQ
parent c9dc951e9e
commit 06aa88aa97
20 changed files with 834 additions and 22 deletions

View File

@@ -301,6 +301,7 @@ tint_unittests_source_set("tint_unittests_core_src") {
"../src/transform/decompose_storage_access_test.cc",
"../src/transform/external_texture_transform_test.cc",
"../src/transform/first_index_offset_test.cc",
"../src/transform/inline_pointer_lets_test.cc",
"../src/transform/renamer_test.cc",
"../src/transform/single_entry_point_test.cc",
"../src/transform/transform_test.cc",

View File

@@ -1 +1,8 @@
SKIP: Failed to generate: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
float3x3 m = float3x3(float3(0.0f, 0.0f, 0.0f), float3(0.0f, 0.0f, 0.0f), float3(0.0f, 0.0f, 0.0f));
m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
m[1] = float3(5.0f, 5.0f, 5.0f);
return;
}

View File

@@ -1 +1,7 @@
SKIP: Failed to generate: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
float3x3 m = float3x3(float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f), float3(7.0f, 8.0f, 9.0f));
m[1] = float3(5.0f, 5.0f, 5.0f);
return;
}

View File

@@ -1 +1,8 @@
SKIP: Failed to generate: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
float3 v = float3(0.0f, 0.0f, 0.0f);
v = float3(1.0f, 2.0f, 3.0f);
v.y = 5.0f;
return;
}

View File

@@ -1 +1,7 @@
SKIP: Failed to generate: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
float3 v = float3(1.0f, 2.0f, 3.0f);
v.y = 5.0f;
return;
}

View File

@@ -1 +1,6 @@
SKIP: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
uint x_10 = 0u;
return;
}

View File

@@ -1 +1,14 @@
SKIP: error: pointers not supported in HLSL
int func(int value, inout int pointer) {
const int x_9 = pointer;
return (value + x_9);
}
[numthreads(1, 1, 1)]
void main() {
int i = 0;
i = 123;
const int x_19 = i;
const int x_18 = func(x_19, i);
return;
}

View File

@@ -1 +1,11 @@
SKIP: error: pointers not supported in HLSL
int func(int value, inout int pointer) {
return (value + pointer);
}
[numthreads(1, 1, 1)]
void main() {
int i = 123;
const int r = func(i, i);
return;
}

View File

@@ -1 +1,8 @@
SKIP: Failed to generate: error: pointers not supported in HLSL
[numthreads(1, 1, 1)]
void main() {
int i = 123;
i = 123;
i = ((100 + 20) + 3);
return;
}

View File

@@ -1 +1,13 @@
SKIP: error: pointers not supported in HLSL
void func(int value, inout int pointer) {
pointer = value;
return;
}
[numthreads(1, 1, 1)]
void main() {
int i = 0;
i = 123;
func(123, i);
return;
}

View File

@@ -1 +1,11 @@
SKIP: error: pointers not supported in HLSL
void func(int value, inout int pointer) {
pointer = value;
}
[numthreads(1, 1, 1)]
void main() {
int i = 123;
func(123, i);
return;
}