Once more I have a problem with my compute shader... I would like to pass a structure containing a pointer into a compute shader. This is my structure example:
struct couleurStruct {
float r;
float g;
float b;
float a;
float *x;
};
Here is my SSBO initialization :
couleurStruct *coul;
coul = (couleurStruct *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(couleurStruct), bufMask);
//coul->x = (float *)glMapBufferRange(GL_SHADER_STORAGE_BUFFER, 0, 1 * sizeof(float), bufMask);
coul->r = 0.0;
coul->g = 1.0;
coul->b = 0.0;
coul->a = 1.0;
coul->x[0] = 0.5;
glUnmapBuffer(GL_SHADER_STORAGE_BUFFER);
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, structBuffer);
I tried a lot of different initializations but without success...
So, is there a way to allocate all the memory needed (because I know the memory I will need inside each of the arrays pointed by my pointers) and pass it to the compute shader? Or is it really impossible to pass a pointer to a compute shader?
Thank you for your help!
Shaders in OpenGL (and Vulkan/D3D for that matter) cannot have pointers. The most you can do is provide an index into some other data structure. So you could make
xan index into some other array. Though it's not clear exactly why it needs to be a pointer.