cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

lucasribeiro
Adept II

Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

Hello guys,

I can write data to cl::BufferGL variables (on GPU) and use it to draw, but I got wrong values when reading back to host. I have ran a couple examples from AMD SDK, including GL_CL interop, and is all ok. I can read and write cl::Buffer, i.e., copy from host to device and copy from device to host.

Code hosted at lucasribeiroufrj/sph-project · GitHub.

The program is written using:

- C++

- Ubuntu 12.06 64 bits, kernel 3.2.0-29-generic

- OpenCL 1.2

- Driver 1124.2 (Binary driver from AMD, Catalyst 13.4)

- AMD APPSDK v2.8

- OpenGL Version: 4.2.12217

- Glew

- Freeglut

The problematic code:

// Terminates OpenCL commands
cl_int status = 0;
status = clFinish( (cq)() );
if ( status != CL_SUCCESS ) { printf("File: %s:%d\n", __FILE__, __LINE__); }

// Create Vertex buffer object
GLint number = 5;
GLuint buffer;
CHk_ERR( glGenBuffers( 1, &buffer ));
CHk_ERR( glBindBuffer( GL_ARRAY_BUFFER, buffer ) );

// initialize buffer object
GLsizeiptr size = static_cast<GLsizeiptr>(sizeof(number));
const GLvoid * data = static_cast<const GLvoid *>(&number);
CHk_ERR( glBufferData( GL_ARRAY_BUFFER, size, data, GL_DYNAMIC_DRAW) );
CHk_ERR( glBindBuffer(GL_ARRAY_BUFFER, 0) );
glFinish();

if ( glGetError() != GL_NO_ERROR ) { printf("File: %s:%d\n", __FILE__, __LINE__); }

// create OpenCL buffer from GL VBO
cl_mem mem = clCreateFromGLBuffer( (context)(), CL_MEM_READ_WRITE, buffer, &status );
if ( status != CL_SUCCESS ) { printf("File: %s:%d\n", __FILE__, __LINE__); }

// Acquire OpenCL memory objects that have been created from OpenGL objects
if ( clEnqueueAcquireGLObjects( (cq)(), 1, &(mem), 0, NULL, NULL ) != CL_SUCCESS ){
  std::cout << "ERROR!";
}

// Read buffer
GLint value;
cq.enqueueReadBuffer( mem, CL_TRUE, 0, size, &value );
std::cout << "Value: " << value << std::endl;

Any help is appreciated!!

Message was edited by: Lucas Azevedo

Tags (3)
0 Kudos
Reply
13 Replies
himanshu_gautam
Grandmaster

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

Hi could you please provide us the test case/sample code to test here. also you can try executing the same in the latest driver ie catalyst 13.8 and let us know the result. If it is the same result probably will check here.

0 Kudos
Reply
lucasribeiro
Adept II

Re: Getting wrong values returned from  cl::BufferGL after a upgrade from HD6790 to HD7850!!

I've created a repository at https://github.com/lucasribeiroufrj/sph-project. I'm going to install the 13.8 driver and test it again. But do i have to install SDK 2.8.1 as well?

Thanks.

0 Kudos
Reply
nou
Exemplar

Re: Getting wrong values returned from  cl::BufferGL after a upgrade from HD6790 to HD7850!!

latest driver should contain latest OpenCL runtime files.

lucasribeiro
Adept II

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

As suggested, I've installed 13.8 driver, but nothing changes. Any other idea?

0 Kudos
Reply
lucasribeiro
Adept II

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

As suggested, I've installed 13.8 driver, but nothing changes. Any other idea?

0 Kudos
Reply
lucasribeiro
Adept II

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

Hi Himanshu,

I've uploaded my project to github, here is the link. Could you please take a look at

$<ROOT>/include/objs/ObjectSPH.cpp line 562.

This line is where I try to read from a cl::BufferGL and I get trash from video memory.

Thanks

0 Kudos
Reply
himanshu_gautam
Grandmaster

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!


Hi,

Were you able to solve this?

btw.. The heading says you started having problem after upgrading your graphics card.

So, i.e. the code worked fine on earlier one and not on the new one??

Please confirm.

I will see if I can test this and then lodge an internal bug - if necessary

Thanks,

Bruhaspati

0 Kudos
Reply
himanshu_gautam
Grandmaster

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

Can you try doing a "clFinish" before doing a ReadBuffer...?

0 Kudos
Reply
himanshu_gautam
Grandmaster

Re: Getting wrong values returned from cl::BufferGL after a upgrade from HD6790 to HD7850!!

Lucas,

I tried compiling code....I have not had success...

I installed clogs 1.0.3 and then it asked for doxygen, boost and so on..

This is not going to work.

If you can isolate the problem to simple compilable code fragment, please post it here.

Use the advanced editor (top right in faded color) to attach files.

I can test it here and let you know of ...

Thanks,

Bruhaspati

0 Kudos
Reply