15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci NV_draw_buffers 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_NV_draw_buffers 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContact 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Greg Roth, NVIDIA Corporation (groth 'at' nvidia.com) 125bd8deadSopenharmony_ci 135bd8deadSopenharmony_ciContributors 145bd8deadSopenharmony_ci 155bd8deadSopenharmony_ci Benj Lipchak, AMD 165bd8deadSopenharmony_ci Bill Licea-Kane, AMD 175bd8deadSopenharmony_ci Rob Mace, NVIDIA Corporation 185bd8deadSopenharmony_ci James Helferty, NVIDIA Corporation 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ciStatus 215bd8deadSopenharmony_ci 225bd8deadSopenharmony_ci Complete. 235bd8deadSopenharmony_ci 245bd8deadSopenharmony_ciVersion 255bd8deadSopenharmony_ci 265bd8deadSopenharmony_ci Last Modified Date: July 11, 2013 275bd8deadSopenharmony_ci NVIDIA Revision: 4.0 285bd8deadSopenharmony_ci 295bd8deadSopenharmony_ciNumber 305bd8deadSopenharmony_ci 315bd8deadSopenharmony_ci OpenGL ES Extension #91 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciDependencies 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci Written against the OpenGL ES 2.0 Specification and the OpenGL ES 365bd8deadSopenharmony_ci Shader Language 1.0.14 Specification. 375bd8deadSopenharmony_ci 385bd8deadSopenharmony_ci This extension interacts with the OpenGL ES 3.0 Specification 395bd8deadSopenharmony_ci 405bd8deadSopenharmony_ciOverview 415bd8deadSopenharmony_ci 425bd8deadSopenharmony_ci This extension extends OpenGL ES 2.0 to allow multiple output 435bd8deadSopenharmony_ci colors, and provides a mechanism for directing those outputs to 445bd8deadSopenharmony_ci multiple color buffers. 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ci This extension serves a similar purpose to ARB_draw_buffers except 475bd8deadSopenharmony_ci that this is for OpenGL ES 2.0. 485bd8deadSopenharmony_ci 495bd8deadSopenharmony_ci When OpenGL ES 3.0 is present, this extension relaxes the order 505bd8deadSopenharmony_ci restriction on color attachments to draw framebuffer objects. 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ciIP Status 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci NVIDIA Proprietary 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ciNew Procedures and Functions 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci void DrawBuffersNV(sizei n, const enum *bufs); 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ciNew Tokens 615bd8deadSopenharmony_ci 625bd8deadSopenharmony_ci Accepted by the <pname> parameters of GetIntegerv, GetFloatv, 635bd8deadSopenharmony_ci and GetDoublev: 645bd8deadSopenharmony_ci 655bd8deadSopenharmony_ci MAX_DRAW_BUFFERS_NV 0x8824 665bd8deadSopenharmony_ci DRAW_BUFFER0_NV 0x8825 675bd8deadSopenharmony_ci DRAW_BUFFER1_NV 0x8826 685bd8deadSopenharmony_ci DRAW_BUFFER2_NV 0x8827 695bd8deadSopenharmony_ci DRAW_BUFFER3_NV 0x8828 705bd8deadSopenharmony_ci DRAW_BUFFER4_NV 0x8829 715bd8deadSopenharmony_ci DRAW_BUFFER5_NV 0x882A 725bd8deadSopenharmony_ci DRAW_BUFFER6_NV 0x882B 735bd8deadSopenharmony_ci DRAW_BUFFER7_NV 0x882C 745bd8deadSopenharmony_ci DRAW_BUFFER8_NV 0x882D 755bd8deadSopenharmony_ci DRAW_BUFFER9_NV 0x882E 765bd8deadSopenharmony_ci DRAW_BUFFER10_NV 0x882F 775bd8deadSopenharmony_ci DRAW_BUFFER11_NV 0x8830 785bd8deadSopenharmony_ci DRAW_BUFFER12_NV 0x8831 795bd8deadSopenharmony_ci DRAW_BUFFER13_NV 0x8832 805bd8deadSopenharmony_ci DRAW_BUFFER14_NV 0x8833 815bd8deadSopenharmony_ci DRAW_BUFFER15_NV 0x8834 825bd8deadSopenharmony_ci 835bd8deadSopenharmony_ci 845bd8deadSopenharmony_ci Accepted by the <bufs> parameter of DrawBuffersNV: 855bd8deadSopenharmony_ci 865bd8deadSopenharmony_ci COLOR_ATTACHMENT0_NV 0x8CE0 875bd8deadSopenharmony_ci COLOR_ATTACHMENT1_NV 0x8CE1 885bd8deadSopenharmony_ci COLOR_ATTACHMENT2_NV 0x8CE2 895bd8deadSopenharmony_ci COLOR_ATTACHMENT3_NV 0x8CE3 905bd8deadSopenharmony_ci COLOR_ATTACHMENT4_NV 0x8CE4 915bd8deadSopenharmony_ci COLOR_ATTACHMENT5_NV 0x8CE5 925bd8deadSopenharmony_ci COLOR_ATTACHMENT6_NV 0x8CE6 935bd8deadSopenharmony_ci COLOR_ATTACHMENT7_NV 0x8CE7 945bd8deadSopenharmony_ci COLOR_ATTACHMENT8_NV 0x8CE8 955bd8deadSopenharmony_ci COLOR_ATTACHMENT9_NV 0x8CE9 965bd8deadSopenharmony_ci COLOR_ATTACHMENT10_NV 0x8CEA 975bd8deadSopenharmony_ci COLOR_ATTACHMENT11_NV 0x8CEB 985bd8deadSopenharmony_ci COLOR_ATTACHMENT12_NV 0x8CEC 995bd8deadSopenharmony_ci COLOR_ATTACHMENT13_NV 0x8CED 1005bd8deadSopenharmony_ci COLOR_ATTACHMENT14_NV 0x8CEE 1015bd8deadSopenharmony_ci COLOR_ATTACHMENT15_NV 0x8CEF 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci 1045bd8deadSopenharmony_ciChanges to Chapter 3 of the OpenGL ES 2.0 Specification (Rasterization) 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci Section 3.2, (Multisampling). Replace the second paragraph: 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci An additional buffer, called the multisample buffer, is added to the 1095bd8deadSopenharmony_ci framebuffer. Pixel sample values, including color, depth, and 1105bd8deadSopenharmony_ci stencil values, are stored in this buffer. Samples contain separate 1115bd8deadSopenharmony_ci color values for each fragment color. When the framebuffer includes 1125bd8deadSopenharmony_ci a multisample buffer, it does not include depth or stencil buffers, 1135bd8deadSopenharmony_ci even if the multisample buffer does not store depth or stencil 1145bd8deadSopenharmony_ci values. The color buffer does coexist with the multisample buffer, 1155bd8deadSopenharmony_ci however. 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ci Section 3.8.2, (Shader Execution) Replace subsection "Shader 1185bd8deadSopenharmony_ci Outputs": 1195bd8deadSopenharmony_ci 1205bd8deadSopenharmony_ci The OpenGL ES Shading Language specification describes the values 1215bd8deadSopenharmony_ci that may be output by a fragment shader. These are gl_FragColor and 1225bd8deadSopenharmony_ci gl_FragData[n]. The final fragment color values or the final 1235bd8deadSopenharmony_ci fragment data values written by a fragment shader are clamped to the 1245bd8deadSopenharmony_ci range [0, 1] and then converted to fixed-point as described in 1255bd8deadSopenharmony_ci section 2.1.2 for framebuffer color components. 1265bd8deadSopenharmony_ci 1275bd8deadSopenharmony_ci Writing to gl_FragColor specifies the fragment color (color number 1285bd8deadSopenharmony_ci zero) that will be used by subsequent stages of the pipeline. 1295bd8deadSopenharmony_ci Writing to gl_FragData[n] specifies the value of fragment color 1305bd8deadSopenharmony_ci number n. Any colors, or color components, associated with a 1315bd8deadSopenharmony_ci fragment that are not written by the fragment shader are undefined. 1325bd8deadSopenharmony_ci A fragment shader may not statically assign values to both 1335bd8deadSopenharmony_ci gl_FragColor and gl_FragData. In this case, a compile or link error 1345bd8deadSopenharmony_ci will result. A shader statically assigns a value to a variable if, 1355bd8deadSopenharmony_ci after preprocessing, it contains a statement that would write to the 1365bd8deadSopenharmony_ci variable, whether or not run-time flow of control will cause that 1375bd8deadSopenharmony_ci statement to be executed. 1385bd8deadSopenharmony_ci 1395bd8deadSopenharmony_ciChanges to Chapter 4 of the OpenGL ES 2.0 Specification (Per-Fragment 1405bd8deadSopenharmony_ciOperations and the Frame Buffer) 1415bd8deadSopenharmony_ci 1425bd8deadSopenharmony_ci Replace Section 4.2.1, "Selecting a Buffer for Writing" 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci By default, color values are written into the front buffer for 1455bd8deadSopenharmony_ci single buffered surfaces or into the back buffer for back buffered 1465bd8deadSopenharmony_ci surfaces as determined when making the context current. To control 1475bd8deadSopenharmony_ci the color buffer into which each of the fragment color values is 1485bd8deadSopenharmony_ci written, DrawBuffersNV is used. 1495bd8deadSopenharmony_ci 1505bd8deadSopenharmony_ci The command 1515bd8deadSopenharmony_ci 1525bd8deadSopenharmony_ci void DrawBuffersNV(sizei n, const enum *bufs); 1535bd8deadSopenharmony_ci 1545bd8deadSopenharmony_ci defines the draw buffers to which all fragment colors are written. 1555bd8deadSopenharmony_ci <n> specifies the number of buffers in <bufs>. <bufs> is a pointer 1565bd8deadSopenharmony_ci to an array of symbolic constants specifying the buffer to which 1575bd8deadSopenharmony_ci each fragment color is written. 1585bd8deadSopenharmony_ci 1595bd8deadSopenharmony_ci Each buffer listed in <bufs> must be NONE, COLOR_ATTACHMENT0, or 1605bd8deadSopenharmony_ci COLOR_ATTACHMENTi_NV, where <i> is the index of the color attachment 1615bd8deadSopenharmony_ci point. Otherwise, an INVALID_ENUM error is generated. DrawBuffersNV 1625bd8deadSopenharmony_ci may only be called when the GL is bound to a framebuffer object. If 1635bd8deadSopenharmony_ci called when the GL is bound to the default framebuffer, an INVALID_- 1645bd8deadSopenharmony_ci OPERATION error is generated. 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci The draw buffers being defined correspond in order to the respective 1675bd8deadSopenharmony_ci fragment colors. The draw buffer for fragment colors beyond <n> is 1685bd8deadSopenharmony_ci set to NONE. 1695bd8deadSopenharmony_ci 1705bd8deadSopenharmony_ci The maximum number of draw buffers is implementation dependent and 1715bd8deadSopenharmony_ci must be at least 1. The number of draw buffers supported can be 1725bd8deadSopenharmony_ci queried by calling GetIntegerv with the symbolic constant 1735bd8deadSopenharmony_ci MAX_DRAW_BUFFERS_NV. An INVALID_VALUE error is generated if <n> is 1745bd8deadSopenharmony_ci less than one or greater than MAX_DRAW_BUFFERS_NV. 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci Except for NONE, a buffer may not appear more then once in the array 1775bd8deadSopenharmony_ci pointed to by <bufs>. Specifying a buffer more then once will result 1785bd8deadSopenharmony_ci in the error INVALID_OPERATION. 1795bd8deadSopenharmony_ci 1805bd8deadSopenharmony_ci If a fragment shader writes to "gl_FragColor", DrawBuffersNV 1815bd8deadSopenharmony_ci specifies a set of draw buffers into which the color written to 1825bd8deadSopenharmony_ci "gl_FragColor" is written. If a fragment shader writes to 1835bd8deadSopenharmony_ci gl_FragData, DrawBuffers specifies a set of draw buffers into which 1845bd8deadSopenharmony_ci each of the multiple output colors defined by these variables are 1855bd8deadSopenharmony_ci separately written. If a fragment shader writes to neither 1865bd8deadSopenharmony_ci gl_FragColor nor gl_FragData the values of the fragment colors 1875bd8deadSopenharmony_ci following shader execution are undefined, and may differ for each 1885bd8deadSopenharmony_ci fragment color. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci If DrawBuffersNV is supplied with a constant COLOR_ATTACHMENT<m> 1915bd8deadSopenharmony_ci where <m> is greater than or equal to the value of 1925bd8deadSopenharmony_ci MAX_COLOR_ATTACHMENTS_NV, then the error INVALID_OPERATION results. 1935bd8deadSopenharmony_ci 1945bd8deadSopenharmony_ci Indicating a buffer or buffers using DrawBuffersNV causes subsequent 1955bd8deadSopenharmony_ci pixel color value writes to affect the indicated buffers. If the GL is 1965bd8deadSopenharmony_ci bound to a draw framebuffer object and a draw buffer selects an attachment 1975bd8deadSopenharmony_ci that has no image attached, then that fragment color is not written. 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci Specifying NONE as the draw buffer for a fragment color will inhibit 2005bd8deadSopenharmony_ci that fragment color from being written to any buffer. 2015bd8deadSopenharmony_ci 2025bd8deadSopenharmony_ci The state required to handle color buffer selection is an integer 2035bd8deadSopenharmony_ci for each supported fragment color. For each framebuffer object, the 2045bd8deadSopenharmony_ci initial state of the draw buffer for fragment color zero is COLOR_- 2055bd8deadSopenharmony_ci ATTACHMENT0 and the initial state of draw buffers for fragment 2065bd8deadSopenharmony_ci colors other than zero is NONE. 2075bd8deadSopenharmony_ci 2085bd8deadSopenharmony_ci The value of the draw buffer selected for fragment color <i> can be 2095bd8deadSopenharmony_ci queried by calling GetIntegerv with the symbolic constant 2105bd8deadSopenharmony_ci DRAW_BUFFER<i>_NV. 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ciChanges to Chapter 3 of the OpenGL Shading Language 1.0 Specification (Basics) 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci Add a new section: 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci 3.3.1 GL_NV_draw_buffers Extension 2175bd8deadSopenharmony_ci 2185bd8deadSopenharmony_ci To use the GL_NV_draw_buffers extension in a shader it must be 2195bd8deadSopenharmony_ci enabled using the #extension directive. 2205bd8deadSopenharmony_ci 2215bd8deadSopenharmony_ci The shading language preprocessor #define GL_NV_draw_buffers will be 2225bd8deadSopenharmony_ci defined to 1, if the GL_NV_draw_buffers extension is supported. 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ciInteractions with OpenGL ES 3.0 2255bd8deadSopenharmony_ci 2265bd8deadSopenharmony_ci Section 4.2.1 of OpenGL ES 3.0, (Selecting a Buffer for Writing). Replace 2275bd8deadSopenharmony_ci the eighth and ninth paragraph: 2285bd8deadSopenharmony_ci 2295bd8deadSopenharmony_ci If the GL is bound to a draw framebuffer object, the ith buffer listed in 2305bd8deadSopenharmony_ci bufs must be COLOR_ATTACHMENTm or NONE, where m is less than the value of 2315bd8deadSopenharmony_ci MAX_COLOR_ATTACHMENTS. Specifying BACK or COLOR_ATTACHMENTm where m is 2325bd8deadSopenharmony_ci greater than or equal to MAX_COLOR_ATTACHMENTS will generate the error 2335bd8deadSopenharmony_ci INVALID_OPERATION. 2345bd8deadSopenharmony_ci 2355bd8deadSopenharmony_ci If an OpenGL ES Shading Language 1.00 or 3.00 fragment shader writes a 2365bd8deadSopenharmony_ci user-defined varying out variable, DrawBuffers specifies a set of draw 2375bd8deadSopenharmony_ci buffers into which each of the multiple output colors defined by these 2385bd8deadSopenharmony_ci variables are separately written. If a fragment shader writes to none of 2395bd8deadSopenharmony_ci gl_FragColor, gl_FragData, nor any user-defined output variables, the 2405bd8deadSopenharmony_ci values of the fragment colors following shader execution are undefined, and 2415bd8deadSopenharmony_ci may differ for each fragment color. If some, but not all user-defined 2425bd8deadSopenharmony_ci output variables are written, the values of fragment colors corresponding 2435bd8deadSopenharmony_ci to unwritten variables are similarly undefined. 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ciNew State 2465bd8deadSopenharmony_ci 2475bd8deadSopenharmony_ci Add Table 6.X Framebuffer (State per framebuffer object): 2485bd8deadSopenharmony_ci 2495bd8deadSopenharmony_ci State Type Get Command Initial Value Description 2505bd8deadSopenharmony_ci --------------- ---- ------------ ------------- ----------- 2515bd8deadSopenharmony_ci DRAW_BUFFERi_NV Z10* GetIntegerv see 4.2.1 Draw buffer selected 2525bd8deadSopenharmony_ci for fragment color i 2535bd8deadSopenharmony_ci 2545bd8deadSopenharmony_ci Add the new Table 6.X "Framebuffer Dependent Values" : 2555bd8deadSopenharmony_ci 2565bd8deadSopenharmony_ci State Type Get Command Min Value Description 2575bd8deadSopenharmony_ci ------------------- ---- ----------- --------- ----------- 2585bd8deadSopenharmony_ci MAX_DRAW_BUFFERS_NV Z+ GetIntegerv 1 Maximum number of 2595bd8deadSopenharmony_ci active draw buffers 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ciIssues 2625bd8deadSopenharmony_ci 2635bd8deadSopenharmony_ci 1. What behavior should be expected if a draw buffer selects an attachment 2645bd8deadSopenharmony_ci for a draw framebuffer that has no image attached? 2655bd8deadSopenharmony_ci 2665bd8deadSopenharmony_ci Early drivers considered this an INVALID_OPERATION and the DrawBuffersNV 2675bd8deadSopenharmony_ci operation did not succeed. (Following precedent set in Issue 55 of 2685bd8deadSopenharmony_ci EXT_framebuffer_object) 2695bd8deadSopenharmony_ci 2705bd8deadSopenharmony_ci OpenGL ES 3.0 and Desktop GL 4.3 consider this legal, and the DrawBuffers 2715bd8deadSopenharmony_ci call succeeds. Missing attachments are simply not written to. 2725bd8deadSopenharmony_ci 2735bd8deadSopenharmony_ci RESOLVED: Behavior should match OpenGL ES 3.0. Application developers are 2745bd8deadSopenharmony_ci cautioned that early Tegra drivers may exhibit the previous behavior. 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ci See ARB_draw_buffers for additional relevant issues. 2775bd8deadSopenharmony_ci 2785bd8deadSopenharmony_ciRevision History 2795bd8deadSopenharmony_ci 2805bd8deadSopenharmony_ci Rev. Date Author Changes 2815bd8deadSopenharmony_ci ---- -------- --------- ------------------------------------ 2825bd8deadSopenharmony_ci 4 07/11/13 jhelferty Updated error behavior for missing 2835bd8deadSopenharmony_ci attachments to match ES 3.0. 2845bd8deadSopenharmony_ci Clarified ES 3.0 interactions. 2855bd8deadSopenharmony_ci 3 06/07/11 groth Clarified default behavior, state tables. 2865bd8deadSopenharmony_ci 2 04/26/11 groth Filled in many missing elements. 2875bd8deadSopenharmony_ci 1 03/03/08 kashida First revision based on 2885bd8deadSopenharmony_ci ARB_draw_buffers. 289