View Full Version : is this vbo pattern possible??
01-29-2011, 08:39 AM
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?
01-29-2011, 10:23 AM
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);
01-29-2011, 10:45 AM
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.
01-29-2011, 02:31 PM
Here simple shader
attribute float posX;
attribute float posY;
attribute float posX;
vec4 Posiotion = vec3(posX, posY, posZ, 1.0);
gl_Position = gl_ModelViewProjectionMatrix * Posiotion;
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 :)
02-03-2011, 11:20 AM
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.