Hi:
My program use cudaMemcpy2DToArray/cudaMemcpy2DFromArray() to do vertical reverse image copy between OpenGL and cuda, the code like below:
void Cuda2Texture(void * cu_src_ptr, size_t cu_src_pitch,GLuint tex_id,int w, int h)
{
CUresult cur;
CUgraphicsResource cu_res = GetCuResource(tex_id);
CUarray cu_ary;
cur = cuGraphicsMapResources(1, &cu_res, NULL);
cur = cuGraphicsSubResourceGetMappedArray(&cu_ary, cu_res, 0, 0);
cur = (CUresult)cudaMemcpy2DToArray(
(cudaArray_t)cu_ary, 0, 0,
(void *)((char *)cu_src_ptr + cu_src_pitch * (h - 1)), (size_t)-cu_src_pitch, // copy from last line of src image buffer,set buffPitch to negative
w, h,
cudaMemcpyDeviceToDevice);
cur = cuGraphicsUnmapResources(1, &cu_res, NULL);
}
the function works well,but compiler report below warning:
warning C4146: unary minus operator applied to unsigned type, result still unsigned
compiler report this warning because the data type of “cu_src_pitch” is size_t,size_t is unsigned int64,I roughly pass a negative “cu_src_pitch” to cuda function, is it valid? Can I use a negative number as cuda mem pitch?