编译特定代码将我的纹理设为 NULL

发布于 2024-09-12 20:03:33 字数 757 浏览 1 评论 0原文

一个非常奇怪的错误:如果我向我的项目添加一些特定的代码,我使用的任何纹理都只包含 0。即使我没有运行任何添加的代码。

这里的具体代码是 nVidia CUDA 示例 [1] 的内核,双三次纹理过滤示例,特别是 CatMulRom 内核。我已将其追溯到其中一个子功能。如果我在那里重置变量,一切都会恢复正常。这真的非常非常奇怪,我不知道它会是什么。添加和使用双三次内核不会产生任何问题。

以下是“修复”问题的更改:

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

如果我重置变量,那么如果我不使用 CatMulRom,它就会起作用。如果我尝试使用它,纹理又会为零。有问题的纹理定义如下:

texture<uchar1, 2, cudaReadModeNormalizedFloat> tex;

我已经编辑掉了模板,希望它能解决问题,但它仍然存在。

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲸落 2024-09-19 20:03:33

你已经耗尽了你的筹码。

You've busted your stack.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文