Load store and memoryless


metal 

https://developer.apple.com/library/archive/documentation/3DDrawing/Conceptual/MTLBestPracticesGuide/LoadandStoreActions.html

https://docs.unity3d.com/ScriptReference/Rendering.RenderBufferLoadAction.html

當前rt選 load 會導致之前一個pass的內容 從system mem copy到 當前tile mem

當前rt 選store 會導致當前pass 內容 從tile 到system mem copy

 

dont care 沒有上述開銷

 

和msaa相關的有

storeAndMultisample 后面那 個flag涉及resolve相關會生成resolve tex

multisample content和resolvecontent都會保存

 

==============

rtt的 action 設置為 clear/store 因為它之后會被采樣

還要往之前rt上畫的 action load/store (store以后會有對它的采樣

這樣 我們管線里應該盡量去掉load

用clear /store (會被采樣

或者 clear/dontcare(不會做rtt被采樣

======================

memoryless就是字面意思 是rendertexture的一個屬性 關掉action store只有tile memory, rtt sample就會失效了

https://docs.unity3d.com/ScriptReference/RenderTextureDescriptor-memoryless.html

So basically what your script is doing (Without memoryless flag):
ViewCamera renders scene objects into renderTexture
- Camera does storeAction to save renderTexture from tile memory to system memory
- Then renderTexture system memory copy is used as shader resource for ViewMonitor
- Lastly some other camera renders ViewMonitor (Where u probably use for testing if it works or not)

Once u enable the memoryless flag, storeAction cannot be done as renderTexture doesn't have system memory for it. So that leads that renderTexture will stay to the color it was created (Most likely gray - internally we even ignore all memoryless rendertexture setting on materials as it is not valid).

https://docs.unity3d.com/ScriptReference/RenderTexture-memorylessMode.html

https://forum.unity.com/threads/how-to-use-memoryless.491167/

所以這個memoryless對平常的管線來說 如果不是做single pass deferred rendering這種是沒用的 只在tile上

或者msaa也能用到這個(這里理解起來有點繞,可以認為是4x那個不入systemmem 所以是memoryless 1x那個是另外 resolve又寫入的 用multisampleResolve做到 經測試 正確)

Render texture color pixels are memoryless when RenderTexture.antiAliasing is set to 2, 4 or 8.

https://docs.unity3d.com/ScriptReference/RenderTextureMemoryless.MSAA.html

rendertexture.antialiasing是sample 數量

 ================

load action 

  • If all the render target pixels are rendered to, choose the DontCare action. There are no costs associated with this action, and texture data is always interpreted as undefined.

  • If the previous contents of the render target do not need to be preserved and only some of its pixels are rendered to, choose the Clear action. This action incurs the cost of writing a clear value to each pixel.

  • If the previous contents of the render target need to be preserved and only some of its pixels are rendered to, choose the Load action. This action incurs the cost of loading the previous contents.

所以這里選Dont care 我們把要load的rt都做掉了,擾動那些要選clear

store action

第一遍不處理msaa的情況 這里選store 因為都要被srv(之后只用tile的和msaa 只用resolve的會選其它action)

depth stencil選dont care

storage mode 

因為還沒有做singlepass所以也不用memoryless 如果是memoryless意味着沒有gpu cpu mem 只有tile mem能省 footprint

=============對於msaa rt 有額外兩種 store action可以 處理 resolve 前後的兩張rt 的store action

srotreAndMultisampleResolve會保存兩種 5x 帶寬

MultisampleResolve 1x帶寬

store 4x帶寬

因爲要用來做srv我們應該選2 把4x那張帶寬和footprint去掉 ios推薦4xmsaa A11

====================

剛剛做到了個很了不起的事情 很開心

我可以設置 mrt 的兩張msaa targets和depth target 的load action 和store action

用event cmd --after depth 

中間發現個事情 mrt msaa 對應的depth target似乎就是1 sample 不是我之前以為的4

我剛剛降了2G的帶寬/s 80M/fra

 

ios上最終要做到40M/frame

一點都不熱


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM