Images without Image support?

So I’m looking to do some image manipulation with OpenCL. I have code up and running with images enabled on my CPU (thanks to the ATI SDK update), but I’d like to run it on my GPU, which does not support images. My initial thought was to do some sort of wrapper that handles images I’ve loaded as buffers instead of cl_images, but I don’t really understand the implications of doing something like that…

I know I could no longer sample my images directly in the kernels, but could I access pixels directly by index instead? What’s the deal with rectangular buffers? I thought buffers were one dimensional? (I know that’s probably a silly question…) What are the hits on speed/concurrent operations? etc.

Has anybody attempted anything like this or have any thoughts?

Thanks in advance!

You can certainly do this, and it will work although performance will not be as good as if you were using the GPU’s texture sampler units. You need to compute each pixel’s linear address from the x/y(/z) coordinates. To do this you need to know the pitch of the image (i.e. the number of bytes from the start of one row to the start of the next row)…

For a 32-bit image (i.e. RGBA with 1 byte per channel) this would look like:

unsigned int pixel_pitch = pitch / sizeof(unsigned int); // pitch is usually provided as bytes
unsigned int image = <pointer to your cl_mem object>;
unsigned int pixel = image[y
pixel_pitch+x];

Thanks so much - I have code up and running already! Just curious - is that the idea behind rectangular buffers? Somehow the idea of reading/writing a 2D/3D region of a 1D object was a bit lost on me, but I guess it’s just helps so you don’t have to manually convert linear -> 2/3D coordinates?

I just curious why don’t you want to use image2d_t or image3d_t? As I know ATI SDK supports it on GPU.

The SDK certainly supports them, but not all GPUs support images. You can query your GPU to check this.

Can I ask you we use another image instead of these
I have a problem to use these images.Please guide me!