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"
44 #include "renderbuffer.h"
52 /** Set this to 1 to help debug FBO incompleteness problems */
55 /** Set this to 1 to debug/log glBlitFramebuffer() calls */
62 * None of the GL_EXT_framebuffer_object functions are compiled into
69 * When glGenRender/FramebuffersEXT() is called we insert pointers to
70 * these placeholder objects into the hash table.
71 * Later, when the object ID is first bound, we replace the placeholder
72 * with the real frame/renderbuffer.
74 static struct gl_framebuffer DummyFramebuffer
;
75 static struct gl_renderbuffer DummyRenderbuffer
;
78 #define IS_CUBE_FACE(TARGET) \
79 ((TARGET) >= GL_TEXTURE_CUBE_MAP_POSITIVE_X && \
80 (TARGET) <= GL_TEXTURE_CUBE_MAP_NEGATIVE_Z)
84 delete_dummy_renderbuffer(struct gl_renderbuffer
*rb
)
90 delete_dummy_framebuffer(struct gl_framebuffer
*fb
)
97 _mesa_init_fbobjects(GLcontext
*ctx
)
99 DummyFramebuffer
.Delete
= delete_dummy_framebuffer
;
100 DummyRenderbuffer
.Delete
= delete_dummy_renderbuffer
;
105 * Helper routine for getting a gl_renderbuffer.
107 struct gl_renderbuffer
*
108 _mesa_lookup_renderbuffer(GLcontext
*ctx
, GLuint id
)
110 struct gl_renderbuffer
*rb
;
115 rb
= (struct gl_renderbuffer
*)
116 _mesa_HashLookup(ctx
->Shared
->RenderBuffers
, id
);
122 * Helper routine for getting a gl_framebuffer.
124 struct gl_framebuffer
*
125 _mesa_lookup_framebuffer(GLcontext
*ctx
, GLuint id
)
127 struct gl_framebuffer
*fb
;
132 fb
= (struct gl_framebuffer
*)
133 _mesa_HashLookup(ctx
->Shared
->FrameBuffers
, id
);
139 * Mark the given framebuffer as invalid. This will force the
140 * test for framebuffer completeness to be done before the framebuffer
144 invalidate_framebuffer(struct gl_framebuffer
*fb
)
146 fb
->_Status
= 0; /* "indeterminate" */
151 * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding
152 * gl_renderbuffer_attachment object.
153 * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to
154 * the depth buffer attachment point.
156 struct gl_renderbuffer_attachment
*
157 _mesa_get_attachment(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
162 switch (attachment
) {
163 case GL_COLOR_ATTACHMENT0_EXT
:
164 case GL_COLOR_ATTACHMENT1_EXT
:
165 case GL_COLOR_ATTACHMENT2_EXT
:
166 case GL_COLOR_ATTACHMENT3_EXT
:
167 case GL_COLOR_ATTACHMENT4_EXT
:
168 case GL_COLOR_ATTACHMENT5_EXT
:
169 case GL_COLOR_ATTACHMENT6_EXT
:
170 case GL_COLOR_ATTACHMENT7_EXT
:
171 case GL_COLOR_ATTACHMENT8_EXT
:
172 case GL_COLOR_ATTACHMENT9_EXT
:
173 case GL_COLOR_ATTACHMENT10_EXT
:
174 case GL_COLOR_ATTACHMENT11_EXT
:
175 case GL_COLOR_ATTACHMENT12_EXT
:
176 case GL_COLOR_ATTACHMENT13_EXT
:
177 case GL_COLOR_ATTACHMENT14_EXT
:
178 case GL_COLOR_ATTACHMENT15_EXT
:
179 i
= attachment
- GL_COLOR_ATTACHMENT0_EXT
;
180 if (i
>= ctx
->Const
.MaxColorAttachments
) {
183 return &fb
->Attachment
[BUFFER_COLOR0
+ i
];
184 case GL_DEPTH_STENCIL_ATTACHMENT
:
186 case GL_DEPTH_ATTACHMENT_EXT
:
187 return &fb
->Attachment
[BUFFER_DEPTH
];
188 case GL_STENCIL_ATTACHMENT_EXT
:
189 return &fb
->Attachment
[BUFFER_STENCIL
];
197 * Remove any texture or renderbuffer attached to the given attachment
198 * point. Update reference counts, etc.
201 _mesa_remove_attachment(GLcontext
*ctx
, struct gl_renderbuffer_attachment
*att
)
203 if (att
->Type
== GL_TEXTURE
) {
204 ASSERT(att
->Texture
);
205 if (ctx
->Driver
.FinishRenderTexture
) {
206 /* tell driver that we're done rendering to this texture. */
207 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
209 _mesa_reference_texobj(&att
->Texture
, NULL
); /* unbind */
210 ASSERT(!att
->Texture
);
212 if (att
->Type
== GL_TEXTURE
|| att
->Type
== GL_RENDERBUFFER_EXT
) {
213 ASSERT(!att
->Texture
);
214 _mesa_reference_renderbuffer(&att
->Renderbuffer
, NULL
); /* unbind */
215 ASSERT(!att
->Renderbuffer
);
218 att
->Complete
= GL_TRUE
;
223 * Bind a texture object to an attachment point.
224 * The previous binding, if any, will be removed first.
227 _mesa_set_texture_attachment(GLcontext
*ctx
,
228 struct gl_framebuffer
*fb
,
229 struct gl_renderbuffer_attachment
*att
,
230 struct gl_texture_object
*texObj
,
231 GLenum texTarget
, GLuint level
, GLuint zoffset
)
233 if (att
->Texture
== texObj
) {
234 /* re-attaching same texture */
235 ASSERT(att
->Type
== GL_TEXTURE
);
236 if (ctx
->Driver
.FinishRenderTexture
)
237 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
241 if (ctx
->Driver
.FinishRenderTexture
&& att
->Texture
)
242 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
243 _mesa_remove_attachment(ctx
, att
);
244 att
->Type
= GL_TEXTURE
;
245 assert(!att
->Texture
);
246 _mesa_reference_texobj(&att
->Texture
, texObj
);
249 /* always update these fields */
250 att
->TextureLevel
= level
;
251 att
->CubeMapFace
= _mesa_tex_target_to_face(texTarget
);
252 att
->Zoffset
= zoffset
;
253 att
->Complete
= GL_FALSE
;
255 if (att
->Texture
->Image
[att
->CubeMapFace
][att
->TextureLevel
]) {
256 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
259 invalidate_framebuffer(fb
);
264 * Bind a renderbuffer to an attachment point.
265 * The previous binding, if any, will be removed first.
268 _mesa_set_renderbuffer_attachment(GLcontext
*ctx
,
269 struct gl_renderbuffer_attachment
*att
,
270 struct gl_renderbuffer
*rb
)
272 /* XXX check if re-doing same attachment, exit early */
273 _mesa_remove_attachment(ctx
, att
);
274 att
->Type
= GL_RENDERBUFFER_EXT
;
275 att
->Texture
= NULL
; /* just to be safe */
276 att
->Complete
= GL_FALSE
;
277 _mesa_reference_renderbuffer(&att
->Renderbuffer
, rb
);
282 * Fallback for ctx->Driver.FramebufferRenderbuffer()
283 * Attach a renderbuffer object to a framebuffer object.
286 _mesa_framebuffer_renderbuffer(GLcontext
*ctx
, struct gl_framebuffer
*fb
,
287 GLenum attachment
, struct gl_renderbuffer
*rb
)
289 struct gl_renderbuffer_attachment
*att
;
291 _glthread_LOCK_MUTEX(fb
->Mutex
);
293 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
296 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
297 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
298 /* do stencil attachment here (depth already done above) */
299 att
= _mesa_get_attachment(ctx
, fb
, GL_STENCIL_ATTACHMENT_EXT
);
301 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
305 _mesa_remove_attachment(ctx
, att
);
308 invalidate_framebuffer(fb
);
310 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
318 att_incomplete(const char *msg
)
321 _mesa_debug(NULL
, "attachment incomplete: %s\n", msg
);
332 fbo_incomplete(const char *msg
, int index
)
335 _mesa_debug(NULL
, "FBO Incomplete: %s [%d]\n", msg
, index
);
346 * Test if an attachment point is complete and update its Complete field.
347 * \param format if GL_COLOR, this is a color attachment point,
348 * if GL_DEPTH, this is a depth component attachment point,
349 * if GL_STENCIL, this is a stencil component attachment point.
352 test_attachment_completeness(const GLcontext
*ctx
, GLenum format
,
353 struct gl_renderbuffer_attachment
*att
)
355 assert(format
== GL_COLOR
|| format
== GL_DEPTH
|| format
== GL_STENCIL
);
357 /* assume complete */
358 att
->Complete
= GL_TRUE
;
360 /* Look for reasons why the attachment might be incomplete */
361 if (att
->Type
== GL_TEXTURE
) {
362 const struct gl_texture_object
*texObj
= att
->Texture
;
363 struct gl_texture_image
*texImage
;
367 att_incomplete("no texobj");
368 att
->Complete
= GL_FALSE
;
372 texImage
= texObj
->Image
[att
->CubeMapFace
][att
->TextureLevel
];
374 att_incomplete("no teximage");
375 att
->Complete
= GL_FALSE
;
378 if (texImage
->Width
< 1 || texImage
->Height
< 1) {
379 att_incomplete("teximage width/height=0");
380 _mesa_printf("texobj = %u\n", texObj
->Name
);
381 _mesa_printf("level = %d\n", att
->TextureLevel
);
382 att
->Complete
= GL_FALSE
;
385 if (texObj
->Target
== GL_TEXTURE_3D
&& att
->Zoffset
>= texImage
->Depth
) {
386 att_incomplete("bad z offset");
387 att
->Complete
= GL_FALSE
;
391 baseFormat
= _mesa_get_format_base_format(texImage
->TexFormat
);
393 if (format
== GL_COLOR
) {
394 if (baseFormat
!= GL_RGB
&&
395 baseFormat
!= GL_RGBA
) {
396 att_incomplete("bad format");
397 att
->Complete
= GL_FALSE
;
400 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
401 att_incomplete("compressed internalformat");
402 att
->Complete
= GL_FALSE
;
406 else if (format
== GL_DEPTH
) {
407 if (baseFormat
== GL_DEPTH_COMPONENT
) {
410 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
411 ctx
->Extensions
.ARB_depth_texture
&&
412 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
416 att
->Complete
= GL_FALSE
;
417 att_incomplete("bad depth format");
422 ASSERT(format
== GL_STENCIL
);
423 if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
424 ctx
->Extensions
.ARB_depth_texture
&&
425 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
429 /* no such thing as stencil-only textures */
430 att_incomplete("illegal stencil texture");
431 att
->Complete
= GL_FALSE
;
436 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
437 const GLenum baseFormat
=
438 _mesa_get_format_base_format(att
->Renderbuffer
->Format
);
440 ASSERT(att
->Renderbuffer
);
441 if (!att
->Renderbuffer
->InternalFormat
||
442 att
->Renderbuffer
->Width
< 1 ||
443 att
->Renderbuffer
->Height
< 1) {
444 att_incomplete("0x0 renderbuffer");
445 att
->Complete
= GL_FALSE
;
448 if (format
== GL_COLOR
) {
449 if (baseFormat
!= GL_RGB
&&
450 baseFormat
!= GL_RGBA
) {
451 att_incomplete("bad renderbuffer color format");
452 att
->Complete
= GL_FALSE
;
456 else if (format
== GL_DEPTH
) {
457 if (baseFormat
== GL_DEPTH_COMPONENT
) {
460 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
461 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
465 att_incomplete("bad renderbuffer depth format");
466 att
->Complete
= GL_FALSE
;
471 assert(format
== GL_STENCIL
);
472 if (baseFormat
== GL_STENCIL_INDEX
) {
475 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
476 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
480 att
->Complete
= GL_FALSE
;
481 att_incomplete("bad renderbuffer stencil format");
487 ASSERT(att
->Type
== GL_NONE
);
495 * Test if the given framebuffer object is complete and update its
496 * Status field with the results.
497 * Calls the ctx->Driver.ValidateFramebuffer() function to allow the
498 * driver to make hardware-specific validation/completeness checks.
499 * Also update the framebuffer's Width and Height fields if the
500 * framebuffer is complete.
503 _mesa_test_framebuffer_completeness(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
506 GLenum intFormat
= GL_NONE
; /* color buffers' internal format */
507 GLuint minWidth
= ~0, minHeight
= ~0, maxWidth
= 0, maxHeight
= 0;
508 GLint numSamples
= -1;
512 assert(fb
->Name
!= 0);
518 /* Start at -2 to more easily loop over all attachment points.
523 for (i
= -2; i
< (GLint
) ctx
->Const
.MaxColorAttachments
; i
++) {
524 struct gl_renderbuffer_attachment
*att
;
528 * XXX for ARB_fbo, only check color buffers that are named by
529 * GL_READ_BUFFER and GL_DRAW_BUFFERi.
532 /* check for attachment completeness
535 att
= &fb
->Attachment
[BUFFER_DEPTH
];
536 test_attachment_completeness(ctx
, GL_DEPTH
, att
);
537 if (!att
->Complete
) {
538 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
539 fbo_incomplete("depth attachment incomplete", -1);
544 att
= &fb
->Attachment
[BUFFER_STENCIL
];
545 test_attachment_completeness(ctx
, GL_STENCIL
, att
);
546 if (!att
->Complete
) {
547 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
548 fbo_incomplete("stencil attachment incomplete", -1);
553 att
= &fb
->Attachment
[BUFFER_COLOR0
+ i
];
554 test_attachment_completeness(ctx
, GL_COLOR
, att
);
555 if (!att
->Complete
) {
556 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
557 fbo_incomplete("color attachment incomplete", i
);
562 /* get width, height, format of the renderbuffer/texture
564 if (att
->Type
== GL_TEXTURE
) {
565 const struct gl_texture_image
*texImg
566 = att
->Texture
->Image
[att
->CubeMapFace
][att
->TextureLevel
];
567 minWidth
= MIN2(minWidth
, texImg
->Width
);
568 maxWidth
= MAX2(maxWidth
, texImg
->Width
);
569 minHeight
= MIN2(minHeight
, texImg
->Height
);
570 maxHeight
= MAX2(maxHeight
, texImg
->Height
);
571 f
= texImg
->_BaseFormat
;
573 if (f
!= GL_RGB
&& f
!= GL_RGBA
&& f
!= GL_DEPTH_COMPONENT
574 && f
!= GL_DEPTH_STENCIL_EXT
) {
575 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
576 fbo_incomplete("texture attachment incomplete", -1);
580 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
581 minWidth
= MIN2(minWidth
, att
->Renderbuffer
->Width
);
582 maxWidth
= MAX2(minWidth
, att
->Renderbuffer
->Width
);
583 minHeight
= MIN2(minHeight
, att
->Renderbuffer
->Height
);
584 maxHeight
= MAX2(minHeight
, att
->Renderbuffer
->Height
);
585 f
= att
->Renderbuffer
->InternalFormat
;
589 assert(att
->Type
== GL_NONE
);
593 if (numSamples
< 0) {
595 numSamples
= att
->Renderbuffer
->NumSamples
;
598 /* Error-check width, height, format, samples
600 if (numImages
== 1) {
601 /* save format, num samples */
607 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
608 /* check that width, height, format are same */
609 if (minWidth
!= maxWidth
|| minHeight
!= maxHeight
) {
610 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
;
611 fbo_incomplete("width or height mismatch", -1);
614 /* check that all color buffer have same format */
615 if (intFormat
!= GL_NONE
&& f
!= intFormat
) {
616 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
617 fbo_incomplete("format mismatch", -1);
621 if (att
->Renderbuffer
&&
622 att
->Renderbuffer
->NumSamples
!= numSamples
) {
623 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
;
624 fbo_incomplete("inconsistant number of samples", i
);
631 #ifndef FEATURE_OES_framebuffer_object
632 /* Check that all DrawBuffers are present */
633 for (j
= 0; j
< ctx
->Const
.MaxDrawBuffers
; j
++) {
634 if (fb
->ColorDrawBuffer
[j
] != GL_NONE
) {
635 const struct gl_renderbuffer_attachment
*att
636 = _mesa_get_attachment(ctx
, fb
, fb
->ColorDrawBuffer
[j
]);
638 if (att
->Type
== GL_NONE
) {
639 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
;
640 fbo_incomplete("missing drawbuffer", j
);
646 /* Check that the ReadBuffer is present */
647 if (fb
->ColorReadBuffer
!= GL_NONE
) {
648 const struct gl_renderbuffer_attachment
*att
649 = _mesa_get_attachment(ctx
, fb
, fb
->ColorReadBuffer
);
651 if (att
->Type
== GL_NONE
) {
652 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
;
653 fbo_incomplete("missing readbuffer", -1);
661 if (numImages
== 0) {
662 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
;
663 fbo_incomplete("no attachments", -1);
667 /* Provisionally set status = COMPLETE ... */
668 fb
->_Status
= GL_FRAMEBUFFER_COMPLETE_EXT
;
670 /* ... but the driver may say the FB is incomplete.
671 * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED
674 if (ctx
->Driver
.ValidateFramebuffer
) {
675 ctx
->Driver
.ValidateFramebuffer(ctx
, fb
);
676 if (fb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
677 fbo_incomplete("driver marked FBO as incomplete", -1);
681 if (fb
->_Status
== GL_FRAMEBUFFER_COMPLETE_EXT
) {
683 * Note that if ARB_framebuffer_object is supported and the attached
684 * renderbuffers/textures are different sizes, the framebuffer
685 * width/height will be set to the smallest width/height.
687 fb
->Width
= minWidth
;
688 fb
->Height
= minHeight
;
690 /* finally, update the visual info for the framebuffer */
691 _mesa_update_framebuffer_visual(fb
);
697 _mesa_IsRenderbufferEXT(GLuint renderbuffer
)
699 GET_CURRENT_CONTEXT(ctx
);
700 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
702 struct gl_renderbuffer
*rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
703 if (rb
!= NULL
&& rb
!= &DummyRenderbuffer
)
711 _mesa_BindRenderbufferEXT(GLenum target
, GLuint renderbuffer
)
713 struct gl_renderbuffer
*newRb
;
714 GET_CURRENT_CONTEXT(ctx
);
716 ASSERT_OUTSIDE_BEGIN_END(ctx
);
718 if (target
!= GL_RENDERBUFFER_EXT
) {
719 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindRenderbufferEXT(target)");
723 /* No need to flush here since the render buffer binding has no
724 * effect on rendering state.
728 newRb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
729 if (newRb
== &DummyRenderbuffer
) {
730 /* ID was reserved, but no real renderbuffer object made yet */
733 else if (!newRb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
734 /* All RB IDs must be Gen'd */
735 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindRenderbuffer(buffer)");
740 /* create new renderbuffer object */
741 newRb
= ctx
->Driver
.NewRenderbuffer(ctx
, renderbuffer
);
743 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindRenderbufferEXT");
746 ASSERT(newRb
->AllocStorage
);
747 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, renderbuffer
, newRb
);
748 newRb
->RefCount
= 1; /* referenced by hash table */
755 ASSERT(newRb
!= &DummyRenderbuffer
);
757 _mesa_reference_renderbuffer(&ctx
->CurrentRenderbuffer
, newRb
);
762 * If the given renderbuffer is anywhere attached to the framebuffer, detach
764 * This is used when a renderbuffer object is deleted.
765 * The spec calls for unbinding.
768 detach_renderbuffer(GLcontext
*ctx
,
769 struct gl_framebuffer
*fb
,
770 struct gl_renderbuffer
*rb
)
773 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
774 if (fb
->Attachment
[i
].Renderbuffer
== rb
) {
775 _mesa_remove_attachment(ctx
, &fb
->Attachment
[i
]);
778 invalidate_framebuffer(fb
);
783 _mesa_DeleteRenderbuffersEXT(GLsizei n
, const GLuint
*renderbuffers
)
786 GET_CURRENT_CONTEXT(ctx
);
788 ASSERT_OUTSIDE_BEGIN_END(ctx
);
789 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
791 for (i
= 0; i
< n
; i
++) {
792 if (renderbuffers
[i
] > 0) {
793 struct gl_renderbuffer
*rb
;
794 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffers
[i
]);
796 /* check if deleting currently bound renderbuffer object */
797 if (rb
== ctx
->CurrentRenderbuffer
) {
799 ASSERT(rb
->RefCount
>= 2);
800 _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT
, 0);
803 if (ctx
->DrawBuffer
->Name
) {
804 detach_renderbuffer(ctx
, ctx
->DrawBuffer
, rb
);
806 if (ctx
->ReadBuffer
->Name
&& ctx
->ReadBuffer
!= ctx
->DrawBuffer
) {
807 detach_renderbuffer(ctx
, ctx
->ReadBuffer
, rb
);
810 /* Remove from hash table immediately, to free the ID.
811 * But the object will not be freed until it's no longer
812 * referenced anywhere else.
814 _mesa_HashRemove(ctx
->Shared
->RenderBuffers
, renderbuffers
[i
]);
816 if (rb
!= &DummyRenderbuffer
) {
817 /* no longer referenced by hash table */
818 _mesa_reference_renderbuffer(&rb
, NULL
);
827 _mesa_GenRenderbuffersEXT(GLsizei n
, GLuint
*renderbuffers
)
829 GET_CURRENT_CONTEXT(ctx
);
833 ASSERT_OUTSIDE_BEGIN_END(ctx
);
836 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenRenderbuffersEXT(n)");
843 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->RenderBuffers
, n
);
845 for (i
= 0; i
< n
; i
++) {
846 GLuint name
= first
+ i
;
847 renderbuffers
[i
] = name
;
848 /* insert dummy placeholder into hash table */
849 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
850 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, name
, &DummyRenderbuffer
);
851 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
857 * Given an internal format token for a render buffer, return the
858 * corresponding base format.
859 * This is very similar to _mesa_base_tex_format() but the set of valid
860 * internal formats is somewhat different.
862 * \return one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX, GL_DEPTH_COMPONENT
863 * GL_DEPTH_STENCIL_EXT or zero if error.
865 * XXX in the future when we support red-only and red-green formats
866 * we'll also return GL_RED and GL_RG.
869 _mesa_base_fbo_format(GLcontext
*ctx
, GLenum internalFormat
)
871 switch (internalFormat
) {
890 case GL_STENCIL_INDEX
:
891 case GL_STENCIL_INDEX1_EXT
:
892 case GL_STENCIL_INDEX4_EXT
:
893 case GL_STENCIL_INDEX8_EXT
:
894 case GL_STENCIL_INDEX16_EXT
:
895 return GL_STENCIL_INDEX
;
896 case GL_DEPTH_COMPONENT
:
897 case GL_DEPTH_COMPONENT16
:
898 case GL_DEPTH_COMPONENT24
:
899 case GL_DEPTH_COMPONENT32
:
900 return GL_DEPTH_COMPONENT
;
901 case GL_DEPTH_STENCIL_EXT
:
902 case GL_DEPTH24_STENCIL8_EXT
:
903 if (ctx
->Extensions
.EXT_packed_depth_stencil
)
904 return GL_DEPTH_STENCIL_EXT
;
907 /* XXX add floating point formats eventually */
914 /** sentinal value, see below */
915 #define NO_SAMPLES 1000
919 * Helper function used by _mesa_RenderbufferStorageEXT() and
920 * _mesa_RenderbufferStorageMultisample().
921 * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT().
924 renderbuffer_storage(GLenum target
, GLenum internalFormat
,
925 GLsizei width
, GLsizei height
, GLsizei samples
)
927 const char *func
= samples
== NO_SAMPLES
?
928 "glRenderbufferStorage" : "RenderbufferStorageMultisample";
929 struct gl_renderbuffer
*rb
;
931 GET_CURRENT_CONTEXT(ctx
);
933 ASSERT_OUTSIDE_BEGIN_END(ctx
);
935 if (target
!= GL_RENDERBUFFER_EXT
) {
936 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(target)", func
);
940 baseFormat
= _mesa_base_fbo_format(ctx
, internalFormat
);
941 if (baseFormat
== 0) {
942 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(internalFormat)", func
);
946 if (width
< 1 || width
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
947 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(width)", func
);
951 if (height
< 1 || height
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
952 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(height)", func
);
956 if (samples
== NO_SAMPLES
) {
957 /* NumSamples == 0 indicates non-multisampling */
960 else if (samples
> ctx
->Const
.MaxSamples
) {
961 /* note: driver may choose to use more samples than what's requested */
962 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(samples)", func
);
966 rb
= ctx
->CurrentRenderbuffer
;
968 _mesa_error(ctx
, GL_INVALID_OPERATION
, func
);
972 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
974 if (rb
->InternalFormat
== internalFormat
&&
975 rb
->Width
== (GLuint
) width
&&
976 rb
->Height
== (GLuint
) height
) {
977 /* no change in allocation needed */
981 /* These MUST get set by the AllocStorage func */
982 rb
->Format
= MESA_FORMAT_NONE
;
983 rb
->NumSamples
= samples
;
985 /* Now allocate the storage */
986 ASSERT(rb
->AllocStorage
);
987 if (rb
->AllocStorage(ctx
, rb
, internalFormat
, width
, height
)) {
988 /* No error - check/set fields now */
989 assert(rb
->Format
!= MESA_FORMAT_NONE
);
990 assert(rb
->Width
== (GLuint
) width
);
991 assert(rb
->Height
== (GLuint
) height
);
992 rb
->InternalFormat
= internalFormat
;
993 rb
->_BaseFormat
= _mesa_base_fbo_format(ctx
, internalFormat
);
994 assert(rb
->_BaseFormat
!= 0);
997 /* Probably ran out of memory - clear the fields */
1000 rb
->Format
= MESA_FORMAT_NONE
;
1001 rb
->InternalFormat
= GL_NONE
;
1002 rb
->_BaseFormat
= GL_NONE
;
1007 test_framebuffer_completeness(ctx, fb);
1009 /* XXX if this renderbuffer is attached anywhere, invalidate attachment
1016 * Helper function for _mesa_GetRenderbufferParameterivEXT() and
1017 * _mesa_GetFramebufferAttachmentParameterivEXT()
1018 * We have to be careful to respect the base format. For example, if a
1019 * renderbuffer/texture was created with internalFormat=GL_RGB but the
1020 * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE
1021 * we need to return zero.
1024 get_component_bits(GLenum pname
, GLenum baseFormat
, gl_format format
)
1027 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1028 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
1029 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1030 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
1031 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1032 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
1033 if (baseFormat
== GL_RGB
|| baseFormat
== GL_RGBA
)
1034 return _mesa_get_format_bits(format
, pname
);
1037 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1038 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
1039 if (baseFormat
== GL_RGBA
|| baseFormat
== GL_ALPHA
)
1040 return _mesa_get_format_bits(format
, pname
);
1043 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1044 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
1045 if (baseFormat
== GL_DEPTH_COMPONENT
|| baseFormat
== GL_DEPTH_STENCIL
)
1046 return _mesa_get_format_bits(format
, pname
);
1049 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1050 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
1051 if (baseFormat
== GL_STENCIL_INDEX
|| baseFormat
== GL_DEPTH_STENCIL
)
1052 return _mesa_get_format_bits(format
, pname
);
1063 _mesa_RenderbufferStorageEXT(GLenum target
, GLenum internalFormat
,
1064 GLsizei width
, GLsizei height
)
1066 /* GL_ARB_fbo says calling this function is equivalent to calling
1067 * glRenderbufferStorageMultisample() with samples=0. We pass in
1068 * a token value here just for error reporting purposes.
1070 renderbuffer_storage(target
, internalFormat
, width
, height
, NO_SAMPLES
);
1075 _mesa_RenderbufferStorageMultisample(GLenum target
, GLsizei samples
,
1076 GLenum internalFormat
,
1077 GLsizei width
, GLsizei height
)
1079 renderbuffer_storage(target
, internalFormat
, width
, height
, samples
);
1085 _mesa_GetRenderbufferParameterivEXT(GLenum target
, GLenum pname
, GLint
*params
)
1087 struct gl_renderbuffer
*rb
;
1088 GET_CURRENT_CONTEXT(ctx
);
1090 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1092 if (target
!= GL_RENDERBUFFER_EXT
) {
1093 _mesa_error(ctx
, GL_INVALID_ENUM
,
1094 "glGetRenderbufferParameterivEXT(target)");
1098 rb
= ctx
->CurrentRenderbuffer
;
1100 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1101 "glGetRenderbufferParameterivEXT");
1105 /* No need to flush here since we're just quering state which is
1106 * not effected by rendering.
1110 case GL_RENDERBUFFER_WIDTH_EXT
:
1111 *params
= rb
->Width
;
1113 case GL_RENDERBUFFER_HEIGHT_EXT
:
1114 *params
= rb
->Height
;
1116 case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT
:
1117 *params
= rb
->InternalFormat
;
1119 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1120 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1121 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1122 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1123 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1124 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1125 *params
= get_component_bits(pname
, rb
->_BaseFormat
, rb
->Format
);
1127 case GL_RENDERBUFFER_SAMPLES
:
1128 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1129 *params
= rb
->NumSamples
;
1134 _mesa_error(ctx
, GL_INVALID_ENUM
,
1135 "glGetRenderbufferParameterivEXT(target)");
1141 GLboolean GLAPIENTRY
1142 _mesa_IsFramebufferEXT(GLuint framebuffer
)
1144 GET_CURRENT_CONTEXT(ctx
);
1145 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
1147 struct gl_framebuffer
*rb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1148 if (rb
!= NULL
&& rb
!= &DummyFramebuffer
)
1156 * Check if any of the attachments of the given framebuffer are textures
1157 * (render to texture). Call ctx->Driver.RenderTexture() for such
1161 check_begin_texture_render(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
1164 ASSERT(ctx
->Driver
.RenderTexture
);
1167 return; /* can't render to texture with winsys framebuffers */
1169 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1170 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1171 struct gl_texture_object
*texObj
= att
->Texture
;
1173 && texObj
->Image
[att
->CubeMapFace
][att
->TextureLevel
]) {
1174 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
1181 * Examine all the framebuffer's attachments to see if any are textures.
1182 * If so, call ctx->Driver.FinishRenderTexture() for each texture to
1183 * notify the device driver that the texture image may have changed.
1186 check_end_texture_render(GLcontext
*ctx
, struct gl_framebuffer
*fb
)
1189 return; /* can't render to texture with winsys framebuffers */
1191 if (ctx
->Driver
.FinishRenderTexture
) {
1193 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1194 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1195 if (att
->Texture
&& att
->Renderbuffer
) {
1196 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
1204 _mesa_BindFramebufferEXT(GLenum target
, GLuint framebuffer
)
1206 struct gl_framebuffer
*newDrawFb
, *newReadFb
;
1207 struct gl_framebuffer
*oldDrawFb
, *oldReadFb
;
1208 GLboolean bindReadBuf
, bindDrawBuf
;
1209 GET_CURRENT_CONTEXT(ctx
);
1212 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1213 ASSERT(ctx
->Extensions
.EXT_framebuffer_object
);
1214 ASSERT(ctx
->Extensions
.EXT_framebuffer_blit
);
1218 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1220 if (!ctx
->Extensions
.EXT_framebuffer_object
) {
1221 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1222 "glBindFramebufferEXT(unsupported)");
1227 #if FEATURE_EXT_framebuffer_blit
1228 case GL_DRAW_FRAMEBUFFER_EXT
:
1229 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1230 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1233 bindDrawBuf
= GL_TRUE
;
1234 bindReadBuf
= GL_FALSE
;
1236 case GL_READ_FRAMEBUFFER_EXT
:
1237 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1238 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1241 bindDrawBuf
= GL_FALSE
;
1242 bindReadBuf
= GL_TRUE
;
1245 case GL_FRAMEBUFFER_EXT
:
1246 bindDrawBuf
= GL_TRUE
;
1247 bindReadBuf
= GL_TRUE
;
1250 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1255 /* Binding a user-created framebuffer object */
1256 newDrawFb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1257 if (newDrawFb
== &DummyFramebuffer
) {
1258 /* ID was reserved, but no real framebuffer object made yet */
1261 else if (!newDrawFb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
1262 /* All FBO IDs must be Gen'd */
1263 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindFramebuffer(buffer)");
1268 /* create new framebuffer object */
1269 newDrawFb
= ctx
->Driver
.NewFramebuffer(ctx
, framebuffer
);
1271 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindFramebufferEXT");
1274 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, framebuffer
, newDrawFb
);
1276 newReadFb
= newDrawFb
;
1279 /* Binding the window system framebuffer (which was originally set
1280 * with MakeCurrent).
1282 newDrawFb
= ctx
->WinSysDrawBuffer
;
1283 newReadFb
= ctx
->WinSysReadBuffer
;
1287 ASSERT(newDrawFb
!= &DummyFramebuffer
);
1289 /* save pointers to current/old framebuffers */
1290 oldDrawFb
= ctx
->DrawBuffer
;
1291 oldReadFb
= ctx
->ReadBuffer
;
1293 /* check if really changing bindings */
1294 if (oldDrawFb
== newDrawFb
)
1295 bindDrawBuf
= GL_FALSE
;
1296 if (oldReadFb
== newReadFb
)
1297 bindReadBuf
= GL_FALSE
;
1300 * OK, now bind the new Draw/Read framebuffers, if they're changing.
1302 * We also check if we're beginning and/or ending render-to-texture.
1303 * When a framebuffer with texture attachments is unbound, call
1304 * ctx->Driver.FinishRenderTexture().
1305 * When a framebuffer with texture attachments is bound, call
1306 * ctx->Driver.RenderTexture().
1308 * Note that if the ReadBuffer has texture attachments we don't consider
1309 * that a render-to-texture case.
1312 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1314 /* check if old readbuffer was render-to-texture */
1315 check_end_texture_render(ctx
, oldReadFb
);
1317 _mesa_reference_framebuffer(&ctx
->ReadBuffer
, newReadFb
);
1321 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1323 /* check if old read/draw buffers were render-to-texture */
1325 check_end_texture_render(ctx
, oldReadFb
);
1327 if (oldDrawFb
!= oldReadFb
)
1328 check_end_texture_render(ctx
, oldDrawFb
);
1330 /* check if newly bound framebuffer has any texture attachments */
1331 check_begin_texture_render(ctx
, newDrawFb
);
1333 _mesa_reference_framebuffer(&ctx
->DrawBuffer
, newDrawFb
);
1336 if ((bindDrawBuf
|| bindReadBuf
) && ctx
->Driver
.BindFramebuffer
) {
1337 ctx
->Driver
.BindFramebuffer(ctx
, target
, newDrawFb
, newReadFb
);
1343 _mesa_DeleteFramebuffersEXT(GLsizei n
, const GLuint
*framebuffers
)
1346 GET_CURRENT_CONTEXT(ctx
);
1348 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1349 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1351 for (i
= 0; i
< n
; i
++) {
1352 if (framebuffers
[i
] > 0) {
1353 struct gl_framebuffer
*fb
;
1354 fb
= _mesa_lookup_framebuffer(ctx
, framebuffers
[i
]);
1356 ASSERT(fb
== &DummyFramebuffer
|| fb
->Name
== framebuffers
[i
]);
1358 /* check if deleting currently bound framebuffer object */
1359 if (fb
== ctx
->DrawBuffer
) {
1361 ASSERT(fb
->RefCount
>= 2);
1362 _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT
, 0);
1364 if (fb
== ctx
->ReadBuffer
) {
1366 ASSERT(fb
->RefCount
>= 2);
1367 _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT
, 0);
1370 /* remove from hash table immediately, to free the ID */
1371 _mesa_HashRemove(ctx
->Shared
->FrameBuffers
, framebuffers
[i
]);
1373 if (fb
!= &DummyFramebuffer
) {
1374 /* But the object will not be freed until it's no longer
1375 * bound in any context.
1377 _mesa_reference_framebuffer(&fb
, NULL
);
1386 _mesa_GenFramebuffersEXT(GLsizei n
, GLuint
*framebuffers
)
1388 GET_CURRENT_CONTEXT(ctx
);
1392 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1395 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenFramebuffersEXT(n)");
1402 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->FrameBuffers
, n
);
1404 for (i
= 0; i
< n
; i
++) {
1405 GLuint name
= first
+ i
;
1406 framebuffers
[i
] = name
;
1407 /* insert dummy placeholder into hash table */
1408 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
1409 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, name
, &DummyFramebuffer
);
1410 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
1417 _mesa_CheckFramebufferStatusEXT(GLenum target
)
1419 struct gl_framebuffer
*buffer
;
1420 GET_CURRENT_CONTEXT(ctx
);
1422 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1425 #if FEATURE_EXT_framebuffer_blit
1426 case GL_DRAW_FRAMEBUFFER_EXT
:
1427 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1428 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1431 buffer
= ctx
->DrawBuffer
;
1433 case GL_READ_FRAMEBUFFER_EXT
:
1434 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1435 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1438 buffer
= ctx
->ReadBuffer
;
1441 case GL_FRAMEBUFFER_EXT
:
1442 buffer
= ctx
->DrawBuffer
;
1445 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1446 return 0; /* formerly GL_FRAMEBUFFER_STATUS_ERROR_EXT */
1449 if (buffer
->Name
== 0) {
1450 /* The window system / default framebuffer is always complete */
1451 return GL_FRAMEBUFFER_COMPLETE_EXT
;
1454 /* No need to flush here */
1456 if (buffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1457 _mesa_test_framebuffer_completeness(ctx
, buffer
);
1460 return buffer
->_Status
;
1466 * Common code called by glFramebufferTexture1D/2D/3DEXT().
1469 framebuffer_texture(GLcontext
*ctx
, const char *caller
, GLenum target
,
1470 GLenum attachment
, GLenum textarget
, GLuint texture
,
1471 GLint level
, GLint zoffset
)
1473 struct gl_renderbuffer_attachment
*att
;
1474 struct gl_texture_object
*texObj
= NULL
;
1475 struct gl_framebuffer
*fb
;
1476 GLboolean error
= GL_FALSE
;
1478 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1481 case GL_READ_FRAMEBUFFER_EXT
:
1482 error
= !ctx
->Extensions
.EXT_framebuffer_blit
;
1483 fb
= ctx
->ReadBuffer
;
1485 case GL_DRAW_FRAMEBUFFER_EXT
:
1486 error
= !ctx
->Extensions
.EXT_framebuffer_blit
;
1488 case GL_FRAMEBUFFER_EXT
:
1489 fb
= ctx
->DrawBuffer
;
1496 _mesa_error(ctx
, GL_INVALID_ENUM
,
1497 "glFramebufferTexture%sEXT(target=0x%x)", caller
, target
);
1503 /* check framebuffer binding */
1504 if (fb
->Name
== 0) {
1505 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1506 "glFramebufferTexture%sEXT", caller
);
1511 /* The textarget, level, and zoffset parameters are only validated if
1512 * texture is non-zero.
1515 GLboolean err
= GL_TRUE
;
1517 texObj
= _mesa_lookup_texture(ctx
, texture
);
1518 if (texObj
!= NULL
) {
1519 if (textarget
== 0) {
1520 err
= (texObj
->Target
!= GL_TEXTURE_3D
) &&
1521 (texObj
->Target
!= GL_TEXTURE_1D_ARRAY_EXT
) &&
1522 (texObj
->Target
!= GL_TEXTURE_2D_ARRAY_EXT
);
1525 err
= (texObj
->Target
== GL_TEXTURE_CUBE_MAP
)
1526 ? !IS_CUBE_FACE(textarget
)
1527 : (texObj
->Target
!= textarget
);
1532 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1533 "glFramebufferTexture%sEXT(texture target mismatch)",
1538 if (texObj
->Target
== GL_TEXTURE_3D
) {
1539 const GLint maxSize
= 1 << (ctx
->Const
.Max3DTextureLevels
- 1);
1540 if (zoffset
< 0 || zoffset
>= maxSize
) {
1541 _mesa_error(ctx
, GL_INVALID_VALUE
,
1542 "glFramebufferTexture%sEXT(zoffset)", caller
);
1546 else if ((texObj
->Target
== GL_TEXTURE_1D_ARRAY_EXT
) ||
1547 (texObj
->Target
== GL_TEXTURE_2D_ARRAY_EXT
)) {
1548 if (zoffset
< 0 || zoffset
>= ctx
->Const
.MaxArrayTextureLayers
) {
1549 _mesa_error(ctx
, GL_INVALID_VALUE
,
1550 "glFramebufferTexture%sEXT(layer)", caller
);
1556 (level
>= _mesa_max_texture_levels(ctx
, texObj
->Target
))) {
1557 _mesa_error(ctx
, GL_INVALID_VALUE
,
1558 "glFramebufferTexture%sEXT(level)", caller
);
1563 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
1565 _mesa_error(ctx
, GL_INVALID_ENUM
,
1566 "glFramebufferTexture%sEXT(attachment)", caller
);
1570 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1572 _glthread_LOCK_MUTEX(fb
->Mutex
);
1574 _mesa_set_texture_attachment(ctx
, fb
, att
, texObj
, textarget
,
1576 /* Set the render-to-texture flag. We'll check this flag in
1577 * glTexImage() and friends to determine if we need to revalidate
1578 * any FBOs that might be rendering into this texture.
1579 * This flag never gets cleared since it's non-trivial to determine
1580 * when all FBOs might be done rendering to this texture. That's OK
1581 * though since it's uncommon to render to a texture then repeatedly
1582 * call glTexImage() to change images in the texture.
1584 texObj
->_RenderToTexture
= GL_TRUE
;
1587 _mesa_remove_attachment(ctx
, att
);
1590 invalidate_framebuffer(fb
);
1592 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
1598 _mesa_FramebufferTexture1DEXT(GLenum target
, GLenum attachment
,
1599 GLenum textarget
, GLuint texture
, GLint level
)
1601 GET_CURRENT_CONTEXT(ctx
);
1603 if ((texture
!= 0) && (textarget
!= GL_TEXTURE_1D
)) {
1604 _mesa_error(ctx
, GL_INVALID_ENUM
,
1605 "glFramebufferTexture1DEXT(textarget)");
1609 framebuffer_texture(ctx
, "1D", target
, attachment
, textarget
, texture
,
1615 _mesa_FramebufferTexture2DEXT(GLenum target
, GLenum attachment
,
1616 GLenum textarget
, GLuint texture
, GLint level
)
1618 GET_CURRENT_CONTEXT(ctx
);
1620 if ((texture
!= 0) &&
1621 (textarget
!= GL_TEXTURE_2D
) &&
1622 (textarget
!= GL_TEXTURE_RECTANGLE_ARB
) &&
1623 (!IS_CUBE_FACE(textarget
))) {
1624 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1625 "glFramebufferTexture2DEXT(textarget=0x%x)", textarget
);
1629 framebuffer_texture(ctx
, "2D", target
, attachment
, textarget
, texture
,
1635 _mesa_FramebufferTexture3DEXT(GLenum target
, GLenum attachment
,
1636 GLenum textarget
, GLuint texture
,
1637 GLint level
, GLint zoffset
)
1639 GET_CURRENT_CONTEXT(ctx
);
1641 if ((texture
!= 0) && (textarget
!= GL_TEXTURE_3D
)) {
1642 _mesa_error(ctx
, GL_INVALID_ENUM
,
1643 "glFramebufferTexture3DEXT(textarget)");
1647 framebuffer_texture(ctx
, "3D", target
, attachment
, textarget
, texture
,
1653 _mesa_FramebufferTextureLayerEXT(GLenum target
, GLenum attachment
,
1654 GLuint texture
, GLint level
, GLint layer
)
1656 GET_CURRENT_CONTEXT(ctx
);
1658 framebuffer_texture(ctx
, "Layer", target
, attachment
, 0, texture
,
1664 _mesa_FramebufferRenderbufferEXT(GLenum target
, GLenum attachment
,
1665 GLenum renderbufferTarget
,
1666 GLuint renderbuffer
)
1668 struct gl_renderbuffer_attachment
*att
;
1669 struct gl_framebuffer
*fb
;
1670 struct gl_renderbuffer
*rb
;
1671 GET_CURRENT_CONTEXT(ctx
);
1673 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1676 #if FEATURE_EXT_framebuffer_blit
1677 case GL_DRAW_FRAMEBUFFER_EXT
:
1678 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1679 _mesa_error(ctx
, GL_INVALID_ENUM
,
1680 "glFramebufferRenderbufferEXT(target)");
1683 fb
= ctx
->DrawBuffer
;
1685 case GL_READ_FRAMEBUFFER_EXT
:
1686 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1687 _mesa_error(ctx
, GL_INVALID_ENUM
,
1688 "glFramebufferRenderbufferEXT(target)");
1691 fb
= ctx
->ReadBuffer
;
1694 case GL_FRAMEBUFFER_EXT
:
1695 fb
= ctx
->DrawBuffer
;
1698 _mesa_error(ctx
, GL_INVALID_ENUM
,
1699 "glFramebufferRenderbufferEXT(target)");
1703 if (renderbufferTarget
!= GL_RENDERBUFFER_EXT
) {
1704 _mesa_error(ctx
, GL_INVALID_ENUM
,
1705 "glFramebufferRenderbufferEXT(renderbufferTarget)");
1709 if (fb
->Name
== 0) {
1710 /* Can't attach new renderbuffers to a window system framebuffer */
1711 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glFramebufferRenderbufferEXT");
1715 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
1717 _mesa_error(ctx
, GL_INVALID_ENUM
,
1718 "glFramebufferRenderbufferEXT(invalid attachment %s)",
1719 _mesa_lookup_enum_by_nr(attachment
));
1724 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
1726 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1727 "glFramebufferRenderbufferEXT(non-existant"
1728 " renderbuffer %u)", renderbuffer
);
1733 /* remove renderbuffer attachment */
1737 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
1738 /* make sure the renderbuffer is a depth/stencil format */
1739 const GLenum baseFormat
=
1740 _mesa_get_format_base_format(att
->Renderbuffer
->Format
);
1741 if (baseFormat
!= GL_DEPTH_STENCIL
) {
1742 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1743 "glFramebufferRenderbufferEXT(renderbuffer"
1744 " is not DEPTH_STENCIL format)");
1750 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1752 assert(ctx
->Driver
.FramebufferRenderbuffer
);
1753 ctx
->Driver
.FramebufferRenderbuffer(ctx
, fb
, attachment
, rb
);
1755 /* Some subsequent GL commands may depend on the framebuffer's visual
1756 * after the binding is updated. Update visual info now.
1758 _mesa_update_framebuffer_visual(fb
);
1763 _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target
, GLenum attachment
,
1764 GLenum pname
, GLint
*params
)
1766 const struct gl_renderbuffer_attachment
*att
;
1767 struct gl_framebuffer
*buffer
;
1768 GET_CURRENT_CONTEXT(ctx
);
1770 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1773 #if FEATURE_EXT_framebuffer_blit
1774 case GL_DRAW_FRAMEBUFFER_EXT
:
1775 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1776 _mesa_error(ctx
, GL_INVALID_ENUM
,
1777 "glGetFramebufferAttachmentParameterivEXT(target)");
1780 buffer
= ctx
->DrawBuffer
;
1782 case GL_READ_FRAMEBUFFER_EXT
:
1783 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1784 _mesa_error(ctx
, GL_INVALID_ENUM
,
1785 "glGetFramebufferAttachmentParameterivEXT(target)");
1788 buffer
= ctx
->ReadBuffer
;
1791 case GL_FRAMEBUFFER_EXT
:
1792 buffer
= ctx
->DrawBuffer
;
1795 _mesa_error(ctx
, GL_INVALID_ENUM
,
1796 "glGetFramebufferAttachmentParameterivEXT(target)");
1800 if (buffer
->Name
== 0) {
1801 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1802 "glGetFramebufferAttachmentParameterivEXT");
1806 att
= _mesa_get_attachment(ctx
, buffer
, attachment
);
1808 _mesa_error(ctx
, GL_INVALID_ENUM
,
1809 "glGetFramebufferAttachmentParameterivEXT(attachment)");
1813 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
1814 /* the depth and stencil attachments must point to the same buffer */
1815 const struct gl_renderbuffer_attachment
*depthAtt
, *stencilAtt
;
1816 depthAtt
= _mesa_get_attachment(ctx
, buffer
, GL_DEPTH_ATTACHMENT
);
1817 stencilAtt
= _mesa_get_attachment(ctx
, buffer
, GL_STENCIL_ATTACHMENT
);
1818 if (depthAtt
->Renderbuffer
!= stencilAtt
->Renderbuffer
) {
1819 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1820 "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL"
1821 " attachments differ)");
1826 /* No need to flush here */
1829 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT
:
1830 *params
= att
->Type
;
1832 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT
:
1833 if (att
->Type
== GL_RENDERBUFFER_EXT
) {
1834 *params
= att
->Renderbuffer
->Name
;
1836 else if (att
->Type
== GL_TEXTURE
) {
1837 *params
= att
->Texture
->Name
;
1840 _mesa_error(ctx
, GL_INVALID_ENUM
,
1841 "glGetFramebufferAttachmentParameterivEXT(pname)");
1844 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT
:
1845 if (att
->Type
== GL_TEXTURE
) {
1846 *params
= att
->TextureLevel
;
1849 _mesa_error(ctx
, GL_INVALID_ENUM
,
1850 "glGetFramebufferAttachmentParameterivEXT(pname)");
1853 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT
:
1854 if (att
->Type
== GL_TEXTURE
) {
1855 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_CUBE_MAP
) {
1856 *params
= GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ att
->CubeMapFace
;
1863 _mesa_error(ctx
, GL_INVALID_ENUM
,
1864 "glGetFramebufferAttachmentParameterivEXT(pname)");
1867 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT
:
1868 if (att
->Type
== GL_TEXTURE
) {
1869 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_3D
) {
1870 *params
= att
->Zoffset
;
1877 _mesa_error(ctx
, GL_INVALID_ENUM
,
1878 "glGetFramebufferAttachmentParameterivEXT(pname)");
1881 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
:
1882 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1883 _mesa_error(ctx
, GL_INVALID_ENUM
,
1884 "glGetFramebufferAttachmentParameterivEXT(pname)");
1887 *params
= _mesa_get_format_color_encoding(att
->Renderbuffer
->Format
);
1890 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE
:
1891 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1892 _mesa_error(ctx
, GL_INVALID_ENUM
,
1893 "glGetFramebufferAttachmentParameterivEXT(pname)");
1897 gl_format format
= att
->Renderbuffer
->Format
;
1898 if (format
== MESA_FORMAT_CI8
|| format
== MESA_FORMAT_S8
) {
1903 *params
= _mesa_get_format_datatype(format
);
1907 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
1908 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
1909 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
1910 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
1911 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
1912 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
1913 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
1914 _mesa_error(ctx
, GL_INVALID_ENUM
,
1915 "glGetFramebufferAttachmentParameterivEXT(pname)");
1917 else if (att
->Texture
) {
1918 const struct gl_texture_image
*texImage
=
1919 _mesa_select_tex_image(ctx
, att
->Texture
, att
->Texture
->Target
,
1922 *params
= get_component_bits(pname
, texImage
->_BaseFormat
,
1923 texImage
->TexFormat
);
1929 else if (att
->Renderbuffer
) {
1930 *params
= get_component_bits(pname
, att
->Renderbuffer
->_BaseFormat
,
1931 att
->Renderbuffer
->Format
);
1938 _mesa_error(ctx
, GL_INVALID_ENUM
,
1939 "glGetFramebufferAttachmentParameterivEXT(pname)");
1946 _mesa_GenerateMipmapEXT(GLenum target
)
1948 struct gl_texture_object
*texObj
;
1949 GET_CURRENT_CONTEXT(ctx
);
1951 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1952 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1958 case GL_TEXTURE_CUBE_MAP
:
1959 /* OK, legal value */
1962 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGenerateMipmapEXT(target)");
1966 texObj
= _mesa_get_current_tex_object(ctx
, target
);
1968 if (texObj
->BaseLevel
>= texObj
->MaxLevel
) {
1973 _mesa_lock_texture(ctx
, texObj
);
1974 if (target
== GL_TEXTURE_CUBE_MAP
) {
1976 for (face
= 0; face
< 6; face
++)
1977 ctx
->Driver
.GenerateMipmap(ctx
,
1978 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
+ face
,
1982 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
1984 _mesa_unlock_texture(ctx
, texObj
);
1988 #if FEATURE_EXT_framebuffer_blit
1990 static const struct gl_renderbuffer_attachment
*
1991 find_attachment(const struct gl_framebuffer
*fb
, const struct gl_renderbuffer
*rb
)
1994 for (i
= 0; i
< Elements(fb
->Attachment
); i
++) {
1995 if (fb
->Attachment
[i
].Renderbuffer
== rb
)
1996 return &fb
->Attachment
[i
];
2004 * Blit rectangular region, optionally from one framebuffer to another.
2006 * Note, if the src buffer is multisampled and the dest is not, this is
2007 * when the samples must be resolved to a single color.
2010 _mesa_BlitFramebufferEXT(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
2011 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
2012 GLbitfield mask
, GLenum filter
)
2014 const GLbitfield legalMaskBits
= (GL_COLOR_BUFFER_BIT
|
2015 GL_DEPTH_BUFFER_BIT
|
2016 GL_STENCIL_BUFFER_BIT
);
2017 const struct gl_framebuffer
*readFb
, *drawFb
;
2018 const struct gl_renderbuffer
*colorReadRb
, *colorDrawRb
;
2019 GET_CURRENT_CONTEXT(ctx
);
2021 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2022 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2024 if (ctx
->NewState
) {
2025 _mesa_update_state(ctx
);
2028 readFb
= ctx
->ReadBuffer
;
2029 drawFb
= ctx
->DrawBuffer
;
2031 if (!readFb
|| !drawFb
) {
2032 /* This will normally never happen but someday we may want to
2033 * support MakeCurrent() with no drawables.
2038 /* check for complete framebuffers */
2039 if (drawFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
||
2040 readFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
2041 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
2042 "glBlitFramebufferEXT(incomplete draw/read buffers)");
2046 if (filter
!= GL_NEAREST
&& filter
!= GL_LINEAR
) {
2047 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlitFramebufferEXT(filter)");
2051 if (mask
& ~legalMaskBits
) {
2052 _mesa_error( ctx
, GL_INVALID_VALUE
, "glBlitFramebufferEXT(mask)");
2056 /* depth/stencil must be blitted with nearest filtering */
2057 if ((mask
& (GL_DEPTH_BUFFER_BIT
| GL_STENCIL_BUFFER_BIT
))
2058 && filter
!= GL_NEAREST
) {
2059 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2060 "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter");
2064 /* get color read/draw renderbuffers */
2065 if (mask
& GL_COLOR_BUFFER_BIT
) {
2066 colorReadRb
= readFb
->_ColorReadBuffer
;
2067 colorDrawRb
= drawFb
->_ColorDrawBuffers
[0];
2070 colorReadRb
= colorDrawRb
= NULL
;
2073 if (mask
& GL_STENCIL_BUFFER_BIT
) {
2074 struct gl_renderbuffer
*readRb
= readFb
->_StencilBuffer
;
2075 struct gl_renderbuffer
*drawRb
= drawFb
->_StencilBuffer
;
2078 _mesa_get_format_bits(readRb
->Format
, GL_STENCIL_BITS
) !=
2079 _mesa_get_format_bits(drawRb
->Format
, GL_STENCIL_BITS
)) {
2080 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2081 "glBlitFramebufferEXT(stencil buffer size mismatch");
2086 if (mask
& GL_DEPTH_BUFFER_BIT
) {
2087 struct gl_renderbuffer
*readRb
= readFb
->_DepthBuffer
;
2088 struct gl_renderbuffer
*drawRb
= drawFb
->_DepthBuffer
;
2091 _mesa_get_format_bits(readRb
->Format
, GL_DEPTH_BITS
) !=
2092 _mesa_get_format_bits(drawRb
->Format
, GL_DEPTH_BITS
)) {
2093 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2094 "glBlitFramebufferEXT(depth buffer size mismatch");
2099 if (readFb
->Visual
.samples
> 0 &&
2100 drawFb
->Visual
.samples
> 0 &&
2101 readFb
->Visual
.samples
!= drawFb
->Visual
.samples
) {
2102 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2103 "glBlitFramebufferEXT(mismatched samples");
2107 /* extra checks for multisample copies... */
2108 if (readFb
->Visual
.samples
> 0 || drawFb
->Visual
.samples
> 0) {
2109 /* src and dest region sizes must be the same */
2110 if (srcX1
- srcX0
!= dstX1
- dstX0
||
2111 srcY1
- srcY0
!= dstY1
- dstY0
) {
2112 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2113 "glBlitFramebufferEXT(bad src/dst multisample region sizes");
2117 /* color formats must match */
2120 colorReadRb
->Format
!= colorDrawRb
->Format
) {
2121 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2122 "glBlitFramebufferEXT(bad src/dst multisample pixel formats");
2127 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
2128 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBlitFramebufferEXT");
2134 _mesa_printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
2136 srcX0
, srcY0
, srcX1
, srcY1
,
2137 dstX0
, dstY0
, dstX1
, dstY1
,
2140 const struct gl_renderbuffer_attachment
*att
;
2142 att
= find_attachment(readFb
, colorReadRb
);
2143 _mesa_printf(" Src FBO %u RB %u (%dx%d) ",
2144 readFb
->Name
, colorReadRb
->Name
,
2145 colorReadRb
->Width
, colorReadRb
->Height
);
2146 if (att
&& att
->Texture
) {
2147 _mesa_printf("Tex %u tgt 0x%x level %u face %u",
2149 att
->Texture
->Target
,
2155 att
= find_attachment(drawFb
, colorDrawRb
);
2156 _mesa_printf(" Dst FBO %u RB %u (%dx%d) ",
2157 drawFb
->Name
, colorDrawRb
->Name
,
2158 colorDrawRb
->Width
, colorDrawRb
->Height
);
2159 if (att
&& att
->Texture
) {
2160 _mesa_printf("Tex %u tgt 0x%x level %u face %u",
2162 att
->Texture
->Target
,
2170 ASSERT(ctx
->Driver
.BlitFramebuffer
);
2171 ctx
->Driver
.BlitFramebuffer(ctx
,
2172 srcX0
, srcY0
, srcX1
, srcY1
,
2173 dstX0
, dstY0
, dstX1
, dstY1
,
2176 #endif /* FEATURE_EXT_framebuffer_blit */