empty texture object

Hi ,

I thought that the following snippet will create an empty texture object of certain width and height. But the application terminates

cl_mem initTexture(int width,int height)
   cl_int ciErrNum;

   cl_image_format image_format;
   image_format.image_channel_order = CL_RGBA;
   image_format.image_channel_data_type = CL_UNSIGNED_INT8;

   //create an empty image 
   cl_mem imageTexture = clCreateImage2D(cxGPUContext,CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
   oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);


   return imageTexture;

Any idea folks ?


The description of the flag CL_MEM_COPY_HOST_PTR states that “this flag is valid only if host_ptr is not NULL”.

So you must either use a valid host_ptr, or create your image without CL_MEM_COPY_HOST_PTR and use clEnqueueFillImage.