From d2d5858be1bbd0363ae7370bce471111bc031eac Mon Sep 17 00:00:00 2001 From: Matt Pharr Date: Fri, 1 Jul 2011 13:45:58 +0100 Subject: [PATCH] It is no longer legal to initialize arrays and structs with single scalar values (that ispc used to smear across the array/struct elements). Now, initializers in variable declarations must be { }-delimited lists, with one element per struct member or array element, respectively. There were a few problems with the previous implementation of the functionality to initialize from scalars. First, the expression would be evaluated once per value initialized, so if it had side-effects, the wrong thing would happen. Next, for large multidimensional arrays, the generated code would be a long series of move instructions, rather than loops (and this in turn made LLVM take a long time.) While both of these problems are fixable, it's a non-trivial amount of re-plumbing for a questionable feature anyway. Fixes issue #50. --- docs/ReleaseNotes.txt | 10 +++++++++- docs/ispc.txt | 8 ++------ stmt.cpp | 13 +------------ tests/array-assignment-varying-control.ispc | 7 +++++-- tests/array-mixed-unif-vary-indexing-2.ispc | 6 +++++- tests/array-mixed-unif-vary-indexing-3.ispc | 6 +++++- tests/array-mixed-unif-vary-indexing.ispc | 6 +++++- tests/array-multidim-gather-scatter.ispc | 6 +++++- tests/array-scatter-unif.ispc | 4 +++- tests/nested-structs-2.ispc | 6 +++++- tests/nested-structs.ispc | 5 ++++- tests/op-plus-equals-ensure-one-lhs-eval.ispc | 5 ++++- tests/packed-store-1.ispc | 4 +++- tests/packed-store-2.ispc | 4 +++- tests/packed-store-3.ispc | 4 +++- tests/packed-store.ispc | 4 +++- tests/pass-varying-lvalue-to-ref.ispc | 4 +++- tests/short-circuit.ispc | 2 +- tests/store-int16.ispc | 4 +++- tests/store-int8.ispc | 4 +++- tests/struct-ref-lvalue.ispc | 4 +++- tests/struct-test-117.ispc | 2 +- tests/struct-test-118.ispc | 2 +- tests/struct-test-119.ispc | 4 +++- tests/struct-test-120.ispc | 4 +++- tests/struct-test-121.ispc | 2 +- tests/struct-test-122.ispc | 2 +- tests/struct-test-123.ispc | 2 +- tests/struct-vary-index-expr.ispc | 4 +++- tests/test-98.ispc | 4 +++- tests/typedef-2.ispc | 5 ++++- tests/unif-struct-test-116.ispc | 2 +- tests/unif-struct-test-117.ispc | 2 +- tests/unif-struct-test-118.ispc | 2 +- tests/unif-struct-test-119.ispc | 4 +++- tests/unif-struct-test-120.ispc | 4 +++- tests/unif-struct-test-121.ispc | 2 +- tests/unif-struct-test-122.ispc | 2 +- tests/unif-struct-test-123.ispc | 2 +- tests/write-same-loc.ispc | 4 +++- 40 files changed, 114 insertions(+), 57 deletions(-) diff --git a/docs/ReleaseNotes.txt b/docs/ReleaseNotes.txt index 7f26e25e..e77ccf61 100644 --- a/docs/ReleaseNotes.txt +++ b/docs/ReleaseNotes.txt @@ -1,4 +1,12 @@ -=== v1.0.2 === +=== v1.0.3 === (not yet released) + +In initializer expressions with variable declarations, it is no longer +legal to initialize arrays and structs with single scalar values that then +initialize their members; they now must be initialized with initializer +lists in braces (or initialized after of the initializer with a loop over +array elements, etc.) + +=== v1.0.2 === (1 July 2011) Floating-point hexidecimal constants are now parsed correctly on Windows (fixes issue #16). diff --git a/docs/ispc.txt b/docs/ispc.txt index dc856b07..12a1ea85 100644 --- a/docs/ispc.txt +++ b/docs/ispc.txt @@ -766,22 +766,18 @@ Variables can also be declared in ``for`` statement initializers: for (int i = 0; ...) -Arrays can be initialized with either a scalar value or with individual -element values in braces: +Arrays can be initialized with individual element values in braces: :: - int foo[10] = x; // all ten elements take the value of x int bar[2][4] = { { 1, 2, 3, 4 }, { 5, 6, 7, 8 } }; -Structures can also be initialized both with scalar values or with element -values in braces: +Structures can also be initialized only with element values in braces: :: struct Color { float r, g, b; }; .... - Color c = 1; // all are one Color d = { 0.5, .75, 1.0 }; // r = 0.5, ... diff --git a/stmt.cpp b/stmt.cpp index c1524103..5110ca96 100644 --- a/stmt.cpp +++ b/stmt.cpp @@ -217,21 +217,10 @@ lInitSymbol(llvm::Value *lvalue, const char *symName, const Type *type, exprList->exprs[i], ctx, pos); } } - else if (initExpr->GetType()->IsNumericType() || - initExpr->GetType()->IsBoolType()) { - // Otherwise initialize all of the elements in turn with the - // initExpr. - for (int i = 0; i < collectionType->GetElementCount(); ++i) { - llvm::Value *ep = ctx->GetElementPtrInst(lvalue, 0, i, "element"); - lInitSymbol(ep, symName, collectionType->GetElementType(i), - initExpr, ctx, pos); - } - } - else { + else Error(initExpr->pos, "Can't assign type \"%s\" to \"%s\".", initExpr->GetType()->GetString().c_str(), collectionType->GetString().c_str()); - } return; } diff --git a/tests/array-assignment-varying-control.ispc b/tests/array-assignment-varying-control.ispc index 629c46d3..458a8cd2 100644 --- a/tests/array-assignment-varying-control.ispc +++ b/tests/array-assignment-varying-control.ispc @@ -11,8 +11,11 @@ void f(reference uniform Foo foo[], float a) { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - float f[40] = a; - float g[40] = b; + float f[40], g[40]; + for (uniform int i = 0; i < 40; ++i) { + f[i] = a; + g[i] = b; + } if (a < 2) f = g; RET[programIndex] = f[a]; diff --git a/tests/array-mixed-unif-vary-indexing-2.ispc b/tests/array-mixed-unif-vary-indexing-2.ispc index bafe7dc7..6eefc9d1 100644 --- a/tests/array-mixed-unif-vary-indexing-2.ispc +++ b/tests/array-mixed-unif-vary-indexing-2.ispc @@ -5,7 +5,11 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform float x[47][47] = 2.; + uniform float x[47][47]; + for (uniform int i = 0; i < 47; ++i) + for (uniform int j = 0; j < 47; ++j) + x[i][j] = 2; + // all are 2 except (3,4) = 0, (1,4) = 1, (2,4) = 1, (4,4) = 1 if (a == 3.) x[a][b-1] = 0; diff --git a/tests/array-mixed-unif-vary-indexing-3.ispc b/tests/array-mixed-unif-vary-indexing-3.ispc index 97e53016..faf0fd9f 100644 --- a/tests/array-mixed-unif-vary-indexing-3.ispc +++ b/tests/array-mixed-unif-vary-indexing-3.ispc @@ -4,7 +4,11 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform float x[47][47] = 2.; + uniform float x[47][47]; + for (uniform int i = 0; i < 47; ++i) + for (uniform int j = 0; j < 47; ++j) + x[i][j] = 2; + // all are 2 except (4,2) = 0, (4,...) = 1, (4,programCount-1)=2 if (a == 3.) x[b-1][a-1] = 0; diff --git a/tests/array-mixed-unif-vary-indexing.ispc b/tests/array-mixed-unif-vary-indexing.ispc index ddefae2d..20ff9a53 100644 --- a/tests/array-mixed-unif-vary-indexing.ispc +++ b/tests/array-mixed-unif-vary-indexing.ispc @@ -5,7 +5,11 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform float x[47][74] = 2.; + uniform float x[47][47]; + for (uniform int i = 0; i < 47; ++i) + for (uniform int j = 0; j < 47; ++j) + x[i][j] = 2; + x[a][b-1] = 0; RET[programIndex] = x[2][a]; } diff --git a/tests/array-multidim-gather-scatter.ispc b/tests/array-multidim-gather-scatter.ispc index 4ef06c11..8a2f3947 100644 --- a/tests/array-multidim-gather-scatter.ispc +++ b/tests/array-multidim-gather-scatter.ispc @@ -4,7 +4,11 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - float x[40][40] = b; + float x[40][40]; + for (uniform int i = 0; i < 40; ++i) + for (uniform int j = 0; j < 40; ++j) + x[i][j] = b; + uniform int index[4] = { 0, 1, 2, 4 }; float v = index[programIndex & 0x3]; x[a][v] = 0; diff --git a/tests/array-scatter-unif.ispc b/tests/array-scatter-unif.ispc index 37dadde7..61aaa24a 100644 --- a/tests/array-scatter-unif.ispc +++ b/tests/array-scatter-unif.ispc @@ -5,7 +5,9 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform float x[40] = 0; + uniform float x[40]; + for (uniform int i = 0; i < 40; ++i) + x[i] = 0.; x[a] = 2; RET[programIndex] = x[4] + x[0] + x[5]; } diff --git a/tests/nested-structs-2.ispc b/tests/nested-structs-2.ispc index a613e9a7..b2f4de31 100644 --- a/tests/nested-structs-2.ispc +++ b/tests/nested-structs-2.ispc @@ -13,7 +13,11 @@ struct Bar { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform Bar bar = 2.; + uniform Bar bar; + for (uniform int i = 0; i < 6; ++i) + for (uniform int j = 0; j < 18; ++j) + bar.foo[i].f[j] = 2.; + bar.foo[5].f[a] = a; RET[programIndex] = bar.foo[b].f[a]; } diff --git a/tests/nested-structs.ispc b/tests/nested-structs.ispc index 2e5115b8..3476a6b8 100644 --- a/tests/nested-structs.ispc +++ b/tests/nested-structs.ispc @@ -13,7 +13,10 @@ struct Bar { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform Bar bar = 2.; + uniform Bar bar; + for (uniform int i = 0; i < 6; ++i) + for (uniform int j = 0; j < 6; ++j) + bar.foo[i].f[j] = 2.; RET[programIndex] = bar.foo[b].f[b]; } diff --git a/tests/op-plus-equals-ensure-one-lhs-eval.ispc b/tests/op-plus-equals-ensure-one-lhs-eval.ispc index b7488f6d..0499c1a3 100644 --- a/tests/op-plus-equals-ensure-one-lhs-eval.ispc +++ b/tests/op-plus-equals-ensure-one-lhs-eval.ispc @@ -2,7 +2,10 @@ export uniform int width() { return programCount; } export void f_fu(uniform float ret[], uniform float aa[], uniform float b) { - uniform float foo[16] = 1; + uniform float foo[16]; + for (uniform int i = 0; i < 16; ++i) + foo[i] = 1; + uniform int i = 0; foo[i++] += 1; ret[programIndex] = i; diff --git a/tests/packed-store-1.ispc b/tests/packed-store-1.ispc index 3a1b410d..5d392379 100644 --- a/tests/packed-store-1.ispc +++ b/tests/packed-store-1.ispc @@ -3,7 +3,9 @@ export uniform int width() { return programCount; } export void f_f(uniform float RET[], uniform float aFOO[]) { float a = aFOO[programIndex]; - uniform int pack[2+programCount] = 0; + uniform int pack[2+programCount]; + for (uniform int i = 0; i < 2+programCount; ++i) + pack[i] = 0; packed_store_active(pack, 2, a); RET[programIndex] = pack[programIndex]; } diff --git a/tests/packed-store-2.ispc b/tests/packed-store-2.ispc index aeb97383..c90a2f7b 100644 --- a/tests/packed-store-2.ispc +++ b/tests/packed-store-2.ispc @@ -3,7 +3,9 @@ export uniform int width() { return programCount; } export void f_f(uniform float RET[], uniform float aFOO[]) { float a = aFOO[programIndex]; - uniform int pack[2+programCount] = 0; + uniform int pack[2+programCount]; + for (uniform int i = 0; i < 2+programCount; ++i) + pack[i] = 0; if ((int)a & 1) packed_store_active(pack, 2, a); RET[programIndex] = pack[programIndex]; diff --git a/tests/packed-store-3.ispc b/tests/packed-store-3.ispc index 1dfe2748..b59693a1 100644 --- a/tests/packed-store-3.ispc +++ b/tests/packed-store-3.ispc @@ -3,7 +3,9 @@ export uniform int width() { return programCount; } export void f_f(uniform float RET[], uniform float aFOO[]) { float a = aFOO[programIndex]; - uniform int pack[2+programCount] = 0; + uniform int pack[2+programCount]; + for (uniform int i = 0; i < 2+programCount; ++i) + pack[i] = 0; uniform int count = 0; if ((int)a & 1) count += packed_store_active(pack, 2, a); diff --git a/tests/packed-store.ispc b/tests/packed-store.ispc index c8036284..bd8f1297 100644 --- a/tests/packed-store.ispc +++ b/tests/packed-store.ispc @@ -3,7 +3,9 @@ export uniform int width() { return programCount; } export void f_f(uniform float RET[], uniform float aFOO[]) { float a = aFOO[programIndex]; - uniform int pack[programCount] = 0; + uniform int pack[programCount]; + for (uniform int i = 0; i < programCount; ++i) + pack[i] = 0; packed_store_active(pack, 0, a); RET[programIndex] = pack[programIndex]; } diff --git a/tests/pass-varying-lvalue-to-ref.ispc b/tests/pass-varying-lvalue-to-ref.ispc index bc182125..c0886a31 100644 --- a/tests/pass-varying-lvalue-to-ref.ispc +++ b/tests/pass-varying-lvalue-to-ref.ispc @@ -4,7 +4,9 @@ export uniform int width() { return programCount; } void inc(reference float v) { ++v; } export void f_fu(uniform float ret[], uniform float aa[], uniform float b) { - uniform float foo[32] = 10; + uniform float foo[32]; + for (uniform int i = 0; i < 32; ++i) + foo[i] = 10; int a = (int)aa[programIndex]; inc(foo[a]); ret[programIndex] = foo[programIndex]; diff --git a/tests/short-circuit.ispc b/tests/short-circuit.ispc index 9e850713..34e196fe 100644 --- a/tests/short-circuit.ispc +++ b/tests/short-circuit.ispc @@ -3,7 +3,7 @@ export uniform int width() { return programCount; } export void f_f(uniform float RET[], uniform float aFOO[]) { float a = aFOO[programIndex]; - uniform float array[4] = 1; + uniform float array[4] = {1,1,1,1}; int index = 1000 * (a-1); RET[programIndex] = (programIndex == 0) ? array[index] : 2.; } diff --git a/tests/store-int16.ispc b/tests/store-int16.ispc index cc21dc07..0659cdc4 100644 --- a/tests/store-int16.ispc +++ b/tests/store-int16.ispc @@ -1,7 +1,9 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { - uniform int x[16] = 0xffffffff; + uniform int x[16]; + for (uniform int i = 0; i < 16; ++i) + x[i] = 0xffffffff; unsigned int val = aFOO[programIndex]; store_to_int16(x, 5, val); unsigned int v = load_from_int16(x, 6); diff --git a/tests/store-int8.ispc b/tests/store-int8.ispc index 45e991bf..6a3602e8 100644 --- a/tests/store-int8.ispc +++ b/tests/store-int8.ispc @@ -1,7 +1,9 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { - uniform int x[8] = 0xffffffff; + uniform int x[8]; + for (uniform int i = 0; i < 8; ++i) + x[i] = 0xffffffff; unsigned int val = aFOO[programIndex]; store_to_int8(x, 2, val); unsigned int v = load_from_int8(x, 1); diff --git a/tests/struct-ref-lvalue.ispc b/tests/struct-ref-lvalue.ispc index 061dfa16..21f2374c 100644 --- a/tests/struct-ref-lvalue.ispc +++ b/tests/struct-ref-lvalue.ispc @@ -11,7 +11,9 @@ void f(reference uniform Foo foo[], float a) { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform Foo foo[17] = a; + uniform Foo foo[17]; + for (uniform int i = 0; i < 17; ++i) + foo[i].f = a; f(foo, a); RET[programIndex] = foo[a].f; } diff --git a/tests/struct-test-117.ispc b/tests/struct-test-117.ispc index 11a3bd40..5cc377ac 100644 --- a/tests/struct-test-117.ispc +++ b/tests/struct-test-117.ispc @@ -9,7 +9,7 @@ struct Foo { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo myFoo = a; + varying Foo myFoo = { a, a }; RET[programIndex] = myFoo.x; } diff --git a/tests/struct-test-118.ispc b/tests/struct-test-118.ispc index 521d8ad9..5eebde3d 100644 --- a/tests/struct-test-118.ispc +++ b/tests/struct-test-118.ispc @@ -8,7 +8,7 @@ struct Foo { }; export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform Foo myFoo[3] = a; + uniform Foo myFoo[3] = { { a, a }, {a, a}, {a, a} }; int i = 1; varying Foo barFoo = myFoo[i]; RET[programIndex] = barFoo.x; diff --git a/tests/struct-test-119.ispc b/tests/struct-test-119.ispc index fddbeb55..1239ac4a 100644 --- a/tests/struct-test-119.ispc +++ b/tests/struct-test-119.ispc @@ -10,7 +10,9 @@ struct Foo { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo myFoo[3] = b; + varying Foo myFoo[3] = { { b, b, {b, b, b} }, + { b, b, {b, b, b} }, + { b, b, {b, b, b} } }; uniform Foo barFoo; barFoo = myFoo[0]; RET[programIndex] = barFoo.x + myFoo[1].i[2]; diff --git a/tests/struct-test-120.ispc b/tests/struct-test-120.ispc index fabc9fc7..41234791 100644 --- a/tests/struct-test-120.ispc +++ b/tests/struct-test-120.ispc @@ -11,7 +11,9 @@ float bar(struct Foo f) { return f.f; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo myFoo[3] = a; + varying Foo myFoo[3] = { { a, a, {a, a, a} }, + { a, a, {a, a, a} }, + { a, a, {a, a, a} } }; RET[programIndex] = bar(myFoo[1]); } diff --git a/tests/struct-test-121.ispc b/tests/struct-test-121.ispc index 576b5193..1e9d9fe0 100644 --- a/tests/struct-test-121.ispc +++ b/tests/struct-test-121.ispc @@ -10,7 +10,7 @@ float bar(varying Foo f) { ++f.x; return f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo f = a; + varying Foo f = { a }; bar(f); RET[programIndex] = f.x; } diff --git a/tests/struct-test-122.ispc b/tests/struct-test-122.ispc index 9cf6d4c3..830aed51 100644 --- a/tests/struct-test-122.ispc +++ b/tests/struct-test-122.ispc @@ -9,7 +9,7 @@ float bar(reference varying Foo f) { ++f.x; return f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo f = a; + varying Foo f = {a}; bar(f); RET[programIndex] = f.x; } diff --git a/tests/struct-test-123.ispc b/tests/struct-test-123.ispc index 9a4a7657..e690d937 100644 --- a/tests/struct-test-123.ispc +++ b/tests/struct-test-123.ispc @@ -9,7 +9,7 @@ void bar(reference varying Foo f) { ++f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - varying Foo f = a; + varying Foo f = {a}; if (a == 1 || a == 4) bar(f); RET[programIndex] = f.x; diff --git a/tests/struct-vary-index-expr.ispc b/tests/struct-vary-index-expr.ispc index 8ea9c01d..11326b56 100644 --- a/tests/struct-vary-index-expr.ispc +++ b/tests/struct-vary-index-expr.ispc @@ -7,7 +7,9 @@ struct Foo { float f; }; export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform Foo foo[17] = a; + uniform Foo foo[17]; + for (uniform int i = 0; i < 17; ++i) + foo[i].f = a; ++foo[a].f; uniform int i[16] = { 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 }; RET[programIndex] = foo[i[programIndex]].f; diff --git a/tests/test-98.ispc b/tests/test-98.ispc index 4ce3c82f..4508fd88 100644 --- a/tests/test-98.ispc +++ b/tests/test-98.ispc @@ -4,7 +4,9 @@ export uniform int width() { return programCount; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform int x[7] = b; + uniform int x[7]; + for (uniform int i = 0; i < 7; ++i) + x[i] = b; RET[programIndex] = x[b]; } diff --git a/tests/typedef-2.ispc b/tests/typedef-2.ispc index dd9a89ab..9217ff2c 100644 --- a/tests/typedef-2.ispc +++ b/tests/typedef-2.ispc @@ -15,7 +15,10 @@ struct Bar { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - Bar bar = b; + Bar bar; + for (uniform int i = 0; i < 16; ++i) + for (uniform int j = 0; j < 16; ++j) + bar.foo[i].x[j] = b; RET[programIndex] = bar.foo[a-1].x[a-1]; } diff --git a/tests/unif-struct-test-116.ispc b/tests/unif-struct-test-116.ispc index 371dbee4..85998c12 100644 --- a/tests/unif-struct-test-116.ispc +++ b/tests/unif-struct-test-116.ispc @@ -8,7 +8,7 @@ struct Foo { }; export void f_fi(uniform float RET[], uniform float a[], uniform int b[]) { - uniform struct Foo myFoo = 2; + uniform struct Foo myFoo = {2,2}; RET[programIndex] = myFoo.x + myFoo.f; } diff --git a/tests/unif-struct-test-117.ispc b/tests/unif-struct-test-117.ispc index bd0de9f2..c6c93122 100644 --- a/tests/unif-struct-test-117.ispc +++ b/tests/unif-struct-test-117.ispc @@ -8,7 +8,7 @@ struct Foo { }; export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo myFoo = a; + uniform struct Foo myFoo = {a,a}; RET[programIndex] = myFoo.x; } diff --git a/tests/unif-struct-test-118.ispc b/tests/unif-struct-test-118.ispc index f4e387af..e1a0c353 100644 --- a/tests/unif-struct-test-118.ispc +++ b/tests/unif-struct-test-118.ispc @@ -8,7 +8,7 @@ struct Foo { }; export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo myFoo[3] = a; + uniform struct Foo myFoo[3] = { { a,a}, {a,a}, {a,a} }; uniform struct Foo barFoo; barFoo = myFoo[1]; RET[programIndex] = barFoo.x; diff --git a/tests/unif-struct-test-119.ispc b/tests/unif-struct-test-119.ispc index 2aa2df1b..b5978059 100644 --- a/tests/unif-struct-test-119.ispc +++ b/tests/unif-struct-test-119.ispc @@ -10,7 +10,9 @@ struct Foo { export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo myFoo[3] = b; + uniform struct Foo myFoo[3] = { { b, b, {b, b, b} }, + { b, b, {b, b, b} }, + { b, b, {b, b, b} } }; uniform struct Foo barFoo; barFoo = myFoo[0]; RET[programIndex] = barFoo.x + myFoo[1].i[2]; diff --git a/tests/unif-struct-test-120.ispc b/tests/unif-struct-test-120.ispc index 41e2d921..738ae218 100644 --- a/tests/unif-struct-test-120.ispc +++ b/tests/unif-struct-test-120.ispc @@ -10,7 +10,9 @@ struct Foo { float bar(uniform struct Foo f) { return f.f; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo myFoo[3] = a; + uniform struct Foo myFoo[3] = { { a, a, {a, a, a} }, + { a, a, {a, a, a} }, + { a, a, {a, a, a} } }; RET[programIndex] = bar(myFoo[1]); } diff --git a/tests/unif-struct-test-121.ispc b/tests/unif-struct-test-121.ispc index 91b351a3..7d65cb0e 100644 --- a/tests/unif-struct-test-121.ispc +++ b/tests/unif-struct-test-121.ispc @@ -9,7 +9,7 @@ float bar(uniform struct Foo f) { ++f.x; return f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo f = a; + uniform struct Foo f = { a }; bar(f); RET[programIndex] = f.x; } diff --git a/tests/unif-struct-test-122.ispc b/tests/unif-struct-test-122.ispc index 8b9cded9..98ab6a8e 100644 --- a/tests/unif-struct-test-122.ispc +++ b/tests/unif-struct-test-122.ispc @@ -9,7 +9,7 @@ float bar(reference uniform struct Foo f) { ++f.x; return f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo f = a; + uniform struct Foo f = {a}; bar(f); RET[programIndex] = f.x; } diff --git a/tests/unif-struct-test-123.ispc b/tests/unif-struct-test-123.ispc index 18535244..79cc0cd8 100644 --- a/tests/unif-struct-test-123.ispc +++ b/tests/unif-struct-test-123.ispc @@ -8,7 +8,7 @@ struct Foo { void bar(reference uniform struct Foo f) { ++f.x; } export void f_fu(uniform float RET[], uniform float aFOO[], uniform float b) { float a = aFOO[programIndex]; - uniform struct Foo f = a; + uniform struct Foo f = {a}; if (a == 1 || a == 4) bar(f); RET[programIndex] = f.x; diff --git a/tests/write-same-loc.ispc b/tests/write-same-loc.ispc index 1ae84904..171fea6f 100644 --- a/tests/write-same-loc.ispc +++ b/tests/write-same-loc.ispc @@ -2,7 +2,9 @@ export uniform int width() { return programCount; } export void f_fu(uniform float ret[], uniform float aa[], uniform float b) { - uniform int foo[10] = 10; + uniform int foo[10]; + for (uniform int i = 0; i < 10; ++i) + foo[i] = 10; int bb = b; foo[bb] = 0; ret[programIndex] = foo[4] + foo[5];