Implement unbound varibility for struct types.
Now, if a struct member has an explicit 'uniform' or 'varying' qualifier, then that member has that variability, regardless of the variability of the struct's variability. Members without 'uniform' or 'varying' have unbound variability, and in turn inherit the variability of the struct. As a result of this, now structs can properly be 'varying' by default, just like all the other types, while still having sensible semantics.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Illegal to assign to type "uniform struct Bar" in type "uniform struct Foo" due to element "a" with type "const varying int32"
|
||||
// Illegal to assign to type "varying struct Bar" in type "varying struct Foo" due to element "a" with type "const varying int32"
|
||||
|
||||
struct Bar {
|
||||
const int a;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Illegal to assign to type "uniform struct Foo" due to element "a" with type "const varying int32"
|
||||
// Illegal to assign to type "varying struct Foo" due to element "a" with type "const varying int32"
|
||||
|
||||
struct Foo {
|
||||
const int a;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Dereference operator "->" can't be applied to non-pointer type "uniform struct Foo"
|
||||
// Dereference operator "->" can't be applied to non-pointer type "varying struct Foo"
|
||||
|
||||
struct Foo { int x; };
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Can't convert from type "uniform int32 * varying" to type "uniform int32 * uniform" for return
|
||||
// Can't convert from type "uniform int32 * varying" to type "varying int32 * uniform" for return
|
||||
|
||||
int * uniform func(int x) {
|
||||
return new int[x];
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "signed" qualifier is illegal with non-integer type "uniform struct Foo"
|
||||
// "signed" qualifier is illegal with non-integer type "varying struct Foo"
|
||||
|
||||
struct Foo {
|
||||
float x;
|
||||
|
||||
7
tests_errors/struct-uniform-gather-1.ispc
Normal file
7
tests_errors/struct-uniform-gather-1.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Gather operation is impossible due to the presence of struct member "x" with uniform type
|
||||
|
||||
struct Foo { uniform int x; };
|
||||
|
||||
void a(uniform Foo array[], int index) {
|
||||
Foo v = array[index];
|
||||
}
|
||||
7
tests_errors/struct-uniform-gather-2.ispc
Normal file
7
tests_errors/struct-uniform-gather-2.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Gather operation is impossible due to the presence of struct member "x" with uniform type
|
||||
|
||||
struct Foo { uniform int x; };
|
||||
|
||||
void a(uniform Foo * uniform array, int index) {
|
||||
Foo v = array[index];
|
||||
}
|
||||
7
tests_errors/struct-uniform-gather-3.ispc
Normal file
7
tests_errors/struct-uniform-gather-3.ispc
Normal file
@@ -0,0 +1,7 @@
|
||||
// Gather operation is impossible due to the presence of struct member "x" with uniform type
|
||||
|
||||
struct Foo { uniform int x; };
|
||||
|
||||
void a(uniform Foo * varying array, int index) {
|
||||
Foo v = array[index];
|
||||
}
|
||||
8
tests_errors/struct-uniform-gather-4.ispc
Normal file
8
tests_errors/struct-uniform-gather-4.ispc
Normal file
@@ -0,0 +1,8 @@
|
||||
// Gather operation is impossible due to the presence of struct member "x" with uniform type
|
||||
|
||||
struct Bar { uniform int x; };
|
||||
struct Foo { varying Bar b; };
|
||||
|
||||
void a(uniform Foo * varying array, int index) {
|
||||
Foo v = array[index];
|
||||
}
|
||||
8
tests_errors/struct-uniform-gather-5.ispc
Normal file
8
tests_errors/struct-uniform-gather-5.ispc
Normal file
@@ -0,0 +1,8 @@
|
||||
// Gather operation is impossible due to the presence of struct member "x" with uniform type
|
||||
|
||||
struct Bar { uniform int x; };
|
||||
struct Foo { Bar b; };
|
||||
|
||||
void a(uniform Foo * varying array, int index) {
|
||||
Foo v = array[index];
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// Can't convert between different struct types "uniform struct Foo" and "uniform struct Bar"
|
||||
// Can't convert between different struct types "varying struct Foo" and "varying struct Bar"
|
||||
|
||||
struct Foo {
|
||||
int a;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "unsigned" qualifier is illegal with "uniform struct Foo" typ
|
||||
// "unsigned" qualifier is illegal with "varying struct Foo" typ
|
||||
|
||||
struct Foo {
|
||||
float x;
|
||||
|
||||
Reference in New Issue
Block a user