15bd8deadSopenharmony_ciName
25bd8deadSopenharmony_ci
35bd8deadSopenharmony_ci    EXT_discard_framebuffer
45bd8deadSopenharmony_ci
55bd8deadSopenharmony_ciName Strings
65bd8deadSopenharmony_ci
75bd8deadSopenharmony_ci    GL_EXT_discard_framebuffer
85bd8deadSopenharmony_ci
95bd8deadSopenharmony_ciContributors
105bd8deadSopenharmony_ci
115bd8deadSopenharmony_ci    Benji Bowman, Imagination Technologies
125bd8deadSopenharmony_ci    John Rosasco, Apple
135bd8deadSopenharmony_ci    Richard Schreyer, Apple
145bd8deadSopenharmony_ci    Stuart Smith, Imagination Technologies
155bd8deadSopenharmony_ci    Michael Swift, Apple
165bd8deadSopenharmony_ci    
175bd8deadSopenharmony_ciContacts
185bd8deadSopenharmony_ci
195bd8deadSopenharmony_ci    Benj Lipchak, Apple (lipchak 'at' apple.com)
205bd8deadSopenharmony_ci
215bd8deadSopenharmony_ciStatus
225bd8deadSopenharmony_ci
235bd8deadSopenharmony_ci    Complete
245bd8deadSopenharmony_ci
255bd8deadSopenharmony_ciVersion
265bd8deadSopenharmony_ci
275bd8deadSopenharmony_ci    Last Modified Date: September 15, 2009
285bd8deadSopenharmony_ci    Revision: #7
295bd8deadSopenharmony_ci
305bd8deadSopenharmony_ciNumber
315bd8deadSopenharmony_ci
325bd8deadSopenharmony_ci    OpenGL ES Extension #64
335bd8deadSopenharmony_ci
345bd8deadSopenharmony_ciDependencies
355bd8deadSopenharmony_ci
365bd8deadSopenharmony_ci    OpenGL ES 1.0 is required.
375bd8deadSopenharmony_ci    
385bd8deadSopenharmony_ci    Written based on the wording of the OpenGL ES 2.0 specification.
395bd8deadSopenharmony_ci
405bd8deadSopenharmony_ci    Requires OES_framebuffer_object or OpenGL ES 2.0.
415bd8deadSopenharmony_ci
425bd8deadSopenharmony_ciOverview
435bd8deadSopenharmony_ci
445bd8deadSopenharmony_ci    This extension provides a new command, DiscardFramebufferEXT, which 
455bd8deadSopenharmony_ci    causes the contents of the named framebuffer attachable images to become 
465bd8deadSopenharmony_ci    undefined.  The contents of the specified buffers are undefined until a 
475bd8deadSopenharmony_ci    subsequent operation modifies the content, and only the modified region 
485bd8deadSopenharmony_ci    is guaranteed to hold valid content.  Effective usage of this command 
495bd8deadSopenharmony_ci    may provide an implementation with new optimization opportunities.
505bd8deadSopenharmony_ci
515bd8deadSopenharmony_ci    Some OpenGL ES implementations cache framebuffer images in a small pool 
525bd8deadSopenharmony_ci    of fast memory.  Before rendering, these implementations must load the
535bd8deadSopenharmony_ci    existing contents of one or more of the logical buffers (color, depth, 
545bd8deadSopenharmony_ci    stencil, etc.) into this memory.  After rendering, some or all of these 
555bd8deadSopenharmony_ci    buffers are likewise stored back to external memory so their contents can
565bd8deadSopenharmony_ci    be used again in the future.  In many applications, some or all of the 
575bd8deadSopenharmony_ci    logical buffers  are cleared at the start of rendering.  If so, the 
585bd8deadSopenharmony_ci    effort to load or store those buffers is wasted.
595bd8deadSopenharmony_ci
605bd8deadSopenharmony_ci    Even without this extension, if a frame of rendering begins with a full-
615bd8deadSopenharmony_ci    screen Clear, an OpenGL ES implementation may optimize away the loading
625bd8deadSopenharmony_ci    of framebuffer contents prior to rendering the frame.  With this extension, 
635bd8deadSopenharmony_ci    an application can use DiscardFramebufferEXT to signal that framebuffer 
645bd8deadSopenharmony_ci    contents will no longer be needed.  In this case an OpenGL ES 
655bd8deadSopenharmony_ci    implementation may also optimize away the storing back of framebuffer 
665bd8deadSopenharmony_ci    contents after rendering the frame.
675bd8deadSopenharmony_ci
685bd8deadSopenharmony_ciIssues
695bd8deadSopenharmony_ci
705bd8deadSopenharmony_ci    1) Should DiscardFramebufferEXT's argument be a list of COLOR_ATTACHMENTx 
715bd8deadSopenharmony_ci    enums, or should it use the same bitfield from Clear and BlitFramebuffer?
725bd8deadSopenharmony_ci        
735bd8deadSopenharmony_ci        RESOLVED: We'll use a sized list of framebuffer attachments.  This
745bd8deadSopenharmony_ci        will give us some future-proofing for when MRTs and multisampled
755bd8deadSopenharmony_ci        FBOs are supported.
765bd8deadSopenharmony_ci        
775bd8deadSopenharmony_ci    2) What happens if the app discards only one of the depth and stencil
785bd8deadSopenharmony_ci    attachments, but those are backed by the same packed_depth_stencil buffer?
795bd8deadSopenharmony_ci    
805bd8deadSopenharmony_ci        a) Generate an error
815bd8deadSopenharmony_ci        b) Both images become undefined
825bd8deadSopenharmony_ci        c) Neither image becomes undefined
835bd8deadSopenharmony_ci        d) Only one of the images becomes undefined
845bd8deadSopenharmony_ci        
855bd8deadSopenharmony_ci        RESOLVED: (b) which sort of falls out of Issue 4.
865bd8deadSopenharmony_ci        
875bd8deadSopenharmony_ci    3) How should DiscardFramebufferEXT interact with the default framebuffer?
885bd8deadSopenharmony_ci
895bd8deadSopenharmony_ci        a) Generate an error
905bd8deadSopenharmony_ci        b) Ignore the hint silently
915bd8deadSopenharmony_ci        c) The contents of the specified attachments become undefined
925bd8deadSopenharmony_ci
935bd8deadSopenharmony_ci        RESOLVED: (c), with appropriate wording to map FBO attachments to
945bd8deadSopenharmony_ci        the corresponding default framebuffer's logical buffers
955bd8deadSopenharmony_ci
965bd8deadSopenharmony_ci    4) What happens when you discard an attachment that doesn't exist?  This is 
975bd8deadSopenharmony_ci    the case where a framebuffer is complete but doesn't have, for example, a
985bd8deadSopenharmony_ci    stencil attachment, yet the app tries to discard the stencil attachment.
995bd8deadSopenharmony_ci
1005bd8deadSopenharmony_ci        a) Generate an error
1015bd8deadSopenharmony_ci        b) Ignore the hint silently
1025bd8deadSopenharmony_ci
1035bd8deadSopenharmony_ci        RESOLVED: (b) for two reasons.  First, this is just a hint anyway, and
1045bd8deadSopenharmony_ci        if we required error detection, then suddenly an implementation can't
1055bd8deadSopenharmony_ci        trivially ignore it.  Second, this is consistent with Clear, which 
1065bd8deadSopenharmony_ci        ignores specified buffers that aren't present.
1075bd8deadSopenharmony_ci    
1085bd8deadSopenharmony_ciNew Procedures and Functions
1095bd8deadSopenharmony_ci
1105bd8deadSopenharmony_ci    void DiscardFramebufferEXT(enum target, 
1115bd8deadSopenharmony_ci                               sizei numAttachments, 
1125bd8deadSopenharmony_ci                               const enum *attachments);
1135bd8deadSopenharmony_ci
1145bd8deadSopenharmony_ciNew Tokens
1155bd8deadSopenharmony_ci
1165bd8deadSopenharmony_ci    Accepted in the <attachments> parameter of DiscardFramebufferEXT when the
1175bd8deadSopenharmony_ci    default framebuffer is bound to <target>:
1185bd8deadSopenharmony_ci
1195bd8deadSopenharmony_ci        COLOR_EXT                                0x1800
1205bd8deadSopenharmony_ci        DEPTH_EXT                                0x1801
1215bd8deadSopenharmony_ci        STENCIL_EXT                              0x1802
1225bd8deadSopenharmony_ci
1235bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment 
1245bd8deadSopenharmony_ciOperations and the Framebuffer)
1255bd8deadSopenharmony_ci    
1265bd8deadSopenharmony_ci    Introduce new section 4.5:
1275bd8deadSopenharmony_ci
1285bd8deadSopenharmony_ci    "4.5 Discarding Framebuffer Contents
1295bd8deadSopenharmony_ci
1305bd8deadSopenharmony_ci    The GL provides a means for discarding portions of every pixel in a 
1315bd8deadSopenharmony_ci    particular buffer, effectively leaving its contents undefined.  The 
1325bd8deadSopenharmony_ci    command
1335bd8deadSopenharmony_ci
1345bd8deadSopenharmony_ci        void DiscardFramebufferEXT(enum target, 
1355bd8deadSopenharmony_ci                                   sizei numAttachments, 
1365bd8deadSopenharmony_ci                                   const enum *attachments);
1375bd8deadSopenharmony_ci
1385bd8deadSopenharmony_ci    effectively signals to the GL that it need not preserve all contents of
1395bd8deadSopenharmony_ci    a bound framebuffer object.  <numAttachments> indicates how many 
1405bd8deadSopenharmony_ci    attachments are supplied in the <attachments> list.  If an attachment is 
1415bd8deadSopenharmony_ci    specified that does not exist in the framebuffer bound to <target>, it is 
1425bd8deadSopenharmony_ci    ignored.  <target> must be FRAMEBUFFER.  
1435bd8deadSopenharmony_ci    
1445bd8deadSopenharmony_ci    If a framebuffer object is bound to <target>, then <attachments> may 
1455bd8deadSopenharmony_ci    contain COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, and/or STENCIL_ATTACHMENT.  If
1465bd8deadSopenharmony_ci    the framebuffer object is not complete, DiscardFramebufferEXT may be 
1475bd8deadSopenharmony_ci    ignored.
1485bd8deadSopenharmony_ci
1495bd8deadSopenharmony_ci    If the default framebuffer is bound to <target>, then <attachment> may 
1505bd8deadSopenharmony_ci    contain COLOR, identifying the color buffer; DEPTH, identifying the depth 
1515bd8deadSopenharmony_ci    buffer; or STENCIL, identifying the stencil buffer."
1525bd8deadSopenharmony_ci
1535bd8deadSopenharmony_ciErrors
1545bd8deadSopenharmony_ci
1555bd8deadSopenharmony_ci    The error INVALID_ENUM is generated if DiscardFramebufferEXT is called
1565bd8deadSopenharmony_ci    with a <target> that is not FRAMEBUFFER.
1575bd8deadSopenharmony_ci    
1585bd8deadSopenharmony_ci    The error INVALID_ENUM is generated if DiscardFramebufferEXT is called with
1595bd8deadSopenharmony_ci    a token other than COLOR_ATTACHMENT0, DEPTH_ATTACHMENT, or 
1605bd8deadSopenharmony_ci    STENCIL_ATTACHMENT in its <attachments> list when a framebuffer object is
1615bd8deadSopenharmony_ci    bound to <target>.
1625bd8deadSopenharmony_ci
1635bd8deadSopenharmony_ci    The error INVALID_ENUM is generated if DiscardFramebufferEXT is called with
1645bd8deadSopenharmony_ci    a token other than COLOR_EXT, DEPTH_EXT, or STENCIL_EXT in its 
1655bd8deadSopenharmony_ci    <attachments> list when the default framebuffer is bound to <target>.
1665bd8deadSopenharmony_ci
1675bd8deadSopenharmony_ci    The error INVALID_VALUE is generated if DiscardFramebufferEXT is called 
1685bd8deadSopenharmony_ci    with <numAttachments> less than zero.
1695bd8deadSopenharmony_ci
1705bd8deadSopenharmony_ciRevision History
1715bd8deadSopenharmony_ci
1725bd8deadSopenharmony_ci    09/15/2009  Benj Lipchak
1735bd8deadSopenharmony_ci        Make attachments argument const enum*.
1745bd8deadSopenharmony_ci        
1755bd8deadSopenharmony_ci    09/07/2009  Benj Lipchak
1765bd8deadSopenharmony_ci        Minor clarification to overview text.
1775bd8deadSopenharmony_ci        
1785bd8deadSopenharmony_ci    08/18/2009  Benj Lipchak
1795bd8deadSopenharmony_ci        Replace null-terminated list with sized list, loosen error checking,
1805bd8deadSopenharmony_ci        and use separate attachment tokens for default framebuffers.
1815bd8deadSopenharmony_ci
1825bd8deadSopenharmony_ci    07/15/2009  Benj Lipchak
1835bd8deadSopenharmony_ci        Minor changes to overview, change GLenum to enum, whitespace fixes.
1845bd8deadSopenharmony_ci
1855bd8deadSopenharmony_ci    07/14/2009  Benj Lipchak
1865bd8deadSopenharmony_ci        Rename entrypoint to DiscardFramebufferEXT to follow verb/object naming
1875bd8deadSopenharmony_ci        style, and rename entire extension to match.  Replace bitfield with
1885bd8deadSopenharmony_ci        null-terminated attachment list.  Add actual spec diffs.  Update
1895bd8deadSopenharmony_ci        overview, issues list, and errors.
1905bd8deadSopenharmony_ci
1915bd8deadSopenharmony_ci    04/30/2009  Richard Schreyer
1925bd8deadSopenharmony_ci        General revision, removed the combined resolve-and-discard feature.
1935bd8deadSopenharmony_ci        
1945bd8deadSopenharmony_ci    04/30/2008  Michael Swift
1955bd8deadSopenharmony_ci        First draft of extension.
1965bd8deadSopenharmony_ci
1975bd8deadSopenharmony_ciTODO:
1985bd8deadSopenharmony_ci- provide examples of intended usage
199