cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

sonkanit
Journeyman III

What is the best way to write data into GL renderbuffer?

With GL interop, I can create cl_mem object from GL renderbuffer, but I don't really know how to write the data to the buffer. I tried to pass the mem object to uchar4* in kernel but it crashed.

 

As long as I know, image2d_t is still not supported by ATI stream 2.01. Please give me some suggestion on how to write the data to GL renderbuffer. I don't want to read data from cl buffer and then copy it to renderbuffer.

 

Thank you in advance.

0 Likes
14 Replies
nou
Exemplar

it is partialy supported

i tested it and currently with 2.01 only *_imagef() functions working. so you can try enable GPU image support and write directly into gl buffer.

0 Likes

So the following kernel code should work?

__kernel void simpleKernel(__global write_only image2d_t buffer)
{
    uint x = get_global_id(0);
    uint y = get_global_id(1);
    write_imagef(buffer, (int2)(x,y), (float4)(1.0, 0.0, 0.0, 1.0));
}

clBuildProgram returned CL_BUILD_PROGRAM_FAILURE and clGetProgramBuildInfo gave a junk log string. What's wrong with it?

By the way this is how I set the kernel arg. m_outputBuffer was created from RGBA8 buffer using clCreateFromGLRenderbuffer with write_only flag.

    //Set Parameters
    size_t bufferSize;
    clGetMemObjectInfo(m_outputBuffer, CL_MEM_SIZE, sizeof(size_t), (void*)&bufferSize, NULL);
    err = clSetKernelArg(m_kernel, 0, bufferSize, &m_outputBuffer);

0 Likes

oh I am reading your linked thread now to enable GPU_IMAGE_SUPPORT.

I will post the result again

0 Likes

I enabled the GPU_IMAGES_SUPPORT in the environment variable

but my Radeon4570 wtih catalyst 10.3 still show CL_DEVICE_IMAGE_SUPPORT: NO

0 Likes

that is because for 4xxx card is not planned any extensions.

0 Likes

Then the best way to draw something is going back to openGL2.x using glDrawPixels to draw memory buffer.

or creating a new texture for each frame could be a better way for openGL3.x+?

 

Anyway, thank you for your answer.

0 Likes

i think best way is use PBO. which you can write into GL buffer from CL and then copy it into texture.

0 Likes

yes. Using PBO seems to be the fastest way without GPU_IMAGES_SUPPORT.

 

Thank you very much.

0 Likes

   I'm a novice to OpenCL and I just learn how to process(like Sobel filter) a .bmp image use OpenCL. After reading the interoperability between OCL and OGL I wonder can I do this in vs2008 : load a .bmp image, process it with OCL, so now I have the new bmp image data in the cl buffer. Then use OGL to show this image immediatly in the buffer without passing the data to the host buffer.

   Is it possible and is there any samples I can refer to?

   thank u in advance!

0 Likes

Originally posted by: libai    I'm a novice to OpenCL and I just learn how to process(like Sobel filter) a .bmp image use OpenCL. After reading the interoperability between OCL and OGL I wonder can I do this in vs2008 : load a .bmp image, process it with OCL, so now I have the new bmp image data in the cl buffer. Then use OGL to show this image immediatly in the buffer without passing the data to the host buffer.

 

   Is it possible and is there any samples I can refer to?

 

   thank u in advance!

 

Libai,

      Please look at NBody sample.

0 Likes

Originally posted by: genaganna
Originally posted by: libai    I'm a novice to OpenCL and I just learn how to process(like Sobel filter) a .bmp image use OpenCL. After reading the interoperability between OCL and OGL I wonder can I do this in vs2008 : load a .bmp image, process it with OCL, so now I have the new bmp image data in the cl buffer. Then use OGL to show this image immediatly in the buffer without passing the data to the host buffer.

 

 

 

   Is it possible and is there any samples I can refer to?

 

 

 

   thank u in advance!

 

 

 

 

Libai,

 

      Please look at NBody sample.

 

 

Thanks, genaganna.

0 Likes

genaganna, I think the Nbody sample is quite different from my question. The sample uses OGL to display data which stored in the host memery. These data is first processed by the GPU and then copy to the host mem (use the command "clEnqueueReadBuffer"). However, what I'm thinking about is to use OGL to directly display data which stored in the GPU memery and these data are processed by the GPU. Thank u.

0 Likes

1. you create OpenGL context
2. you create OpenCL context
3. create VBO, texture after creating OpenCL
4. create cl_mem from GL object
5. acquire GL object. before that ensure that all OpenGL commands is done glFinish()
6. run kernel
7. release GL object, clFinish()
8. use GL object in drawing

if you search this forum you can find my example of GL/CL interoperability

0 Likes
libai
Journeyman III

thanks nou. I have found your sample. I will have a look at it first, if I have any question I will post it here

0 Likes