コード例 #1
0
  /**
    Constructor based on existing host memory. Will keep any region of interest
    valid, by determining 'intersection' of regions.
    @param data existing device memroy
    @param ofs offset to new region
    @param _size size of new region
  */
  inline HostMemoryReference( HostMemory<Type, Dim> &data, const Size<Dim> &ofs,
                              const Size<Dim> &_size):
    Layout<Type, Dim>(data),
    Pointer<Type, Dim>(data),
    HostMemory<Type, Dim>(data)
  {
    this->buffer = data.getBuffer() + data.getOffset(ofs);
    this->size = _size;

    for(int i = Dim; i--;)
    {
      // Min and Max did not work here !!!
      int new_ofs = (int)this->region_ofs[i]-(int)ofs[i];
      if (new_ofs < 0)
        new_ofs = 0;
      if (new_ofs > (int)this->size[i])
        new_ofs = (int)this->size[i];
      this->region_ofs[i] = new_ofs;
      int new_size = this->region_size[i];
      if (this->region_size[i] > this->size[i] - this->region_ofs[i])
        new_size = this->size[i] - this->region_ofs[i];
      this->region_size[i] = new_size;
    }
  }
コード例 #2
0
void
copy(Texture<Type, Dim> &dst, const HostMemory<Type, Dim> &src)
{
  CUDA_CHECK_SIZE;
  dst.glTexSubImage(src.getBuffer());
}