2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (C) 1999-2009 VMware, Inc. All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 * GL_EXT/ARB_framebuffer_object extensions
40 #include "framebuffer.h"
43 #include "renderbuffer.h"
49 /** Set this to 1 to help debug FBO incompleteness problems */
52 /** Set this to 1 to debug/log glBlitFramebuffer() calls */
59 * None of the GL_EXT_framebuffer_object functions are compiled into
66 * When glGenRender/FramebuffersEXT() is called we insert pointers to
67 * these placeholder objects into the hash table.
68 * Later, when the object ID is first bound, we replace the placeholder
69 * with the real frame/renderbuffer.
71 static struct gl_framebuffer DummyFramebuffer
;
72 static struct gl_renderbuffer DummyRenderbuffer
;
75 #define IS_CUBE_FACE(TARGET) \
76 ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \
77 (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
81 delete_dummy_renderbuffer(struct gl_renderbuffer
*rb
)
87 delete_dummy_framebuffer(struct gl_framebuffer
*fb
)
94 _mesa_init_fbobjects(GLcontext
*ctx
)
96 DummyFramebuffer
.Delete
= delete_dummy_framebuffer
;
97 DummyRenderbuffer
.Delete
= delete_dummy_renderbuffer
;
102 * Helper routine for getting a gl_renderbuffer.
104 struct gl_renderbuffer
*
105 _mesa_lookup_renderbuffer(GLcontext
*ctx
, GLuint id
)
107 struct gl_renderbuffer
*rb
;
112 rb
= (struct gl_renderbuffer
*)
113 _mesa_HashLookup(ctx
->Shared
->RenderBuffers
, id
);
119 * Helper routine for getting a gl_framebuffer.
121 struct gl_framebuffer
*
122 _mesa_lookup_framebuffer(GLcontext
*ctx
, GLuint id
)
124 struct gl_framebuffer
*fb
;
129 fb
= (struct gl_framebuffer
*)
130 _mesa_HashLookup(ctx
->Shared
->FrameBuffers
, id
);
136 * Mark the given framebuffer as invalid. This will force the
137 * test for framebuffer completeness to be done before the framebuffer
141 invalidate_framebuffer(struct gl_framebuffer
*fb
)
143 fb
->_Status
= 0; /* "indeterminate" */
148 * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding
149 * gl_renderbuffer_attachment object.
150 * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to
151 * the depth buffer attachment point.
153 struct gl_renderbuffer_attachment
*
154 _mesa_get_attachment(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
159 switch (attachment
) {
160 case GL_COLOR_ATTACHMENT0_EXT
:
161 case GL_COLOR_ATTACHMENT1_EXT
:
162 case GL_COLOR_ATTACHMENT2_EXT
:
163 case GL_COLOR_ATTACHMENT3_EXT
:
164 case GL_COLOR_ATTACHMENT4_EXT
:
165 case GL_COLOR_ATTACHMENT5_EXT
:
166 case GL_COLOR_ATTACHMENT6_EXT
:
167 case GL_COLOR_ATTACHMENT7_EXT
:
168 case GL_COLOR_ATTACHMENT8_EXT
:
169 case GL_COLOR_ATTACHMENT9_EXT
:
170 case GL_COLOR_ATTACHMENT10_EXT
:
171 case GL_COLOR_ATTACHMENT11_EXT
:
172 case GL_COLOR_ATTACHMENT12_EXT
:
173 case GL_COLOR_ATTACHMENT13_EXT
:
174 case GL_COLOR_ATTACHMENT14_EXT
:
175 case GL_COLOR_ATTACHMENT15_EXT
:
176 i
= attachment
- GL_COLOR_ATTACHMENT0_EXT
;
177 if (i
>= ctx
->Const
.MaxColorAttachments
) {
180 return &fb
->Attachment
[BUFFER_COLOR0
+ i
];
181 case GL_DEPTH_STENCIL_ATTACHMENT
:
183 case GL_DEPTH_ATTACHMENT_EXT
:
184 return &fb
->Attachment
[BUFFER_DEPTH
];
185 case GL_STENCIL_ATTACHMENT_EXT
:
186 return &fb
->Attachment
[BUFFER_STENCIL
];
194 * Remove any texture or renderbuffer attached to the given attachment
195 * point. Update reference counts, etc.
198 _mesa_remove_attachment(GLcontext
*ctx
, struct gl_renderbuffer_attachment
*att
)
200 if (att
->Type
== GL_TEXTURE
) {
201 ASSERT(att
->Texture
);
202 if (ctx
->Driver
.FinishRenderTexture
) {
203 /* tell driver that we're done rendering to this texture. */
204 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
206 _mesa_reference_texobj(&att
->Texture
, NULL
); /* unbind */
207 ASSERT(!att
->Texture
);
209 if (att
->Type
== GL_TEXTURE
|| att
->Type
== GL_RENDERBUFFER_EXT
) {
210 ASSERT(!att
->Texture
);
211 _mesa_reference_renderbuffer(&att
->Renderbuffer
, NULL
); /* unbind */
212 ASSERT(!att
->Renderbuffer
);
215 att
->Complete
= GL_TRUE
;
220 * Bind a texture object to an attachment point.
221 * The previous binding, if any, will be removed first.
224 _mesa_set_texture_attachment(GLcontext
*ctx
,
225 struct gl_framebuffer
*fb
,
226 struct gl_renderbuffer_attachment
*att
,
227 struct gl_texture_object
*texObj
,
228 GLenum texTarget
, GLuint level
, GLuint zoffset
)
230 if (att
->Texture
== texObj
) {
231 /* re-attaching same texture */
232 ASSERT(att
->Type
== GL_TEXTURE
);
233 if (ctx
->Driver
.FinishRenderTexture
)
234 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
238 if (ctx
->Driver
.FinishRenderTexture
&& att
->Texture
)
239 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
240 _mesa_remove_attachment(ctx
, att
);
241 att
->Type
= GL_TEXTURE
;
242 assert(!att
->Texture
);
243 _mesa_reference_texobj(&att
->Texture
, texObj
);
246 /* always update these fields */
247 att
->TextureLevel
= level
;
248 att
->CubeMapFace
= _mesa_tex_target_to_face(texTarget
);
249 att
->Zoffset
= zoffset
;
250 att
->Complete
= GL_FALSE
;
252 if (att
->Texture
->Image
[att
->CubeMapFace
][att
->TextureLevel
]) {
253 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
256 invalidate_framebuffer(fb
);
261 * Bind a renderbuffer to an attachment point.
262 * The previous binding, if any, will be removed first.
265 _mesa_set_renderbuffer_attachment(GLcontext
*ctx
,
266 struct gl_renderbuffer_attachment
*att
,
267 struct gl_renderbuffer
*rb
)
269 /* XXX check if re-doing same attachment, exit early */
270 _mesa_remove_attachment(ctx
, att
);
271 att
->Type
= GL_RENDERBUFFER_EXT
;
272 att
->Texture
= NULL
; /* just to be safe */
273 att
->Complete
= GL_FALSE
;
274 _mesa_reference_renderbuffer(&att
->Renderbuffer
, rb
);
279 * Fallback for ctx->Driver.FramebufferRenderbuffer()
280 * Attach a renderbuffer object to a framebuffer object.
283 _mesa_framebuffer_renderbuffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
284 GLenum attachment
, struct gl_renderbuffer
*rb
)
286 struct gl_renderbuffer_attachment
*att
;
288 _glthread_LOCK_MUTEX(fb
->Mutex
);
290 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
293 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
294 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
295 /* do stencil attachment here (depth already done above) */
296 att
= _mesa_get_attachment(ctx
, fb
, GL_STENCIL_ATTACHMENT_EXT
);
298 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
302 _mesa_remove_attachment(ctx
, att
);
305 invalidate_framebuffer(fb
);
307 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
315 att_incomplete(const char *msg
)
318 _mesa_debug(NULL
, "attachment incomplete: %s\n", msg
);
329 fbo_incomplete(const char *msg
, int index
)
332 _mesa_debug(NULL
, "FBO Incomplete: %s [%d]\n", msg
, index
);
343 * Test if an attachment point is complete and update its Complete field.
344 * \param format if GL_COLOR, this is a color attachment point,
345 * if GL_DEPTH, this is a depth component attachment point,
346 * if GL_STENCIL, this is a stencil component attachment point.
349 test_attachment_completeness(const GLcontext
*ctx
, GLenum format
,
350 struct gl_renderbuffer_attachment
*att
)
352 assert(format
== GL_COLOR
|| format
== GL_DEPTH
|| format
== GL_STENCIL
);
354 /* assume complete */
355 att
->Complete
= GL_TRUE
;
357 /* Look for reasons why the attachment might be incomplete */
358 if (att
->Type
== GL_TEXTURE
) {
359 const struct gl_texture_object
*texObj
= att
->Texture
;
360 struct gl_texture_image
*texImage
;
364 att_incomplete("no texobj");
365 att
->Complete
= GL_FALSE
;
369 texImage
= texObj
->Image
[att
->CubeMapFace
][att
->TextureLevel
];
371 att_incomplete("no teximage");
372 att
->Complete
= GL_FALSE
;
375 if (texImage
->Width
< 1 || texImage
->Height
< 1) {
376 att_incomplete("teximage width/height=0");
377 printf("texobj = %u\n", texObj
->Name
);
378 printf("level = %d\n", att
->TextureLevel
);
379 att
->Complete
= GL_FALSE
;
382 if (texObj
->Target
== GL_TEXTURE_3D
&& att
->Zoffset
>= texImage
->Depth
) {
383 att_incomplete("bad z offset");
384 att
->Complete
= GL_FALSE
;
388 baseFormat
= _mesa_get_format_base_format(texImage
->TexFormat
);
390 if (format
== GL_COLOR
) {
391 if (baseFormat
!= GL_RGB
&&
392 baseFormat
!= GL_RGBA
) {
393 att_incomplete("bad format");
394 att
->Complete
= GL_FALSE
;
397 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
398 att_incomplete("compressed internalformat");
399 att
->Complete
= GL_FALSE
;
403 else if (format
== GL_DEPTH
) {
404 if (baseFormat
== GL_DEPTH_COMPONENT
) {
407 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
408 ctx
->Extensions
.ARB_depth_texture
&&
409 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
413 att
->Complete
= GL_FALSE
;
414 att_incomplete("bad depth format");
419 ASSERT(format
== GL_STENCIL
);
420 if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
421 ctx
->Extensions
.ARB_depth_texture
&&
422 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
426 /* no such thing as stencil-only textures */
427 att_incomplete("illegal stencil texture");
428 att
->Complete
= GL_FALSE
;
433 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
434 const GLenum baseFormat
=
435 _mesa_get_format_base_format(att
->Renderbuffer
->Format
);
437 ASSERT(att
->Renderbuffer
);
438 if (!att
->Renderbuffer
->InternalFormat
||
439 att
->Renderbuffer
->Width
< 1 ||
440 att
->Renderbuffer
->Height
< 1) {
441 att_incomplete("0x0 renderbuffer");
442 att
->Complete
= GL_FALSE
;
445 if (format
== GL_COLOR
) {
446 if (baseFormat
!= GL_RGB
&&
447 baseFormat
!= GL_RGBA
) {
448 att_incomplete("bad renderbuffer color format");
449 att
->Complete
= GL_FALSE
;
453 else if (format
== GL_DEPTH
) {
454 if (baseFormat
== GL_DEPTH_COMPONENT
) {
457 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
458 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
462 att_incomplete("bad renderbuffer depth format");
463 att
->Complete
= GL_FALSE
;
468 assert(format
== GL_STENCIL
);
469 if (baseFormat
== GL_STENCIL_INDEX
) {
472 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
473 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
477 att
->Complete
= GL_FALSE
;
478 att_incomplete("bad renderbuffer stencil format");
484 ASSERT(att
->Type
== GL_NONE
);
492 * Test if the given framebuffer object is complete and update its
493 * Status field with the results.
494 * Calls the ctx->Driver.ValidateFramebuffer() function to allow the
495 * driver to make hardware-specific validation/completeness checks.
496 * Also update the framebuffer's Width and Height fields if the
497 * framebuffer is complete.
500 _mesa_test_framebuffer_completeness(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
503 GLenum intFormat
= GL_NONE
; /* color buffers' internal format */
504 GLuint minWidth
= ~0, minHeight
= ~0, maxWidth
= 0, maxHeight
= 0;
505 GLint numSamples
= -1;
509 assert(fb
->Name
!= 0);
515 /* Start at -2 to more easily loop over all attachment points.
520 for (i
= -2; i
< (GLint
) ctx
->Const
.MaxColorAttachments
; i
++) {
521 struct gl_renderbuffer_attachment
*att
;
525 * XXX for ARB_fbo, only check color buffers that are named by
526 * GL_READ_BUFFER and GL_DRAW_BUFFERi.
529 /* check for attachment completeness
532 att
= &fb
->Attachment
[BUFFER_DEPTH
];
533 test_attachment_completeness(ctx
, GL_DEPTH
, att
);
534 if (!att
->Complete
) {
535 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
536 fbo_incomplete("depth attachment incomplete", -1);
541 att
= &fb
->Attachment
[BUFFER_STENCIL
];
542 test_attachment_completeness(ctx
, GL_STENCIL
, att
);
543 if (!att
->Complete
) {
544 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
545 fbo_incomplete("stencil attachment incomplete", -1);
550 att
= &fb
->Attachment
[BUFFER_COLOR0
+ i
];
551 test_attachment_completeness(ctx
, GL_COLOR
, att
);
552 if (!att
->Complete
) {
553 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
554 fbo_incomplete("color attachment incomplete", i
);
559 /* get width, height, format of the renderbuffer/texture
561 if (att
->Type
== GL_TEXTURE
) {
562 const struct gl_texture_image
*texImg
563 = att
->Texture
->Image
[att
->CubeMapFace
][att
->TextureLevel
];
564 minWidth
= MIN2(minWidth
, texImg
->Width
);
565 maxWidth
= MAX2(maxWidth
, texImg
->Width
);
566 minHeight
= MIN2(minHeight
, texImg
->Height
);
567 maxHeight
= MAX2(maxHeight
, texImg
->Height
);
568 f
= texImg
->_BaseFormat
;
570 if (f
!= GL_RGB
&& f
!= GL_RGBA
&& f
!= GL_DEPTH_COMPONENT
571 && f
!= GL_DEPTH_STENCIL_EXT
) {
572 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
573 fbo_incomplete("texture attachment incomplete", -1);
577 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
578 minWidth
= MIN2(minWidth
, att
->Renderbuffer
->Width
);
579 maxWidth
= MAX2(minWidth
, att
->Renderbuffer
->Width
);
580 minHeight
= MIN2(minHeight
, att
->Renderbuffer
->Height
);
581 maxHeight
= MAX2(minHeight
, att
->Renderbuffer
->Height
);
582 f
= att
->Renderbuffer
->InternalFormat
;
586 assert(att
->Type
== GL_NONE
);
590 if (numSamples
< 0) {
592 numSamples
= att
->Renderbuffer
->NumSamples
;
595 /* Error-check width, height, format, samples
597 if (numImages
== 1) {
598 /* save format, num samples */
604 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
605 /* check that width, height, format are same */
606 if (minWidth
!= maxWidth
|| minHeight
!= maxHeight
) {
607 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
;
608 fbo_incomplete("width or height mismatch", -1);
611 /* check that all color buffer have same format */
612 if (intFormat
!= GL_NONE
&& f
!= intFormat
) {
613 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
614 fbo_incomplete("format mismatch", -1);
618 if (att
->Renderbuffer
&&
619 att
->Renderbuffer
->NumSamples
!= numSamples
) {
620 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
;
621 fbo_incomplete("inconsistant number of samples", i
);
628 #ifndef FEATURE_OES_framebuffer_object
629 /* Check that all DrawBuffers are present */
630 for (j
= 0; j
< ctx
->Const
.MaxDrawBuffers
; j
++) {
631 if (fb
->ColorDrawBuffer
[j
] != GL_NONE
) {
632 const struct gl_renderbuffer_attachment
*att
633 = _mesa_get_attachment(ctx
, fb
, fb
->ColorDrawBuffer
[j
]);
635 if (att
->Type
== GL_NONE
) {
636 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
;
637 fbo_incomplete("missing drawbuffer", j
);
643 /* Check that the ReadBuffer is present */
644 if (fb
->ColorReadBuffer
!= GL_NONE
) {
645 const struct gl_renderbuffer_attachment
*att
646 = _mesa_get_attachment(ctx
, fb
, fb
->ColorReadBuffer
);
648 if (att
->Type
== GL_NONE
) {
649 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
;
650 fbo_incomplete("missing readbuffer", -1);
658 if (numImages
== 0) {
659 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
;
660 fbo_incomplete("no attachments", -1);
664 /* Provisionally set status = COMPLETE ... */
665 fb
->_Status
= GL_FRAMEBUFFER_COMPLETE_EXT
;
667 /* ... but the driver may say the FB is incomplete.
668 * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED
671 if (ctx
->Driver
.ValidateFramebuffer
) {
672 ctx
->Driver
.ValidateFramebuffer(ctx
, fb
);
673 if (fb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
674 fbo_incomplete("driver marked FBO as incomplete", -1);
678 if (fb
->_Status
== GL_FRAMEBUFFER_COMPLETE_EXT
) {
680 * Note that if ARB_framebuffer_object is supported and the attached
681 * renderbuffers/textures are different sizes, the framebuffer
682 * width/height will be set to the smallest width/height.
684 fb
->Width
= minWidth
;
685 fb
->Height
= minHeight
;
687 /* finally, update the visual info for the framebuffer */
688 _mesa_update_framebuffer_visual(fb
);
694 _mesa_IsRenderbufferEXT(GLuint renderbuffer
)
696 GET_CURRENT_CONTEXT(ctx
);
697 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
699 struct gl_renderbuffer
*rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
700 if (rb
!= NULL
&& rb
!= &DummyRenderbuffer
)
708 _mesa_BindRenderbufferEXT(GLenum target
, GLuint renderbuffer
)
710 struct gl_renderbuffer
*newRb
;
711 GET_CURRENT_CONTEXT(ctx
);
713 ASSERT_OUTSIDE_BEGIN_END(ctx
);
715 if (target
!= GL_RENDERBUFFER_EXT
) {
716 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindRenderbufferEXT(target)");
720 /* No need to flush here since the render buffer binding has no
721 * effect on rendering state.
725 newRb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
726 if (newRb
== &DummyRenderbuffer
) {
727 /* ID was reserved, but no real renderbuffer object made yet */
730 else if (!newRb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
731 /* All RB IDs must be Gen'd */
732 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindRenderbuffer(buffer)");
737 /* create new renderbuffer object */
738 newRb
= ctx
->Driver
.NewRenderbuffer(ctx
, renderbuffer
);
740 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindRenderbufferEXT");
743 ASSERT(newRb
->AllocStorage
);
744 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, renderbuffer
, newRb
);
745 newRb
->RefCount
= 1; /* referenced by hash table */
752 ASSERT(newRb
!= &DummyRenderbuffer
);
754 _mesa_reference_renderbuffer(&ctx
->CurrentRenderbuffer
, newRb
);
759 * If the given renderbuffer is anywhere attached to the framebuffer, detach
761 * This is used when a renderbuffer object is deleted.
762 * The spec calls for unbinding.
765 detach_renderbuffer(GLcontext
*ctx
,
766 struct gl_framebuffer
*fb
,
767 struct gl_renderbuffer
*rb
)
770 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
771 if (fb
->Attachment
[i
].Renderbuffer
== rb
) {
772 _mesa_remove_attachment(ctx
, &fb
->Attachment
[i
]);
775 invalidate_framebuffer(fb
);
780 _mesa_DeleteRenderbuffersEXT(GLsizei n
, const GLuint
*renderbuffers
)
783 GET_CURRENT_CONTEXT(ctx
);
785 ASSERT_OUTSIDE_BEGIN_END(ctx
);
786 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
788 for (i
= 0; i
< n
; i
++) {
789 if (renderbuffers
[i
] > 0) {
790 struct gl_renderbuffer
*rb
;
791 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffers
[i
]);
793 /* check if deleting currently bound renderbuffer object */
794 if (rb
== ctx
->CurrentRenderbuffer
) {
796 ASSERT(rb
->RefCount
>= 2);
797 _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT
, 0);
800 if (ctx
->DrawBuffer
->Name
) {
801 detach_renderbuffer(ctx
, ctx
->DrawBuffer
, rb
);
803 if (ctx
->ReadBuffer
->Name
&& ctx
->ReadBuffer
!= ctx
->DrawBuffer
) {
804 detach_renderbuffer(ctx
, ctx
->ReadBuffer
, rb
);
807 /* Remove from hash table immediately, to free the ID.
808 * But the object will not be freed until it's no longer
809 * referenced anywhere else.
811 _mesa_HashRemove(ctx
->Shared
->RenderBuffers
, renderbuffers
[i
]);
813 if (rb
!= &DummyRenderbuffer
) {
814 /* no longer referenced by hash table */
815 _mesa_reference_renderbuffer(&rb
, NULL
);
824 _mesa_GenRenderbuffersEXT(GLsizei n
, GLuint
*renderbuffers
)
826 GET_CURRENT_CONTEXT(ctx
);
830 ASSERT_OUTSIDE_BEGIN_END(ctx
);
833 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenRenderbuffersEXT(n)");
840 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->RenderBuffers
, n
);
842 for (i
= 0; i
< n
; i
++) {
843 GLuint name
= first
+ i
;
844 renderbuffers
[i
] = name
;
845 /* insert dummy placeholder into hash table */
846 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
847 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, name
, &DummyRenderbuffer
);
848 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
854 * Given an internal format token for a render buffer, return the
855 * corresponding base format.
856 * This is very similar to _mesa_base_tex_format() but the set of valid
857 * internal formats is somewhat different.
859 * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT
860 * GL_DEPTH_STENCIL_EXT or zero if error.
862 * XXX in the future when we support red-only and red-green formats
863 * we'll also return GL_RED and GL_RG.
866 _mesa_base_fbo_format(GLcontext
*ctx
, GLenum internalFormat
)
868 switch (internalFormat
) {
887 case GL_STENCIL_INDEX
:
888 case GL_STENCIL_INDEX1_EXT
:
889 case GL_STENCIL_INDEX4_EXT
:
890 case GL_STENCIL_INDEX8_EXT
:
891 case GL_STENCIL_INDEX16_EXT
:
892 return GL_STENCIL_INDEX
;
893 case GL_DEPTH_COMPONENT
:
894 case GL_DEPTH_COMPONENT16
:
895 case GL_DEPTH_COMPONENT24
:
896 case GL_DEPTH_COMPONENT32
:
897 return GL_DEPTH_COMPONENT
;
898 case GL_DEPTH_STENCIL_EXT
:
899 case GL_DEPTH24_STENCIL8_EXT
:
900 if (ctx
->Extensions
.EXT_packed_depth_stencil
)
901 return GL_DEPTH_STENCIL_EXT
;
904 /* XXX add floating point formats eventually */
911 /** sentinal value, see below */
912 #define NO_SAMPLES 1000
916 * Helper function used by _mesa_RenderbufferStorageEXT() and
917 * _mesa_RenderbufferStorageMultisample().
918 * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT().
921 renderbuffer_storage(GLenum target
, GLenum internalFormat
,
922 GLsizei width
, GLsizei height
, GLsizei samples
)
924 const char *func
= samples
== NO_SAMPLES
?
925 "glRenderbufferStorage" : "RenderbufferStorageMultisample";
926 struct gl_renderbuffer
*rb
;
928 GET_CURRENT_CONTEXT(ctx
);
930 ASSERT_OUTSIDE_BEGIN_END(ctx
);
932 if (target
!= GL_RENDERBUFFER_EXT
) {
933 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(target)", func
);
937 baseFormat
= _mesa_base_fbo_format(ctx
, internalFormat
);
938 if (baseFormat
== 0) {
939 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(internalFormat)", func
);
943 if (width
< 1 || width
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
944 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(width)", func
);
948 if (height
< 1 || height
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
949 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(height)", func
);
953 if (samples
== NO_SAMPLES
) {
954 /* NumSamples == 0 indicates non-multisampling */
957 else if (samples
> (GLsizei
) ctx
->Const
.MaxSamples
) {
958 /* note: driver may choose to use more samples than what's requested */
959 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(samples)", func
);
963 rb
= ctx
->CurrentRenderbuffer
;
965 _mesa_error(ctx
, GL_INVALID_OPERATION
, func
);
969 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
971 if (rb
->InternalFormat
== internalFormat
&&
972 rb
->Width
== (GLuint
) width
&&
973 rb
->Height
== (GLuint
) height
) {
974 /* no change in allocation needed */
978 /* These MUST get set by the AllocStorage func */
979 rb
->Format
= MESA_FORMAT_NONE
;
980 rb
->NumSamples
= samples
;
982 /* Now allocate the storage */
983 ASSERT(rb
->AllocStorage
);
984 if (rb
->AllocStorage(ctx
, rb
, internalFormat
, width
, height
)) {
985 /* No error - check/set fields now */
986 assert(rb
->Format
!= MESA_FORMAT_NONE
);
987 assert(rb
->Width
== (GLuint
) width
);
988 assert(rb
->Height
== (GLuint
) height
);
989 rb
->InternalFormat
= internalFormat
;
990 rb
->_BaseFormat
= baseFormat
;
991 assert(rb
->_BaseFormat
!= 0);
994 /* Probably ran out of memory - clear the fields */
997 rb
->Format
= MESA_FORMAT_NONE
;
998 rb
->InternalFormat
= GL_NONE
;
999 rb
->_BaseFormat
= GL_NONE
;
1004 test_framebuffer_completeness(ctx, fb);
1006 /* XXX if this renderbuffer is attached anywhere, invalidate attachment
1011 #if FEATURE_OES_EGL_image
1013 _mesa_EGLImageTargetRenderbufferStorageOES (GLenum target
, GLeglImageOES image
)
1015 struct gl_renderbuffer
*rb
;
1016 GET_CURRENT_CONTEXT(ctx
);
1017 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1019 if (target
!= GL_RENDERBUFFER
) {
1020 _mesa_error(ctx
, GL_INVALID_ENUM
, "EGLImageTargetRenderbufferStorageOES");
1024 rb
= ctx
->CurrentRenderbuffer
;
1026 _mesa_error(ctx
, GL_INVALID_OPERATION
, "EGLImageTargetRenderbufferStorageOES");
1030 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1032 ctx
->Driver
.EGLImageTargetRenderbufferStorage(ctx
, rb
, image
);
1037 * Helper function for _mesa_GetRenderbufferParameterivEXT() and
1038 * _mesa_GetFramebufferAttachmentParameterivEXT()
1039 * We have to be careful to respect the base format. For example, if a
1040 * renderbuffer/texture was created with internalFormat=GL_RGB but the
1041 * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE
1042 * we need to return zero.
1045 get_component_bits(GLenum pname
, GLenum baseFormat
, gl_format format
)
1048 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1049 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
1050 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1051 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
1052 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1053 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
1054 if (baseFormat
== GL_RGB
|| baseFormat
== GL_RGBA
)
1055 return _mesa_get_format_bits(format
, pname
);
1058 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1059 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
1060 if (baseFormat
== GL_RGBA
|| baseFormat
== GL_ALPHA
)
1061 return _mesa_get_format_bits(format
, pname
);
1064 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1065 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
1066 if (baseFormat
== GL_DEPTH_COMPONENT
|| baseFormat
== GL_DEPTH_STENCIL
)
1067 return _mesa_get_format_bits(format
, pname
);
1070 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1071 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
1072 if (baseFormat
== GL_STENCIL_INDEX
|| baseFormat
== GL_DEPTH_STENCIL
)
1073 return _mesa_get_format_bits(format
, pname
);
1084 _mesa_RenderbufferStorageEXT(GLenum target
, GLenum internalFormat
,
1085 GLsizei width
, GLsizei height
)
1087 /* GL_ARB_fbo says calling this function is equivalent to calling
1088 * glRenderbufferStorageMultisample() with samples=0. We pass in
1089 * a token value here just for error reporting purposes.
1091 renderbuffer_storage(target
, internalFormat
, width
, height
, NO_SAMPLES
);
1096 _mesa_RenderbufferStorageMultisample(GLenum target
, GLsizei samples
,
1097 GLenum internalFormat
,
1098 GLsizei width
, GLsizei height
)
1100 renderbuffer_storage(target
, internalFormat
, width
, height
, samples
);
1106 _mesa_GetRenderbufferParameterivEXT(GLenum target
, GLenum pname
, GLint
*params
)
1108 struct gl_renderbuffer
*rb
;
1109 GET_CURRENT_CONTEXT(ctx
);
1111 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1113 if (target
!= GL_RENDERBUFFER_EXT
) {
1114 _mesa_error(ctx
, GL_INVALID_ENUM
,
1115 "glGetRenderbufferParameterivEXT(target)");
1119 rb
= ctx
->CurrentRenderbuffer
;
1121 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1122 "glGetRenderbufferParameterivEXT");
1126 /* No need to flush here since we're just quering state which is
1127 * not effected by rendering.
1131 case GL_RENDERBUFFER_WIDTH_EXT
:
1132 *params
= rb
->Width
;
1134 case GL_RENDERBUFFER_HEIGHT_EXT
:
1135 *params
= rb
->Height
;
1137 case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT
:
1138 *params
= rb
->InternalFormat
;
1140 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1141 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1142 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1143 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1144 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1145 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1146 *params
= get_component_bits(pname
, rb
->_BaseFormat
, rb
->Format
);
1148 case GL_RENDERBUFFER_SAMPLES
:
1149 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1150 *params
= rb
->NumSamples
;
1155 _mesa_error(ctx
, GL_INVALID_ENUM
,
1156 "glGetRenderbufferParameterivEXT(target)");
1162 GLboolean GLAPIENTRY
1163 _mesa_IsFramebufferEXT(GLuint framebuffer
)
1165 GET_CURRENT_CONTEXT(ctx
);
1166 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
1168 struct gl_framebuffer
*rb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1169 if (rb
!= NULL
&& rb
!= &DummyFramebuffer
)
1177 * Check if any of the attachments of the given framebuffer are textures
1178 * (render to texture). Call ctx->Driver.RenderTexture() for such
1182 check_begin_texture_render(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
1185 ASSERT(ctx
->Driver
.RenderTexture
);
1188 return; /* can't render to texture with winsys framebuffers */
1190 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1191 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1192 struct gl_texture_object
*texObj
= att
->Texture
;
1194 && texObj
->Image
[att
->CubeMapFace
][att
->TextureLevel
]) {
1195 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
1202 * Examine all the framebuffer's attachments to see if any are textures.
1203 * If so, call ctx->Driver.FinishRenderTexture() for each texture to
1204 * notify the device driver that the texture image may have changed.
1207 check_end_texture_render(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
1210 return; /* can't render to texture with winsys framebuffers */
1212 if (ctx
->Driver
.FinishRenderTexture
) {
1214 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1215 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1216 if (att
->Texture
&& att
->Renderbuffer
) {
1217 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
1225 _mesa_BindFramebufferEXT(GLenum target
, GLuint framebuffer
)
1227 struct gl_framebuffer
*newDrawFb
, *newReadFb
;
1228 struct gl_framebuffer
*oldDrawFb
, *oldReadFb
;
1229 GLboolean bindReadBuf
, bindDrawBuf
;
1230 GET_CURRENT_CONTEXT(ctx
);
1233 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1234 ASSERT(ctx
->Extensions
.EXT_framebuffer_object
);
1235 ASSERT(ctx
->Extensions
.EXT_framebuffer_blit
);
1239 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1241 if (!ctx
->Extensions
.EXT_framebuffer_object
) {
1242 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1243 "glBindFramebufferEXT(unsupported)");
1248 #if FEATURE_EXT_framebuffer_blit
1249 case GL_DRAW_FRAMEBUFFER_EXT
:
1250 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1251 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1254 bindDrawBuf
= GL_TRUE
;
1255 bindReadBuf
= GL_FALSE
;
1257 case GL_READ_FRAMEBUFFER_EXT
:
1258 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1259 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1262 bindDrawBuf
= GL_FALSE
;
1263 bindReadBuf
= GL_TRUE
;
1266 case GL_FRAMEBUFFER_EXT
:
1267 bindDrawBuf
= GL_TRUE
;
1268 bindReadBuf
= GL_TRUE
;
1271 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1276 /* Binding a user-created framebuffer object */
1277 newDrawFb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1278 if (newDrawFb
== &DummyFramebuffer
) {
1279 /* ID was reserved, but no real framebuffer object made yet */
1282 else if (!newDrawFb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
1283 /* All FBO IDs must be Gen'd */
1284 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindFramebuffer(buffer)");
1289 /* create new framebuffer object */
1290 newDrawFb
= ctx
->Driver
.NewFramebuffer(ctx
, framebuffer
);
1292 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindFramebufferEXT");
1295 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, framebuffer
, newDrawFb
);
1297 newReadFb
= newDrawFb
;
1300 /* Binding the window system framebuffer (which was originally set
1301 * with MakeCurrent).
1303 newDrawFb
= ctx
->WinSysDrawBuffer
;
1304 newReadFb
= ctx
->WinSysReadBuffer
;
1308 ASSERT(newDrawFb
!= &DummyFramebuffer
);
1310 /* save pointers to current/old framebuffers */
1311 oldDrawFb
= ctx
->DrawBuffer
;
1312 oldReadFb
= ctx
->ReadBuffer
;
1314 /* check if really changing bindings */
1315 if (oldDrawFb
== newDrawFb
)
1316 bindDrawBuf
= GL_FALSE
;
1317 if (oldReadFb
== newReadFb
)
1318 bindReadBuf
= GL_FALSE
;
1321 * OK, now bind the new Draw/Read framebuffers, if they're changing.
1323 * We also check if we're beginning and/or ending render-to-texture.
1324 * When a framebuffer with texture attachments is unbound, call
1325 * ctx->Driver.FinishRenderTexture().
1326 * When a framebuffer with texture attachments is bound, call
1327 * ctx->Driver.RenderTexture().
1329 * Note that if the ReadBuffer has texture attachments we don't consider
1330 * that a render-to-texture case.
1333 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1335 /* check if old readbuffer was render-to-texture */
1336 check_end_texture_render(ctx
, oldReadFb
);
1338 _mesa_reference_framebuffer(&ctx
->ReadBuffer
, newReadFb
);
1342 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1344 /* check if old read/draw buffers were render-to-texture */
1346 check_end_texture_render(ctx
, oldReadFb
);
1348 if (oldDrawFb
!= oldReadFb
)
1349 check_end_texture_render(ctx
, oldDrawFb
);
1351 /* check if newly bound framebuffer has any texture attachments */
1352 check_begin_texture_render(ctx
, newDrawFb
);
1354 _mesa_reference_framebuffer(&ctx
->DrawBuffer
, newDrawFb
);
1357 if ((bindDrawBuf
|| bindReadBuf
) && ctx
->Driver
.BindFramebuffer
) {
1358 ctx
->Driver
.BindFramebuffer(ctx
, target
, newDrawFb
, newReadFb
);
1364 _mesa_DeleteFramebuffersEXT(GLsizei n
, const GLuint
*framebuffers
)
1367 GET_CURRENT_CONTEXT(ctx
);
1369 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1370 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1372 for (i
= 0; i
< n
; i
++) {
1373 if (framebuffers
[i
] > 0) {
1374 struct gl_framebuffer
*fb
;
1375 fb
= _mesa_lookup_framebuffer(ctx
, framebuffers
[i
]);
1377 ASSERT(fb
== &DummyFramebuffer
|| fb
->Name
== framebuffers
[i
]);
1379 /* check if deleting currently bound framebuffer object */
1380 if (ctx
->Extensions
.EXT_framebuffer_blit
) {
1381 /* separate draw/read binding points */
1382 if (fb
== ctx
->DrawBuffer
) {
1384 ASSERT(fb
->RefCount
>= 2);
1385 _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT
, 0);
1387 if (fb
== ctx
->ReadBuffer
) {
1389 ASSERT(fb
->RefCount
>= 2);
1390 _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT
, 0);
1394 /* only one binding point for read/draw buffers */
1395 if (fb
== ctx
->DrawBuffer
|| fb
== ctx
->ReadBuffer
) {
1397 ASSERT(fb
->RefCount
>= 2);
1398 _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT
, 0);
1402 /* remove from hash table immediately, to free the ID */
1403 _mesa_HashRemove(ctx
->Shared
->FrameBuffers
, framebuffers
[i
]);
1405 if (fb
!= &DummyFramebuffer
) {
1406 /* But the object will not be freed until it's no longer
1407 * bound in any context.
1409 _mesa_reference_framebuffer(&fb
, NULL
);
1418 _mesa_GenFramebuffersEXT(GLsizei n
, GLuint
*framebuffers
)
1420 GET_CURRENT_CONTEXT(ctx
);
1424 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1427 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenFramebuffersEXT(n)");
1434 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->FrameBuffers
, n
);
1436 for (i
= 0; i
< n
; i
++) {
1437 GLuint name
= first
+ i
;
1438 framebuffers
[i
] = name
;
1439 /* insert dummy placeholder into hash table */
1440 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
1441 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, name
, &DummyFramebuffer
);
1442 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
1449 _mesa_CheckFramebufferStatusEXT(GLenum target
)
1451 struct gl_framebuffer
*buffer
;
1452 GET_CURRENT_CONTEXT(ctx
);
1454 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1457 #if FEATURE_EXT_framebuffer_blit
1458 case GL_DRAW_FRAMEBUFFER_EXT
:
1459 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1460 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1463 buffer
= ctx
->DrawBuffer
;
1465 case GL_READ_FRAMEBUFFER_EXT
:
1466 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1467 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1470 buffer
= ctx
->ReadBuffer
;
1473 case GL_FRAMEBUFFER_EXT
:
1474 buffer
= ctx
->DrawBuffer
;
1477 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1478 return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */
1481 if (buffer
->Name
== 0) {
1482 /* The window system / default framebuffer is always complete */
1483 return GL_FRAMEBUFFER_COMPLETE_EXT
;
1486 /* No need to flush here */
1488 if (buffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1489 _mesa_test_framebuffer_completeness(ctx
, buffer
);
1492 return buffer
->_Status
;
1498 * Common code called by glFramebufferTexture1D/2D/3DEXT().
1501 framebuffer_texture(GLcontext
*ctx
, const char *caller
, GLenum target
,
1502 GLenum attachment
, GLenum textarget
, GLuint texture
,
1503 GLint level
, GLint zoffset
)
1505 struct gl_renderbuffer_attachment
*att
;
1506 struct gl_texture_object
*texObj
= NULL
;
1507 struct gl_framebuffer
*fb
;
1508 GLboolean error
= GL_FALSE
;
1510 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1513 case GL_READ_FRAMEBUFFER_EXT
:
1514 error
= !ctx
->Extensions
.EXT_framebuffer_blit
;
1515 fb
= ctx
->ReadBuffer
;
1517 case GL_DRAW_FRAMEBUFFER_EXT
:
1518 error
= !ctx
->Extensions
.EXT_framebuffer_blit
;
1520 case GL_FRAMEBUFFER_EXT
:
1521 fb
= ctx
->DrawBuffer
;
1528 _mesa_error(ctx
, GL_INVALID_ENUM
,
1529 "glFramebufferTexture%sEXT(target=0x%x)", caller
, target
);
1535 /* check framebuffer binding */
1536 if (fb
->Name
== 0) {
1537 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1538 "glFramebufferTexture%sEXT", caller
);
1543 /* The textarget, level, and zoffset parameters are only validated if
1544 * texture is non-zero.
1547 GLboolean err
= GL_TRUE
;
1549 texObj
= _mesa_lookup_texture(ctx
, texture
);
1550 if (texObj
!= NULL
) {
1551 if (textarget
== 0) {
1552 err
= (texObj
->Target
!= GL_TEXTURE_3D
) &&
1553 (texObj
->Target
!= GL_TEXTURE_1D_ARRAY_EXT
) &&
1554 (texObj
->Target
!= GL_TEXTURE_2D_ARRAY_EXT
);
1557 err
= (texObj
->Target
== GL_TEXTURE_CUBE_MAP
)
1558 ? !IS_CUBE_FACE(textarget
)
1559 : (texObj
->Target
!= textarget
);
1564 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1565 "glFramebufferTexture%sEXT(texture target mismatch)",
1570 if (texObj
->Target
== GL_TEXTURE_3D
) {
1571 const GLint maxSize
= 1 << (ctx
->Const
.Max3DTextureLevels
- 1);
1572 if (zoffset
< 0 || zoffset
>= maxSize
) {
1573 _mesa_error(ctx
, GL_INVALID_VALUE
,
1574 "glFramebufferTexture%sEXT(zoffset)", caller
);
1578 else if ((texObj
->Target
== GL_TEXTURE_1D_ARRAY_EXT
) ||
1579 (texObj
->Target
== GL_TEXTURE_2D_ARRAY_EXT
)) {
1580 if (zoffset
< 0 || zoffset
>= ctx
->Const
.MaxArrayTextureLayers
) {
1581 _mesa_error(ctx
, GL_INVALID_VALUE
,
1582 "glFramebufferTexture%sEXT(layer)", caller
);
1588 (level
>= _mesa_max_texture_levels(ctx
, texObj
->Target
))) {
1589 _mesa_error(ctx
, GL_INVALID_VALUE
,
1590 "glFramebufferTexture%sEXT(level)", caller
);
1595 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
1597 _mesa_error(ctx
, GL_INVALID_ENUM
,
1598 "glFramebufferTexture%sEXT(attachment)", caller
);
1602 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1604 _glthread_LOCK_MUTEX(fb
->Mutex
);
1606 _mesa_set_texture_attachment(ctx
, fb
, att
, texObj
, textarget
,
1608 /* Set the render-to-texture flag. We'll check this flag in
1609 * glTexImage() and friends to determine if we need to revalidate
1610 * any FBOs that might be rendering into this texture.
1611 * This flag never gets cleared since it's non-trivial to determine
1612 * when all FBOs might be done rendering to this texture. That's OK
1613 * though since it's uncommon to render to a texture then repeatedly
1614 * call glTexImage() to change images in the texture.
1616 texObj
->_RenderToTexture
= GL_TRUE
;
1619 _mesa_remove_attachment(ctx
, att
);
1622 invalidate_framebuffer(fb
);
1624 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
1630 _mesa_FramebufferTexture1DEXT(GLenum target
, GLenum attachment
,
1631 GLenum textarget
, GLuint texture
, GLint level
)
1633 GET_CURRENT_CONTEXT(ctx
);
1635 if ((texture
!= 0) && (textarget
!= GL_TEXTURE_1D
)) {
1636 _mesa_error(ctx
, GL_INVALID_ENUM
,
1637 "glFramebufferTexture1DEXT(textarget)");
1641 framebuffer_texture(ctx
, "1D", target
, attachment
, textarget
, texture
,
1647 _mesa_FramebufferTexture2DEXT(GLenum target
, GLenum attachment
,
1648 GLenum textarget
, GLuint texture
, GLint level
)
1650 GET_CURRENT_CONTEXT(ctx
);
1652 if ((texture
!= 0) &&
1653 (textarget
!= GL_TEXTURE_2D
) &&
1654 (textarget
!= GL_TEXTURE_RECTANGLE_ARB
) &&
1655 (!IS_CUBE_FACE(textarget
))) {
1656 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1657 "glFramebufferTexture2DEXT(textarget=0x%x)", textarget
);
1661 framebuffer_texture(ctx
, "2D", target
, attachment
, textarget
, texture
,
1667 _mesa_FramebufferTexture3DEXT(GLenum target
, GLenum attachment
,
1668 GLenum textarget
, GLuint texture
,
1669 GLint level
, GLint zoffset
)
1671 GET_CURRENT_CONTEXT(ctx
);
1673 if ((texture
!= 0) && (textarget
!= GL_TEXTURE_3D
)) {
1674 _mesa_error(ctx
, GL_INVALID_ENUM
,
1675 "glFramebufferTexture3DEXT(textarget)");
1679 framebuffer_texture(ctx
, "3D", target
, attachment
, textarget
, texture
,
1685 _mesa_FramebufferTextureLayerEXT(GLenum target
, GLenum attachment
,
1686 GLuint texture
, GLint level
, GLint layer
)
1688 GET_CURRENT_CONTEXT(ctx
);
1690 framebuffer_texture(ctx
, "Layer", target
, attachment
, 0, texture
,
1696 _mesa_FramebufferRenderbufferEXT(GLenum target
, GLenum attachment
,
1697 GLenum renderbufferTarget
,
1698 GLuint renderbuffer
)
1700 struct gl_renderbuffer_attachment
*att
;
1701 struct gl_framebuffer
*fb
;
1702 struct gl_renderbuffer
*rb
;
1703 GET_CURRENT_CONTEXT(ctx
);
1705 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1708 #if FEATURE_EXT_framebuffer_blit
1709 case GL_DRAW_FRAMEBUFFER_EXT
:
1710 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1711 _mesa_error(ctx
, GL_INVALID_ENUM
,
1712 "glFramebufferRenderbufferEXT(target)");
1715 fb
= ctx
->DrawBuffer
;
1717 case GL_READ_FRAMEBUFFER_EXT
:
1718 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1719 _mesa_error(ctx
, GL_INVALID_ENUM
,
1720 "glFramebufferRenderbufferEXT(target)");
1723 fb
= ctx
->ReadBuffer
;
1726 case GL_FRAMEBUFFER_EXT
:
1727 fb
= ctx
->DrawBuffer
;
1730 _mesa_error(ctx
, GL_INVALID_ENUM
,
1731 "glFramebufferRenderbufferEXT(target)");
1735 if (renderbufferTarget
!= GL_RENDERBUFFER_EXT
) {
1736 _mesa_error(ctx
, GL_INVALID_ENUM
,
1737 "glFramebufferRenderbufferEXT(renderbufferTarget)");
1741 if (fb
->Name
== 0) {
1742 /* Can't attach new renderbuffers to a window system framebuffer */
1743 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glFramebufferRenderbufferEXT");
1747 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
1749 _mesa_error(ctx
, GL_INVALID_ENUM
,
1750 "glFramebufferRenderbufferEXT(invalid attachment %s)",
1751 _mesa_lookup_enum_by_nr(attachment
));
1756 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
1758 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1759 "glFramebufferRenderbufferEXT(non-existant"
1760 " renderbuffer %u)", renderbuffer
);
1765 /* remove renderbuffer attachment */
1769 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
1770 /* make sure the renderbuffer is a depth/stencil format */
1771 const GLenum baseFormat
=
1772 _mesa_get_format_base_format(att
->Renderbuffer
->Format
);
1773 if (baseFormat
!= GL_DEPTH_STENCIL
) {
1774 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1775 "glFramebufferRenderbufferEXT(renderbuffer"
1776 " is not DEPTH_STENCIL format)");
1782 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1784 assert(ctx
->Driver
.FramebufferRenderbuffer
);
1785 ctx
->Driver
.FramebufferRenderbuffer(ctx
, fb
, attachment
, rb
);
1787 /* Some subsequent GL commands may depend on the framebuffer's visual
1788 * after the binding is updated. Update visual info now.
1790 _mesa_update_framebuffer_visual(fb
);
1795 _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target
, GLenum attachment
,
1796 GLenum pname
, GLint
*params
)
1798 const struct gl_renderbuffer_attachment
*att
;
1799 struct gl_framebuffer
*buffer
;
1800 GET_CURRENT_CONTEXT(ctx
);
1802 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1805 #if FEATURE_EXT_framebuffer_blit
1806 case GL_DRAW_FRAMEBUFFER_EXT
:
1807 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1808 _mesa_error(ctx
, GL_INVALID_ENUM
,
1809 "glGetFramebufferAttachmentParameterivEXT(target)");
1812 buffer
= ctx
->DrawBuffer
;
1814 case GL_READ_FRAMEBUFFER_EXT
:
1815 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1816 _mesa_error(ctx
, GL_INVALID_ENUM
,
1817 "glGetFramebufferAttachmentParameterivEXT(target)");
1820 buffer
= ctx
->ReadBuffer
;
1823 case GL_FRAMEBUFFER_EXT
:
1824 buffer
= ctx
->DrawBuffer
;
1827 _mesa_error(ctx
, GL_INVALID_ENUM
,
1828 "glGetFramebufferAttachmentParameterivEXT(target)");
1832 if (buffer
->Name
== 0) {
1833 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1834 "glGetFramebufferAttachmentParameterivEXT");
1838 att
= _mesa_get_attachment(ctx
, buffer
, attachment
);
1840 _mesa_error(ctx
, GL_INVALID_ENUM
,
1841 "glGetFramebufferAttachmentParameterivEXT(attachment)");
1845 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
1846 /* the depth and stencil attachments must point to the same buffer */
1847 const struct gl_renderbuffer_attachment
*depthAtt
, *stencilAtt
;
1848 depthAtt
= _mesa_get_attachment(ctx
, buffer
, GL_DEPTH_ATTACHMENT
);
1849 stencilAtt
= _mesa_get_attachment(ctx
, buffer
, GL_STENCIL_ATTACHMENT
);
1850 if (depthAtt
->Renderbuffer
!= stencilAtt
->Renderbuffer
) {
1851 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1852 "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL"
1853 " attachments differ)");
1858 /* No need to flush here */
1861 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT
:
1862 *params
= att
->Type
;
1864 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT
:
1865 if (att
->Type
== GL_RENDERBUFFER_EXT
) {
1866 *params
= att
->Renderbuffer
->Name
;
1868 else if (att
->Type
== GL_TEXTURE
) {
1869 *params
= att
->Texture
->Name
;
1872 _mesa_error(ctx
, GL_INVALID_ENUM
,
1873 "glGetFramebufferAttachmentParameterivEXT(pname)");
1876 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT
:
1877 if (att
->Type
== GL_TEXTURE
) {
1878 *params
= att
->TextureLevel
;
1881 _mesa_error(ctx
, GL_INVALID_ENUM
,
1882 "glGetFramebufferAttachmentParameterivEXT(pname)");
1885 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT
:
1886 if (att
->Type
== GL_TEXTURE
) {
1887 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_CUBE_MAP
) {
1888 *params
= GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ att
->CubeMapFace
;
1895 _mesa_error(ctx
, GL_INVALID_ENUM
,
1896 "glGetFramebufferAttachmentParameterivEXT(pname)");
1899 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT
:
1900 if (att
->Type
== GL_TEXTURE
) {
1901 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_3D
) {
1902 *params
= att
->Zoffset
;
1909 _mesa_error(ctx
, GL_INVALID_ENUM
,
1910 "glGetFramebufferAttachmentParameterivEXT(pname)");
1913 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
:
1914 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1915 _mesa_error(ctx
, GL_INVALID_ENUM
,
1916 "glGetFramebufferAttachmentParameterivEXT(pname)");
1919 *params
= _mesa_get_format_color_encoding(att
->Renderbuffer
->Format
);
1922 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE
:
1923 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1924 _mesa_error(ctx
, GL_INVALID_ENUM
,
1925 "glGetFramebufferAttachmentParameterivEXT(pname)");
1929 gl_format format
= att
->Renderbuffer
->Format
;
1930 if (format
== MESA_FORMAT_CI8
|| format
== MESA_FORMAT_S8
) {
1935 *params
= _mesa_get_format_datatype(format
);
1939 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
1940 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
1941 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
1942 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
1943 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
1944 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
1945 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1946 _mesa_error(ctx
, GL_INVALID_ENUM
,
1947 "glGetFramebufferAttachmentParameterivEXT(pname)");
1949 else if (att
->Texture
) {
1950 const struct gl_texture_image
*texImage
=
1951 _mesa_select_tex_image(ctx
, att
->Texture
, att
->Texture
->Target
,
1954 *params
= get_component_bits(pname
, texImage
->_BaseFormat
,
1955 texImage
->TexFormat
);
1961 else if (att
->Renderbuffer
) {
1962 *params
= get_component_bits(pname
, att
->Renderbuffer
->_BaseFormat
,
1963 att
->Renderbuffer
->Format
);
1970 _mesa_error(ctx
, GL_INVALID_ENUM
,
1971 "glGetFramebufferAttachmentParameterivEXT(pname)");
1978 _mesa_GenerateMipmapEXT(GLenum target
)
1980 struct gl_texture_object
*texObj
;
1981 GET_CURRENT_CONTEXT(ctx
);
1983 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1984 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1990 case GL_TEXTURE_CUBE_MAP
:
1991 /* OK, legal value */
1994 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGenerateMipmapEXT(target)");
1998 texObj
= _mesa_get_current_tex_object(ctx
, target
);
2000 if (texObj
->BaseLevel
>= texObj
->MaxLevel
) {
2005 _mesa_lock_texture(ctx
, texObj
);
2006 if (target
== GL_TEXTURE_CUBE_MAP
) {
2008 for (face
= 0; face
< 6; face
++)
2009 ctx
->Driver
.GenerateMipmap(ctx
,
2010 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
+ face
,
2014 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
2016 _mesa_unlock_texture(ctx
, texObj
);
2020 #if FEATURE_EXT_framebuffer_blit
2022 static const struct gl_renderbuffer_attachment
*
2023 find_attachment(const struct gl_framebuffer
*fb
, const struct gl_renderbuffer
*rb
)
2026 for (i
= 0; i
< Elements(fb
->Attachment
); i
++) {
2027 if (fb
->Attachment
[i
].Renderbuffer
== rb
)
2028 return &fb
->Attachment
[i
];
2036 * Blit rectangular region, optionally from one framebuffer to another.
2038 * Note, if the src buffer is multisampled and the dest is not, this is
2039 * when the samples must be resolved to a single color.
2042 _mesa_BlitFramebufferEXT(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
2043 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
2044 GLbitfield mask
, GLenum filter
)
2046 const GLbitfield legalMaskBits
= (GL_COLOR_BUFFER_BIT
|
2047 GL_DEPTH_BUFFER_BIT
|
2048 GL_STENCIL_BUFFER_BIT
);
2049 const struct gl_framebuffer
*readFb
, *drawFb
;
2050 const struct gl_renderbuffer
*colorReadRb
, *colorDrawRb
;
2051 GET_CURRENT_CONTEXT(ctx
);
2053 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2054 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2056 if (ctx
->NewState
) {
2057 _mesa_update_state(ctx
);
2060 readFb
= ctx
->ReadBuffer
;
2061 drawFb
= ctx
->DrawBuffer
;
2063 if (!readFb
|| !drawFb
) {
2064 /* This will normally never happen but someday we may want to
2065 * support MakeCurrent() with no drawables.
2070 /* check for complete framebuffers */
2071 if (drawFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
||
2072 readFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
2073 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
2074 "glBlitFramebufferEXT(incomplete draw/read buffers)");
2078 if (filter
!= GL_NEAREST
&& filter
!= GL_LINEAR
) {
2079 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlitFramebufferEXT(filter)");
2083 if (mask
& ~legalMaskBits
) {
2084 _mesa_error( ctx
, GL_INVALID_VALUE
, "glBlitFramebufferEXT(mask)");
2088 /* depth/stencil must be blitted with nearest filtering */
2089 if ((mask
& (GL_DEPTH_BUFFER_BIT
| GL_STENCIL_BUFFER_BIT
))
2090 && filter
!= GL_NEAREST
) {
2091 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2092 "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter");
2096 /* get color read/draw renderbuffers */
2097 if (mask
& GL_COLOR_BUFFER_BIT
) {
2098 colorReadRb
= readFb
->_ColorReadBuffer
;
2099 colorDrawRb
= drawFb
->_ColorDrawBuffers
[0];
2102 colorReadRb
= colorDrawRb
= NULL
;
2105 if (mask
& GL_STENCIL_BUFFER_BIT
) {
2106 struct gl_renderbuffer
*readRb
= readFb
->_StencilBuffer
;
2107 struct gl_renderbuffer
*drawRb
= drawFb
->_StencilBuffer
;
2110 _mesa_get_format_bits(readRb
->Format
, GL_STENCIL_BITS
) !=
2111 _mesa_get_format_bits(drawRb
->Format
, GL_STENCIL_BITS
)) {
2112 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2113 "glBlitFramebufferEXT(stencil buffer size mismatch");
2118 if (mask
& GL_DEPTH_BUFFER_BIT
) {
2119 struct gl_renderbuffer
*readRb
= readFb
->_DepthBuffer
;
2120 struct gl_renderbuffer
*drawRb
= drawFb
->_DepthBuffer
;
2123 _mesa_get_format_bits(readRb
->Format
, GL_DEPTH_BITS
) !=
2124 _mesa_get_format_bits(drawRb
->Format
, GL_DEPTH_BITS
)) {
2125 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2126 "glBlitFramebufferEXT(depth buffer size mismatch");
2131 if (readFb
->Visual
.samples
> 0 &&
2132 drawFb
->Visual
.samples
> 0 &&
2133 readFb
->Visual
.samples
!= drawFb
->Visual
.samples
) {
2134 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2135 "glBlitFramebufferEXT(mismatched samples");
2139 /* extra checks for multisample copies... */
2140 if (readFb
->Visual
.samples
> 0 || drawFb
->Visual
.samples
> 0) {
2141 /* src and dest region sizes must be the same */
2142 if (srcX1
- srcX0
!= dstX1
- dstX0
||
2143 srcY1
- srcY0
!= dstY1
- dstY0
) {
2144 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2145 "glBlitFramebufferEXT(bad src/dst multisample region sizes");
2149 /* color formats must match */
2152 colorReadRb
->Format
!= colorDrawRb
->Format
) {
2153 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2154 "glBlitFramebufferEXT(bad src/dst multisample pixel formats");
2159 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
2160 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBlitFramebufferEXT");
2166 printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
2168 srcX0
, srcY0
, srcX1
, srcY1
,
2169 dstX0
, dstY0
, dstX1
, dstY1
,
2172 const struct gl_renderbuffer_attachment
*att
;
2174 att
= find_attachment(readFb
, colorReadRb
);
2175 printf(" Src FBO %u RB %u (%dx%d) ",
2176 readFb
->Name
, colorReadRb
->Name
,
2177 colorReadRb
->Width
, colorReadRb
->Height
);
2178 if (att
&& att
->Texture
) {
2179 printf("Tex %u tgt 0x%x level %u face %u",
2181 att
->Texture
->Target
,
2187 att
= find_attachment(drawFb
, colorDrawRb
);
2188 printf(" Dst FBO %u RB %u (%dx%d) ",
2189 drawFb
->Name
, colorDrawRb
->Name
,
2190 colorDrawRb
->Width
, colorDrawRb
->Height
);
2191 if (att
&& att
->Texture
) {
2192 printf("Tex %u tgt 0x%x level %u face %u",
2194 att
->Texture
->Target
,
2202 ASSERT(ctx
->Driver
.BlitFramebuffer
);
2203 ctx
->Driver
.BlitFramebuffer(ctx
,
2204 srcX0
, srcY0
, srcX1
, srcY1
,
2205 dstX0
, dstY0
, dstX1
, dstY1
,
2208 #endif /* FEATURE_EXT_framebuffer_blit */