Note that there are some explanatory texts on larger screens.

plurals
  1. POenqueueWriteImage fail on GPU
    text
    copied!<p>I am developing some kernels which works with image buffers. The problem is that when I create my Image2D by directly copying the data of the image, everything works well.</p> <p>If I try to enqueue a write to my image buffer, it won't works for my GPU.</p> <p>Here is a basic kernel :</p> <pre><code>__kernel void myKernel(__read_only image2d_t in, __write_only image2d_t out) { const int x = get_global_id(0); const int y = get_global_id(1); const sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_CLAMP_TO_EDGE | CLK_FILTER_NEAREST; uint4 pixel = read_imageui(in, sampler, (int2)(x, y)); write_imageui(out, (int2)(x, y), pixel); } </code></pre> <p>Well, that simple kernel give me a black image on my GPU, but works well on my CPU.</p> <p>To make it works, I have to do release the buffer image and creating a new one by directly passing data using <code>CL_MEM_COPY_HOST_PTR</code>. I use the good data format : CL_RGBA, CL_UNSIGNED_INT8 and the size of my image is good.</p> <p>The problem has been encountered with JOCL and the C++ binding of the API. (I didn't test the C API).</p> <p>Finally, it runs by recreating the buffer, but is it a good idea ? Is it just normal ? Which actions can I perform to avoid it ?</p> <p>By the way, I'm running on Intel SDK for OpenCL (Intel Core I7) and ATI AMD APP SDK (HD6800).</p> <p>[edit]</p> <p>Here is the code I use to write in my buffers.</p> <p>First, the allocation part :</p> <pre><code>cl_image_format imageFormat = new cl_image_format(); imageFormat.image_channel_order = CL_RGBA; imageFormat.image_channel_data_type = CL_UNSIGNED_INT8; inputImageMem = clCreateImage2D( context, CL_MEM_READ_ONLY, new cl_image_format[]{imageFormat}, imageSizeX, imageSizeY, 0, null, null); </code></pre> <p>And when running, called for each frame, the part which doesn't work on GPU :</p> <pre><code>clEnqueueWriteImage(commandQueue, inputImageMem, CL_TRUE, new long[]{0, 0, 0}, new long[]{imageSizeX, imageSizeY, 1}, 0, 0, Pointer.to(data), 0, null, null); </code></pre> <p>The part which works on both GPU and CPU but force me to recreate the buffer :</p> <pre><code>clReleaseMemObject(inputImageMem); cl_image_format imageFormat = new cl_image_format(); imageFormat.image_channel_order = CL_RGBA; imageFormat.image_channel_data_type = CL_UNSIGNED_INT8; inputImageMem = clCreateImage2D(context, CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, new cl_image_format[]{imageFormat}, imageSizeX, imageSizeY, 0, Pointer.to(data), null); </code></pre> <p>The data sent is an array of int of size <code>imageSizeX*imageSizeY</code>. I get it by this code :</p> <pre><code>DataBufferInt dataBuffer = (DataBufferInt)image.getRaster().getDataBuffer(); int data[] = dataBuffer.getData(); </code></pre> <p>The code above is in java using JOCL, the same problem appear in an another C++ program using the C++ OpenCL Wrapper. The only differences are that in Java the virtual machine crash (after 3~4 frames) and in C++ the result is a black image.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload