Can GLSL concatenate static arrays?

I’m trying to translate some code that was ported from GLSL to Java back into GLSL. The code starts by setting up a few static buffers and in one place has this code:


private static int p[] = {151,160,137,91,90,15, ... };

// To remove the need for index wrapping, double the permutation table length
private static int perm[] = new int[512];
static { for(int i=0; i<512; i++) perm[i]=p[i & 255]; }

I’m trying to figure out if there is a neat way to do the same in GLSL, or if I should just cut and paste two copies of the p array into perm. I’ve noticed that this will compile in GLSL, but I don’t know if it is actually giving me an array that is two concatenated copes of p:

const int p[] = {151,160,137,91,90,15,...};

const int perm[] = {p, p};

Edit:

Okay, it looks like const int perm[] = {p, p}; is just creating an array of the addresses. Still, is there a way to concatenate two copies of this array?

GLSL is not Java. It’s an execution environment that is entirely unlike Java. So things that might be fast in Java aren’t going to be fast in GLSL.

Duplicating an array at runtime, for every shader invocation of that state, just to avoid doing an integer & operation is not helping your performance. And there’s no way to duplicate it at compile time unless you do it manually.

Doing the math will be way faster.