How Much Does A Tex2D/TexCUBE Cost

基础知识 同时被 2 个专栏收录
55 篇文章 0 订阅
46 篇文章 0 订阅

On mobile, texture sample probably takes as much as "several to several dozen simple math operations".
On PC, the ratio is higher, for one texture sample you can afford dozens to hundreds of math operations.

And then there's funky hardware like PowerVR (e.g. everything in iOS) where several "non dependent" texture samples can be though to be free, but dependent ones do cost quite a lot more.

A dependent texture read is a texture read in which the texture coordinates depend on some calculation within the (fragment) shader instead of on a varying. As the values of this calculation cannot be known ahead of time it is not possible to pre-fetch texture data and so stalls in shader processing occur.

If your shader requires more than one dependent texture read:

When a dependent texture read occurs the current thread running on the USSE within the SGX is suspended until the comparatively slow read is completed, and another thread is swapped in. By re-arranging the code within the shader so that the two dependent texture reads were back-to-back, another performance improvement was gained. This works because the compiler can now batch these dependent texture reads together, whereas previously the shader looked as follows:

• Mathematics
• Texture Read
• Wait
• Mathematics
• Texture Read
• Wait

It now looks as follows:

• Mathematics
• Texture Read
• Texture Read
• Wait

This effectively hides some of the wait time of the first texture read behind the execution time of the second texture read. Unfortunately a wait of some description is inevitable due to the limitations of dependent texture reads. Nonetheless, the strong parallelism of the PowerVR SGX hardware ensures that these waits can be used effectively by other threads



^ But don't forget to check the code in the compiled shader and/or use #pragma glsl_no_optimize when you use more than one dependent texture read.

 

From:https://forum.unity.com/threads/how-much-does-a-tex2d-texcube-cost.182469/

More:https://gdcvault.com/play/1015331/Bringing-AAA-Graphics-to-Mobile

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值