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.




  • 0
  • 0
  • 0
  • 一键三连
  • 扫一扫,分享海报

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
钱包余额 0