C ++ AMP纹理...是为了什么? [英] C++ AMP Textures... what for?

查看:94
本文介绍了C ++ AMP纹理...是为了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用纹理而不是数组的原因是什么?在我看来,它们只是另一个容器.谢谢.

What is the reason for using textures instead of arrays? It seems to me they are just another container. Thanks.

推荐答案

纹理有多种用途,尽管是否继续淡入淡出还是一个有趣的问题.在最基本的水平上,它们为您提供了通常无法获得的某些打包(子字大小)格式 在C ++ AMP中(但显然可以以ADT形式手动实现),例如字节或短支持.另一方面,它们允许与DirectX进行互操作,您可以在其中进行大量的纹理工作.

There are multiple uses for textures, albeit it is an interesting question whether or not going forward they are going to fade into oblivion or not. On the most basic level, they give you certain packed (sub-word sized) formats that you don't normally get in C++ AMP (but can obviously manually implement in the form of ADTs) e.g. byte or short support. In another regard, they allow for interoperability with DirectX where you would do significant texture work.

但是,更有趣的方面是更不透明且与硬件有关.虽然您在纹理中看到的只是另一个容器,但在实现纹理的方式方面,故事却更加细微. (通常)内存中的纹理模糊不清 线性布置,就像缓冲区/容器的情况一样.混乱往往取决于硬件(并且完全不透明),并且旨在以人们通常访问纹理的方式(即 通常是在特定坐标周围获取一些纹理像素内核,例如过滤,而不是线性遍历数据).因此,如果您的访问模式匹配,您将看到使用纹理的好处.此外, 在某些硬件(例如NVIDIA Fermi)上,纹理缓存与通用缓存是分开的,并且具有(潜在)优势,因此您必须使用纹理来获取该特定路径.

The more interesting aspect, though, is more opaque and hardware dependent. Whilst what you see in a texture is just another container, in terms of how textures are implemented the story is more nuanced. Textures are (normally) swizzled in memory as opposed to being laid out linearly, as would be the case for a buffer / container. The swizzling tends to be hardware dependent (and utterly opaque), and aims to optimally exploit the caching structure in the context of the way one typically accesses a texture (which is, more often than not, fetching some kernel of texels around a particular coordinate, so as to e.g. filtering, as opposed to just linearly striding through the data). So, if your access pattern matches, you will see benefits from using textures. Furthermore, on some hardware (e.g. NVIDIA Fermi) the texture cache is separate from the general purpose cache and has (potentially) advantages, and you'd have to use a texture to fetch through that particular path.


这篇关于C ++ AMP纹理...是为了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆