15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_read_buffer 45bd8deadSopenharmony_ci NV_read_buffer_front 55bd8deadSopenharmony_ci 65bd8deadSopenharmony_ciName Strings 75bd8deadSopenharmony_ci 85bd8deadSopenharmony_ci GL_NV_read_buffer 95bd8deadSopenharmony_ci GL_NV_read_buffer_front 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ciContact 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ci Greg Roth, NVIDIA Corporation (groth 'at' nvidia.com) 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ciContributors 165bd8deadSopenharmony_ci 175bd8deadSopenharmony_ci Koji Ashida, NVIDIA Corporation 185bd8deadSopenharmony_ci Gregory Prisament, NVIDIA Corporation 195bd8deadSopenharmony_ci Greg Roth, NVIDIA Corporation 205bd8deadSopenharmony_ci James Helferty, NVIDIA Corporation 215bd8deadSopenharmony_ci Antoine Chauveau, NVIDIA Corporation 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciStatus 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Complete. 265bd8deadSopenharmony_ci 275bd8deadSopenharmony_ciVersion 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ci Last Modified Date: September 27, 2013 305bd8deadSopenharmony_ci NVIDIA Revision: 7.0 315bd8deadSopenharmony_ci 325bd8deadSopenharmony_ciNumber 335bd8deadSopenharmony_ci 345bd8deadSopenharmony_ci OpenGL ES Extension #93 355bd8deadSopenharmony_ci 365bd8deadSopenharmony_ciDependencies 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci Written against the OpenGL ES 2.0 Specification. 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ci NV_draw_buffers affects this extension. 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ciOverview 435bd8deadSopenharmony_ci 445bd8deadSopenharmony_ci Unextended OpenGL ES 2.0 only supports using ReadPixels to read from 455bd8deadSopenharmony_ci the default color buffer of the currently-bound framebuffer. 465bd8deadSopenharmony_ci However, it is useful for debugging to be able to read from 475bd8deadSopenharmony_ci non-default color buffers. Particularly, when the NV_draw_buffers 485bd8deadSopenharmony_ci extension is supported, each framebuffer may contain multiple color 495bd8deadSopenharmony_ci buffers. This extension provides a mechanism to select which color 505bd8deadSopenharmony_ci buffer to read from. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci This document describes two extensions to allow an implementation to 535bd8deadSopenharmony_ci support a subset of the total functionality. 545bd8deadSopenharmony_ci 555bd8deadSopenharmony_ci The NV_read_buffer extension adds the command ReadBufferNV, which is 565bd8deadSopenharmony_ci used to select which color buffer of the currently-bound framebuffer 575bd8deadSopenharmony_ci to use as the source for subsequent calls to ReadPixels, 585bd8deadSopenharmony_ci CopyTexImage2D, and CopyTexSubImage2D. If the system-provided 595bd8deadSopenharmony_ci framebuffer is bound, then ReadBufferNV accepts value BACK. If a 605bd8deadSopenharmony_ci user-created FBO is bound, then ReadBufferNV accepts COLOR_ATTACHMENT0. 615bd8deadSopenharmony_ci Additionally, if the NV_draw_buffers extension is supported, 625bd8deadSopenharmony_ci ReadBufferNV accepts COLOR_ATTACHMENTn_NV (n is 0 to 15). 635bd8deadSopenharmony_ci 645bd8deadSopenharmony_ci The NV_read_buffer_front extension requires NV_read_buffer and adds 655bd8deadSopenharmony_ci the ability to select the system-provided FRONT color buffer as the 665bd8deadSopenharmony_ci source for read operations when the system-provided framebuffer is 675bd8deadSopenharmony_ci bound and contains both a front and back buffer. 685bd8deadSopenharmony_ci 695bd8deadSopenharmony_ciNew Procedures and Functions 705bd8deadSopenharmony_ci 715bd8deadSopenharmony_ci void ReadBufferNV(GLenum mode) 725bd8deadSopenharmony_ci 735bd8deadSopenharmony_ciNew Tokens 745bd8deadSopenharmony_ci 755bd8deadSopenharmony_ci Accepted by the <pname> parameter of GetIntegerv: 765bd8deadSopenharmony_ci 775bd8deadSopenharmony_ci READ_BUFFER_NV 0x0C02 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ciChanges to Chapter 4 of the OpenGL ES 2.0 Specification 805bd8deadSopenharmony_ci(Per-Fragment Operations and the Framebuffer) 815bd8deadSopenharmony_ci 825bd8deadSopenharmony_ci Section 4.3.1 (Reading Pixels), subsection "Obtaining Pixels from 835bd8deadSopenharmony_ci the Framebuffer" add: 845bd8deadSopenharmony_ci 855bd8deadSopenharmony_ci For color formats, the read buffer from which values are obtained 865bd8deadSopenharmony_ci is one of the color buffers; the selection of color buffer for the 875bd8deadSopenharmony_ci bound framebuffer object is controlled with ReadBufferNV. 885bd8deadSopenharmony_ci 895bd8deadSopenharmony_ci The command 905bd8deadSopenharmony_ci 915bd8deadSopenharmony_ci void ReadBufferNV(enum src); 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci takes a symbolic constant as argument. <src> must be FRONT, BACK, 945bd8deadSopenharmony_ci NONE, COLOR_ATTACHMENT0, or COLOR_ATTACHMENTi_NV, where <i> is the 955bd8deadSopenharmony_ci index of the color attachment point. Otherwise, an INVALID_ENUM 965bd8deadSopenharmony_ci error is generated. Further, the acceptable values for <src> depend 975bd8deadSopenharmony_ci on whether the GL is using the default framebuffer (i.e. 985bd8deadSopenharmony_ci FRAMEBUFFER_BINDING is zero), or a framebuffer object (i.e. 995bd8deadSopenharmony_ci FRAMEBUFFER_BINDING is non-zero) and whether the default framebuffer 1005bd8deadSopenharmony_ci is single or double buffered. For more information about framebuffer 1015bd8deadSopenharmony_ci objects, see section 4.4. 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci If the object bound to FRAMEBUFFER_BINDING is not framebuffer 1045bd8deadSopenharmony_ci complete (as defined in section 4.4.5), then ReadPixels generates 1055bd8deadSopenharmony_ci the error INVALID_FRAMEBUFFER_OPERATION. If ReadBufferNV is supplied 1065bd8deadSopenharmony_ci with a constant that is neither legal for the default framebuffer, 1075bd8deadSopenharmony_ci nor legal for a framebuffer object, then the error INVALID_ENUM 1085bd8deadSopenharmony_ci results. 1095bd8deadSopenharmony_ci 1105bd8deadSopenharmony_ci When FRAMEBUFFER_BINDING is zero, i.e. the default framebuffer, 1115bd8deadSopenharmony_ci <src> must be FRONT, BACK or NONE. If the requested buffer is 1125bd8deadSopenharmony_ci missing, the error INVALID_OPERATION is generated. If there is a default 1135bd8deadSopenharmony_ci framebuffer associated with the context, the initial setting for 1145bd8deadSopenharmony_ci READ_BUFFER_NV is BACK, otherwise it is NONE. 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci When the GL is using a framebuffer object, <src> must be NONE, 1175bd8deadSopenharmony_ci COLOR_ATTACHMENT0, or COLOR_ATTACHMENTi_NV, where <i> is the index 1185bd8deadSopenharmony_ci of the color attachment point. Specifying COLOR_ATTACHMENT0 or 1195bd8deadSopenharmony_ci COLOR_ATTACHMENTi_NV enables reading from the image attached to the 1205bd8deadSopenharmony_ci framebuffer at COLOR_ATTACHMENTi_NV. For framebuffer objects, the 1215bd8deadSopenharmony_ci initial setting for READ_BUFFER_NV is COLOR_ATTACHMENT0. 1225bd8deadSopenharmony_ci 1235bd8deadSopenharmony_ci ReadPixels generates an INVALID_OPERATION error if it attempts to 1245bd8deadSopenharmony_ci select a color buffer while READ_BUFFER_NV is NONE or if the GL is 1255bd8deadSopenharmony_ci using a framebuffer object (i.e., READ_FRAMEBUFFER_BINDING is non-zero) 1265bd8deadSopenharmony_ci and the read buffer selects an attachment that has no image attached. 1275bd8deadSopenharmony_ci 1285bd8deadSopenharmony_ci Section 4.3.2 (Pixel Draw/Read State) Replace first paragraph: 1295bd8deadSopenharmony_ci 1305bd8deadSopenharmony_ci The state required for pixel operations consists of the parameters 1315bd8deadSopenharmony_ci that are set with PixelStore. This state has been summarized in 1325bd8deadSopenharmony_ci tables 3.1. Additional state includes an integer indicating the 1335bd8deadSopenharmony_ci current setting of ReadBufferNV. State set with PixelStore is GL 1345bd8deadSopenharmony_ci client state. 1355bd8deadSopenharmony_ci 1365bd8deadSopenharmony_ci 1375bd8deadSopenharmony_ciDependencies on NV_read_buffer_front: 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ci If NV_read_buffer_front is not supported, add to the third paragraph 1405bd8deadSopenharmony_ci describing ReadBufferNV: 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci If <src> is FRONT, the error INVALID_ENUM is generated. 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ciDependencies on NV_draw_buffers: 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci If NV_draw_buffers is not supported, change all references to 1475bd8deadSopenharmony_ci "COLOR_ATTACHMENTi_NV, where <i> is the index of the color attachment 1485bd8deadSopenharmony_ci point" or simply "COLOR_ATTACHMENTi_NV" to "COLOR_ATTACHMENT0". 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ciNew State 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci Add Table 6.X Framebuffer (State per framebuffer object): 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci State Type Get Command Initial Value Description 1555bd8deadSopenharmony_ci --------------- ---- ------------ ------------- ----------- 1565bd8deadSopenharmony_ci READ_BUFFER_NV Z10* GetIntegerv see 4.2.1 Read source buffer 1575bd8deadSopenharmony_ci 1585bd8deadSopenharmony_ciIssues 1595bd8deadSopenharmony_ci 1605bd8deadSopenharmony_ci 1. Should we use ReadBufferNV to specify whether ReadPixels reads 1615bd8deadSopenharmony_ci from the window system provided framebuffer or FBO? 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci No. The switching is automatic with FBO binding. The read buffer 1645bd8deadSopenharmony_ci state belongs to the rendering surface, so switching the rendering 1655bd8deadSopenharmony_ci surface automatically switches which read buffer to use. 1665bd8deadSopenharmony_ci 1675bd8deadSopenharmony_ci This is consistent with the behavior of OpenGL 2.0 with the 1685bd8deadSopenharmony_ci ARB_framebuffer_object extension and unextended OpenGL 3.0. 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci 2. Should we have FRONT/BACK, LEFT/RIGHT buffer enums for <mode> 1715bd8deadSopenharmony_ci parameter of ReadBufferNV to be used with window system provided 1725bd8deadSopenharmony_ci framebuffers? 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci OpenGL ES 2.0 does not support stereo framebuffers, so for now we 1755bd8deadSopenharmony_ci only support FRONT and BACK. 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci 3. Why separate NV_read_buffer and NV_read_buffer_front? 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci SUGGESTION: Some platforms, such as those with a compositing 1805bd8deadSopenharmony_ci window system, may be unable to read from the front buffer. 1815bd8deadSopenharmony_ci However, we would like to allow these platforms to read from any 1825bd8deadSopenharmony_ci of the buffers drawn to using the NV_draw_buffers extension. 1835bd8deadSopenharmony_ci 1845bd8deadSopenharmony_ci 4. Should this extension allow reading from depth and stencil buffers? 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci While originally part of this document, support for reading from 1875bd8deadSopenharmony_ci depth and stencil buffers has been moved to the 1885bd8deadSopenharmony_ci NV_read_depth_stencil extension. It is clearer to devote one 1895bd8deadSopenharmony_ci document to the re-introduction of ReadBuffer, and a separate 1905bd8deadSopenharmony_ci document to legalizing new format and type combinations for 1915bd8deadSopenharmony_ci ReadPixels. 1925bd8deadSopenharmony_ci 1935bd8deadSopenharmony_ci 5. Should ReadBufferNV() pass if READ_BUFFER points to a non- 1945bd8deadSopenharmony_ci existent buffer? 1955bd8deadSopenharmony_ci 1965bd8deadSopenharmony_ci Early drivers followed the precedent set by Issue 55 of the 1975bd8deadSopenharmony_ci EXT_framebuffer_object spec; ReadBufferNV() would cause an error if 1985bd8deadSopenharmony_ci a FBO was bound and the requested buffer did not exist. 1995bd8deadSopenharmony_ci 2005bd8deadSopenharmony_ci OpenGL ES 3.0 and OpenGL 4.3 allow it to pass. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci RESOLVED: Behavior should match OpenGL ES 3.0. Application developers 2035bd8deadSopenharmony_ci are cautioned that early Tegra drivers may exhibit the previous 2045bd8deadSopenharmony_ci behavior. 2055bd8deadSopenharmony_ci 2065bd8deadSopenharmony_ci 6. What should happen if COLOR_ATTACHMENT0, the default ReadBufferNV 2075bd8deadSopenharmony_ci is not bound and ReadBufferNV() gets called on this attachment? 2085bd8deadSopenharmony_ci 2095bd8deadSopenharmony_ci Behavior matches the resolution of Issue 5. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci 7. Version 6 of this specification isn't compatible with OpenGL ES 3.0. 2125bd8deadSopenharmony_ci For contexts without a back buffer, this extension makes FRONT the 2135bd8deadSopenharmony_ci default read buffer. ES 3.0 instead calls it BACK. 2145bd8deadSopenharmony_ci How can this be harmonized? 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci RESOLVED: Update the specification to match ES 3.0 behavior. This 2175bd8deadSopenharmony_ci introduces a backwards incompatibility, but few applications are 2185bd8deadSopenharmony_ci expected to be affected. In the EGL ecosystem where ES 2.0 is 2195bd8deadSopenharmony_ci prevalent, only pixmaps have no backbuffer and their usage remains 2205bd8deadSopenharmony_ci limited. 2215bd8deadSopenharmony_ci 2225bd8deadSopenharmony_ci 2235bd8deadSopenharmony_ciRevision History 2245bd8deadSopenharmony_ci 2255bd8deadSopenharmony_ci Rev. Date Author Changes 2265bd8deadSopenharmony_ci ---- -------- --------- ------------------------------------- 2275bd8deadSopenharmony_ci 7 09/27/13 achauveau Harmonize BACK vs. FRONT selection 2285bd8deadSopenharmony_ci with GLES 3.0. 2295bd8deadSopenharmony_ci 6 07/11/13 jhelferty Changes in behavior to match GLES 3.0 2305bd8deadSopenharmony_ci 5 06/07/11 groth Responded to feedback. Clarified 2315bd8deadSopenharmony_ci non-FBO behavior and state ownership. 2325bd8deadSopenharmony_ci added a few issues. 2335bd8deadSopenharmony_ci 4 06/01/11 groth Mostly rewrote spec edits to better 2345bd8deadSopenharmony_ci match the spec and more clearly 2355bd8deadSopenharmony_ci describe behavior. 2365bd8deadSopenharmony_ci 3 03/22/09 gprisament Split depth & stencil reading into 2375bd8deadSopenharmony_ci separate document 2385bd8deadSopenharmony_ci (NV_read_depth_stencil). 2395bd8deadSopenharmony_ci Inline dependencies on NV_draw_buffers 2405bd8deadSopenharmony_ci Re-wrote overview section. 2415bd8deadSopenharmony_ci 2 07/03/08 kashida Change to depend on 2425bd8deadSopenharmony_ci NV_packed_depth_stencil2 2435bd8deadSopenharmony_ci 1 06/10/07 kashida First revision. 244