OpenGL/DirectX:Mipmapping如何提高性能? [英] OpenGL/DirectX: How does Mipmapping improve performance?

查看:90
本文介绍了OpenGL/DirectX:Mipmapping如何提高性能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常了解mipmapping.我不了解(在硬件/驱动程序级别上)的是mipmapping如何提高应用程序的性能(至少经常有人声称).在执行片段着色器之前,驱动程序不知道将要访问哪个mipmap级别,因此无论如何,所有mipmap级别都必须存在于VRAM中,还是我错了?

I understand mipmapping pretty well. What I do not understand (on a hardware/driver level) is how mipmapping improves the performance of an application (at least this is often claimed). The driver does not know until the fragment shader is executed which mipmap level is going to be accessed, so anyway all mipmap levels need to be present in the VRAM, or am I wrong?

究竟是什么导致性能提高?

What exactly is causing the performance improvement?

推荐答案

您毫无疑问地知道,mip链较低LOD中的每个texel覆盖了整个纹理图像区域的较高百分比,对吗?

You are no doubt aware that each texel in the lower LODs of the mip-chain covers a higher percentage of the total texture image area, correct?

在远处采样纹理时,硬件将使用较低的LOD.发生这种情况时,解决缩小问题所需的样本邻域会变小,因此需要更少(未缓存)的访存.这完全是关于纹理采样期间实际需要获取的内存量,而不是占用的内存量(假设您没有遇到纹理颠簸).

When you sample a texture at a distant location the hardware will use a lower LOD. When this happens, the sample neighborhood necessary to resolve minification becomes smaller, so fewer (uncached) fetches are necessary. It is all about the amount of memory that actually has to be fetched during texture sampling, and not the amount of memory occupied (assuming you are not running into texture thrashing).

我认为这可能值得一看,所以我将借鉴以下优秀教程系列中的以下图:

I think this probably deserves a visual representation, so I will borrow the following diagram from the excellent series of tutorials at arcsynthesis.org.

    

     

在左侧,您会看到当您始终对单个LOD进行纯朴的采样时会发生什么(顺便说一下,此图显示了线性最小化滤波),而在右侧,您看到了mipmapping会发生什么.它不仅可以通过更紧密地匹配片段的有效大小来提高图像质量,而且由于较低的Mipmap LOD中的纹理像素数量较少,因此可以更有效地进行缓存.

On the left, you see what happens when you naïvely sample at a single LOD all of the time (this diagram is showing linear minification filtering, by the way) and on the right you see what happens with mipmapping. Not only does it improve image quality by more closely matching the fragment's effective size, but because the number of texels in lower mipmap LODs are fewer it can be cached much more efficiently.

这篇关于OpenGL/DirectX:Mipmapping如何提高性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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