Results 1 to 2 of 2

Thread: Proper row pitch and slice pitch value

  1. #1

    Proper row pitch and slice pitch value

    Hi forum,

    How to decide the row pitch and slice pitch value while creating a 3D opengl image buffer. Initially i am allocating a 3D buffer on the host as follows:

    Code :
       //calculate the number of elements to deal with - width , height and depth
       unsigned int elements = static_cast<unsigned int>(w * h * d);
     
       //allocate memory for the number of elements
       float *volumeData = (float*)malloc(elements * 4 * sizeof(float));
       float *ptr = volumeData;
     
       //POPULATE WITH random values
       for(unsigned int i = 0; i < elements;i++)
       {
          *ptr++ = frand()*2.0f-1.0f;
          *ptr++ = frand()*2.0f-1.0f;
          *ptr++ = frand()*2.0f-1.0f;
          *ptr++ = frand()*2.0f-1.0f;
       }

    Image channel format is CL_RGBA and data type is CL_FLOAT.

    I am not sure if the row pitch value should be image_width * sizeof(float). I tried it and got invalid image size error.

    Any hint?


    Thanks

  2. #2
    Junior Member
    Join Date
    Jan 2014
    Posts
    1
    Quote Originally Posted by sajis997 View Post
    Hi forum,

    How to decide the row pitch and slice pitch value while creating a 3D opengl image buffer. Initially i am allocating a 3D buffer on the host as follows:

    <snip>

    Image channel format is CL_RGBA and data type is CL_FLOAT.

    I am not sure if the row pitch value should be image_width * sizeof(float). I tried it and got invalid image size error.

    Any hint?
    Thanks
    A RGBA is 4 data elements per pixel, so pitch would be calculated as:

    row_pitch = 4 * sizeof(float) * image_width_in_pixels;

Posting Permissions

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