Is there any alignment issue with glBufferData.

Is there any alignment issue with glBufferData.

When an openGL buffer object is mapped to cuda and process with the mapped pointer, I got invalid value in the mapped pointer.

I want to split a buffer object data to two buffer objects.
I started a kernel for doing so, with mapped pointers of buffer objects.

There is no problem for my splitting logic, because it work in normal cases.
My problem is when I create a buffer object of size 92524, I got some invalid values in my split kernel.

  1. Creating a bufferObject with size 92524. // 4 bytes for holding argb data
    glGenBuffers( 1 , Bufer1 );
    glBindBuffer( GL_PIXEL_UNPACK_BUFFER, Bufer1 );
    byte* pMyData = new byte[92524];
    glBufferData( GL_PIXEL_UNPACK_BUFFER, , 92524, pMyData, GL_DYNAMIC_DRAW );
    glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 )

  2. Creating another bufferObject with 41204. // 4 bytes for holding argb data

glGenBuffers( 1 , Bufer2 );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, Bufer2 );
byte* pMyData = new byte[41204];
glBufferData( GL_PIXEL_UNPACK_BUFFER, , 41204, pMyData, GL_DYNAMIC_DRAW );
glBindBuffer( GL_PIXEL_UNPACK_BUFFER, 0 )

Is there any chance for getting some invalid data in mapped pointer of buffer object Bufer2.

cudaGLRegisterBufferObject( Buufer2 )
byte* ptr;
cudaGLMapBufferObject( &pDevicePointer_o, Bufer2 );

I got valid data when first buffer size is 102524.

Sorry for my bad english,
Thanks in advance,
Santhosh

There shouldn’t be any alignment issues with using data in buffer objects.

I can’t see anything wrong with your code (except it should be “glGenBuffers(1, &Bufer1)” but I assume that’s just a typo). Please post the full code that reproduces the problem.

Hi,

Thanks for ur reply.

I’m not callling cudaGLSetGLDevice for setting opengl device to CUDA.

Is there any problem if i use OPengl buffers without cudaGLSetGLDevice.

Now I just called cudaGLSetGLDevice( 0 ), but still the problem exists. What is the expected parameter for cudaGLSetGLDevice.

I read cudaSetDevice() uses 0 in default, thats why i used 0 for cudaGLSetGLDevice.

I think my code is Ok, its very simple logic for splitting a buffer object to two buffer objects.

But it do not produce the expected output, when I create a previous buffer object with size(92524).

Thanks in advance.

Solved…

That issue is solved when I installed latest driver from Nvidia.