[工作積累] OpenGL ES3.0: glInvalidateFramebuffer

來源:互聯網
上載者:User

標籤: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_ATTACHMENTiGL_DEPTH_ATTACHMENTGL_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

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.