cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

kos
Journeyman III

How to properly copy FLoat2 data to gpu ?

I'm trying to do this way :

CALfloat* fdata = NULL;
  CALfloat* idata = reinterpret_cast<CALfloat*>( data);
  calResMap((CALvoid**)&fdata, &pitch, Res, 0);
  for (int i = 0; i < region.first; ++i)
  {
  CALfloat* tmp = &fdata[i * pitch];
  for (int j = 0; j < region.second; ++j)
  {
  tmp[2*j] = *(idata + (i*pitch) + 2*j);
  tmp[2*j+1] = *(idata + (i*pitch) + 2*j+1);
  }
  }

but sometimes pitch > width.

0 Likes
2 Replies
gaurav_garg
Adept I

tmp[2*j] = *(idata + (i*pitch) + 2*j);   tmp[2*j+1] = *(idata + (i*pitch) + 2*j+1);

 

but sometimes pitch > width.

 



Source pointer indexing needs to be done using width-

tmp[2*j] = *(idata + (i*width) + 2*j);   tmp[2*j+1] = *(idata + (i*width) + 2*j+1);

Take a look at method CopyDataToGPU used in CAL samples.

0 Likes

Thank you that helps.

0 Likes