Results 1 to 3 of 3

Thread: set image format

  1. #1

    set image format

    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

  2. #2

    Re: set image format

    Unextended OpenCL doesn't have a mechanism to share device memory between a buffer and an image. You need to refer to the cl_khr_image2d_from_buffer extension in the OpenCL 1.2 extensions specification.

  3. #3

    Re: set image format

    Hi

    Will it be possible to create an empty image object where host ptr is null and then later copy the contents of the linear buffer to the image object ?

    In case of empty image object what should be the data type for the image format?

    Regards
    Sajjad

Similar Threads

  1. RGB image in RGBA format
    By wscrosswy in forum OpenCL
    Replies: 3
    Last Post: 06-08-2011, 08:58 AM
  2. No image format 24 bit RGB?
    By user42 in forum OpenVG and VGU
    Replies: 1
    Last Post: 09-16-2008, 12:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •