in OpenCL, big non fixed size generic arrays of data are commonly passed to the global GPU memory as cl_mem objects from application side (unformatted byte buffers within global memory scope) which are seen in the OpenCL kernels (equivalent to shader programs in GLSL) as traditional C pointers: typeName* varName Thus, accessing a value from theses buffers is simply done by using the operator : typeName a = varName[i]. How about GLSL, specially for compute shaders?
In my experience with vertex shaders, I pass generic buffers as texture buffers like:
glActiveTexture(GL_TEXTUREi);//with i from 0 to max
glBufferData(GL_TEXTURE_BUFFER, data_size_in_bytes, data_array, GL_STATIC_DRAW);
glTexBuffer(GL_TEXTURE_BUFFER, buffer_data_type, tex_Buffer);// be buffer_data_type GL_RGB32F, GL_R8UI or whatever.
and in the shader program I declare uniform (i/u)samplerBuffer varName and fetch values from the buffer like texelFetch(varName, i). Is that the best way to do it for generic type non fixed size and random read/write access to global scope data buffers?
By the way, what about 64-bits integer and double arrays, what to do, what kind of buffer to use? (I understand that high floating precision is not a primary goal with computer shader)
I’ve read about buffers, instead of samplerBuffer, but they seem to be intended to other usages (very fast access but they are more limited in size and not specially designed for random access).
thx for your time,