3D texture problem

Hi,

I tried to create a 3D texture the type of whose texels is float4.

On the host side, an 1D array whose length is whd*4 is created to hold texel values. In this array, texels are stored along the x direction first, then y direction, and finally z direction, for example

tex_111.x tex_111.y tex_111.z … tex_w11.x tex_w11.y tex_w11.z tex_w11.w, tex_121.x tex_121.y, tex_121.z, tex_121.w, … tex_w21.x

The relevant code is shown below, however, I got an ‘invalid argument’ cuda run-time error on the line ‘CUDA_SAFE_CALL(cudaMemcpy3D(&copyParms));’

cudaArray* ary = 0;

    cudaExtent  gridSize = make_cudaExtent(w, h, d);

    cudaChannelFormatDesc desc = cudaCreateChannelDesc<float4>();

    CUDA_SAFE_CALL(cudaMalloc3DArray(&ary, &desc, gridSize));

cudaMemcpy3DParms copyParms = {0};

    copyParms.srcPtr = make_cudaPitchedPtr((void*)h_data, gridSize.width*sizeof(float4), gridSize.width, gridSize.height);

    copyParms.dstArray = ary;

    copyParms.extent = gridSize;

    copyParms.kind = cudaMemcpyHostToDevice;

    CUDA_SAFE_CALL(cudaMemcpy3D(&copyParms));

Can someone please tell me where I was wrong? Thanks

Yifei

The problem was caused by my mistake.

Which was what? I am having the same problem. Code looks good, but I get a cudaErrorInvalidValue.