I have a case where I want to write something like this:
uniform int* uniform array = ...;
uniform int offset = 0;
foreach(x = ...) {
if ( should_append(x) ) {
array[offset++] = x;
}
}
... but of course, that doesn't compile.
Is there an idiom for doing this in ISPC? It seems like it would be possible with some combination of broadcast()-like operations but I can't quite put my finger on it (and maybe it's simply just not practical).
I'm thinking of something like:
foreach(x = ...) {
if ( should_append(x) ) {
int varying_offset = some_incrementing_magic(offset);
array[varying_offset] = x;
}
}
... where each lane computes its own (unique) array offset based on the results of the gang.
Thanks in advance,
Mike