可以用整数索引 CUDA 纹理吗

发布于 2024-12-02 03:01:13 字数 188 浏览 3 评论 0原文

正如题目所说。可以使用整数坐标访问 CUDA 纹理吗? 前任。

tex2D(myTex, 1, 1);

我想在纹理中存储浮点值,并将其用作我的帧缓冲区。 我会将其传递给 OpenGL,而不是在屏幕上渲染。

这种寻址方式可以吗?我不想在像素之间进行插值。我想要来自精确指定点的值。

Just like topic says. Can one access CUDA texture using integer coordinates?
ex.

tex2D(myTex, 1, 1);

I'd like to store float values in texture, and use it as my framebuffer.
I will pass it to OpenGL than to render on a screen.

Is this addressing possible? I don't want to interpolate between pixels. I want value from exactly specified point.

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

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

发布评论

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

评论(2

神魇的王 2024-12-09 03:01:13

注意:当您对多维纹理使用 0.5 偏移表示法时,实际上并没有进行插值(实际像素值从 (0.5, 0.5) 开始)。如果您真的担心,请设置舍入到最近点而不是默认的双线性。

如果您改用 1D 纹理(当基础数据是 2D 时),则可能会由于其他维度中缺乏数据局部性而导致性能下降。

Note: there isn't really interpolation going on when you use the 0.5 offset notation for multi-dimensional textures (the actual pixel values start at (0.5, 0.5)). If you're really worried, set round-to-nearest point rather than default of bilinear.

If you use 1D textures instead (when the underlying data is 2D), you may lose performance due to lack of data locality in the other dimension.

身边 2024-12-09 03:01:13

如果您想使用纹理缓存而不使用任何特定于纹理的操作(例如插值),则可以使用 tex1Dfetch()。这使您可以使用整数进行索引。

大小限制为 2^27 个元素,因此您将能够使用 float 访问 512 MB,或者使用 int2 访问 1GB [也可用于通过 __hiloint2double() 检索双精度数]。可以通过在其顶部映射覆盖数据的多个纹理来访问更大的数据。

您必须将任何多维数组访问映射到 tex1Dfetch() 支持的一维数组。我一直使用简单的 C 宏来实现这一点。

If you want to use the texture cache without using any of the texture-specific operations such as interpolation, you can use tex1Dfetch(). This lets you index with integers.

The size limit is 2^27 elements, so you will be able to access 512 MB with floats, or 1GB with int2 [which can also be used to retrieve doubles via __hiloint2double()]. Larger data can be accessed by mapping multiple textures on top of it that cover the data.

You will have to map any multi-dimensional array accesses to the one-dimensional array supported by tex1Dfetch(). I have always used simple C macros for that.

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