问题描述
我一直在阅读计算机图形学的论文,并且每隔一段时间我都会遇到在查询着色器代码中查询纹理的上下文中使用的术语依赖纹理读取或依赖纹理获取。什么是依赖纹理读取,这与正常纹理读取有何区别?
纹理读取是指从一个纹理查找(或其他着色器计算)中返回值用于确定要从第二个纹理查找的位置。一个重要的含义是纹理坐标(你从哪里查找)不会被确定,直到着色器执行的中间......没有一种可以在着色器上进行的静态分析(即使知道所有参数的值)那会告诉你什么时候坐标会提前。它还严格地命令两个纹理读取,并限制执行顺序可以通过驱动程序中的优化等来改变。图形卡,这种东西往往有很多限制。例如,在一个点(IIRC),您可以从多个纹理中查找,但只能使用少量不同的纹理坐标。实际上,硬件的实现方式是某些类型的相关纹理读取要么不可能,要么效率非常低。
在最新一代或两代卡片中,您不应该不得不担心这一点。但是你可能会在几年前阅读书籍或文章,当时你确实需要密切关注这些事情。
I've been reading papers on computer graphics, and every so often I come across the term "dependent texture read" or "dependent texture fetch" used in the context of querying textures in shader code. What is a dependent texture read, and what is the difference between this and a "normal" texture read?
A "dependent texture read" is when return values from one texture lookup (or other in-shader computations) are used to determine WHERE to look up from a second texture. An important implication is that the texture coordinates (where you look up from) is not determined until the middle of execution of the shader... there's no kind of static analysis you can do on the shader (even knowing the values of all parameters) that will tell you what the coordinates will be ahead of time. It also strictly orders the two texture reads and limits how much the execution order could be changed by optimizations in the driver, etc.
On older graphics cards, there used to be quite a few limitations on this kind of thing. For example, at one point (IIRC) you could look up from multiple textures but only with a small number of distinct texture coordinates. The hardware was actually implemented in a way that certain types of dependent texture reads were either impossible or very inefficient.
In the latest generation or two of cards, you shouldn't have to worry about this. But you may be reading books or articles from a couple years ago when you really did have to pay close attention to such things.
这篇关于什么是依赖纹理读取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!