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 w*h*d*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));'

[code]
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));
[/code]

Can someone please tell me where I was wrong? Thanks

Yifei
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 w*h*d*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

#1
Posted 04/23/2012 01:51 PM   
The problem was caused by my mistake.
The problem was caused by my mistake.

#2
Posted 04/24/2012 12:24 AM   
Scroll To Top