CUDA: Get subset of 3D Surface

416 views Asked by At

I want to render some slices of a 3d surface.

cudaArray* surfArray;
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(8, 8, 8, 8, cudaChannelFormatKindUnsigned);
cudaExtent surfSize = make_cudaExtent(640,480,2);
cudaMalloc3DArray(&surfArray,&channelDesc,surfSize,cudaArraySurfaceLoadStore);

Therefore, I tried to get the subsets via MemcpyArrayToArray() and an offset.

cudaGraphicsSubResourceGetMappedArray(&cu_rgbArray,tex_rgb,0,0);
cudaMemcpyArrayToArray(cu_rgbArray,0,0,surfArray,0,0,640*480*sizeof(uchar4),cudaMemcpyDeviceToDevice);

cudaGraphicsSubResourceGetMappedArray(&cu_depthArray,tex_depth,0,0);
cudaMemcpyArrayToArray(cu_depthArray,0,0,surfArray,640,480,640*480*sizeof(uchar4),cudaMemcpyDeviceToDevice);

However, while the first memcpy succeeds, the second one fails. (It does succeed if the offset is 0,0).

Any thoughts how to get around this problem without an extra kernel?

1

There are 1 answers

0
harrism On

I believe you should use cudaMemcpy3D, not cudaMemcpyArrayToArray.