Add foreach_unique iteration construct.

Idea via Ingo Wald / IVL compiler.
This commit is contained in:
Matt Pharr
2012-06-20 10:03:44 -07:00
parent fae47e0dfc
commit 3bc66136b2
17 changed files with 488 additions and 6 deletions

View File

@@ -0,0 +1,12 @@
// Iteration domain type in "foreach_tiled" loop must be an atomic, pointer, or enum type
struct Point { float x, y; };
uniform int foo(Point p) {
uniform int count = 0;
foreach_unique (pt in p)
++count;
return count;
}

View File

@@ -0,0 +1,8 @@
// Can't assign to type "const uniform int32"
void foo(int x) {
foreach_unique (u in x)
++u;
}

View File

@@ -0,0 +1,10 @@
// Error: "break" statement is illegal outside of for/while/do loops
void foo(int x) {
foreach_unique (u in x) {
if (u == 0)
break;
}
}

View File

@@ -0,0 +1,10 @@
// Error: "return" statement is illegal inside a "foreach" loop
void foo(int x) {
foreach_unique (u in x) {
if (u == 0)
return;
}
}