cudaAddressModeBorder是否适用于非标准化坐标?

cudaAddressModeBorder是否适用于非标准化坐标?,cuda,textures,nvidia,Cuda,Textures,Nvidia,我正在使用纹理对象访问PGM图像像素。我的愿望是让纹理获取给定坐标中的像素值,如果超出边界,则为0 这是我的纹理描述: unsigned char *device_input=NULL; size_t input_pitch; checkCudaErrors(cudaMallocPitch(&device_input, &input_pitch, sizeof(unsigned char)*IMAGE_WIDTH, IMAGE_HEIGHT)); checkCudaErrors(

我正在使用纹理对象访问PGM图像像素。我的愿望是让纹理获取给定坐标中的像素值,如果超出边界,则为0

这是我的纹理描述:

unsigned char *device_input=NULL;
size_t input_pitch;
checkCudaErrors(cudaMallocPitch(&device_input, &input_pitch, sizeof(unsigned char)*IMAGE_WIDTH, IMAGE_HEIGHT));
checkCudaErrors(cudaMemcpy2D(device_input, input_pitch, image, sizeof(unsigned char)*IMAGE_WIDTH, sizeof(unsigned char)*IMAGE_WIDTH, IMAGE_HEIGHT, cudaMemcpyHostToDevice));

cudaResourceDesc resDesc;
memset(&resDesc, 0, sizeof(resDesc));
resDesc.resType = cudaResourceTypePitch2D;
resDesc.res.pitch2D.devPtr = device_input; // 
resDesc.res.pitch2D.pitchInBytes =  input_pitch;
resDesc.res.pitch2D.width = IMAGE_WIDTH;
resDesc.res.pitch2D.height = IMAGE_HEIGHT;
resDesc.res.pitch2D.desc = cudaCreateChannelDesc<unsigned char>();

cudaTextureDesc texDesc;
memset(&texDesc, 0, sizeof(texDesc));
texDesc.readMode = cudaReadModeElementType;
texDesc.normalizedCoords=false;
texDesc.addressMode[0]=cudaAddressModeBorder;
texDesc.addressMode[1]=cudaAddressModeBorder;

cudaTextureObject_t tex;
cudaCreateTextureObject(&tex, &resDesc, &texDesc, NULL);
无符号字符*设备输入=NULL;
大小输入音高;
检查CUDAERRORS(CUDAMALLOCITCH(&device_input,&input_pitch,sizeof(unsigned char)*图像宽度,图像高度));
检查CUDAERRORS(cudaMemcpy2D(设备输入、输入音高、图像、sizeof(无符号字符)*图像宽度、sizeof(无符号字符)*图像宽度、图像高度、cudaMemcpyHostToDevice));
cudaResourceDesc resDesc;
memset(&resDesc,0,sizeof(resDesc));
resDesc.resType=cudaResourceTypePitch2D;
resDesc.res.pitch2D.devPtr=设备输入;//
resDesc.res.pitch2D.pitchInBytes=输入音调;
resDesc.res.pitch2D.width=图像宽度;
resDesc.res.pitch2D.height=图像高度;
resDesc.res.pitch2D.desc=cudaCreateChannelDesc();
CudatextureDisc texDesc;
memset(&texDesc,0,sizeof(texDesc));
texDesc.readMode=cudaReadModeElementType;
texDesc.normalizedCoords=false;
texDesc.addressMode[0]=cudaAddressModeBorder;
texDesc.addressMode[1]=cudaAddressModeBorder;
cudaTextureObject_t tex;
cudaCreateTextureObject(&tex,&resDesc,&texDesc,NULL);
但是,在我的内核中:

tex2D<unsigned char>(tex_inputImage,-100,-100)
tex2D(tex_输入图像,-100,-100)
它显然在图像的边界之外,返回图像[0,0]处的值,而不是值0

这同样适用于:

tex2D<unsigned char>(tex_inputImage,IMAGE_WIDTH+1,IMAGE_HEIGHT+1)
tex2D(tex\u输入图像,图像宽度+1,图像高度+1)
返回图像[image\u WIDTH,image\u HEIGHT]处的值,而不是0

请注意,通过使用规范化坐标,cudaAddressModeBorder可以按预期工作,但我不想使用规范化坐标。根据nvidia的编程指南(),cudaAddressModeBorder由非规范化坐标支持


我做错什么了吗?

以下是我自己问题的答案:

该程序在一台驱动程序版本为319.32的机器上运行,显然该驱动程序有一个bug,在使用法线坐标()时,该bug处理了
cudaAddressModeBorder
cudaAddressModeClamp


该错误在319.49版中已修复,
cudaAddressModeBorder
在标准化和非标准化坐标下都能正常工作

经过进一步调查,这似乎是一个已知的驱动程序错误,希望nvidia能尽快修复它:您运行的驱动程序版本是什么?你试过最新的吗?