標籤:des style http ar io color os sp on
https://www.khronos.org/opengles/sdk/docs/man3/html/glInvalidateFramebuffer.xhtml
這個在GLES2.0上只有Extension:
https://www.khronos.org/registry/gles/extensions/EXT/EXT_discard_framebuffer.txt
原理跟D3D9 的Present參數(D3DSWAPEFFECT_DISCARD)類似:
http://msdn.microsoft.com/en-us/library/windows/desktop/bb172612(v=vs.85).aspx
理論上, 每一幀的繪製都可以基於之前幀的繪製內容疊加, 所以需要保持之前backbuffer內容的有效性, 但是即時遊戲中每一幀之間一般不這麼做.
如果原有的backbuffer在swap之後內容不再有效, 這樣可以避免GPU直接操作的frame buffer cache(fast memory)再重新寫回video memory. 而且從下一次繪製開始, GPU也不關心原有backbuffer的內容, 不用再把backbuffer的內容load到frame buffer cache中. 這也是為什麼要求video memory內的backbuffer資料必須是無效的.
這樣可以節省頻寬, 提高效率, 同時可能節省video memory開銷.
這裡的video memory不一定是顯卡內的物理顯存. 對於現代行動裝置, 大部分是GPU和CPU共用的實體記憶體, 類似XBOX和PS4的Unified Memory Access.
然而OpenGL/ES的架構上只能是先準備使用者記憶體, 然後"upload"給API, 實際上是從記憶體到記憶體的copy.
需要注意的是, 當FBO為預設FBO時, 輸入的參數是不一樣的:
If a framebuffer object is bound, then attachments may contain GL_COLOR_ATTACHMENTi, GL_DEPTH_ATTACHMENT, GL_STENCIL_ATTACHMENT, and/or GL_DEPTH_STENCIL_ATTACHMENT. If the framebuffer object is not complete, glInvalidateFramebuffer may be ignored.
If the default framebuffer is bound, then attachments may contain GL_COLOR, identifying the color buffer; GL_DEPTH, identifying the depth buffer; and/or GL_STENCIL, identifying the stencil buffer.
[工作積累] OpenGL ES3.0: glInvalidateFramebuffer