2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2007 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
28 * glReadBuffer, DrawBuffer functions.
45 * Return bitmask of BUFFER_BIT_* flags indicating which color buffers are
46 * available to the rendering context (for drawing or reading).
47 * This depends on the type of framebuffer. For window system framebuffers
48 * we look at the framebuffer's visual. But for user-create framebuffers we
49 * look at the number of supported color attachments.
50 * \param fb the framebuffer to draw to, or read from
51 * \return bitmask of BUFFER_BIT_* flags
54 supported_buffer_bitmask(const struct gl_context
*ctx
,
55 const struct gl_framebuffer
*fb
)
57 GLbitfield mask
= 0x0;
59 if (_mesa_is_user_fbo(fb
)) {
60 /* A user-created renderbuffer */
62 for (i
= 0; i
< ctx
->Const
.MaxColorAttachments
; i
++) {
63 mask
|= (BUFFER_BIT_COLOR0
<< i
);
67 /* A window system framebuffer */
69 mask
= BUFFER_BIT_FRONT_LEFT
; /* always have this */
70 if (fb
->Visual
.stereoMode
) {
71 mask
|= BUFFER_BIT_FRONT_RIGHT
;
72 if (fb
->Visual
.doubleBufferMode
) {
73 mask
|= BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
76 else if (fb
->Visual
.doubleBufferMode
) {
77 mask
|= BUFFER_BIT_BACK_LEFT
;
80 for (i
= 0; i
< fb
->Visual
.numAuxBuffers
; i
++) {
81 mask
|= (BUFFER_BIT_AUX0
<< i
);
90 * Helper routine used by glDrawBuffer and glDrawBuffersARB.
91 * Given a GLenum naming one or more color buffers (such as
92 * GL_FRONT_AND_BACK), return the corresponding bitmask of BUFFER_BIT_* flags.
95 draw_buffer_enum_to_bitmask(const struct gl_context
*ctx
, GLenum buffer
)
101 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_FRONT_RIGHT
;
103 if (_mesa_is_gles(ctx
)) {
104 /* Page 181 (page 192 of the PDF) in section 4.2.1 of the OpenGL
105 * ES 3.0.1 specification says:
107 * "When draw buffer zero is BACK, color values are written
108 * into the sole buffer for single-buffered contexts, or into
109 * the back buffer for double-buffered contexts."
111 * Since there is no stereo rendering in ES 3.0, only return the
112 * LEFT bits. This also satisfies the "n must be 1" requirement.
114 * We also do this for GLES 1 and 2 because those APIs have no
115 * concept of selecting the front and back buffer anyway and it's
116 * convenient to be able to maintain the magic behaviour of
117 * GL_BACK in that case.
119 if (ctx
->DrawBuffer
->Visual
.doubleBufferMode
)
120 return BUFFER_BIT_BACK_LEFT
;
121 return BUFFER_BIT_FRONT_LEFT
;
123 return BUFFER_BIT_BACK_LEFT
| BUFFER_BIT_BACK_RIGHT
;
125 return BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
127 return BUFFER_BIT_FRONT_RIGHT
;
129 return BUFFER_BIT_BACK_RIGHT
;
131 return BUFFER_BIT_BACK_LEFT
;
132 case GL_FRONT_AND_BACK
:
133 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
134 | BUFFER_BIT_FRONT_RIGHT
| BUFFER_BIT_BACK_RIGHT
;
136 return BUFFER_BIT_FRONT_LEFT
| BUFFER_BIT_BACK_LEFT
;
138 return BUFFER_BIT_FRONT_LEFT
;
140 return BUFFER_BIT_AUX0
;
144 return 1 << BUFFER_COUNT
; /* invalid, but not BAD_MASK */
145 case GL_COLOR_ATTACHMENT0_EXT
:
146 return BUFFER_BIT_COLOR0
;
147 case GL_COLOR_ATTACHMENT1_EXT
:
148 return BUFFER_BIT_COLOR1
;
149 case GL_COLOR_ATTACHMENT2_EXT
:
150 return BUFFER_BIT_COLOR2
;
151 case GL_COLOR_ATTACHMENT3_EXT
:
152 return BUFFER_BIT_COLOR3
;
153 case GL_COLOR_ATTACHMENT4_EXT
:
154 return BUFFER_BIT_COLOR4
;
155 case GL_COLOR_ATTACHMENT5_EXT
:
156 return BUFFER_BIT_COLOR5
;
157 case GL_COLOR_ATTACHMENT6_EXT
:
158 return BUFFER_BIT_COLOR6
;
159 case GL_COLOR_ATTACHMENT7_EXT
:
160 return BUFFER_BIT_COLOR7
;
169 * Helper routine used by glReadBuffer.
170 * Given a GLenum naming a color buffer, return the index of the corresponding
171 * renderbuffer (a BUFFER_* value).
172 * return -1 for an invalid buffer.
175 read_buffer_enum_to_index(GLenum buffer
)
179 return BUFFER_FRONT_LEFT
;
181 return BUFFER_BACK_LEFT
;
183 return BUFFER_FRONT_RIGHT
;
185 return BUFFER_FRONT_RIGHT
;
187 return BUFFER_BACK_RIGHT
;
189 return BUFFER_BACK_LEFT
;
191 return BUFFER_FRONT_LEFT
;
193 return BUFFER_FRONT_LEFT
;
199 return BUFFER_COUNT
; /* invalid, but not -1 */
200 case GL_COLOR_ATTACHMENT0_EXT
:
201 return BUFFER_COLOR0
;
202 case GL_COLOR_ATTACHMENT1_EXT
:
203 return BUFFER_COLOR1
;
204 case GL_COLOR_ATTACHMENT2_EXT
:
205 return BUFFER_COLOR2
;
206 case GL_COLOR_ATTACHMENT3_EXT
:
207 return BUFFER_COLOR3
;
208 case GL_COLOR_ATTACHMENT4_EXT
:
209 return BUFFER_COLOR4
;
210 case GL_COLOR_ATTACHMENT5_EXT
:
211 return BUFFER_COLOR5
;
212 case GL_COLOR_ATTACHMENT6_EXT
:
213 return BUFFER_COLOR6
;
214 case GL_COLOR_ATTACHMENT7_EXT
:
215 return BUFFER_COLOR7
;
224 * Called by glDrawBuffer().
225 * Specify which renderbuffer(s) to draw into for the first color output.
226 * <buffer> can name zero, one, two or four renderbuffers!
227 * \sa _mesa_DrawBuffers
229 * \param buffer buffer token such as GL_LEFT or GL_FRONT_AND_BACK, etc.
231 * Note that the behaviour of this function depends on whether the
232 * current ctx->DrawBuffer is a window-system framebuffer or a user-created
233 * framebuffer object.
234 * In the former case, we update the per-context ctx->Color.DrawBuffer
235 * state var _and_ the FB's ColorDrawBuffer state.
236 * In the later case, we update the FB's ColorDrawBuffer state only.
238 * Furthermore, upon a MakeCurrent() or BindFramebuffer() call, if the
239 * new FB is a window system FB, we need to re-update the FB's
240 * ColorDrawBuffer state to match the context. This is handled in
241 * _mesa_update_framebuffer().
243 * See the GL_EXT_framebuffer_object spec for more info.
246 _mesa_DrawBuffer(GLenum buffer
)
249 GET_CURRENT_CONTEXT(ctx
);
251 FLUSH_VERTICES(ctx
, 0);
253 if (MESA_VERBOSE
& VERBOSE_API
) {
254 _mesa_debug(ctx
, "glDrawBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
257 if (buffer
== GL_NONE
) {
261 const GLbitfield supportedMask
262 = supported_buffer_bitmask(ctx
, ctx
->DrawBuffer
);
263 destMask
= draw_buffer_enum_to_bitmask(ctx
, buffer
);
264 if (destMask
== BAD_MASK
) {
265 /* totally bogus buffer */
266 _mesa_error(ctx
, GL_INVALID_ENUM
,
267 "glDrawBuffer(buffer=0x%x)", buffer
);
270 destMask
&= supportedMask
;
271 if (destMask
== 0x0) {
272 /* none of the named color buffers exist! */
273 _mesa_error(ctx
, GL_INVALID_OPERATION
,
274 "glDrawBuffer(buffer=0x%x)", buffer
);
279 /* if we get here, there's no error so set new state */
280 _mesa_drawbuffers(ctx
, ctx
->DrawBuffer
, 1, &buffer
, &destMask
);
283 * Call device driver function.
285 if (ctx
->Driver
.DrawBuffers
)
286 ctx
->Driver
.DrawBuffers(ctx
, 1, &buffer
);
287 else if (ctx
->Driver
.DrawBuffer
)
288 ctx
->Driver
.DrawBuffer(ctx
, buffer
);
293 * Called by glDrawBuffersARB; specifies the destination color renderbuffers
294 * for N fragment program color outputs.
295 * \sa _mesa_DrawBuffer
296 * \param n number of outputs
297 * \param buffers array [n] of renderbuffer names. Unlike glDrawBuffer, the
298 * names cannot specify more than one buffer. For example,
299 * GL_FRONT_AND_BACK is illegal.
302 _mesa_DrawBuffers(GLsizei n
, const GLenum
*buffers
)
305 GLbitfield usedBufferMask
, supportedMask
;
306 GLbitfield destMask
[MAX_DRAW_BUFFERS
];
307 GET_CURRENT_CONTEXT(ctx
);
309 FLUSH_VERTICES(ctx
, 0);
311 /* Turns out n==0 is a valid input that should not produce an error.
312 * The remaining code below correctly handles the n==0 case.
314 * From the OpenGL 3.0 specification, page 258:
315 * "An INVALID_VALUE error is generated if n is greater than
318 if (n
< 0 || n
> (GLsizei
) ctx
->Const
.MaxDrawBuffers
) {
319 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDrawBuffersARB(n)");
323 supportedMask
= supported_buffer_bitmask(ctx
, ctx
->DrawBuffer
);
324 usedBufferMask
= 0x0;
326 /* From the ES 3.0 specification, page 180:
327 * "If the GL is bound to the default framebuffer, then n must be 1
328 * and the constant must be BACK or NONE."
329 * (same restriction applies with GL_EXT_draw_buffers specification)
331 if (ctx
->API
== API_OPENGLES2
&& _mesa_is_winsys_fbo(ctx
->DrawBuffer
) &&
332 (n
!= 1 || (buffers
[0] != GL_NONE
&& buffers
[0] != GL_BACK
))) {
333 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffers(buffer)");
337 /* complicated error checking... */
338 for (output
= 0; output
< n
; output
++) {
339 /* Section 4.2 (Whole Framebuffer Operations) of the OpenGL 3.0
340 * specification says:
342 * "Each buffer listed in bufs must be BACK, NONE, or one of the values
343 * from table 4.3 (NONE, COLOR_ATTACHMENTi)"
345 if (_mesa_is_gles3(ctx
) && buffers
[output
] != GL_NONE
&&
346 buffers
[output
] != GL_BACK
&&
347 (buffers
[output
] < GL_COLOR_ATTACHMENT0
||
348 buffers
[output
] >= GL_COLOR_ATTACHMENT0
+ ctx
->Const
.MaxColorAttachments
)) {
349 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffers(buffer)");
353 if (buffers
[output
] == GL_NONE
) {
354 destMask
[output
] = 0x0;
357 /* Page 259 (page 275 of the PDF) in section 4.2.1 of the OpenGL 3.0
358 * spec (20080923) says:
360 * "If the GL is bound to a framebuffer object and DrawBuffers is
361 * supplied with [...] COLOR_ATTACHMENTm where m is greater than
362 * or equal to the value of MAX_COLOR_ATTACHMENTS, then the error
363 * INVALID_OPERATION results."
365 if (_mesa_is_user_fbo(ctx
->DrawBuffer
) && buffers
[output
] >=
366 GL_COLOR_ATTACHMENT0
+ ctx
->Const
.MaxDrawBuffers
) {
367 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffersARB(buffer)");
371 destMask
[output
] = draw_buffer_enum_to_bitmask(ctx
, buffers
[output
]);
373 /* From the OpenGL 3.0 specification, page 258:
374 * "Each buffer listed in bufs must be one of the values from tables
375 * 4.5 or 4.6. Otherwise, an INVALID_ENUM error is generated.
377 if (destMask
[output
] == BAD_MASK
) {
378 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffersARB(buffer)");
382 /* From the OpenGL 4.0 specification, page 256:
383 * "For both the default framebuffer and framebuffer objects, the
384 * constants FRONT, BACK, LEFT, RIGHT, and FRONT_AND_BACK are not
385 * valid in the bufs array passed to DrawBuffers, and will result in
386 * the error INVALID_ENUM. This restriction is because these
387 * constants may themselves refer to multiple buffers, as shown in
389 * Previous versions of the OpenGL specification say INVALID_OPERATION,
390 * but the Khronos conformance tests expect INVALID_ENUM.
392 if (_mesa_bitcount(destMask
[output
]) > 1) {
393 _mesa_error(ctx
, GL_INVALID_ENUM
, "glDrawBuffersARB(buffer)");
397 /* From the OpenGL 3.0 specification, page 259:
398 * "If the GL is bound to the default framebuffer and DrawBuffers is
399 * supplied with a constant (other than NONE) that does not indicate
400 * any of the color buffers allocated to the GL context by the window
401 * system, the error INVALID_OPERATION will be generated.
403 * If the GL is bound to a framebuffer object and DrawBuffers is
404 * supplied with a constant from table 4.6 [...] then the error
405 * INVALID_OPERATION results."
407 destMask
[output
] &= supportedMask
;
408 if (destMask
[output
] == 0) {
409 _mesa_error(ctx
, GL_INVALID_OPERATION
,
410 "glDrawBuffersARB(unsupported buffer)");
414 /* ES 3.0 is even more restrictive. From the ES 3.0 spec, page 180:
415 * "If the GL is bound to a framebuffer object, the ith buffer listed
416 * in bufs must be COLOR_ATTACHMENTi or NONE. [...] INVALID_OPERATION."
417 * (same restriction applies with GL_EXT_draw_buffers specification)
419 if (ctx
->API
== API_OPENGLES2
&& _mesa_is_user_fbo(ctx
->DrawBuffer
) &&
420 buffers
[output
] != GL_NONE
&&
421 buffers
[output
] != GL_COLOR_ATTACHMENT0
+ output
) {
422 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glDrawBuffers(buffer)");
426 /* From the OpenGL 3.0 specification, page 258:
427 * "Except for NONE, a buffer may not appear more than once in the
428 * array pointed to by bufs. Specifying a buffer more then once will
429 * result in the error INVALID_OPERATION."
431 if (destMask
[output
] & usedBufferMask
) {
432 _mesa_error(ctx
, GL_INVALID_OPERATION
,
433 "glDrawBuffersARB(duplicated buffer)");
438 usedBufferMask
|= destMask
[output
];
442 /* OK, if we get here, there were no errors so set the new state */
443 _mesa_drawbuffers(ctx
, ctx
->DrawBuffer
, n
, buffers
, destMask
);
446 * Call device driver function. Note that n can be equal to 0,
447 * in which case we don't want to reference buffers[0], which
450 if (ctx
->Driver
.DrawBuffers
)
451 ctx
->Driver
.DrawBuffers(ctx
, n
, buffers
);
452 else if (ctx
->Driver
.DrawBuffer
)
453 ctx
->Driver
.DrawBuffer(ctx
, n
> 0 ? buffers
[0] : GL_NONE
);
458 * Performs necessary state updates when _mesa_drawbuffers makes an
462 updated_drawbuffers(struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
464 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
466 if (ctx
->API
== API_OPENGL_COMPAT
&& !ctx
->Extensions
.ARB_ES2_compatibility
) {
467 /* Flag the FBO as requiring validation. */
468 if (_mesa_is_user_fbo(fb
)) {
476 * Helper function to set the GL_DRAW_BUFFER state in the context and
477 * current FBO. Called via glDrawBuffer(), glDrawBuffersARB()
479 * All error checking will have been done prior to calling this function
480 * so nothing should go wrong at this point.
482 * \param ctx current context
483 * \param fb the desired draw buffer
484 * \param n number of color outputs to set
485 * \param buffers array[n] of colorbuffer names, like GL_LEFT.
486 * \param destMask array[n] of BUFFER_BIT_* bitmasks which correspond to the
487 * colorbuffer names. (i.e. GL_FRONT_AND_BACK =>
488 * BUFFER_BIT_FRONT_LEFT | BUFFER_BIT_BACK_LEFT).
491 _mesa_drawbuffers(struct gl_context
*ctx
, struct gl_framebuffer
*fb
,
492 GLuint n
, const GLenum
*buffers
, const GLbitfield
*destMask
)
494 GLbitfield mask
[MAX_DRAW_BUFFERS
];
498 /* compute destMask values now */
499 const GLbitfield supportedMask
= supported_buffer_bitmask(ctx
, fb
);
501 for (output
= 0; output
< n
; output
++) {
502 mask
[output
] = draw_buffer_enum_to_bitmask(ctx
, buffers
[output
]);
503 assert(mask
[output
] != BAD_MASK
);
504 mask
[output
] &= supportedMask
;
510 * destMask[0] may have up to four bits set
511 * (ex: glDrawBuffer(GL_FRONT_AND_BACK)).
512 * Otherwise, destMask[x] can only have one bit set.
514 if (n
> 0 && _mesa_bitcount(destMask
[0]) > 1) {
515 GLuint count
= 0, destMask0
= destMask
[0];
517 GLint bufIndex
= ffs(destMask0
) - 1;
518 if (fb
->_ColorDrawBufferIndexes
[count
] != bufIndex
) {
519 updated_drawbuffers(ctx
, fb
);
520 fb
->_ColorDrawBufferIndexes
[count
] = bufIndex
;
523 destMask0
&= ~(1 << bufIndex
);
525 fb
->ColorDrawBuffer
[0] = buffers
[0];
526 fb
->_NumColorDrawBuffers
= count
;
530 for (buf
= 0; buf
< n
; buf
++ ) {
532 GLint bufIndex
= ffs(destMask
[buf
]) - 1;
533 /* only one bit should be set in the destMask[buf] field */
534 assert(_mesa_bitcount(destMask
[buf
]) == 1);
535 if (fb
->_ColorDrawBufferIndexes
[buf
] != bufIndex
) {
536 updated_drawbuffers(ctx
, fb
);
537 fb
->_ColorDrawBufferIndexes
[buf
] = bufIndex
;
542 if (fb
->_ColorDrawBufferIndexes
[buf
] != -1) {
543 updated_drawbuffers(ctx
, fb
);
544 fb
->_ColorDrawBufferIndexes
[buf
] = -1;
547 fb
->ColorDrawBuffer
[buf
] = buffers
[buf
];
549 fb
->_NumColorDrawBuffers
= count
;
552 /* set remaining outputs to -1 (GL_NONE) */
553 for (buf
= fb
->_NumColorDrawBuffers
; buf
< ctx
->Const
.MaxDrawBuffers
; buf
++) {
554 if (fb
->_ColorDrawBufferIndexes
[buf
] != -1) {
555 updated_drawbuffers(ctx
, fb
);
556 fb
->_ColorDrawBufferIndexes
[buf
] = -1;
559 for (buf
= n
; buf
< ctx
->Const
.MaxDrawBuffers
; buf
++) {
560 fb
->ColorDrawBuffer
[buf
] = GL_NONE
;
563 if (_mesa_is_winsys_fbo(fb
)) {
564 /* also set context drawbuffer state */
565 for (buf
= 0; buf
< ctx
->Const
.MaxDrawBuffers
; buf
++) {
566 if (ctx
->Color
.DrawBuffer
[buf
] != fb
->ColorDrawBuffer
[buf
]) {
567 updated_drawbuffers(ctx
, fb
);
568 ctx
->Color
.DrawBuffer
[buf
] = fb
->ColorDrawBuffer
[buf
];
576 * Update the current drawbuffer's _ColorDrawBufferIndex[] list, etc.
577 * from the context's Color.DrawBuffer[] state.
578 * Use when changing contexts.
581 _mesa_update_draw_buffers(struct gl_context
*ctx
)
583 /* should be a window system FBO */
584 assert(_mesa_is_winsys_fbo(ctx
->DrawBuffer
));
586 _mesa_drawbuffers(ctx
, ctx
->DrawBuffer
, ctx
->Const
.MaxDrawBuffers
,
587 ctx
->Color
.DrawBuffer
, NULL
);
592 * Like \sa _mesa_drawbuffers(), this is a helper function for setting
593 * GL_READ_BUFFER state in the context and current FBO.
594 * \param ctx the rendering context
595 * \param buffer GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENT0, etc.
596 * \param bufferIndex the numerical index corresponding to 'buffer'
599 _mesa_readbuffer(struct gl_context
*ctx
, GLenum buffer
, GLint bufferIndex
)
601 struct gl_framebuffer
*fb
= ctx
->ReadBuffer
;
603 if (_mesa_is_winsys_fbo(fb
)) {
604 /* Only update the per-context READ_BUFFER state if we're bound to
605 * a window-system framebuffer.
607 ctx
->Pixel
.ReadBuffer
= buffer
;
610 fb
->ColorReadBuffer
= buffer
;
611 fb
->_ColorReadBufferIndex
= bufferIndex
;
613 ctx
->NewState
|= _NEW_BUFFERS
;
619 * Called by glReadBuffer to set the source renderbuffer for reading pixels.
620 * \param mode color buffer such as GL_FRONT, GL_BACK, etc.
623 _mesa_ReadBuffer(GLenum buffer
)
625 struct gl_framebuffer
*fb
;
626 GLbitfield supportedMask
;
628 GET_CURRENT_CONTEXT(ctx
);
630 FLUSH_VERTICES(ctx
, 0);
632 if (MESA_VERBOSE
& VERBOSE_API
)
633 _mesa_debug(ctx
, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
635 fb
= ctx
->ReadBuffer
;
637 if (MESA_VERBOSE
& VERBOSE_API
)
638 _mesa_debug(ctx
, "glReadBuffer %s\n", _mesa_lookup_enum_by_nr(buffer
));
640 if (buffer
== GL_NONE
) {
641 /* This is legal--it means that no buffer should be bound for reading. */
645 /* general case / window-system framebuffer */
646 srcBuffer
= read_buffer_enum_to_index(buffer
);
647 if (srcBuffer
== -1) {
648 _mesa_error(ctx
, GL_INVALID_ENUM
,
649 "glReadBuffer(buffer=0x%x)", buffer
);
652 supportedMask
= supported_buffer_bitmask(ctx
, fb
);
653 if (((1 << srcBuffer
) & supportedMask
) == 0) {
654 _mesa_error(ctx
, GL_INVALID_OPERATION
,
655 "glReadBuffer(buffer=0x%x)", buffer
);
660 /* OK, all error checking has been completed now */
662 _mesa_readbuffer(ctx
, buffer
, srcBuffer
);
665 * Call device driver function.
667 if (ctx
->Driver
.ReadBuffer
)
668 (*ctx
->Driver
.ReadBuffer
)(ctx
, buffer
);