Hello,
I’m testing new CUDA 5.0 version and i’m implementing a Texture Object manager sample using the new functions.
Well, first I define the objects
cudaTextureObject_t texObject;
struct cudaResourceDesc resDesc;
struct cudaTextureDesc ptexDesc;
Second, I create a cudaArray
cudaChannelFormatDesc channelDesc = cudaCreateChannelDesc(32, 0, 0, 0, cudaChannelFormatKindFloat);
cudaArray * cuArray;
float h_data[1000];
for(int i=0;i<1000;i++){
h_data[i]=i;
}
cudaMallocArray(&cuArray, &channelDesc, width, height);
cudaMemcpyToArray(cuArray, 0, 0, (void *)h_data, sizeof(float)*w*h,cudaMemcpyHostToDevice);
Third, I initialize the variables
memset(&resDesc, 0, sizeof(resDesc));
resDesc.res.array.array = cuArray;
resDesc.resType = cudaResourceTypeArray;
memset(&ptexDesc, 0, sizeof (ptexDesc));
ptexDesc.addressMode[0] = cudaAddressModeWrap;
ptexDesc.addressMode[1] = cudaAddressModeWrap;
ptexDesc.filterMode = cudaFilterModeLinear;
ptexDesc.readMode = cudaReadModeElementType;
ptexDesc.normalizedCoords = 1;
Finally, I try to create the cudaTextureObject_t object
cudaCreateTextureObject(&texObject,&resDesc,&ptexDesc,NULL);
…and it fails.
Thanks for your time
ADRIAN