The SobelFilter example from the CUDA SDK (version 8) reads a grayscale .pgm file, and cudaBindTextureToArray(tex, array) in the sobelFilter() function of SobelFilter_kernels.cu works properly in that case. However, when I try to read a 24-bit color .ppm file, where the g_Bpp is 4 instead of 1, cudeBindTextureToArray(tex, array) returns an error:
r_kernels.cu(246) : CUDA Runtime API error 11: invalid argument
extern "C" void sobelFilter(Pixel *odata, int iw, int ih, enum SobelDisplayMode mode, float fScale)
{
checkCudaErrors(cudaBindTextureToArray(tex, array));
From SobelFilter.cpp (original .pgm code commented out):
void loadDefaultImage(char *loc_exec)
{
//printf("Reading image: lena.pgm\n");
//const char *image_filename = "lena.pgm";
printf("Reading image: ref_example.ppm\n");
const char *image_filename = "ref_example.ppm";
char *image_path = sdkFindFilePath(image_filename, loc_exec);
if (image_path == NULL)
{
printf("Failed to read image file: <%s>\n", image_filename);
exit(EXIT_FAILURE);
}
initializeData(image_path);
free(image_path);
}
The image appears to be loaded into memory correctly, but I get that error when trying to bind it to a CUDA texture array. How do I get the file to load correctly with cudaBindTextureToArray()?