engine icon indicating copy to clipboard operation
engine copied to clipboard

Investigate performance improvement by using invalidateFramebuffer

Open mvaligursky opened this issue 4 years ago • 3 comments

the WebGl2 function to be used: https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/invalidateFramebuffer

see "When to call glInvalidateFramebuffer?" section here https://community.arm.com/developer/tools-software/graphics/b/blog/posts/mali-performance-2-how-to-correctly-handle-framebuffers

see "Optimizing for tilers" section here: https://www.dropbox.com/s/89pvx9obhv6m0pk/High%20Quality,%20High%20Performance%20Graphics%20in%20Filament%20(Handout).pdf?dl=0

There are TWO MAJOR optimizations you MUST implement before you do ANYTHING else in your engine The first one of them is handling tiling GPUs properly

mvaligursky avatar Aug 28 '20 14:08 mvaligursky

also see Camera section here: https://learn.unity.com/tutorial/optimizing-graphics-in-unity#5c7f8528edbc2a002053b5ab (sections: Discard and Restore buffer; Tile-based Rendering)

mvaligursky avatar Sep 03 '20 15:09 mvaligursky

another reference:

invalidateFramebuffer Storing data that you won't use again can have high cost, particularly on tiled-rendering GPUs common on mobile. When you're done with the contents of a framebuffer attachment, use invalidateFramebuffer to discard the data, instead of leaving the driver to waste time storing the data for later use. DEPTH/STENCIL and/or multisampled attachments in particular are great candidates for invalidateFramebuffer.

https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/WebGL_best_practices

mvaligursky avatar Dec 20 '20 21:12 mvaligursky

note, that there is an equivalent for a viewport, which we could use as well https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/invalidateSubFramebuffer

mvaligursky avatar Jun 08 '22 12:06 mvaligursky

I consider this done. The viewport equivalent is not used, but this is rarely used path.

mvaligursky avatar Feb 23 '23 14:02 mvaligursky