15bd8deadSopenharmony_ciName 25bd8deadSopenharmony_ci 35bd8deadSopenharmony_ci ARB_draw_buffers 45bd8deadSopenharmony_ci 55bd8deadSopenharmony_ciName Strings 65bd8deadSopenharmony_ci 75bd8deadSopenharmony_ci GL_ARB_draw_buffers 85bd8deadSopenharmony_ci 95bd8deadSopenharmony_ciContributors 105bd8deadSopenharmony_ci 115bd8deadSopenharmony_ci Benj Lipchak, AMD 125bd8deadSopenharmony_ci Bill Licea-Kane, AMD 135bd8deadSopenharmony_ci 145bd8deadSopenharmony_ciContact 155bd8deadSopenharmony_ci 165bd8deadSopenharmony_ci Rob Mace, NVIDIA (rmace 'at' nvidia.com) 175bd8deadSopenharmony_ci 185bd8deadSopenharmony_ciNotice 195bd8deadSopenharmony_ci 205bd8deadSopenharmony_ci Copyright (c) 2004-2013 The Khronos Group Inc. Copyright terms at 215bd8deadSopenharmony_ci http://www.khronos.org/registry/speccopyright.html 225bd8deadSopenharmony_ci 235bd8deadSopenharmony_ciSpecification Update Policy 245bd8deadSopenharmony_ci 255bd8deadSopenharmony_ci Khronos-approved extension specifications are updated in response to 265bd8deadSopenharmony_ci issues and bugs prioritized by the Khronos OpenGL Working Group. For 275bd8deadSopenharmony_ci extensions which have been promoted to a core Specification, fixes will 285bd8deadSopenharmony_ci first appear in the latest version of that core Specification, and will 295bd8deadSopenharmony_ci eventually be backported to the extension document. This policy is 305bd8deadSopenharmony_ci described in more detail at 315bd8deadSopenharmony_ci https://www.khronos.org/registry/OpenGL/docs/update_policy.php 325bd8deadSopenharmony_ci 335bd8deadSopenharmony_ciIP Status 345bd8deadSopenharmony_ci 355bd8deadSopenharmony_ci No known IP issues. 365bd8deadSopenharmony_ci 375bd8deadSopenharmony_ciStatus 385bd8deadSopenharmony_ci 395bd8deadSopenharmony_ci Complete. Approved by the ARB on July 23, 2004. 405bd8deadSopenharmony_ci 415bd8deadSopenharmony_ciVersion 425bd8deadSopenharmony_ci 435bd8deadSopenharmony_ci Last Modified Date: February 19, 2008 445bd8deadSopenharmony_ci Revision: 17 455bd8deadSopenharmony_ci 465bd8deadSopenharmony_ciNumber 475bd8deadSopenharmony_ci 485bd8deadSopenharmony_ci ARB Extension #37 495bd8deadSopenharmony_ci 505bd8deadSopenharmony_ciDependencies 515bd8deadSopenharmony_ci 525bd8deadSopenharmony_ci The extension is written against the OpenGL 1.5 Specification. 535bd8deadSopenharmony_ci 545bd8deadSopenharmony_ci OpenGL 1.3 is required. 555bd8deadSopenharmony_ci 565bd8deadSopenharmony_ci ARB_fragment_program affects the definition of this extension. 575bd8deadSopenharmony_ci 585bd8deadSopenharmony_ci ARB_fragment_shader affects the definition of this extension. 595bd8deadSopenharmony_ci 605bd8deadSopenharmony_ci 615bd8deadSopenharmony_ciOverview 625bd8deadSopenharmony_ci 635bd8deadSopenharmony_ci This extension extends ARB_fragment_program and ARB_fragment_shader 645bd8deadSopenharmony_ci to allow multiple output colors, and provides a mechanism for 655bd8deadSopenharmony_ci directing those outputs to multiple color buffers. 665bd8deadSopenharmony_ci 675bd8deadSopenharmony_ci 685bd8deadSopenharmony_ciIssues 695bd8deadSopenharmony_ci 705bd8deadSopenharmony_ci (1) How many GL_DRAW_BUFFER#_ARB enums should be reserved? 715bd8deadSopenharmony_ci 725bd8deadSopenharmony_ci RESOLVED: We only need 4 currently, but for future expandability 735bd8deadSopenharmony_ci it would be nice to keep the enums in sequence. We'll specify 745bd8deadSopenharmony_ci 16 for now, which will be more than enough for a long time. 755bd8deadSopenharmony_ci 765bd8deadSopenharmony_ci (2) How should multisample work when there are multiple output 775bd8deadSopenharmony_ci colors being rendered to multiple draw buffers? 785bd8deadSopenharmony_ci 795bd8deadSopenharmony_ci Basic options are: 805bd8deadSopenharmony_ci (a) Color 0 is written to the multisample buffer and then the 815bd8deadSopenharmony_ci multisample buffer is resolved to all the color buffers. 825bd8deadSopenharmony_ci This option would be consistent with GL's idea of a single 835bd8deadSopenharmony_ci multisample buffer, but would be really useless and defeat 845bd8deadSopenharmony_ci the purpose of multiple output colors. 855bd8deadSopenharmony_ci (b) Have a separate multisample color buffer for each output 865bd8deadSopenharmony_ci color/draw buffer. This would be useful but would all 875bd8deadSopenharmony_ci implementations be able to handle it? 885bd8deadSopenharmony_ci (c) Don't allow multiple output colors and multisampling to 895bd8deadSopenharmony_ci be combined by restricting MAX_DRAW_BUFFERS_ARB to 1 905bd8deadSopenharmony_ci for contexts with multisample buffers. This is simple 915bd8deadSopenharmony_ci and would allow a future extension to allow (b). 925bd8deadSopenharmony_ci 935bd8deadSopenharmony_ci RESOLUTION: (b) and (c). Samples will contain separate color 945bd8deadSopenharmony_ci values for each output color. Implementations that can not 955bd8deadSopenharmony_ci support this can restrict MAX_DRAW_BUFFERS_ARB to 1 for contexts 965bd8deadSopenharmony_ci with multisample buffers. 975bd8deadSopenharmony_ci 985bd8deadSopenharmony_ci (3) Should gl_FragColor be aliased to gl_FragData[0]? 995bd8deadSopenharmony_ci 1005bd8deadSopenharmony_ci RESOLUTION: No. A shader should write either gl_FragColor, or 1015bd8deadSopenharmony_ci gl_FragData[n], but not both. 1025bd8deadSopenharmony_ci 1035bd8deadSopenharmony_ci Writing to gl_FragColor will write to all draw buffers specified 1045bd8deadSopenharmony_ci with DrawBuffersARB. 1055bd8deadSopenharmony_ci 1065bd8deadSopenharmony_ci (4) Should gl_FragData[n] be clamped? 1075bd8deadSopenharmony_ci 1085bd8deadSopenharmony_ci RESOLUTION: They will be clamped if fragment color clamping is 1095bd8deadSopenharmony_ci enabled. 1105bd8deadSopenharmony_ci 1115bd8deadSopenharmony_ci 1125bd8deadSopenharmony_ciNew Procedures and Functions 1135bd8deadSopenharmony_ci 1145bd8deadSopenharmony_ci void DrawBuffersARB(sizei n, const enum *bufs); 1155bd8deadSopenharmony_ci 1165bd8deadSopenharmony_ci 1175bd8deadSopenharmony_ciNew Tokens 1185bd8deadSopenharmony_ci 1195bd8deadSopenharmony_ci Accepted by the <pname> parameters of GetIntegerv, GetFloatv, 1205bd8deadSopenharmony_ci and GetDoublev: 1215bd8deadSopenharmony_ci 1225bd8deadSopenharmony_ci MAX_DRAW_BUFFERS_ARB 0x8824 1235bd8deadSopenharmony_ci DRAW_BUFFER0_ARB 0x8825 1245bd8deadSopenharmony_ci DRAW_BUFFER1_ARB 0x8826 1255bd8deadSopenharmony_ci DRAW_BUFFER2_ARB 0x8827 1265bd8deadSopenharmony_ci DRAW_BUFFER3_ARB 0x8828 1275bd8deadSopenharmony_ci DRAW_BUFFER4_ARB 0x8829 1285bd8deadSopenharmony_ci DRAW_BUFFER5_ARB 0x882A 1295bd8deadSopenharmony_ci DRAW_BUFFER6_ARB 0x882B 1305bd8deadSopenharmony_ci DRAW_BUFFER7_ARB 0x882C 1315bd8deadSopenharmony_ci DRAW_BUFFER8_ARB 0x882D 1325bd8deadSopenharmony_ci DRAW_BUFFER9_ARB 0x882E 1335bd8deadSopenharmony_ci DRAW_BUFFER10_ARB 0x882F 1345bd8deadSopenharmony_ci DRAW_BUFFER11_ARB 0x8830 1355bd8deadSopenharmony_ci DRAW_BUFFER12_ARB 0x8831 1365bd8deadSopenharmony_ci DRAW_BUFFER13_ARB 0x8832 1375bd8deadSopenharmony_ci DRAW_BUFFER14_ARB 0x8833 1385bd8deadSopenharmony_ci DRAW_BUFFER15_ARB 0x8834 1395bd8deadSopenharmony_ci 1405bd8deadSopenharmony_ci 1415bd8deadSopenharmony_ciAdditions to Chapter 2 of the OpenGL 1.5 Specification (OpenGL 1425bd8deadSopenharmony_ciOperation) 1435bd8deadSopenharmony_ci 1445bd8deadSopenharmony_ci None 1455bd8deadSopenharmony_ci 1465bd8deadSopenharmony_ci 1475bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL 1.5 Specification (Rasterization) 1485bd8deadSopenharmony_ci 1495bd8deadSopenharmony_ci Modify Section 3.2.1, Multisampling (p. 71) 1505bd8deadSopenharmony_ci 1515bd8deadSopenharmony_ci (replace the second paragraph with) 1525bd8deadSopenharmony_ci 1535bd8deadSopenharmony_ci An additional buffer, called the multisample buffer, is added to the 1545bd8deadSopenharmony_ci framebuffer. Pixel sample values, including color, depth, and 1555bd8deadSopenharmony_ci stencil values, are stored in this buffer. Samples contain separate 1565bd8deadSopenharmony_ci color values for each output color. When the framebuffer includes a 1575bd8deadSopenharmony_ci multisample buffer, it does not include depth or stencil buffers, 1585bd8deadSopenharmony_ci even if the multisample buffer does not store depth or stencil 1595bd8deadSopenharmony_ci values. Color buffers (left, right, front, back, and aux) do coexist 1605bd8deadSopenharmony_ci with the multisample buffer, however. 1615bd8deadSopenharmony_ci 1625bd8deadSopenharmony_ci 1635bd8deadSopenharmony_ci Modify Section 3.11.2, Fragment Program Grammar and Semantic 1645bd8deadSopenharmony_ci Restrictions (ARB_fragment_program) 1655bd8deadSopenharmony_ci 1665bd8deadSopenharmony_ci (replace <resultBinding> grammar rule with these rules) 1675bd8deadSopenharmony_ci 1685bd8deadSopenharmony_ci <resultBinding> ::= "result" "." "color" <optOutputColorNum> 1695bd8deadSopenharmony_ci | "result" "." "depth" 1705bd8deadSopenharmony_ci 1715bd8deadSopenharmony_ci <optOutputColorNum> ::= "" 1725bd8deadSopenharmony_ci | "[" <outputColorNum> "]" 1735bd8deadSopenharmony_ci 1745bd8deadSopenharmony_ci <outputColorNum> ::= <integer> from 0 to MAX_DRAW_BUFFERS_ARB-1 1755bd8deadSopenharmony_ci 1765bd8deadSopenharmony_ci 1775bd8deadSopenharmony_ci Modify Section 3.11.3.4, Fragment Program Results 1785bd8deadSopenharmony_ci 1795bd8deadSopenharmony_ci (modify Table X.3) 1805bd8deadSopenharmony_ci 1815bd8deadSopenharmony_ci Binding Components Description 1825bd8deadSopenharmony_ci ----------------------------- ---------- ---------------------------- 1835bd8deadSopenharmony_ci result.color[n] (r,g,b,a) color n 1845bd8deadSopenharmony_ci result.depth (*,*,*,d) depth coordinate 1855bd8deadSopenharmony_ci 1865bd8deadSopenharmony_ci Table X.3: Fragment Result Variable Bindings. Components labeled 1875bd8deadSopenharmony_ci "*" are unused. "[n]" is optional -- color <n> is used if 1885bd8deadSopenharmony_ci specified; color 0 is used otherwise. 1895bd8deadSopenharmony_ci 1905bd8deadSopenharmony_ci (modify third paragraph) If a result variable binding matches 1915bd8deadSopenharmony_ci "result.color[n]", updates to the "x", "y", "z", and "w" components 1925bd8deadSopenharmony_ci of the result variable modify the "r", "g", "b", and "a" components, 1935bd8deadSopenharmony_ci respectively, of the fragment's corresponding output color. If 1945bd8deadSopenharmony_ci "result.color[n]" is not both bound by the fragment program and 1955bd8deadSopenharmony_ci written by some instruction of the program, the output color <n> of 1965bd8deadSopenharmony_ci the fragment program is undefined. 1975bd8deadSopenharmony_ci 1985bd8deadSopenharmony_ci 1995bd8deadSopenharmony_ci Add a new Section 3.11.4.5.3 (ARB_fragment_program) 2005bd8deadSopenharmony_ci 2015bd8deadSopenharmony_ci 3.11.4.5.3 Draw Buffers Program Option 2025bd8deadSopenharmony_ci 2035bd8deadSopenharmony_ci If a fragment program specifies the "ARB_draw_buffers" option, 2045bd8deadSopenharmony_ci it will generate multiple output colors, and the result binding 2055bd8deadSopenharmony_ci "result.color[n]" is allowed, as described in section 3.11.3.4, 2065bd8deadSopenharmony_ci and with modified grammar rules as set forth in section 3.11.2. 2075bd8deadSopenharmony_ci If this option is not specified, a fragment program that attempts 2085bd8deadSopenharmony_ci to bind "result.color[n]" will fail to load, and only "result.color" 2095bd8deadSopenharmony_ci will be allowed. 2105bd8deadSopenharmony_ci 2115bd8deadSopenharmony_ci 2125bd8deadSopenharmony_ci Add a new section 3.11.6 (ARB_fragment_shader) 2135bd8deadSopenharmony_ci 2145bd8deadSopenharmony_ci Section 3.11.6 Fragment Shader Output 2155bd8deadSopenharmony_ci 2165bd8deadSopenharmony_ci The OpenGL Shading Language specification describes the values that 2175bd8deadSopenharmony_ci may be output by a fragment shader. These are gl_FragColor, 2185bd8deadSopenharmony_ci gl_FragData[n], and gl_FragDepth. If fragment color clamping is 2195bd8deadSopenharmony_ci enabled, the final fragment color values or the final fragment data 2205bd8deadSopenharmony_ci values written by a fragment shader are clamped to the range [0,1] 2215bd8deadSopenharmony_ci and then converted to fixed-point as described in section 2.13.9, 2225bd8deadSopenharmony_ci Final Color Processing. 2235bd8deadSopenharmony_ci 2245bd8deadSopenharmony_ci The final fragment depth written by a fragment shader is first 2255bd8deadSopenharmony_ci clamped to [0,1] then converted to fixed-point as if it were a 2265bd8deadSopenharmony_ci window z value. See Section 2.10.1, Controlling the Viewport. Note 2275bd8deadSopenharmony_ci that the depth range computation is NOT applied here, only the 2285bd8deadSopenharmony_ci conversion to fixed-point. 2295bd8deadSopenharmony_ci 2305bd8deadSopenharmony_ci The OpenGL Shading Language specification defines what happens when 2315bd8deadSopenharmony_ci color and/or depth are not written. Those rules are repeated here. 2325bd8deadSopenharmony_ci 2335bd8deadSopenharmony_ci Writing to gl_FragColor specifies the fragment color that will be 2345bd8deadSopenharmony_ci used by the subsequent fixed functionality pipeline. If subsequent 2355bd8deadSopenharmony_ci fixed functionality consumes fragment color and an execution of a 2365bd8deadSopenharmony_ci fragment shader does not write a value to gl_FragColor then the 2375bd8deadSopenharmony_ci fragment color consumed is undefined. 2385bd8deadSopenharmony_ci 2395bd8deadSopenharmony_ci Writing to gl_FragData[n] specifies the fragment data that will be 2405bd8deadSopenharmony_ci used by the subsequent fixed functionality pipeline. If subsequent 2415bd8deadSopenharmony_ci fixed functionality consumes fragment data and an execution of a 2425bd8deadSopenharmony_ci fragment shader does not write a value to gl_FragData[n] then the 2435bd8deadSopenharmony_ci fragment data consumed is undefined. 2445bd8deadSopenharmony_ci 2455bd8deadSopenharmony_ci If a shader statically assigns a value to gl_FragColor, it may not 2465bd8deadSopenharmony_ci assign a value to gl_FragData[n]. If a shader statically writes a 2475bd8deadSopenharmony_ci value to gl_FragData[n], it may not assign a value to gl_FragColor. 2485bd8deadSopenharmony_ci That is, a shader may assign values to either gl_FragColor or 2495bd8deadSopenharmony_ci gl_FragData[n], but not both. 2505bd8deadSopenharmony_ci 2515bd8deadSopenharmony_ci Writing to gl_FragDepth will establish the depth value for the 2525bd8deadSopenharmony_ci fragment being processed. If depth buffering is enabled, and a 2535bd8deadSopenharmony_ci shader does not write gl_FragDepth, then the fixed function value 2545bd8deadSopenharmony_ci for depth will be used as the fragment's depth value. If a shader 2555bd8deadSopenharmony_ci statically assigns a value to gl_FragDepth, and there is an 2565bd8deadSopenharmony_ci execution path through the shader that does not set gl_FragDepth, 2575bd8deadSopenharmony_ci then the value of the fragment's depth may be undefined for some 2585bd8deadSopenharmony_ci executions of the shader. That is, if a shader statically writes 2595bd8deadSopenharmony_ci gl_FragDepth, then it is responsible for always writing it. 2605bd8deadSopenharmony_ci 2615bd8deadSopenharmony_ci Note, statically assigning a value to gl_FragColor, gl_FragData[n] 2625bd8deadSopenharmony_ci or gl_FragDepth means that there is a line of code in the fragment 2635bd8deadSopenharmony_ci shader source that writes a value to gl_FragColor, gl_FragData[n] 2645bd8deadSopenharmony_ci or gl_FragDepth, respectively, even if that line of code is never 2655bd8deadSopenharmony_ci executed. 2665bd8deadSopenharmony_ci 2675bd8deadSopenharmony_ci 2685bd8deadSopenharmony_ciAdditions to Chapter 4 of the OpenGL 1.5 Specification (Per-Fragment 2695bd8deadSopenharmony_ciOperations and the Frame Buffer) 2705bd8deadSopenharmony_ci 2715bd8deadSopenharmony_ci 2725bd8deadSopenharmony_ci Replace Section 4.2.1, Selecting a Buffer for Writing (p. 183) 2735bd8deadSopenharmony_ci 2745bd8deadSopenharmony_ci 4.2.1 Selecting Color Buffers for Writing 2755bd8deadSopenharmony_ci 2765bd8deadSopenharmony_ci The first such operation is controlling the color buffers into 2775bd8deadSopenharmony_ci which each of the output colors are written. This is accomplished 2785bd8deadSopenharmony_ci with either DrawBuffer or DrawBuffersARB. 2795bd8deadSopenharmony_ci 2805bd8deadSopenharmony_ci The command 2815bd8deadSopenharmony_ci 2825bd8deadSopenharmony_ci void DrawBuffer(enum buf); 2835bd8deadSopenharmony_ci 2845bd8deadSopenharmony_ci defines the set of color buffers to which output color 0 is written. 2855bd8deadSopenharmony_ci <buf> is a symbolic constant specifying zero, one, two, or four 2865bd8deadSopenharmony_ci buffers for writing. The constants are NONE, FRONT_LEFT, 2875bd8deadSopenharmony_ci FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, FRONT, BACK, LEFT, RIGHT, 2885bd8deadSopenharmony_ci FRONT_AND_BACK, and AUX0 through AUXn, where n + 1 is the number 2895bd8deadSopenharmony_ci of available auxiliary buffers. 2905bd8deadSopenharmony_ci 2915bd8deadSopenharmony_ci The constants refer to the four potentially visible buffers front 2925bd8deadSopenharmony_ci left, front right, back left, and back right, and to the auxiliary 2935bd8deadSopenharmony_ci buffers. Arguments other than AUXi that omit reference to LEFT or 2945bd8deadSopenharmony_ci RIGHT refer to both left and right buffers. Arguments other than 2955bd8deadSopenharmony_ci AUXi that omit reference to FRONT or BACK refer to both front and 2965bd8deadSopenharmony_ci back buffers. AUXi enables drawing only to auxiliary buffer i. 2975bd8deadSopenharmony_ci Each AUXi adheres to AUXi = AUX0 + i. The constants and the buffers 2985bd8deadSopenharmony_ci they indicate are summarized in Table 4.3. If DrawBuffer is 2995bd8deadSopenharmony_ci supplied with a constant (other than NONE) that does not indicate 3005bd8deadSopenharmony_ci any of the color buffers allocated to the GL context, the error 3015bd8deadSopenharmony_ci INVALID_OPERATION results. 3025bd8deadSopenharmony_ci 3035bd8deadSopenharmony_ci symbolic front front back back aux 3045bd8deadSopenharmony_ci constant left right left right i 3055bd8deadSopenharmony_ci -------- ----- ----- ---- ----- --- 3065bd8deadSopenharmony_ci NONE 3075bd8deadSopenharmony_ci FRONT_LEFT * 3085bd8deadSopenharmony_ci FRONT_RIGHT * 3095bd8deadSopenharmony_ci BACK_LEFT * 3105bd8deadSopenharmony_ci BACK_RIGHT * 3115bd8deadSopenharmony_ci FRONT * * 3125bd8deadSopenharmony_ci BACK * * 3135bd8deadSopenharmony_ci LEFT * * 3145bd8deadSopenharmony_ci RIGHT * * 3155bd8deadSopenharmony_ci FRONT_AND_BACK * * * * 3165bd8deadSopenharmony_ci AUXi * 3175bd8deadSopenharmony_ci 3185bd8deadSopenharmony_ci Table 4.3: Arguments to DrawBuffer and the buffers that they 3195bd8deadSopenharmony_ci indicate. 3205bd8deadSopenharmony_ci 3215bd8deadSopenharmony_ci 3225bd8deadSopenharmony_ci DrawBuffer will set the draw buffer for output colors other than 0 3235bd8deadSopenharmony_ci to NONE. 3245bd8deadSopenharmony_ci 3255bd8deadSopenharmony_ci The command 3265bd8deadSopenharmony_ci 3275bd8deadSopenharmony_ci void DrawBuffersARB(sizei n, const enum *bufs); 3285bd8deadSopenharmony_ci 3295bd8deadSopenharmony_ci defines the draw buffers to which all output colors are written. 3305bd8deadSopenharmony_ci <n> specifies the number of buffers in <bufs>. <bufs> is a pointer 3315bd8deadSopenharmony_ci to an array of symbolic constants specifying the buffer to which 3325bd8deadSopenharmony_ci each output color is written. The constants may be NONE, 3335bd8deadSopenharmony_ci FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, and AUX0 through 3345bd8deadSopenharmony_ci AUXn, where n + 1 is the number of available auxiliary buffers. The 3355bd8deadSopenharmony_ci draw buffers being defined correspond in order to the respective 3365bd8deadSopenharmony_ci output colors. The draw buffer for output colors beyond <n> is set 3375bd8deadSopenharmony_ci to NONE. 3385bd8deadSopenharmony_ci 3395bd8deadSopenharmony_ci Except for NONE, a buffer should not appear more then once in the 3405bd8deadSopenharmony_ci array pointed to by <bufs>. Specifying a buffer more then once 3415bd8deadSopenharmony_ci will result in the error INVALID_OPERATION. 3425bd8deadSopenharmony_ci 3435bd8deadSopenharmony_ci If a fragment program is not using the "ARB_draw_buffers" option, 3445bd8deadSopenharmony_ci DrawBuffersARB specifies a set of draw buffers into which output 3455bd8deadSopenharmony_ci color 0 is written. 3465bd8deadSopenharmony_ci 3475bd8deadSopenharmony_ci If a fragment shader writes to "gl_FragColor", DrawBuffersARB 3485bd8deadSopenharmony_ci specifies a set of draw buffers into which the color written to 3495bd8deadSopenharmony_ci "gl_FragColor" is written. 3505bd8deadSopenharmony_ci 3515bd8deadSopenharmony_ci The maximum number of draw buffers is implementation dependent and 3525bd8deadSopenharmony_ci must be at least 1. The number of draw buffers supported can 3535bd8deadSopenharmony_ci be queried with the state MAX_DRAW_BUFFERS_ARB. 3545bd8deadSopenharmony_ci 3555bd8deadSopenharmony_ci The constants FRONT, BACK, LEFT, RIGHT, and FRONT_AND_BACK that 3565bd8deadSopenharmony_ci refer to multiple buffers are not valid for use in DrawBuffersARB 3575bd8deadSopenharmony_ci and will result in the error INVALID_OPERATION. 3585bd8deadSopenharmony_ci 3595bd8deadSopenharmony_ci If DrawBuffersARB is supplied with a constant (other than NONE) 3605bd8deadSopenharmony_ci that does not indicate any of the color buffers allocated to 3615bd8deadSopenharmony_ci the GL context, the error INVALID_OPERATION will be generated. If 3625bd8deadSopenharmony_ci <n> is greater than MAX_DRAW_BUFFERS_ARB, the error 3635bd8deadSopenharmony_ci INVALID_OPERATION will be generated. 3645bd8deadSopenharmony_ci 3655bd8deadSopenharmony_ci Indicating a buffer or buffers using DrawBuffer or DrawBuffersARB 3665bd8deadSopenharmony_ci causes subsequent pixel color value writes to affect the indicated 3675bd8deadSopenharmony_ci buffers. If more than one color buffer is selected for drawing, 3685bd8deadSopenharmony_ci blending and logical operations are computed and applied 3695bd8deadSopenharmony_ci independently for each buffer. If there are multiple output colors 3705bd8deadSopenharmony_ci being written to multiple buffers, the alpha used in alpha to 3715bd8deadSopenharmony_ci coverage and alpha test is the alpha of output color 0. 3725bd8deadSopenharmony_ci 3735bd8deadSopenharmony_ci Specifying NONE as the draw buffer for an output color will inhibit 3745bd8deadSopenharmony_ci that output color from being written to any buffer. 3755bd8deadSopenharmony_ci 3765bd8deadSopenharmony_ci Monoscopic contexts include only left buffers, while stereoscopic 3775bd8deadSopenharmony_ci contexts include both left and right buffers. Likewise, single 3785bd8deadSopenharmony_ci buffered contexts include only front buffers, while double buffered 3795bd8deadSopenharmony_ci contexts include both front and back buffers. The type of context 3805bd8deadSopenharmony_ci is selected at GL initialization. 3815bd8deadSopenharmony_ci 3825bd8deadSopenharmony_ci The state required to handle color buffer selection is an integer 3835bd8deadSopenharmony_ci for each supported output color. In the initial state, draw buffer 3845bd8deadSopenharmony_ci for output color 0 is FRONT if there are no back buffers; otherwise 3855bd8deadSopenharmony_ci it is BACK. The initial state of draw buffers for output colors 3865bd8deadSopenharmony_ci other then 0 is NONE. 3875bd8deadSopenharmony_ci 3885bd8deadSopenharmony_ci 3895bd8deadSopenharmony_ciAdditions to Chapter 5 of the OpenGL 1.5 Specification (Special 3905bd8deadSopenharmony_ciFunctions) 3915bd8deadSopenharmony_ci 3925bd8deadSopenharmony_ci None 3935bd8deadSopenharmony_ci 3945bd8deadSopenharmony_ci 3955bd8deadSopenharmony_ciAdditions to Chapter 6 of the OpenGL 1.5 Specification (State and 3965bd8deadSopenharmony_ciState Requests) 3975bd8deadSopenharmony_ci 3985bd8deadSopenharmony_ci None 3995bd8deadSopenharmony_ci 4005bd8deadSopenharmony_ci 4015bd8deadSopenharmony_ciAdditions to Chapter 3 of the OpenGL Shading Language 1.10 Specification 4025bd8deadSopenharmony_ci(Basics) 4035bd8deadSopenharmony_ci 4045bd8deadSopenharmony_ci Add a new Section 3.3.1, GL_ARB_draw_buffers Extension (p. 13) 4055bd8deadSopenharmony_ci 4065bd8deadSopenharmony_ci 3.3.1 GL_ARB_draw_buffers Extension 4075bd8deadSopenharmony_ci 4085bd8deadSopenharmony_ci To use the GL_ARB_draw_buffers extension in a shader it must be 4095bd8deadSopenharmony_ci enabled using the #extension directive. 4105bd8deadSopenharmony_ci 4115bd8deadSopenharmony_ci The shading language preprocessor #define GL_ARB_draw_buffers will 4125bd8deadSopenharmony_ci be defined to 1, if the GL_ARB_draw_buffers extension is supported. 4135bd8deadSopenharmony_ci 4145bd8deadSopenharmony_ci 4155bd8deadSopenharmony_ciDependencies on ARB_fragment_program 4165bd8deadSopenharmony_ci 4175bd8deadSopenharmony_ci If ARB_fragment_program is not supported then all changes to 4185bd8deadSopenharmony_ci section 3.11 of ARB_fragment_program and the fragment program 4195bd8deadSopenharmony_ci specific part of section 4.2.1 are removed. 4205bd8deadSopenharmony_ci 4215bd8deadSopenharmony_ci 4225bd8deadSopenharmony_ciDependencies on ARB_fragment_shader 4235bd8deadSopenharmony_ci 4245bd8deadSopenharmony_ci If ARB_fragment_shader is not supported then all changes to 4255bd8deadSopenharmony_ci section 3.11 of ARB_fragment_shader, section 3.3.1 of the Shading 4265bd8deadSopenharmony_ci Language Specification, and the fragment shader specific part of 4275bd8deadSopenharmony_ci section 4.2.1 are removed. 4285bd8deadSopenharmony_ci 4295bd8deadSopenharmony_ci 4305bd8deadSopenharmony_ciInteractions with possible future extensions 4315bd8deadSopenharmony_ci 4325bd8deadSopenharmony_ci If there is some other future extension that defines multiple 4335bd8deadSopenharmony_ci color outputs then this extension and glDrawBuffersARB could be 4345bd8deadSopenharmony_ci used to define the destinations for those outputs. This extension 4355bd8deadSopenharmony_ci need not be used only with ARB_fragment_program. 4365bd8deadSopenharmony_ci 4375bd8deadSopenharmony_ciGLX Protocol 4385bd8deadSopenharmony_ci 4395bd8deadSopenharmony_ci The following rendering command is potentially large, and hence can 4405bd8deadSopenharmony_ci be sent in a glxRender or glxRenderLarge request. 4415bd8deadSopenharmony_ci 4425bd8deadSopenharmony_ci DrawBuffersARB 4435bd8deadSopenharmony_ci 2 8+(4*n) rendering command length 4445bd8deadSopenharmony_ci 2 233 rendering command opcode 4455bd8deadSopenharmony_ci 4 CARD32 n 4465bd8deadSopenharmony_ci n*4 LISTofCARD32 list of draw buffers 4475bd8deadSopenharmony_ci 4485bd8deadSopenharmony_ci If the command is encoded in a glxRenderLarge request, the command 4495bd8deadSopenharmony_ci opcode and command length fields above are expanded to 4 bytes each: 4505bd8deadSopenharmony_ci 4515bd8deadSopenharmony_ci 4 12+(4*n) rendering command length 4525bd8deadSopenharmony_ci 4 233 rendering command opcode 4535bd8deadSopenharmony_ci 4545bd8deadSopenharmony_ciErrors 4555bd8deadSopenharmony_ci 4565bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by DrawBuffersARB if a 4575bd8deadSopenharmony_ci color buffer not currently allocated to the GL context is specified. 4585bd8deadSopenharmony_ci 4595bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by DrawBuffersARB if <n> 4605bd8deadSopenharmony_ci is greater than the state MAX_DRAW_BUFFERS_ARB. 4615bd8deadSopenharmony_ci 4625bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by DrawBuffersARB if value 4635bd8deadSopenharmony_ci in <bufs> does not correspond to one of the allowed buffers. 4645bd8deadSopenharmony_ci 4655bd8deadSopenharmony_ci The error INVALID_OPERATION is generated by DrawBuffersARB if a draw 4665bd8deadSopenharmony_ci buffer other then NONE is specified more then once in <bufs>. 4675bd8deadSopenharmony_ci 4685bd8deadSopenharmony_ci 4695bd8deadSopenharmony_ciNew State 4705bd8deadSopenharmony_ci 4715bd8deadSopenharmony_ci (table 6.19, p227) add the following entry: 4725bd8deadSopenharmony_ci 4735bd8deadSopenharmony_ci Get Value Type Get Command Initial Value Description Section Attribute 4745bd8deadSopenharmony_ci ------------------------------- ------ ------------- ------------- -------------------- ------------ ------------ 4755bd8deadSopenharmony_ci DRAW_BUFFERi_ARB Z10* GetIntegerv see 4.2.1 Draw buffer selected 4.2.1 color-buffer 4765bd8deadSopenharmony_ci for output color i 4775bd8deadSopenharmony_ci 4785bd8deadSopenharmony_ci 4795bd8deadSopenharmony_ciNew Implementation Dependent State 4805bd8deadSopenharmony_ci 4815bd8deadSopenharmony_ci Get Value Type Get Command Minimum Value Description Sec. Attribute 4825bd8deadSopenharmony_ci --------- ---- ----------- ------------- ------------------- ----- --------- 4835bd8deadSopenharmony_ci MAX_DRAW_BUFFERS_ARB Z+ GetIntegerv 1 Maximum number of 4.2.1 - 4845bd8deadSopenharmony_ci active draw buffers 4855bd8deadSopenharmony_ci 4865bd8deadSopenharmony_ci 4875bd8deadSopenharmony_ciRevision History 4885bd8deadSopenharmony_ci 4895bd8deadSopenharmony_ci Date: 2/19/2008 4905bd8deadSopenharmony_ci Revision: 17 (Mark Kilgard, NVIDIA) 4915bd8deadSopenharmony_ci - Updated contact 4925bd8deadSopenharmony_ci 4935bd8deadSopenharmony_ci Date: 11/4/2006 4945bd8deadSopenharmony_ci Revision: 16 (Benj Lipchak, AMD) 4955bd8deadSopenharmony_ci - Updated contact info after ATI/AMD merger. 4965bd8deadSopenharmony_ci 4975bd8deadSopenharmony_ci Date: 12/13/2004 4985bd8deadSopenharmony_ci Revision: 15 (Ian Romanick, IBM) 4995bd8deadSopenharmony_ci - Added GLX protocol. 5005bd8deadSopenharmony_ci 5015bd8deadSopenharmony_ci Date: 7/26/2004 5025bd8deadSopenharmony_ci Revision: 14 5035bd8deadSopenharmony_ci - Clarified interaction of gl_FragColor and multiple draw buffers. 5045bd8deadSopenharmony_ci - Updated dependencies section. 5055bd8deadSopenharmony_ci - Added real ARB extension #. 5065bd8deadSopenharmony_ci 5075bd8deadSopenharmony_ci Date: 7/22/2004 5085bd8deadSopenharmony_ci Revision: 13 5095bd8deadSopenharmony_ci - Converted from ATI_draw_buffers to ARB_draw_buffers. 5105bd8deadSopenharmony_ci 5115bd8deadSopenharmony_ci Date: 7/21/2004 5125bd8deadSopenharmony_ci Revision: 12 5135bd8deadSopenharmony_ci - Updated intro to mention ARB_fragment_shader. 5145bd8deadSopenharmony_ci - Marked which sections modify ARB_fragment_program and 5155bd8deadSopenharmony_ci ARB_fragment_shader. 5165bd8deadSopenharmony_ci - Added "Dependencies on ARB_fragment_shader". 5175bd8deadSopenharmony_ci - Added extension section 3.3.1 to Shading Language spec. 5185bd8deadSopenharmony_ci - Resolved interaction with multisample (issue 2). 5195bd8deadSopenharmony_ci - Fixed typos. 5205bd8deadSopenharmony_ci 5215bd8deadSopenharmony_ci Date: 6/9/2004 5225bd8deadSopenharmony_ci Revision: 11 5235bd8deadSopenharmony_ci - Added GLSL integration. 5245bd8deadSopenharmony_ci 5255bd8deadSopenharmony_ci Date: 4/27/2004 5265bd8deadSopenharmony_ci Revision: 10 5275bd8deadSopenharmony_ci - Replaced modification to section 4.2.1 with a complete 5285bd8deadSopenharmony_ci replacement for the section, the individual modifications were 5295bd8deadSopenharmony_ci getting too cumbersome. 5305bd8deadSopenharmony_ci - Added issue (2) on multisampling. 5315bd8deadSopenharmony_ci 5325bd8deadSopenharmony_ci Date: 4/15/2004 5335bd8deadSopenharmony_ci Revision: 9 5345bd8deadSopenharmony_ci - Specified that it is the alpha of color 0 that is used for alpha 5355bd8deadSopenharmony_ci test. 5365bd8deadSopenharmony_ci 5375bd8deadSopenharmony_ci Date: 12/30/2002 5385bd8deadSopenharmony_ci Revision: 8 5395bd8deadSopenharmony_ci - Clarified that DrawBuffersATI will set the set of draw buffers 5405bd8deadSopenharmony_ci to write color output 0 to when the "ATI_draw_buffer" fragments 5415bd8deadSopenharmony_ci program option is not in use. 5425bd8deadSopenharmony_ci 5435bd8deadSopenharmony_ci Date: 9/27/2002 5445bd8deadSopenharmony_ci Revision: 7 5455bd8deadSopenharmony_ci - Fixed confusion between meaning of color buffer and draw buffer 5465bd8deadSopenharmony_ci in last revision. 5475bd8deadSopenharmony_ci - Fixed mistake in when an error is generated based on the <n> 5485bd8deadSopenharmony_ci argument of DrawBuffersATI. 5495bd8deadSopenharmony_ci 5505bd8deadSopenharmony_ci Date: 9/26/2002 5515bd8deadSopenharmony_ci Revision: 6 5525bd8deadSopenharmony_ci - Cleaned up and put in sync with latest ARB_fragment_program 5535bd8deadSopenharmony_ci revision (#22). Some meaningless changes made just in the name 5545bd8deadSopenharmony_ci of consistency. 5555bd8deadSopenharmony_ci 5565bd8deadSopenharmony_ci Date: 9/11/2002 5575bd8deadSopenharmony_ci Revision: 5 5585bd8deadSopenharmony_ci - Added section 3.11.4.5.3. 5595bd8deadSopenharmony_ci - Added enum numbers to New Tokens. 5605bd8deadSopenharmony_ci 5615bd8deadSopenharmony_ci Date: 9/9/2002 5625bd8deadSopenharmony_ci Revision: 4 5635bd8deadSopenharmony_ci - Changed error from MAX_OUTPUT_COLORS to MAX_DRAW_BUFFERS_ATI. 5645bd8deadSopenharmony_ci - Changed 3.10 section numbers to 3.11 to match change to 5655bd8deadSopenharmony_ci ARB_fragment_program spec. 5665bd8deadSopenharmony_ci - Changed ARB_fragment_program from required to affects, and 5675bd8deadSopenharmony_ci added section on interactions with it and future extensions 5685bd8deadSopenharmony_ci that define multiple color outputs. 5695bd8deadSopenharmony_ci 5705bd8deadSopenharmony_ci Date: 9/6/2002 5715bd8deadSopenharmony_ci Revision: 3 5725bd8deadSopenharmony_ci - Changed error to INVALID OPERATION. 5735bd8deadSopenharmony_ci - Cleaned up typos. 5745bd8deadSopenharmony_ci 5755bd8deadSopenharmony_ci Date: 8/19/2002 5765bd8deadSopenharmony_ci Revision: 2 5775bd8deadSopenharmony_ci - Added a paragraph that specifically points out that the 5785bd8deadSopenharmony_ci constants that refer to multiple buffers are not allowed with 5795bd8deadSopenharmony_ci DrawBuffersATI. 5805bd8deadSopenharmony_ci - Changed bufs to <bufs> in a couple of places. 5815bd8deadSopenharmony_ci 5825bd8deadSopenharmony_ci Date: 8/16/2002 5835bd8deadSopenharmony_ci Revision: 1 5845bd8deadSopenharmony_ci - First draft for circulation. 585