tags:

views:

50

answers:

1

A very strange error: if I add some specific code to my project, any textures I use contain nothing but 0. Even when I'm not running any of the code that was added.

The specific code here is the kernels of an nVidia CUDA sample [1], the Bicubic Texture Filtering sample, in specific the CatMulRom kernel. I've traced it down to one of the subfunctions. If I reset a variable there, everything returns to normal. It's really, really strange and I have no idea anymore what it could be. Adding and using the bicubic kernel causes no problems.

Here's the change that "fixes" the problem:

__host__ __device__
float catrom_w1(float a)
{
    a = 1;  // Fix
    return 1.0f + a*a*(-2.5f + 1.5f*a);
}

If I reset the variable, it works if I'm not using CatMulRom. If I do try to use it the textures are zero again. The textures in question are defined as follows:

texture<uchar1, 2, cudaReadModeNormalizedFloat> tex;

I've edited away the template, hoping it would solve the problem, but it persists.

[1] http://developer.download.nvidia.com/compute/cuda/sdk/website/samples.html

+3  A: 

You've busted your stack.

DeadMG
Makes sense. Any tips on how to find out where/why?
David Verhasselt
@David Verhasselt: Unfortunately, I'm not an expert on busted stacks since I've never done it and never used CUDA. However, your code is a classic case. I would look at the function that runs just before this one, or any functions it calls, first. Then see if you can download a tool for it.
DeadMG