in my shader I use a function that stores and returns the resulting data in two arrays. Everything works correctly but I assume it is very bad style of coding.
The result is correct, but the bigger those arrays are, the longer the program takes to start and the lower the framerate.
Here the relevant code snippets:
struct RET
{
float a1[10][20];
float a2[10][20];
};
static float array1[10][20];
static float array2[10][20];
RET foo1()
{
RET r;
// write and read array1 and array2
r.a1 = array1;
r.a2 = array2;
return r;
}
Well, this is awkward but it was the only way to get it working.
I actually don't see any reason for array1 and array2 to be static and global. But if I try it like follows the program throws an error message at start:
RET foo2()
{
RET r;
// write and read r.a1 and r.a2
return r;
}
1. Is this behaviour comprehensible?
2. How could I realize my task in a proper and more efficient way?
3. Do I maybe need to pack the data into float4s?