is this vbo pattern possible??

im working on some 3d application where i need to aply some CUDA kernels to the VBO data.

if i use packed float3 or float4 values, everything works but memory is not coalesced for the first case, and for the float4 it should be coalesced but for some reason its not being coalesced.

the only way i could get full memory coalesced is having the VBO as this:

x1x2x3…xn y1y2y3…yn z1z2z3…zn

i though that giving a stride of 4bytes would work, but im getting only black screen.

is this VBO design possible in OpenGL?

What pipeline you use for visualization, fixed function or programmable? If programmable - you may setup vertex attribute arrays for each position vector component as separate attribute without stride, for example

in float posX;
in float posY;
in float posZ;

vec3 Posiotion = vec3(posX, posY, posZ);

i was using (glVertexpointer the glDrawElements), im not using any shader at all so i guess im using fixed pipeline.

i dont mind writing a shader, i’ve used GLSL i remember i did a helloworld. maybe i need to refresh my memories about shaders a little.

if you could help me with some directions on your recomendation would be great

edit: the float4 packed vbo should be coallesced, i just dont know why its making problems, ill try to solve this first because i might end with the same problem with the other approach.

Here simple shader

#version 120
attribute float posX;
attribute float posY;
attribute float posX;
void main()
  vec4 Posiotion = vec3(posX, posY, posZ, 1.0);
  gl_Position = gl_ModelViewProjectionMatrix * Posiotion;
#version 120
void main()
  gl_FragColor = vec4(0.5, 0.0, 0.0, 1.0);


  1. Create OpenGL array buffer, transfer data to VGA
  2. Compile shader program
  3. Register buffer for CUDA
  4. Map buffer by CUDA, execute kernel, unmap buffer
  5. Bind buffer, setup three arrays by VertexAttribPointer with right offset
  6. Bind shader program
  7. DrawArrays, but if you have an element buffer - DrawElements
  8. Profit :slight_smile:

many thanks!