2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Functions for allocating/managing framebuffers and renderbuffers.
28 * Also, routines for reading/writing renderbuffer data as ubytes,
29 * ushorts, uints, etc.
36 #include "depthstencil.h"
39 #include "framebuffer.h"
40 #include "renderbuffer.h"
46 * Compute/set the _DepthMax field for the given framebuffer.
47 * This value depends on the Z buffer resolution.
50 compute_depth_max(struct gl_framebuffer
*fb
)
52 if (fb
->Visual
.depthBits
== 0) {
53 /* Special case. Even if we don't have a depth buffer we need
54 * good values for DepthMax for Z vertex transformation purposes
55 * and for per-fragment fog computation.
57 fb
->_DepthMax
= (1 << 16) - 1;
59 else if (fb
->Visual
.depthBits
< 32) {
60 fb
->_DepthMax
= (1 << fb
->Visual
.depthBits
) - 1;
63 /* Special case since shift values greater than or equal to the
64 * number of bits in the left hand expression's type are undefined.
66 fb
->_DepthMax
= 0xffffffff;
68 fb
->_DepthMaxF
= (GLfloat
) fb
->_DepthMax
;
70 /* Minimum resolvable depth value, for polygon offset */
71 fb
->_MRD
= 1.0 / fb
->_DepthMaxF
;
76 * Create and initialize a gl_framebuffer object.
77 * This is intended for creating _window_system_ framebuffers, not generic
78 * framebuffer objects ala GL_EXT_framebuffer_object.
80 * \sa _mesa_new_framebuffer
82 struct gl_framebuffer
*
83 _mesa_create_framebuffer(const GLvisual
*visual
)
85 struct gl_framebuffer
*fb
= CALLOC_STRUCT(gl_framebuffer
);
88 _mesa_initialize_framebuffer(fb
, visual
);
95 * Allocate a new gl_framebuffer object.
96 * This is the default function for ctx->Driver.NewFramebuffer().
97 * This is for allocating user-created framebuffers, not window-system
99 * \sa _mesa_create_framebuffer
101 struct gl_framebuffer
*
102 _mesa_new_framebuffer(GLcontext
*ctx
, GLuint name
)
104 struct gl_framebuffer
*fb
;
107 fb
= CALLOC_STRUCT(gl_framebuffer
);
111 fb
->ColorDrawBuffer
[0] = GL_COLOR_ATTACHMENT0_EXT
;
112 fb
->_ColorDrawBufferMask
[0] = BUFFER_BIT_COLOR0
;
113 fb
->ColorReadBuffer
= GL_COLOR_ATTACHMENT0_EXT
;
114 fb
->_ColorReadBufferIndex
= BUFFER_COLOR0
;
115 fb
->Delete
= _mesa_destroy_framebuffer
;
122 * Initialize a gl_framebuffer object. Typically used to initialize
123 * window system-created framebuffers, not user-created framebuffers.
124 * \sa _mesa_create_framebuffer
127 _mesa_initialize_framebuffer(struct gl_framebuffer
*fb
, const GLvisual
*visual
)
132 _mesa_bzero(fb
, sizeof(struct gl_framebuffer
));
134 _glthread_INIT_MUTEX(fb
->Mutex
);
138 /* save the visual */
139 fb
->Visual
= *visual
;
141 /* Init read/draw renderbuffer state */
142 if (visual
->doubleBufferMode
) {
143 fb
->ColorDrawBuffer
[0] = GL_BACK
;
144 fb
->_ColorDrawBufferMask
[0] = BUFFER_BIT_BACK_LEFT
;
145 fb
->ColorReadBuffer
= GL_BACK
;
146 fb
->_ColorReadBufferIndex
= BUFFER_BACK_LEFT
;
149 fb
->ColorDrawBuffer
[0] = GL_FRONT
;
150 fb
->_ColorDrawBufferMask
[0] = BUFFER_BIT_FRONT_LEFT
;
151 fb
->ColorReadBuffer
= GL_FRONT
;
152 fb
->_ColorReadBufferIndex
= BUFFER_FRONT_LEFT
;
155 fb
->Delete
= _mesa_destroy_framebuffer
;
156 fb
->_Status
= GL_FRAMEBUFFER_COMPLETE_EXT
;
158 compute_depth_max(fb
);
163 * Deallocate buffer and everything attached to it.
164 * Typically called via the gl_framebuffer->Delete() method.
167 _mesa_destroy_framebuffer(struct gl_framebuffer
*fb
)
170 _mesa_free_framebuffer_data(fb
);
177 * Free all the data hanging off the given gl_framebuffer, but don't free
178 * the gl_framebuffer object itself.
181 _mesa_free_framebuffer_data(struct gl_framebuffer
*fb
)
186 assert(fb
->RefCount
== 0);
188 _glthread_DESTROY_MUTEX(fb
->Mutex
);
190 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
191 struct gl_renderbuffer_attachment
*att
= &fb
->Attachment
[i
];
192 if (att
->Renderbuffer
) {
193 _mesa_reference_renderbuffer(&att
->Renderbuffer
, NULL
);
196 _mesa_reference_texobj(&att
->Texture
, NULL
);
198 ASSERT(!att
->Renderbuffer
);
199 ASSERT(!att
->Texture
);
203 /* unbind _Depth/_StencilBuffer to decr ref counts */
204 _mesa_reference_renderbuffer(&fb
->_DepthBuffer
, NULL
);
205 _mesa_reference_renderbuffer(&fb
->_StencilBuffer
, NULL
);
210 * Set *ptr to point to fb, with refcounting and locking.
213 _mesa_reference_framebuffer(struct gl_framebuffer
**ptr
,
214 struct gl_framebuffer
*fb
)
222 _mesa_unreference_framebuffer(ptr
);
226 _glthread_LOCK_MUTEX(fb
->Mutex
);
228 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
234 * Undo/remove a reference to a framebuffer object.
235 * Decrement the framebuffer object's reference count and delete it when
236 * the refcount hits zero.
237 * Note: we pass the address of a pointer and set it to NULL.
240 _mesa_unreference_framebuffer(struct gl_framebuffer
**fb
)
244 GLboolean deleteFlag
= GL_FALSE
;
246 _glthread_LOCK_MUTEX((*fb
)->Mutex
);
247 ASSERT((*fb
)->RefCount
> 0);
249 deleteFlag
= ((*fb
)->RefCount
== 0);
250 _glthread_UNLOCK_MUTEX((*fb
)->Mutex
);
263 * Resize the given framebuffer's renderbuffers to the new width and height.
264 * This should only be used for window-system framebuffers, not
265 * user-created renderbuffers (i.e. made with GL_EXT_framebuffer_object).
266 * This will typically be called via ctx->Driver.ResizeBuffers() or directly
267 * from a device driver.
269 * \note it's possible for ctx to be null since a window can be resized
270 * without a currently bound rendering context.
273 _mesa_resize_framebuffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
274 GLuint width
, GLuint height
)
278 /* XXX I think we could check if the size is not changing
282 /* For window system framebuffers, Name is zero */
283 assert(fb
->Name
== 0);
285 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
286 struct gl_renderbuffer_attachment
*att
= &fb
->Attachment
[i
];
287 if (att
->Type
== GL_RENDERBUFFER_EXT
&& att
->Renderbuffer
) {
288 struct gl_renderbuffer
*rb
= att
->Renderbuffer
;
289 /* only resize if size is changing */
290 if (rb
->Width
!= width
|| rb
->Height
!= height
) {
291 /* could just as well pass rb->_ActualFormat here */
292 if (rb
->AllocStorage(ctx
, rb
, rb
->InternalFormat
, width
, height
)) {
293 ASSERT(rb
->Width
== width
);
294 ASSERT(rb
->Height
== height
);
297 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "Resizing framebuffer");
304 if (fb
->_DepthBuffer
) {
305 struct gl_renderbuffer
*rb
= fb
->_DepthBuffer
;
306 if (rb
->Width
!= width
|| rb
->Height
!= height
) {
307 if (!rb
->AllocStorage(ctx
, rb
, rb
->InternalFormat
, width
, height
)) {
308 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "Resizing framebuffer");
313 if (fb
->_StencilBuffer
) {
314 struct gl_renderbuffer
*rb
= fb
->_StencilBuffer
;
315 if (rb
->Width
!= width
|| rb
->Height
!= height
) {
316 if (!rb
->AllocStorage(ctx
, rb
, rb
->InternalFormat
, width
, height
)) {
317 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "Resizing framebuffer");
326 /* update scissor / window bounds */
327 _mesa_update_draw_buffer_bounds(ctx
);
328 /* Signal new buffer state so that swrast will update its clipping
329 * info (the CLIP_BIT flag).
331 ctx
->NewState
|= _NEW_BUFFERS
;
337 * Examine all the framebuffer's renderbuffers to update the Width/Height
338 * fields of the framebuffer. If we have renderbuffers with different
339 * sizes, set the framebuffer's width and height to zero.
340 * Note: this is only intended for user-created framebuffers, not
341 * window-system framebuffes.
344 update_framebuffer_size(struct gl_framebuffer
*fb
)
346 GLboolean haveSize
= GL_FALSE
;
349 /* user-created framebuffers only */
352 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
353 struct gl_renderbuffer_attachment
*att
= &fb
->Attachment
[i
];
354 const struct gl_renderbuffer
*rb
= att
->Renderbuffer
;
357 if (rb
->Width
!= fb
->Width
&& rb
->Height
!= fb
->Height
) {
365 fb
->Width
= rb
->Width
;
366 fb
->Height
= rb
->Height
;
375 * Update the context's current drawing buffer's Xmin, Xmax, Ymin, Ymax fields.
376 * These values are computed from the buffer's width and height and
377 * the scissor box, if it's enabled.
378 * \param ctx the GL context.
381 _mesa_update_draw_buffer_bounds(GLcontext
*ctx
)
383 struct gl_framebuffer
*buffer
= ctx
->DrawBuffer
;
389 /* user-created framebuffer size depends on the renderbuffers */
390 update_framebuffer_size(buffer
);
395 buffer
->_Xmax
= buffer
->Width
;
396 buffer
->_Ymax
= buffer
->Height
;
398 if (ctx
->Scissor
.Enabled
) {
399 if (ctx
->Scissor
.X
> buffer
->_Xmin
) {
400 buffer
->_Xmin
= ctx
->Scissor
.X
;
402 if (ctx
->Scissor
.Y
> buffer
->_Ymin
) {
403 buffer
->_Ymin
= ctx
->Scissor
.Y
;
405 if (ctx
->Scissor
.X
+ ctx
->Scissor
.Width
< buffer
->_Xmax
) {
406 buffer
->_Xmax
= ctx
->Scissor
.X
+ ctx
->Scissor
.Width
;
408 if (ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
< buffer
->_Ymax
) {
409 buffer
->_Ymax
= ctx
->Scissor
.Y
+ ctx
->Scissor
.Height
;
411 /* finally, check for empty region */
412 if (buffer
->_Xmin
> buffer
->_Xmax
) {
413 buffer
->_Xmin
= buffer
->_Xmax
;
415 if (buffer
->_Ymin
> buffer
->_Ymax
) {
416 buffer
->_Ymin
= buffer
->_Ymax
;
420 ASSERT(buffer
->_Xmin
<= buffer
->_Xmax
);
421 ASSERT(buffer
->_Ymin
<= buffer
->_Ymax
);
426 * The glGet queries of the framebuffer red/green/blue size, stencil size,
427 * etc. are satisfied by the fields of ctx->DrawBuffer->Visual. These can
428 * change depending on the renderbuffer bindings. This function updates
429 * the given framebuffer's Visual from the current renderbuffer bindings.
431 * This may apply to user-created framebuffers or window system framebuffers.
433 * Also note: ctx->DrawBuffer->Visual.depthBits might not equal
434 * ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Renderbuffer.DepthBits.
435 * The former one is used to convert floating point depth values into
439 _mesa_update_framebuffer_visual(struct gl_framebuffer
*fb
)
443 _mesa_bzero(&fb
->Visual
, sizeof(fb
->Visual
));
444 fb
->Visual
.rgbMode
= GL_TRUE
; /* assume this */
446 #if 0 /* this _might_ be needed */
447 if (fb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
448 /* leave visual fields zero'd */
453 /* find first RGB or CI renderbuffer */
454 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
455 if (fb
->Attachment
[i
].Renderbuffer
) {
456 const struct gl_renderbuffer
*rb
= fb
->Attachment
[i
].Renderbuffer
;
457 if (rb
->_BaseFormat
== GL_RGBA
|| rb
->_BaseFormat
== GL_RGB
) {
458 fb
->Visual
.redBits
= rb
->RedBits
;
459 fb
->Visual
.greenBits
= rb
->GreenBits
;
460 fb
->Visual
.blueBits
= rb
->BlueBits
;
461 fb
->Visual
.alphaBits
= rb
->AlphaBits
;
462 fb
->Visual
.rgbBits
= fb
->Visual
.redBits
463 + fb
->Visual
.greenBits
+ fb
->Visual
.blueBits
;
464 fb
->Visual
.floatMode
= GL_FALSE
;
467 else if (rb
->_BaseFormat
== GL_COLOR_INDEX
) {
468 fb
->Visual
.indexBits
= rb
->IndexBits
;
469 fb
->Visual
.rgbMode
= GL_FALSE
;
475 if (fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
) {
476 fb
->Visual
.haveDepthBuffer
= GL_TRUE
;
478 = fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
->DepthBits
;
481 if (fb
->Attachment
[BUFFER_STENCIL
].Renderbuffer
) {
482 fb
->Visual
.haveStencilBuffer
= GL_TRUE
;
483 fb
->Visual
.stencilBits
484 = fb
->Attachment
[BUFFER_STENCIL
].Renderbuffer
->StencilBits
;
487 if (fb
->Attachment
[BUFFER_ACCUM
].Renderbuffer
) {
488 fb
->Visual
.haveAccumBuffer
= GL_TRUE
;
489 fb
->Visual
.accumRedBits
490 = fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
->RedBits
;
491 fb
->Visual
.accumGreenBits
492 = fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
->GreenBits
;
493 fb
->Visual
.accumBlueBits
494 = fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
->BlueBits
;
495 fb
->Visual
.accumAlphaBits
496 = fb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
->AlphaBits
;
499 compute_depth_max(fb
);
504 * Update the framebuffer's _DepthBuffer field using the renderbuffer
505 * found at the given attachment index.
507 * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
508 * create and install a depth wrapper/adaptor.
510 * \param fb the framebuffer whose _DepthBuffer field to update
511 * \param attIndex indicates the renderbuffer to possibly wrap
514 _mesa_update_depth_buffer(GLcontext
*ctx
,
515 struct gl_framebuffer
*fb
,
518 struct gl_renderbuffer
*depthRb
;
520 /* only one possiblity for now */
521 ASSERT(attIndex
== BUFFER_DEPTH
);
523 depthRb
= fb
->Attachment
[attIndex
].Renderbuffer
;
525 if (depthRb
&& depthRb
->_ActualFormat
== GL_DEPTH24_STENCIL8_EXT
) {
526 /* The attached depth buffer is a GL_DEPTH_STENCIL renderbuffer */
527 if (!fb
->_DepthBuffer
528 || fb
->_DepthBuffer
->Wrapped
!= depthRb
529 || fb
->_DepthBuffer
->_BaseFormat
!= GL_DEPTH_COMPONENT
) {
530 /* need to update wrapper */
531 struct gl_renderbuffer
*wrapper
532 = _mesa_new_z24_renderbuffer_wrapper(ctx
, depthRb
);
533 _mesa_reference_renderbuffer(&fb
->_DepthBuffer
, wrapper
);
534 ASSERT(fb
->_DepthBuffer
->Wrapped
== depthRb
);
538 /* depthRb may be null */
539 _mesa_reference_renderbuffer(&fb
->_DepthBuffer
, depthRb
);
545 * Update the framebuffer's _StencilBuffer field using the renderbuffer
546 * found at the given attachment index.
548 * If that attachment points to a combined GL_DEPTH_STENCIL renderbuffer,
549 * create and install a stencil wrapper/adaptor.
551 * \param fb the framebuffer whose _StencilBuffer field to update
552 * \param attIndex indicates the renderbuffer to possibly wrap
555 _mesa_update_stencil_buffer(GLcontext
*ctx
,
556 struct gl_framebuffer
*fb
,
559 struct gl_renderbuffer
*stencilRb
;
561 ASSERT(attIndex
== BUFFER_DEPTH
||
562 attIndex
== BUFFER_STENCIL
);
564 stencilRb
= fb
->Attachment
[attIndex
].Renderbuffer
;
566 if (stencilRb
&& stencilRb
->_ActualFormat
== GL_DEPTH24_STENCIL8_EXT
) {
567 /* The attached stencil buffer is a GL_DEPTH_STENCIL renderbuffer */
568 if (!fb
->_StencilBuffer
569 || fb
->_StencilBuffer
->Wrapped
!= stencilRb
570 || fb
->_StencilBuffer
->_BaseFormat
!= GL_STENCIL_INDEX
) {
571 /* need to update wrapper */
572 struct gl_renderbuffer
*wrapper
573 = _mesa_new_s8_renderbuffer_wrapper(ctx
, stencilRb
);
574 _mesa_reference_renderbuffer(&fb
->_StencilBuffer
, wrapper
);
575 ASSERT(fb
->_StencilBuffer
->Wrapped
== stencilRb
);
579 /* stencilRb may be null */
580 _mesa_reference_renderbuffer(&fb
->_StencilBuffer
, stencilRb
);
586 * Update the list of color drawing renderbuffer pointers.
587 * Later, when we're rendering we'll loop from 0 to _NumColorDrawBuffers
591 update_color_draw_buffers(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
596 * Fragment programs can write to multiple colorbuffers with
597 * the GL_ARB_draw_buffers extension.
599 for (output
= 0; output
< ctx
->Const
.MaxDrawBuffers
; output
++) {
600 GLbitfield bufferMask
= fb
->_ColorDrawBufferMask
[output
];
603 if (!fb
->DeletePending
) {
604 /* We need the inner loop here because glDrawBuffer(GL_FRONT_AND_BACK)
605 * can specify writing to two or four color buffers (for example).
607 for (i
= 0; bufferMask
&& i
< BUFFER_COUNT
; i
++) {
608 const GLuint bufferBit
= 1 << i
;
609 if (bufferBit
& bufferMask
) {
610 struct gl_renderbuffer
*rb
= fb
->Attachment
[i
].Renderbuffer
;
611 if (rb
&& rb
->Width
> 0 && rb
->Height
> 0) {
612 fb
->_ColorDrawBuffers
[output
][count
] = rb
;
617 _mesa_warning(ctx, "DrawBuffer names a missing buffer!\n");
620 bufferMask
&= ~bufferBit
;
624 fb
->_NumColorDrawBuffers
[output
] = count
;
630 * Update the color read renderbuffer pointer.
631 * Unlike the DrawBuffer, we can only read from one (or zero) color buffers.
634 update_color_read_buffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
637 if (fb
->_ColorReadBufferIndex
== -1 ||
641 fb
->_ColorReadBuffer
= NULL
; /* legal! */
644 ASSERT(fb
->_ColorReadBufferIndex
>= 0);
645 ASSERT(fb
->_ColorReadBufferIndex
< BUFFER_COUNT
);
647 = fb
->Attachment
[fb
->_ColorReadBufferIndex
].Renderbuffer
;
653 * Update a gl_framebuffer's derived state.
655 * Specifically, update these framebuffer fields:
657 * _NumColorDrawBuffers
662 * If the framebuffer is user-created, make sure it's complete.
664 * The following functions (at least) can effect framebuffer state:
665 * glReadBuffer, glDrawBuffer, glDrawBuffersARB, glFramebufferRenderbufferEXT,
666 * glRenderbufferStorageEXT.
669 update_framebuffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
671 /* Completeness only matters for user-created framebuffers */
673 /* XXX: EXT_framebuffer_blit:
674 framebuffer must still be complete wrt read/draw? */
675 _mesa_test_framebuffer_completeness(ctx
, fb
);
676 _mesa_update_framebuffer_visual(fb
);
679 /* Strictly speaking, we don't need to update the draw-state
680 * if this FB is bound as ctx->ReadBuffer (and conversely, the
681 * read-state if this FB is bound as ctx->DrawBuffer), but no
684 update_color_draw_buffers(ctx
, fb
);
685 update_color_read_buffer(ctx
, fb
);
686 _mesa_update_depth_buffer(ctx
, fb
, BUFFER_DEPTH
);
687 _mesa_update_stencil_buffer(ctx
, fb
, BUFFER_STENCIL
);
689 compute_depth_max(fb
);
694 * Update state related to the current draw/read framebuffers.
697 _mesa_update_framebuffer(GLcontext
*ctx
)
699 struct gl_framebuffer
*drawFb
= ctx
->DrawBuffer
;
700 struct gl_framebuffer
*readFb
= ctx
->ReadBuffer
;
702 update_framebuffer(ctx
, drawFb
);
703 if (readFb
!= drawFb
)
704 update_framebuffer(ctx
, readFb
);
709 * Check if the renderbuffer for a read operation (glReadPixels, glCopyPixels,
710 * glCopyTex[Sub]Image, etc. exists.
711 * \param format a basic image format such as GL_RGB, GL_RGBA, GL_ALPHA,
712 * GL_DEPTH_COMPONENT, etc. or GL_COLOR, GL_DEPTH, GL_STENCIL.
713 * \return GL_TRUE if buffer exists, GL_FALSE otherwise
716 _mesa_source_buffer_exists(GLcontext
*ctx
, GLenum format
)
718 const struct gl_renderbuffer_attachment
*att
719 = ctx
->ReadBuffer
->Attachment
;
721 if (ctx
->ReadBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
732 case GL_LUMINANCE_ALPHA
:
740 if (ctx
->ReadBuffer
->_ColorReadBuffer
== NULL
) {
743 /* XXX enable this post 6.5 release:
744 ASSERT(ctx->ReadBuffer->_ColorReadBuffer->RedBits > 0 ||
745 ctx->ReadBuffer->_ColorReadBuffer->IndexBits > 0);
749 case GL_DEPTH_COMPONENT
:
750 if (!att
[BUFFER_DEPTH
].Renderbuffer
) {
753 ASSERT(att
[BUFFER_DEPTH
].Renderbuffer
->DepthBits
> 0);
756 case GL_STENCIL_INDEX
:
757 if (!att
[BUFFER_STENCIL
].Renderbuffer
) {
760 ASSERT(att
[BUFFER_STENCIL
].Renderbuffer
->StencilBits
> 0);
762 case GL_DEPTH_STENCIL_EXT
:
763 if (!att
[BUFFER_DEPTH
].Renderbuffer
||
764 !att
[BUFFER_STENCIL
].Renderbuffer
) {
767 ASSERT(att
[BUFFER_DEPTH
].Renderbuffer
->DepthBits
> 0);
768 ASSERT(att
[BUFFER_STENCIL
].Renderbuffer
->StencilBits
> 0);
772 "Unexpected format 0x%x in _mesa_source_buffer_exists",
783 * As above, but for drawing operations.
784 * XXX code do some code merging w/ above function.
787 _mesa_dest_buffer_exists(GLcontext
*ctx
, GLenum format
)
789 const struct gl_renderbuffer_attachment
*att
790 = ctx
->ReadBuffer
->Attachment
;
792 if (ctx
->DrawBuffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
803 case GL_LUMINANCE_ALPHA
:
811 /* nothing special */
812 /* Could assert that colorbuffer has RedBits > 0 */
815 case GL_DEPTH_COMPONENT
:
816 if (!att
[BUFFER_DEPTH
].Renderbuffer
) {
819 ASSERT(att
[BUFFER_DEPTH
].Renderbuffer
->DepthBits
> 0);
822 case GL_STENCIL_INDEX
:
823 if (!att
[BUFFER_STENCIL
].Renderbuffer
) {
826 ASSERT(att
[BUFFER_STENCIL
].Renderbuffer
->StencilBits
> 0);
828 case GL_DEPTH_STENCIL_EXT
:
829 if (!att
[BUFFER_DEPTH
].Renderbuffer
||
830 !att
[BUFFER_STENCIL
].Renderbuffer
) {
833 ASSERT(att
[BUFFER_DEPTH
].Renderbuffer
->DepthBits
> 0);
834 ASSERT(att
[BUFFER_STENCIL
].Renderbuffer
->StencilBits
> 0);
838 "Unexpected format 0x%x in _mesa_source_buffer_exists",