Hi forum,

i have defined and allocated memory for a float2 data type as follows:

Code :
    typedef cl_float2 cData;
 
    hvfield = (cData*)malloc(sizeof(cData) * DS);
 
    memset(hvfield,0,sizeof(cData) * DS);
 
    dvfield = clCreateBuffer(cxGPUContext,CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,sizeof(cData) * DS,hvfield, &ciErrNum);
    oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
 
 
    vxfield = clCreateBuffer(cxGPUContext,CL_MEM_READ_WRITE,sizeof(cData) * PDS,NULL,&ciErrNum);
    oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
 
    vyfield = clCreateBuffer(cxGPUContext,CL_MEM_READ_WRITE,sizeof(cData) * PDS,NULL,&ciErrNum);
    oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);



Then i want to create a image buffer that that points to the linear device memory by dvfield. But i do not understand how to define the image format for the 2D texture(the code with ?????) :

Code :
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_mem imageTexture = clCreateImage2D(cxGPUContext,CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR,
					 &image_format,width,height,width * sizeof(cData),dvfield,
					 &ciErrNum);
   oclCheckErrorEX(ciErrNum, CL_SUCCESS, pCleanup);
 
   return imageTexture;
}

Any idea?


Regards
Sajjad