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 "mfeatures.h"
46 #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
;
77 /* We bind this framebuffer when applications pass a NULL
78 * drawable/surface in make current. */
79 static struct gl_framebuffer IncompleteFramebuffer
;
83 delete_dummy_renderbuffer(struct gl_renderbuffer
*rb
)
89 delete_dummy_framebuffer(struct gl_framebuffer
*fb
)
96 _mesa_init_fbobjects(struct gl_context
*ctx
)
98 _glthread_INIT_MUTEX(DummyFramebuffer
.Mutex
);
99 _glthread_INIT_MUTEX(DummyRenderbuffer
.Mutex
);
100 _glthread_INIT_MUTEX(IncompleteFramebuffer
.Mutex
);
101 DummyFramebuffer
.Delete
= delete_dummy_framebuffer
;
102 DummyRenderbuffer
.Delete
= delete_dummy_renderbuffer
;
103 IncompleteFramebuffer
.Delete
= delete_dummy_framebuffer
;
106 struct gl_framebuffer
*
107 _mesa_get_incomplete_framebuffer(void)
109 return &IncompleteFramebuffer
;
113 * Helper routine for getting a gl_renderbuffer.
115 struct gl_renderbuffer
*
116 _mesa_lookup_renderbuffer(struct gl_context
*ctx
, GLuint id
)
118 struct gl_renderbuffer
*rb
;
123 rb
= (struct gl_renderbuffer
*)
124 _mesa_HashLookup(ctx
->Shared
->RenderBuffers
, id
);
130 * Helper routine for getting a gl_framebuffer.
132 struct gl_framebuffer
*
133 _mesa_lookup_framebuffer(struct gl_context
*ctx
, GLuint id
)
135 struct gl_framebuffer
*fb
;
140 fb
= (struct gl_framebuffer
*)
141 _mesa_HashLookup(ctx
->Shared
->FrameBuffers
, id
);
147 * Mark the given framebuffer as invalid. This will force the
148 * test for framebuffer completeness to be done before the framebuffer
152 invalidate_framebuffer(struct gl_framebuffer
*fb
)
154 fb
->_Status
= 0; /* "indeterminate" */
159 * Return the gl_framebuffer object which corresponds to the given
160 * framebuffer target, such as GL_DRAW_FRAMEBUFFER.
161 * Check support for GL_EXT_framebuffer_blit to determine if certain
163 * \return gl_framebuffer pointer or NULL if target is illegal
165 static struct gl_framebuffer
*
166 get_framebuffer_target(struct gl_context
*ctx
, GLenum target
)
169 case GL_DRAW_FRAMEBUFFER
:
170 return ctx
->Extensions
.EXT_framebuffer_blit
&& ctx
->API
== API_OPENGL
171 ? ctx
->DrawBuffer
: NULL
;
172 case GL_READ_FRAMEBUFFER
:
173 return ctx
->Extensions
.EXT_framebuffer_blit
&& ctx
->API
== API_OPENGL
174 ? ctx
->ReadBuffer
: NULL
;
175 case GL_FRAMEBUFFER_EXT
:
176 return ctx
->DrawBuffer
;
184 * Given a GL_*_ATTACHMENTn token, return a pointer to the corresponding
185 * gl_renderbuffer_attachment object.
186 * This function is only used for user-created FB objects, not the
187 * default / window-system FB object.
188 * If \p attachment is GL_DEPTH_STENCIL_ATTACHMENT, return a pointer to
189 * the depth buffer attachment point.
191 struct gl_renderbuffer_attachment
*
192 _mesa_get_attachment(struct gl_context
*ctx
, struct gl_framebuffer
*fb
,
197 assert(_mesa_is_user_fbo(fb
));
199 switch (attachment
) {
200 case GL_COLOR_ATTACHMENT0_EXT
:
201 case GL_COLOR_ATTACHMENT1_EXT
:
202 case GL_COLOR_ATTACHMENT2_EXT
:
203 case GL_COLOR_ATTACHMENT3_EXT
:
204 case GL_COLOR_ATTACHMENT4_EXT
:
205 case GL_COLOR_ATTACHMENT5_EXT
:
206 case GL_COLOR_ATTACHMENT6_EXT
:
207 case GL_COLOR_ATTACHMENT7_EXT
:
208 case GL_COLOR_ATTACHMENT8_EXT
:
209 case GL_COLOR_ATTACHMENT9_EXT
:
210 case GL_COLOR_ATTACHMENT10_EXT
:
211 case GL_COLOR_ATTACHMENT11_EXT
:
212 case GL_COLOR_ATTACHMENT12_EXT
:
213 case GL_COLOR_ATTACHMENT13_EXT
:
214 case GL_COLOR_ATTACHMENT14_EXT
:
215 case GL_COLOR_ATTACHMENT15_EXT
:
216 /* Only OpenGL ES 1.x forbids color attachments other than
217 * GL_COLOR_ATTACHMENT0. For all other APIs the limit set by the
220 i
= attachment
- GL_COLOR_ATTACHMENT0_EXT
;
221 if (i
>= ctx
->Const
.MaxColorAttachments
222 || (i
> 0 && ctx
->API
== API_OPENGLES
)) {
225 return &fb
->Attachment
[BUFFER_COLOR0
+ i
];
226 case GL_DEPTH_STENCIL_ATTACHMENT
:
227 if (ctx
->API
!= API_OPENGL
)
230 case GL_DEPTH_ATTACHMENT_EXT
:
231 return &fb
->Attachment
[BUFFER_DEPTH
];
232 case GL_STENCIL_ATTACHMENT_EXT
:
233 return &fb
->Attachment
[BUFFER_STENCIL
];
241 * As above, but only used for getting attachments of the default /
242 * window-system framebuffer (not user-created framebuffer objects).
244 static struct gl_renderbuffer_attachment
*
245 _mesa_get_fb0_attachment(struct gl_context
*ctx
, struct gl_framebuffer
*fb
,
248 assert(_mesa_is_winsys_fbo(fb
));
250 switch (attachment
) {
252 return &fb
->Attachment
[BUFFER_FRONT_LEFT
];
254 return &fb
->Attachment
[BUFFER_FRONT_RIGHT
];
256 return &fb
->Attachment
[BUFFER_BACK_LEFT
];
258 return &fb
->Attachment
[BUFFER_BACK_RIGHT
];
260 if (fb
->Visual
.numAuxBuffers
== 1) {
261 return &fb
->Attachment
[BUFFER_AUX0
];
265 /* Page 336 (page 352 of the PDF) of the OpenGL 3.0 spec says:
267 * "If the default framebuffer is bound to target, then attachment must
268 * be one of FRONT LEFT, FRONT RIGHT, BACK LEFT, BACK RIGHT, or AUXi,
269 * identifying a color buffer; DEPTH, identifying the depth buffer; or
270 * STENCIL, identifying the stencil buffer."
272 * Revision #34 of the ARB_framebuffer_object spec has essentially the same
273 * language. However, revision #33 of the ARB_framebuffer_object spec
276 * "If the default framebuffer is bound to <target>, then <attachment>
277 * must be one of FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT, AUXi,
278 * DEPTH_BUFFER, or STENCIL_BUFFER, identifying a color buffer, the
279 * depth buffer, or the stencil buffer, and <pname> may be
280 * FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE or
281 * FRAMEBUFFER_ATTACHMENT_OBJECT_NAME."
283 * The enum values for DEPTH_BUFFER and STENCIL_BUFFER have been removed
284 * from glext.h, so shipping apps should not use those values.
286 * Note that neither EXT_framebuffer_object nor OES_framebuffer_object
287 * support queries of the window system FBO.
290 return &fb
->Attachment
[BUFFER_DEPTH
];
292 return &fb
->Attachment
[BUFFER_STENCIL
];
301 * Remove any texture or renderbuffer attached to the given attachment
302 * point. Update reference counts, etc.
305 _mesa_remove_attachment(struct gl_context
*ctx
,
306 struct gl_renderbuffer_attachment
*att
)
308 if (att
->Type
== GL_TEXTURE
) {
309 ASSERT(att
->Texture
);
310 if (ctx
->Driver
.FinishRenderTexture
) {
311 /* tell driver that we're done rendering to this texture. */
312 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
314 _mesa_reference_texobj(&att
->Texture
, NULL
); /* unbind */
315 ASSERT(!att
->Texture
);
317 if (att
->Type
== GL_TEXTURE
|| att
->Type
== GL_RENDERBUFFER_EXT
) {
318 ASSERT(!att
->Texture
);
319 _mesa_reference_renderbuffer(&att
->Renderbuffer
, NULL
); /* unbind */
320 ASSERT(!att
->Renderbuffer
);
323 att
->Complete
= GL_TRUE
;
328 * Bind a texture object to an attachment point.
329 * The previous binding, if any, will be removed first.
332 _mesa_set_texture_attachment(struct gl_context
*ctx
,
333 struct gl_framebuffer
*fb
,
334 struct gl_renderbuffer_attachment
*att
,
335 struct gl_texture_object
*texObj
,
336 GLenum texTarget
, GLuint level
, GLuint zoffset
)
338 if (att
->Texture
== texObj
) {
339 /* re-attaching same texture */
340 ASSERT(att
->Type
== GL_TEXTURE
);
341 if (ctx
->Driver
.FinishRenderTexture
)
342 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
346 if (ctx
->Driver
.FinishRenderTexture
&& att
->Texture
)
347 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
348 _mesa_remove_attachment(ctx
, att
);
349 att
->Type
= GL_TEXTURE
;
350 assert(!att
->Texture
);
351 _mesa_reference_texobj(&att
->Texture
, texObj
);
354 /* always update these fields */
355 att
->TextureLevel
= level
;
356 att
->CubeMapFace
= _mesa_tex_target_to_face(texTarget
);
357 att
->Zoffset
= zoffset
;
358 att
->Complete
= GL_FALSE
;
360 if (_mesa_get_attachment_teximage(att
)) {
361 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
364 invalidate_framebuffer(fb
);
369 * Bind a renderbuffer to an attachment point.
370 * The previous binding, if any, will be removed first.
373 _mesa_set_renderbuffer_attachment(struct gl_context
*ctx
,
374 struct gl_renderbuffer_attachment
*att
,
375 struct gl_renderbuffer
*rb
)
377 /* XXX check if re-doing same attachment, exit early */
378 _mesa_remove_attachment(ctx
, att
);
379 att
->Type
= GL_RENDERBUFFER_EXT
;
380 att
->Texture
= NULL
; /* just to be safe */
381 att
->Complete
= GL_FALSE
;
382 _mesa_reference_renderbuffer(&att
->Renderbuffer
, rb
);
387 * Fallback for ctx->Driver.FramebufferRenderbuffer()
388 * Attach a renderbuffer object to a framebuffer object.
391 _mesa_framebuffer_renderbuffer(struct gl_context
*ctx
,
392 struct gl_framebuffer
*fb
,
393 GLenum attachment
, struct gl_renderbuffer
*rb
)
395 struct gl_renderbuffer_attachment
*att
;
397 _glthread_LOCK_MUTEX(fb
->Mutex
);
399 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
402 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
403 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
404 /* do stencil attachment here (depth already done above) */
405 att
= _mesa_get_attachment(ctx
, fb
, GL_STENCIL_ATTACHMENT_EXT
);
407 _mesa_set_renderbuffer_attachment(ctx
, att
, rb
);
409 rb
->AttachedAnytime
= GL_TRUE
;
412 _mesa_remove_attachment(ctx
, att
);
415 invalidate_framebuffer(fb
);
417 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
422 * Fallback for ctx->Driver.ValidateFramebuffer()
423 * Check if the renderbuffer's formats are supported by the software
425 * Drivers should probably override this.
428 _mesa_validate_framebuffer(struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
431 for (buf
= 0; buf
< BUFFER_COUNT
; buf
++) {
432 const struct gl_renderbuffer
*rb
= fb
->Attachment
[buf
].Renderbuffer
;
434 switch (rb
->_BaseFormat
) {
436 case GL_LUMINANCE_ALPHA
:
441 fb
->_Status
= GL_FRAMEBUFFER_UNSUPPORTED
;
445 switch (rb
->Format
) {
446 /* XXX This list is likely incomplete. */
447 case MESA_FORMAT_RGB9_E5_FLOAT
:
448 fb
->_Status
= GL_FRAMEBUFFER_UNSUPPORTED
;
451 /* render buffer format is supported by software rendering */
463 att_incomplete(const char *msg
)
466 _mesa_debug(NULL
, "attachment incomplete: %s\n", msg
);
477 fbo_incomplete(const char *msg
, int index
)
480 _mesa_debug(NULL
, "FBO Incomplete: %s [%d]\n", msg
, index
);
489 * Is the given base format a legal format for a color renderbuffer?
492 _mesa_is_legal_color_format(const struct gl_context
*ctx
, GLenum baseFormat
)
494 switch (baseFormat
) {
499 case GL_LUMINANCE_ALPHA
:
502 return ctx
->Extensions
.ARB_framebuffer_object
;
505 return ctx
->Extensions
.ARB_texture_rg
;
513 * Is the given base format a legal format for a depth/stencil renderbuffer?
516 is_legal_depth_format(const struct gl_context
*ctx
, GLenum baseFormat
)
518 switch (baseFormat
) {
519 case GL_DEPTH_COMPONENT
:
520 case GL_DEPTH_STENCIL_EXT
:
529 * Test if an attachment point is complete and update its Complete field.
530 * \param format if GL_COLOR, this is a color attachment point,
531 * if GL_DEPTH, this is a depth component attachment point,
532 * if GL_STENCIL, this is a stencil component attachment point.
535 test_attachment_completeness(const struct gl_context
*ctx
, GLenum format
,
536 struct gl_renderbuffer_attachment
*att
)
538 assert(format
== GL_COLOR
|| format
== GL_DEPTH
|| format
== GL_STENCIL
);
540 /* assume complete */
541 att
->Complete
= GL_TRUE
;
543 /* Look for reasons why the attachment might be incomplete */
544 if (att
->Type
== GL_TEXTURE
) {
545 const struct gl_texture_object
*texObj
= att
->Texture
;
546 struct gl_texture_image
*texImage
;
550 att_incomplete("no texobj");
551 att
->Complete
= GL_FALSE
;
555 texImage
= texObj
->Image
[att
->CubeMapFace
][att
->TextureLevel
];
557 att_incomplete("no teximage");
558 att
->Complete
= GL_FALSE
;
561 if (texImage
->Width
< 1 || texImage
->Height
< 1) {
562 att_incomplete("teximage width/height=0");
563 printf("texobj = %u\n", texObj
->Name
);
564 printf("level = %d\n", att
->TextureLevel
);
565 att
->Complete
= GL_FALSE
;
568 if (texObj
->Target
== GL_TEXTURE_3D
&& att
->Zoffset
>= texImage
->Depth
) {
569 att_incomplete("bad z offset");
570 att
->Complete
= GL_FALSE
;
574 baseFormat
= _mesa_get_format_base_format(texImage
->TexFormat
);
576 if (format
== GL_COLOR
) {
577 if (!_mesa_is_legal_color_format(ctx
, baseFormat
)) {
578 att_incomplete("bad format");
579 att
->Complete
= GL_FALSE
;
582 if (_mesa_is_format_compressed(texImage
->TexFormat
)) {
583 att_incomplete("compressed internalformat");
584 att
->Complete
= GL_FALSE
;
588 else if (format
== GL_DEPTH
) {
589 if (baseFormat
== GL_DEPTH_COMPONENT
) {
592 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
593 ctx
->Extensions
.ARB_depth_texture
&&
594 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
598 att
->Complete
= GL_FALSE
;
599 att_incomplete("bad depth format");
604 ASSERT(format
== GL_STENCIL
);
605 if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
606 ctx
->Extensions
.ARB_depth_texture
&&
607 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
611 /* no such thing as stencil-only textures */
612 att_incomplete("illegal stencil texture");
613 att
->Complete
= GL_FALSE
;
618 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
619 const GLenum baseFormat
=
620 _mesa_get_format_base_format(att
->Renderbuffer
->Format
);
622 ASSERT(att
->Renderbuffer
);
623 if (!att
->Renderbuffer
->InternalFormat
||
624 att
->Renderbuffer
->Width
< 1 ||
625 att
->Renderbuffer
->Height
< 1) {
626 att_incomplete("0x0 renderbuffer");
627 att
->Complete
= GL_FALSE
;
630 if (format
== GL_COLOR
) {
631 if (!_mesa_is_legal_color_format(ctx
, baseFormat
)) {
632 att_incomplete("bad renderbuffer color format");
633 att
->Complete
= GL_FALSE
;
637 else if (format
== GL_DEPTH
) {
638 if (baseFormat
== GL_DEPTH_COMPONENT
) {
641 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
642 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
646 att_incomplete("bad renderbuffer depth format");
647 att
->Complete
= GL_FALSE
;
652 assert(format
== GL_STENCIL
);
653 if (baseFormat
== GL_STENCIL_INDEX
) {
656 else if (ctx
->Extensions
.EXT_packed_depth_stencil
&&
657 baseFormat
== GL_DEPTH_STENCIL_EXT
) {
661 att
->Complete
= GL_FALSE
;
662 att_incomplete("bad renderbuffer stencil format");
668 ASSERT(att
->Type
== GL_NONE
);
676 * Test if the given framebuffer object is complete and update its
677 * Status field with the results.
678 * Calls the ctx->Driver.ValidateFramebuffer() function to allow the
679 * driver to make hardware-specific validation/completeness checks.
680 * Also update the framebuffer's Width and Height fields if the
681 * framebuffer is complete.
684 _mesa_test_framebuffer_completeness(struct gl_context
*ctx
,
685 struct gl_framebuffer
*fb
)
688 GLenum intFormat
= GL_NONE
; /* color buffers' internal format */
689 GLuint minWidth
= ~0, minHeight
= ~0, maxWidth
= 0, maxHeight
= 0;
690 GLint numSamples
= -1;
694 assert(_mesa_is_user_fbo(fb
));
700 /* Start at -2 to more easily loop over all attachment points.
705 for (i
= -2; i
< (GLint
) ctx
->Const
.MaxColorAttachments
; i
++) {
706 struct gl_renderbuffer_attachment
*att
;
711 * XXX for ARB_fbo, only check color buffers that are named by
712 * GL_READ_BUFFER and GL_DRAW_BUFFERi.
715 /* check for attachment completeness
718 att
= &fb
->Attachment
[BUFFER_DEPTH
];
719 test_attachment_completeness(ctx
, GL_DEPTH
, att
);
720 if (!att
->Complete
) {
721 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
722 fbo_incomplete("depth attachment incomplete", -1);
727 att
= &fb
->Attachment
[BUFFER_STENCIL
];
728 test_attachment_completeness(ctx
, GL_STENCIL
, att
);
729 if (!att
->Complete
) {
730 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
731 fbo_incomplete("stencil attachment incomplete", -1);
736 att
= &fb
->Attachment
[BUFFER_COLOR0
+ i
];
737 test_attachment_completeness(ctx
, GL_COLOR
, att
);
738 if (!att
->Complete
) {
739 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
;
740 fbo_incomplete("color attachment incomplete", i
);
745 /* get width, height, format of the renderbuffer/texture
747 if (att
->Type
== GL_TEXTURE
) {
748 const struct gl_texture_image
*texImg
=
749 _mesa_get_attachment_teximage(att
);
750 minWidth
= MIN2(minWidth
, texImg
->Width
);
751 maxWidth
= MAX2(maxWidth
, texImg
->Width
);
752 minHeight
= MIN2(minHeight
, texImg
->Height
);
753 maxHeight
= MAX2(maxHeight
, texImg
->Height
);
754 f
= texImg
->_BaseFormat
;
755 attFormat
= texImg
->TexFormat
;
757 if (!_mesa_is_legal_color_format(ctx
, f
) &&
758 !is_legal_depth_format(ctx
, f
)) {
759 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
760 fbo_incomplete("texture attachment incomplete", -1);
764 else if (att
->Type
== GL_RENDERBUFFER_EXT
) {
765 minWidth
= MIN2(minWidth
, att
->Renderbuffer
->Width
);
766 maxWidth
= MAX2(minWidth
, att
->Renderbuffer
->Width
);
767 minHeight
= MIN2(minHeight
, att
->Renderbuffer
->Height
);
768 maxHeight
= MAX2(minHeight
, att
->Renderbuffer
->Height
);
769 f
= att
->Renderbuffer
->InternalFormat
;
770 attFormat
= att
->Renderbuffer
->Format
;
774 assert(att
->Type
== GL_NONE
);
778 if (att
->Renderbuffer
&& numSamples
< 0) {
780 numSamples
= att
->Renderbuffer
->NumSamples
;
783 /* check if integer color */
784 fb
->_IntegerColor
= _mesa_is_format_integer_color(attFormat
);
786 /* Error-check width, height, format, samples
788 if (numImages
== 1) {
789 /* save format, num samples */
795 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
796 /* check that width, height, format are same */
797 if (minWidth
!= maxWidth
|| minHeight
!= maxHeight
) {
798 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
;
799 fbo_incomplete("width or height mismatch", -1);
802 /* check that all color buffers are the same format */
803 if (intFormat
!= GL_NONE
&& f
!= intFormat
) {
804 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
;
805 fbo_incomplete("format mismatch", -1);
809 if (att
->Renderbuffer
&&
810 att
->Renderbuffer
->NumSamples
!= numSamples
) {
811 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE
;
812 fbo_incomplete("inconsistant number of samples", i
);
819 if (ctx
->API
== API_OPENGL
&& !ctx
->Extensions
.ARB_ES2_compatibility
) {
820 /* Check that all DrawBuffers are present */
821 for (j
= 0; j
< ctx
->Const
.MaxDrawBuffers
; j
++) {
822 if (fb
->ColorDrawBuffer
[j
] != GL_NONE
) {
823 const struct gl_renderbuffer_attachment
*att
824 = _mesa_get_attachment(ctx
, fb
, fb
->ColorDrawBuffer
[j
]);
826 if (att
->Type
== GL_NONE
) {
827 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT
;
828 fbo_incomplete("missing drawbuffer", j
);
834 /* Check that the ReadBuffer is present */
835 if (fb
->ColorReadBuffer
!= GL_NONE
) {
836 const struct gl_renderbuffer_attachment
*att
837 = _mesa_get_attachment(ctx
, fb
, fb
->ColorReadBuffer
);
839 if (att
->Type
== GL_NONE
) {
840 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT
;
841 fbo_incomplete("missing readbuffer", -1);
850 if (numImages
== 0) {
851 fb
->_Status
= GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
;
852 fbo_incomplete("no attachments", -1);
856 /* Provisionally set status = COMPLETE ... */
857 fb
->_Status
= GL_FRAMEBUFFER_COMPLETE_EXT
;
859 /* ... but the driver may say the FB is incomplete.
860 * Drivers will most likely set the status to GL_FRAMEBUFFER_UNSUPPORTED
863 if (ctx
->Driver
.ValidateFramebuffer
) {
864 ctx
->Driver
.ValidateFramebuffer(ctx
, fb
);
865 if (fb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
866 fbo_incomplete("driver marked FBO as incomplete", -1);
870 if (fb
->_Status
== GL_FRAMEBUFFER_COMPLETE_EXT
) {
872 * Note that if ARB_framebuffer_object is supported and the attached
873 * renderbuffers/textures are different sizes, the framebuffer
874 * width/height will be set to the smallest width/height.
876 fb
->Width
= minWidth
;
877 fb
->Height
= minHeight
;
879 /* finally, update the visual info for the framebuffer */
880 _mesa_update_framebuffer_visual(ctx
, fb
);
886 _mesa_IsRenderbufferEXT(GLuint renderbuffer
)
888 GET_CURRENT_CONTEXT(ctx
);
889 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
891 struct gl_renderbuffer
*rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
892 if (rb
!= NULL
&& rb
!= &DummyRenderbuffer
)
900 _mesa_BindRenderbufferEXT(GLenum target
, GLuint renderbuffer
)
902 struct gl_renderbuffer
*newRb
;
903 GET_CURRENT_CONTEXT(ctx
);
905 ASSERT_OUTSIDE_BEGIN_END(ctx
);
907 if (target
!= GL_RENDERBUFFER_EXT
) {
908 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindRenderbufferEXT(target)");
912 /* No need to flush here since the render buffer binding has no
913 * effect on rendering state.
917 newRb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
918 if (newRb
== &DummyRenderbuffer
) {
919 /* ID was reserved, but no real renderbuffer object made yet */
922 else if (!newRb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
923 /* All RB IDs must be Gen'd */
924 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindRenderbuffer(buffer)");
929 /* create new renderbuffer object */
930 newRb
= ctx
->Driver
.NewRenderbuffer(ctx
, renderbuffer
);
932 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindRenderbufferEXT");
935 ASSERT(newRb
->AllocStorage
);
936 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, renderbuffer
, newRb
);
937 newRb
->RefCount
= 1; /* referenced by hash table */
944 ASSERT(newRb
!= &DummyRenderbuffer
);
946 _mesa_reference_renderbuffer(&ctx
->CurrentRenderbuffer
, newRb
);
951 * If the given renderbuffer is anywhere attached to the framebuffer, detach
953 * This is used when a renderbuffer object is deleted.
954 * The spec calls for unbinding.
957 detach_renderbuffer(struct gl_context
*ctx
,
958 struct gl_framebuffer
*fb
,
959 struct gl_renderbuffer
*rb
)
962 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
963 if (fb
->Attachment
[i
].Renderbuffer
== rb
) {
964 _mesa_remove_attachment(ctx
, &fb
->Attachment
[i
]);
967 invalidate_framebuffer(fb
);
972 _mesa_DeleteRenderbuffersEXT(GLsizei n
, const GLuint
*renderbuffers
)
975 GET_CURRENT_CONTEXT(ctx
);
977 ASSERT_OUTSIDE_BEGIN_END(ctx
);
978 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
980 for (i
= 0; i
< n
; i
++) {
981 if (renderbuffers
[i
] > 0) {
982 struct gl_renderbuffer
*rb
;
983 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffers
[i
]);
985 /* check if deleting currently bound renderbuffer object */
986 if (rb
== ctx
->CurrentRenderbuffer
) {
988 ASSERT(rb
->RefCount
>= 2);
989 _mesa_BindRenderbufferEXT(GL_RENDERBUFFER_EXT
, 0);
992 if (_mesa_is_user_fbo(ctx
->DrawBuffer
)) {
993 detach_renderbuffer(ctx
, ctx
->DrawBuffer
, rb
);
995 if (_mesa_is_user_fbo(ctx
->ReadBuffer
)
996 && ctx
->ReadBuffer
!= ctx
->DrawBuffer
) {
997 detach_renderbuffer(ctx
, ctx
->ReadBuffer
, rb
);
1000 /* Remove from hash table immediately, to free the ID.
1001 * But the object will not be freed until it's no longer
1002 * referenced anywhere else.
1004 _mesa_HashRemove(ctx
->Shared
->RenderBuffers
, renderbuffers
[i
]);
1006 if (rb
!= &DummyRenderbuffer
) {
1007 /* no longer referenced by hash table */
1008 _mesa_reference_renderbuffer(&rb
, NULL
);
1017 _mesa_GenRenderbuffersEXT(GLsizei n
, GLuint
*renderbuffers
)
1019 GET_CURRENT_CONTEXT(ctx
);
1023 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1026 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenRenderbuffersEXT(n)");
1033 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->RenderBuffers
, n
);
1035 for (i
= 0; i
< n
; i
++) {
1036 GLuint name
= first
+ i
;
1037 renderbuffers
[i
] = name
;
1038 /* insert dummy placeholder into hash table */
1039 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
1040 _mesa_HashInsert(ctx
->Shared
->RenderBuffers
, name
, &DummyRenderbuffer
);
1041 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
1047 * Given an internal format token for a render buffer, return the
1048 * corresponding base format (one of GL_RGB, GL_RGBA, GL_STENCIL_INDEX,
1049 * GL_DEPTH_COMPONENT, GL_DEPTH_STENCIL_EXT, GL_ALPHA, GL_LUMINANCE,
1050 * GL_LUMINANCE_ALPHA, GL_INTENSITY, etc).
1052 * This is similar to _mesa_base_tex_format() but the set of valid
1053 * internal formats is different.
1055 * Note that even if a format is determined to be legal here, validation
1056 * of the FBO may fail if the format is not supported by the driver/GPU.
1058 * \param internalFormat as passed to glRenderbufferStorage()
1059 * \return the base internal format, or 0 if internalFormat is illegal
1062 _mesa_base_fbo_format(struct gl_context
*ctx
, GLenum internalFormat
)
1065 * Notes: some formats such as alpha, luminance, etc. were added
1066 * with GL_ARB_framebuffer_object.
1068 switch (internalFormat
) {
1074 return ctx
->Extensions
.ARB_framebuffer_object
? GL_ALPHA
: 0;
1078 case GL_LUMINANCE12
:
1079 case GL_LUMINANCE16
:
1080 return ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE
: 0;
1081 case GL_LUMINANCE_ALPHA
:
1082 case GL_LUMINANCE4_ALPHA4
:
1083 case GL_LUMINANCE6_ALPHA2
:
1084 case GL_LUMINANCE8_ALPHA8
:
1085 case GL_LUMINANCE12_ALPHA4
:
1086 case GL_LUMINANCE12_ALPHA12
:
1087 case GL_LUMINANCE16_ALPHA16
:
1088 return ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE_ALPHA
: 0;
1092 case GL_INTENSITY12
:
1093 case GL_INTENSITY16
:
1094 return ctx
->Extensions
.ARB_framebuffer_object
? GL_INTENSITY
: 0;
1113 case GL_SRGB8_ALPHA8_EXT
:
1115 case GL_STENCIL_INDEX
:
1116 case GL_STENCIL_INDEX1_EXT
:
1117 case GL_STENCIL_INDEX4_EXT
:
1118 case GL_STENCIL_INDEX8_EXT
:
1119 case GL_STENCIL_INDEX16_EXT
:
1120 return GL_STENCIL_INDEX
;
1121 case GL_DEPTH_COMPONENT
:
1122 case GL_DEPTH_COMPONENT16
:
1123 case GL_DEPTH_COMPONENT24
:
1124 case GL_DEPTH_COMPONENT32
:
1125 return GL_DEPTH_COMPONENT
;
1126 case GL_DEPTH_STENCIL_EXT
:
1127 case GL_DEPTH24_STENCIL8_EXT
:
1128 if (ctx
->Extensions
.EXT_packed_depth_stencil
)
1129 return GL_DEPTH_STENCIL_EXT
;
1132 case GL_DEPTH_COMPONENT32F
:
1133 if (ctx
->Extensions
.ARB_depth_buffer_float
)
1134 return GL_DEPTH_COMPONENT
;
1137 case GL_DEPTH32F_STENCIL8
:
1138 if (ctx
->Extensions
.ARB_depth_buffer_float
)
1139 return GL_DEPTH_STENCIL
;
1145 return ctx
->Extensions
.ARB_texture_rg
? GL_RED
: 0;
1149 return ctx
->Extensions
.ARB_texture_rg
? GL_RG
: 0;
1150 /* signed normalized texture formats */
1154 return ctx
->Extensions
.EXT_texture_snorm
? GL_RED
: 0;
1158 return ctx
->Extensions
.EXT_texture_snorm
? GL_RG
: 0;
1161 case GL_RGB16_SNORM
:
1162 return ctx
->Extensions
.EXT_texture_snorm
? GL_RGB
: 0;
1164 case GL_RGBA8_SNORM
:
1165 case GL_RGBA16_SNORM
:
1166 return ctx
->Extensions
.EXT_texture_snorm
? GL_RGBA
: 0;
1167 case GL_ALPHA_SNORM
:
1168 case GL_ALPHA8_SNORM
:
1169 case GL_ALPHA16_SNORM
:
1170 return ctx
->Extensions
.EXT_texture_snorm
&&
1171 ctx
->Extensions
.ARB_framebuffer_object
? GL_ALPHA
: 0;
1172 case GL_LUMINANCE_SNORM
:
1173 case GL_LUMINANCE8_SNORM
:
1174 case GL_LUMINANCE16_SNORM
:
1175 return ctx
->Extensions
.EXT_texture_snorm
&&
1176 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE
: 0;
1177 case GL_LUMINANCE_ALPHA_SNORM
:
1178 case GL_LUMINANCE8_ALPHA8_SNORM
:
1179 case GL_LUMINANCE16_ALPHA16_SNORM
:
1180 return ctx
->Extensions
.EXT_texture_snorm
&&
1181 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE_ALPHA
: 0;
1182 case GL_INTENSITY_SNORM
:
1183 case GL_INTENSITY8_SNORM
:
1184 case GL_INTENSITY16_SNORM
:
1185 return ctx
->Extensions
.EXT_texture_snorm
&&
1186 ctx
->Extensions
.ARB_framebuffer_object
? GL_INTENSITY
: 0;
1189 return ctx
->Extensions
.ARB_texture_rg
&&
1190 ctx
->Extensions
.ARB_texture_float
? GL_RED
: 0;
1193 return ctx
->Extensions
.ARB_texture_rg
&&
1194 ctx
->Extensions
.ARB_texture_float
? GL_RG
: 0;
1197 return ctx
->Extensions
.ARB_texture_float
? GL_RGB
: 0;
1200 return ctx
->Extensions
.ARB_texture_float
? GL_RGBA
: 0;
1201 case GL_ALPHA16F_ARB
:
1202 case GL_ALPHA32F_ARB
:
1203 return ctx
->Extensions
.ARB_texture_float
&&
1204 ctx
->Extensions
.ARB_framebuffer_object
? GL_ALPHA
: 0;
1205 case GL_LUMINANCE16F_ARB
:
1206 case GL_LUMINANCE32F_ARB
:
1207 return ctx
->Extensions
.ARB_texture_float
&&
1208 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE
: 0;
1209 case GL_LUMINANCE_ALPHA16F_ARB
:
1210 case GL_LUMINANCE_ALPHA32F_ARB
:
1211 return ctx
->Extensions
.ARB_texture_float
&&
1212 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE_ALPHA
: 0;
1213 case GL_INTENSITY16F_ARB
:
1214 case GL_INTENSITY32F_ARB
:
1215 return ctx
->Extensions
.ARB_texture_float
&&
1216 ctx
->Extensions
.ARB_framebuffer_object
? GL_INTENSITY
: 0;
1218 return ctx
->Extensions
.EXT_texture_shared_exponent
? GL_RGB
: 0;
1219 case GL_R11F_G11F_B10F
:
1220 return ctx
->Extensions
.EXT_packed_float
? GL_RGB
: 0;
1222 case GL_RGBA8UI_EXT
:
1223 case GL_RGBA16UI_EXT
:
1224 case GL_RGBA32UI_EXT
:
1226 case GL_RGBA16I_EXT
:
1227 case GL_RGBA32I_EXT
:
1228 return ctx
->Extensions
.EXT_texture_integer
? GL_RGBA
: 0;
1231 case GL_RGB16UI_EXT
:
1232 case GL_RGB32UI_EXT
:
1236 return ctx
->Extensions
.EXT_texture_integer
? GL_RGB
: 0;
1244 return ctx
->Extensions
.ARB_texture_rg
&&
1245 ctx
->Extensions
.EXT_texture_integer
? GL_RED
: 0;
1253 return ctx
->Extensions
.ARB_texture_rg
&&
1254 ctx
->Extensions
.EXT_texture_integer
? GL_RG
: 0;
1256 case GL_INTENSITY8I_EXT
:
1257 case GL_INTENSITY8UI_EXT
:
1258 case GL_INTENSITY16I_EXT
:
1259 case GL_INTENSITY16UI_EXT
:
1260 case GL_INTENSITY32I_EXT
:
1261 case GL_INTENSITY32UI_EXT
:
1262 return ctx
->Extensions
.EXT_texture_integer
&&
1263 ctx
->Extensions
.ARB_framebuffer_object
? GL_INTENSITY
: 0;
1265 case GL_LUMINANCE8I_EXT
:
1266 case GL_LUMINANCE8UI_EXT
:
1267 case GL_LUMINANCE16I_EXT
:
1268 case GL_LUMINANCE16UI_EXT
:
1269 case GL_LUMINANCE32I_EXT
:
1270 case GL_LUMINANCE32UI_EXT
:
1271 return ctx
->Extensions
.EXT_texture_integer
&&
1272 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE
: 0;
1274 case GL_LUMINANCE_ALPHA8I_EXT
:
1275 case GL_LUMINANCE_ALPHA8UI_EXT
:
1276 case GL_LUMINANCE_ALPHA16I_EXT
:
1277 case GL_LUMINANCE_ALPHA16UI_EXT
:
1278 case GL_LUMINANCE_ALPHA32I_EXT
:
1279 case GL_LUMINANCE_ALPHA32UI_EXT
:
1280 return ctx
->Extensions
.EXT_texture_integer
&&
1281 ctx
->Extensions
.ARB_framebuffer_object
? GL_LUMINANCE_ALPHA
: 0;
1283 case GL_ALPHA8I_EXT
:
1284 case GL_ALPHA8UI_EXT
:
1285 case GL_ALPHA16I_EXT
:
1286 case GL_ALPHA16UI_EXT
:
1287 case GL_ALPHA32I_EXT
:
1288 case GL_ALPHA32UI_EXT
:
1289 return ctx
->Extensions
.EXT_texture_integer
&&
1290 ctx
->Extensions
.ARB_framebuffer_object
? GL_ALPHA
: 0;
1293 return ctx
->Extensions
.ARB_texture_rgb10_a2ui
? GL_RGBA
: 0;
1301 * Invalidate a renderbuffer attachment. Called from _mesa_HashWalk().
1304 invalidate_rb(GLuint key
, void *data
, void *userData
)
1306 struct gl_framebuffer
*fb
= (struct gl_framebuffer
*) data
;
1307 struct gl_renderbuffer
*rb
= (struct gl_renderbuffer
*) userData
;
1309 /* If this is a user-created FBO */
1310 if (_mesa_is_user_fbo(fb
)) {
1312 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1313 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1314 if (att
->Type
== GL_RENDERBUFFER
&&
1315 att
->Renderbuffer
== rb
) {
1316 /* Mark fb status as indeterminate to force re-validation */
1325 /** sentinal value, see below */
1326 #define NO_SAMPLES 1000
1330 * Helper function used by _mesa_RenderbufferStorageEXT() and
1331 * _mesa_RenderbufferStorageMultisample().
1332 * samples will be NO_SAMPLES if called by _mesa_RenderbufferStorageEXT().
1335 renderbuffer_storage(GLenum target
, GLenum internalFormat
,
1336 GLsizei width
, GLsizei height
, GLsizei samples
)
1338 const char *func
= samples
== NO_SAMPLES
?
1339 "glRenderbufferStorage" : "RenderbufferStorageMultisample";
1340 struct gl_renderbuffer
*rb
;
1342 GET_CURRENT_CONTEXT(ctx
);
1344 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1346 if (target
!= GL_RENDERBUFFER_EXT
) {
1347 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(target)", func
);
1351 baseFormat
= _mesa_base_fbo_format(ctx
, internalFormat
);
1352 if (baseFormat
== 0) {
1353 _mesa_error(ctx
, GL_INVALID_ENUM
, "%s(internalFormat)", func
);
1357 if (width
< 0 || width
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
1358 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(width)", func
);
1362 if (height
< 0 || height
> (GLsizei
) ctx
->Const
.MaxRenderbufferSize
) {
1363 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(height)", func
);
1367 if (samples
== NO_SAMPLES
) {
1368 /* NumSamples == 0 indicates non-multisampling */
1371 else if (samples
> (GLsizei
) ctx
->Const
.MaxSamples
) {
1372 /* note: driver may choose to use more samples than what's requested */
1373 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s(samples)", func
);
1377 rb
= ctx
->CurrentRenderbuffer
;
1379 _mesa_error(ctx
, GL_INVALID_OPERATION
, "%s", func
);
1383 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1385 if (rb
->InternalFormat
== internalFormat
&&
1386 rb
->Width
== (GLuint
) width
&&
1387 rb
->Height
== (GLuint
) height
&&
1388 rb
->NumSamples
== samples
) {
1389 /* no change in allocation needed */
1393 /* These MUST get set by the AllocStorage func */
1394 rb
->Format
= MESA_FORMAT_NONE
;
1395 rb
->NumSamples
= samples
;
1397 /* Now allocate the storage */
1398 ASSERT(rb
->AllocStorage
);
1399 if (rb
->AllocStorage(ctx
, rb
, internalFormat
, width
, height
)) {
1400 /* No error - check/set fields now */
1401 assert(rb
->Format
!= MESA_FORMAT_NONE
);
1402 assert(rb
->Width
== (GLuint
) width
);
1403 assert(rb
->Height
== (GLuint
) height
);
1404 rb
->InternalFormat
= internalFormat
;
1405 rb
->_BaseFormat
= baseFormat
;
1406 assert(rb
->_BaseFormat
!= 0);
1409 /* Probably ran out of memory - clear the fields */
1412 rb
->Format
= MESA_FORMAT_NONE
;
1413 rb
->InternalFormat
= GL_NONE
;
1414 rb
->_BaseFormat
= GL_NONE
;
1418 /* Invalidate the framebuffers the renderbuffer is attached in. */
1419 if (rb
->AttachedAnytime
) {
1420 _mesa_HashWalk(ctx
->Shared
->FrameBuffers
, invalidate_rb
, rb
);
1425 #if FEATURE_OES_EGL_image
1427 _mesa_EGLImageTargetRenderbufferStorageOES(GLenum target
, GLeglImageOES image
)
1429 struct gl_renderbuffer
*rb
;
1430 GET_CURRENT_CONTEXT(ctx
);
1431 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1433 if (!ctx
->Extensions
.OES_EGL_image
) {
1434 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1435 "glEGLImageTargetRenderbufferStorageOES(unsupported)");
1439 if (target
!= GL_RENDERBUFFER
) {
1440 _mesa_error(ctx
, GL_INVALID_ENUM
,
1441 "EGLImageTargetRenderbufferStorageOES");
1445 rb
= ctx
->CurrentRenderbuffer
;
1447 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1448 "EGLImageTargetRenderbufferStorageOES");
1452 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1454 ctx
->Driver
.EGLImageTargetRenderbufferStorage(ctx
, rb
, image
);
1460 * Helper function for _mesa_GetRenderbufferParameterivEXT() and
1461 * _mesa_GetFramebufferAttachmentParameterivEXT()
1462 * We have to be careful to respect the base format. For example, if a
1463 * renderbuffer/texture was created with internalFormat=GL_RGB but the
1464 * driver actually chose a GL_RGBA format, when the user queries ALPHA_SIZE
1465 * we need to return zero.
1468 get_component_bits(GLenum pname
, GLenum baseFormat
, gl_format format
)
1470 if (_mesa_base_format_has_channel(baseFormat
, pname
))
1471 return _mesa_get_format_bits(format
, pname
);
1479 _mesa_RenderbufferStorageEXT(GLenum target
, GLenum internalFormat
,
1480 GLsizei width
, GLsizei height
)
1482 /* GL_ARB_fbo says calling this function is equivalent to calling
1483 * glRenderbufferStorageMultisample() with samples=0. We pass in
1484 * a token value here just for error reporting purposes.
1486 renderbuffer_storage(target
, internalFormat
, width
, height
, NO_SAMPLES
);
1491 _mesa_RenderbufferStorageMultisample(GLenum target
, GLsizei samples
,
1492 GLenum internalFormat
,
1493 GLsizei width
, GLsizei height
)
1495 renderbuffer_storage(target
, internalFormat
, width
, height
, samples
);
1500 * OpenGL ES version of glRenderBufferStorage.
1503 _es_RenderbufferStorageEXT(GLenum target
, GLenum internalFormat
,
1504 GLsizei width
, GLsizei height
)
1506 switch (internalFormat
) {
1508 /* XXX this confuses GL_RENDERBUFFER_INTERNAL_FORMAT_OES */
1509 /* choose a closest format */
1510 internalFormat
= GL_RGB5
;
1516 renderbuffer_storage(target
, internalFormat
, width
, height
, 0);
1521 _mesa_GetRenderbufferParameterivEXT(GLenum target
, GLenum pname
, GLint
*params
)
1523 struct gl_renderbuffer
*rb
;
1524 GET_CURRENT_CONTEXT(ctx
);
1526 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1528 if (target
!= GL_RENDERBUFFER_EXT
) {
1529 _mesa_error(ctx
, GL_INVALID_ENUM
,
1530 "glGetRenderbufferParameterivEXT(target)");
1534 rb
= ctx
->CurrentRenderbuffer
;
1536 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1537 "glGetRenderbufferParameterivEXT");
1541 /* No need to flush here since we're just quering state which is
1542 * not effected by rendering.
1546 case GL_RENDERBUFFER_WIDTH_EXT
:
1547 *params
= rb
->Width
;
1549 case GL_RENDERBUFFER_HEIGHT_EXT
:
1550 *params
= rb
->Height
;
1552 case GL_RENDERBUFFER_INTERNAL_FORMAT_EXT
:
1553 *params
= rb
->InternalFormat
;
1555 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1556 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1557 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1558 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1559 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1560 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1561 *params
= get_component_bits(pname
, rb
->_BaseFormat
, rb
->Format
);
1563 case GL_RENDERBUFFER_SAMPLES
:
1564 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1565 *params
= rb
->NumSamples
;
1570 _mesa_error(ctx
, GL_INVALID_ENUM
,
1571 "glGetRenderbufferParameterivEXT(target)");
1577 GLboolean GLAPIENTRY
1578 _mesa_IsFramebufferEXT(GLuint framebuffer
)
1580 GET_CURRENT_CONTEXT(ctx
);
1581 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
1583 struct gl_framebuffer
*rb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1584 if (rb
!= NULL
&& rb
!= &DummyFramebuffer
)
1592 * Check if any of the attachments of the given framebuffer are textures
1593 * (render to texture). Call ctx->Driver.RenderTexture() for such
1597 check_begin_texture_render(struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
1600 ASSERT(ctx
->Driver
.RenderTexture
);
1602 if (_mesa_is_winsys_fbo(fb
))
1603 return; /* can't render to texture with winsys framebuffers */
1605 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1606 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1607 if (att
->Texture
&& _mesa_get_attachment_teximage(att
)) {
1608 ctx
->Driver
.RenderTexture(ctx
, fb
, att
);
1615 * Examine all the framebuffer's attachments to see if any are textures.
1616 * If so, call ctx->Driver.FinishRenderTexture() for each texture to
1617 * notify the device driver that the texture image may have changed.
1620 check_end_texture_render(struct gl_context
*ctx
, struct gl_framebuffer
*fb
)
1622 if (_mesa_is_winsys_fbo(fb
))
1623 return; /* can't render to texture with winsys framebuffers */
1625 if (ctx
->Driver
.FinishRenderTexture
) {
1627 for (i
= 0; i
< BUFFER_COUNT
; i
++) {
1628 struct gl_renderbuffer_attachment
*att
= fb
->Attachment
+ i
;
1629 if (att
->Texture
&& att
->Renderbuffer
) {
1630 ctx
->Driver
.FinishRenderTexture(ctx
, att
);
1638 _mesa_BindFramebufferEXT(GLenum target
, GLuint framebuffer
)
1640 struct gl_framebuffer
*newDrawFb
, *newReadFb
;
1641 struct gl_framebuffer
*oldDrawFb
, *oldReadFb
;
1642 GLboolean bindReadBuf
, bindDrawBuf
;
1643 GET_CURRENT_CONTEXT(ctx
);
1646 if (ctx
->Extensions
.ARB_framebuffer_object
) {
1647 ASSERT(ctx
->Extensions
.EXT_framebuffer_object
);
1648 ASSERT(ctx
->Extensions
.EXT_framebuffer_blit
);
1652 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1654 if (!ctx
->Extensions
.EXT_framebuffer_object
) {
1655 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1656 "glBindFramebufferEXT(unsupported)");
1661 #if FEATURE_EXT_framebuffer_blit
1662 case GL_DRAW_FRAMEBUFFER_EXT
:
1663 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1664 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1667 bindDrawBuf
= GL_TRUE
;
1668 bindReadBuf
= GL_FALSE
;
1670 case GL_READ_FRAMEBUFFER_EXT
:
1671 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
1672 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1675 bindDrawBuf
= GL_FALSE
;
1676 bindReadBuf
= GL_TRUE
;
1679 case GL_FRAMEBUFFER_EXT
:
1680 bindDrawBuf
= GL_TRUE
;
1681 bindReadBuf
= GL_TRUE
;
1684 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBindFramebufferEXT(target)");
1689 /* Binding a user-created framebuffer object */
1690 newDrawFb
= _mesa_lookup_framebuffer(ctx
, framebuffer
);
1691 if (newDrawFb
== &DummyFramebuffer
) {
1692 /* ID was reserved, but no real framebuffer object made yet */
1695 else if (!newDrawFb
&& ctx
->Extensions
.ARB_framebuffer_object
) {
1696 /* All FBO IDs must be Gen'd */
1697 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBindFramebuffer(buffer)");
1702 /* create new framebuffer object */
1703 newDrawFb
= ctx
->Driver
.NewFramebuffer(ctx
, framebuffer
);
1705 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glBindFramebufferEXT");
1708 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, framebuffer
, newDrawFb
);
1710 newReadFb
= newDrawFb
;
1713 /* Binding the window system framebuffer (which was originally set
1714 * with MakeCurrent).
1716 newDrawFb
= ctx
->WinSysDrawBuffer
;
1717 newReadFb
= ctx
->WinSysReadBuffer
;
1721 ASSERT(newDrawFb
!= &DummyFramebuffer
);
1723 /* save pointers to current/old framebuffers */
1724 oldDrawFb
= ctx
->DrawBuffer
;
1725 oldReadFb
= ctx
->ReadBuffer
;
1727 /* check if really changing bindings */
1728 if (oldDrawFb
== newDrawFb
)
1729 bindDrawBuf
= GL_FALSE
;
1730 if (oldReadFb
== newReadFb
)
1731 bindReadBuf
= GL_FALSE
;
1734 * OK, now bind the new Draw/Read framebuffers, if they're changing.
1736 * We also check if we're beginning and/or ending render-to-texture.
1737 * When a framebuffer with texture attachments is unbound, call
1738 * ctx->Driver.FinishRenderTexture().
1739 * When a framebuffer with texture attachments is bound, call
1740 * ctx->Driver.RenderTexture().
1742 * Note that if the ReadBuffer has texture attachments we don't consider
1743 * that a render-to-texture case.
1746 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1748 /* check if old readbuffer was render-to-texture */
1749 check_end_texture_render(ctx
, oldReadFb
);
1751 _mesa_reference_framebuffer(&ctx
->ReadBuffer
, newReadFb
);
1755 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1757 /* check if old read/draw buffers were render-to-texture */
1759 check_end_texture_render(ctx
, oldReadFb
);
1761 if (oldDrawFb
!= oldReadFb
)
1762 check_end_texture_render(ctx
, oldDrawFb
);
1764 /* check if newly bound framebuffer has any texture attachments */
1765 check_begin_texture_render(ctx
, newDrawFb
);
1767 _mesa_reference_framebuffer(&ctx
->DrawBuffer
, newDrawFb
);
1770 if ((bindDrawBuf
|| bindReadBuf
) && ctx
->Driver
.BindFramebuffer
) {
1771 ctx
->Driver
.BindFramebuffer(ctx
, target
, newDrawFb
, newReadFb
);
1777 _mesa_DeleteFramebuffersEXT(GLsizei n
, const GLuint
*framebuffers
)
1780 GET_CURRENT_CONTEXT(ctx
);
1782 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1783 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
1785 for (i
= 0; i
< n
; i
++) {
1786 if (framebuffers
[i
] > 0) {
1787 struct gl_framebuffer
*fb
;
1788 fb
= _mesa_lookup_framebuffer(ctx
, framebuffers
[i
]);
1790 ASSERT(fb
== &DummyFramebuffer
|| fb
->Name
== framebuffers
[i
]);
1792 /* check if deleting currently bound framebuffer object */
1793 if (ctx
->Extensions
.EXT_framebuffer_blit
) {
1794 /* separate draw/read binding points */
1795 if (fb
== ctx
->DrawBuffer
) {
1797 ASSERT(fb
->RefCount
>= 2);
1798 _mesa_BindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT
, 0);
1800 if (fb
== ctx
->ReadBuffer
) {
1802 ASSERT(fb
->RefCount
>= 2);
1803 _mesa_BindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT
, 0);
1807 /* only one binding point for read/draw buffers */
1808 if (fb
== ctx
->DrawBuffer
|| fb
== ctx
->ReadBuffer
) {
1810 ASSERT(fb
->RefCount
>= 2);
1811 _mesa_BindFramebufferEXT(GL_FRAMEBUFFER_EXT
, 0);
1815 /* remove from hash table immediately, to free the ID */
1816 _mesa_HashRemove(ctx
->Shared
->FrameBuffers
, framebuffers
[i
]);
1818 if (fb
!= &DummyFramebuffer
) {
1819 /* But the object will not be freed until it's no longer
1820 * bound in any context.
1822 _mesa_reference_framebuffer(&fb
, NULL
);
1831 _mesa_GenFramebuffersEXT(GLsizei n
, GLuint
*framebuffers
)
1833 GET_CURRENT_CONTEXT(ctx
);
1837 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1840 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGenFramebuffersEXT(n)");
1847 first
= _mesa_HashFindFreeKeyBlock(ctx
->Shared
->FrameBuffers
, n
);
1849 for (i
= 0; i
< n
; i
++) {
1850 GLuint name
= first
+ i
;
1851 framebuffers
[i
] = name
;
1852 /* insert dummy placeholder into hash table */
1853 _glthread_LOCK_MUTEX(ctx
->Shared
->Mutex
);
1854 _mesa_HashInsert(ctx
->Shared
->FrameBuffers
, name
, &DummyFramebuffer
);
1855 _glthread_UNLOCK_MUTEX(ctx
->Shared
->Mutex
);
1862 _mesa_CheckFramebufferStatusEXT(GLenum target
)
1864 struct gl_framebuffer
*buffer
;
1865 GET_CURRENT_CONTEXT(ctx
);
1867 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, 0);
1869 buffer
= get_framebuffer_target(ctx
, target
);
1871 _mesa_error(ctx
, GL_INVALID_ENUM
, "glCheckFramebufferStatus(target)");
1875 if (_mesa_is_winsys_fbo(buffer
)) {
1876 /* The window system / default framebuffer is always complete */
1877 return GL_FRAMEBUFFER_COMPLETE_EXT
;
1880 /* No need to flush here */
1882 if (buffer
->_Status
!= GL_FRAMEBUFFER_COMPLETE
) {
1883 _mesa_test_framebuffer_completeness(ctx
, buffer
);
1886 return buffer
->_Status
;
1891 * Replicate the src attachment point. Used by framebuffer_texture() when
1892 * the same texture is attached at GL_DEPTH_ATTACHMENT and
1893 * GL_STENCIL_ATTACHMENT.
1896 reuse_framebuffer_texture_attachment(struct gl_framebuffer
*fb
,
1897 gl_buffer_index dst
,
1898 gl_buffer_index src
)
1900 struct gl_renderbuffer_attachment
*dst_att
= &fb
->Attachment
[dst
];
1901 struct gl_renderbuffer_attachment
*src_att
= &fb
->Attachment
[src
];
1903 assert(src_att
->Texture
!= NULL
);
1904 assert(src_att
->Renderbuffer
!= NULL
);
1906 _mesa_reference_texobj(&dst_att
->Texture
, src_att
->Texture
);
1907 _mesa_reference_renderbuffer(&dst_att
->Renderbuffer
, src_att
->Renderbuffer
);
1908 dst_att
->Type
= src_att
->Type
;
1909 dst_att
->Complete
= src_att
->Complete
;
1910 dst_att
->TextureLevel
= src_att
->TextureLevel
;
1911 dst_att
->Zoffset
= src_att
->Zoffset
;
1916 * Common code called by glFramebufferTexture1D/2D/3DEXT().
1919 framebuffer_texture(struct gl_context
*ctx
, const char *caller
, GLenum target
,
1920 GLenum attachment
, GLenum textarget
, GLuint texture
,
1921 GLint level
, GLint zoffset
)
1923 struct gl_renderbuffer_attachment
*att
;
1924 struct gl_texture_object
*texObj
= NULL
;
1925 struct gl_framebuffer
*fb
;
1927 ASSERT_OUTSIDE_BEGIN_END(ctx
);
1929 fb
= get_framebuffer_target(ctx
, target
);
1931 _mesa_error(ctx
, GL_INVALID_ENUM
,
1932 "glFramebufferTexture%sEXT(target=0x%x)", caller
, target
);
1936 /* check framebuffer binding */
1937 if (_mesa_is_winsys_fbo(fb
)) {
1938 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1939 "glFramebufferTexture%sEXT", caller
);
1943 /* The textarget, level, and zoffset parameters are only validated if
1944 * texture is non-zero.
1947 GLboolean err
= GL_TRUE
;
1949 texObj
= _mesa_lookup_texture(ctx
, texture
);
1950 if (texObj
!= NULL
) {
1951 if (textarget
== 0) {
1952 /* XXX what's the purpose of this? */
1953 err
= (texObj
->Target
!= GL_TEXTURE_3D
) &&
1954 (texObj
->Target
!= GL_TEXTURE_1D_ARRAY_EXT
) &&
1955 (texObj
->Target
!= GL_TEXTURE_2D_ARRAY_EXT
);
1958 err
= (texObj
->Target
== GL_TEXTURE_CUBE_MAP
)
1959 ? !_mesa_is_cube_face(textarget
)
1960 : (texObj
->Target
!= textarget
);
1964 /* can't render to a non-existant texture */
1965 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1966 "glFramebufferTexture%sEXT(non existant texture)",
1972 _mesa_error(ctx
, GL_INVALID_OPERATION
,
1973 "glFramebufferTexture%sEXT(texture target mismatch)",
1978 if (texObj
->Target
== GL_TEXTURE_3D
) {
1979 const GLint maxSize
= 1 << (ctx
->Const
.Max3DTextureLevels
- 1);
1980 if (zoffset
< 0 || zoffset
>= maxSize
) {
1981 _mesa_error(ctx
, GL_INVALID_VALUE
,
1982 "glFramebufferTexture%sEXT(zoffset)", caller
);
1986 else if ((texObj
->Target
== GL_TEXTURE_1D_ARRAY_EXT
) ||
1987 (texObj
->Target
== GL_TEXTURE_2D_ARRAY_EXT
)) {
1988 if (zoffset
< 0 || zoffset
>= ctx
->Const
.MaxArrayTextureLayers
) {
1989 _mesa_error(ctx
, GL_INVALID_VALUE
,
1990 "glFramebufferTexture%sEXT(layer)", caller
);
1996 (level
>= _mesa_max_texture_levels(ctx
, texObj
->Target
))) {
1997 _mesa_error(ctx
, GL_INVALID_VALUE
,
1998 "glFramebufferTexture%sEXT(level)", caller
);
2003 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
2005 _mesa_error(ctx
, GL_INVALID_ENUM
,
2006 "glFramebufferTexture%sEXT(attachment)", caller
);
2010 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2012 _glthread_LOCK_MUTEX(fb
->Mutex
);
2014 if (attachment
== GL_DEPTH_ATTACHMENT
&&
2015 texObj
== fb
->Attachment
[BUFFER_STENCIL
].Texture
) {
2016 /* The texture object is already attached to the stencil attachment
2017 * point. Don't create a new renderbuffer; just reuse the stencil
2018 * attachment's. This is required to prevent a GL error in
2019 * glGetFramebufferAttachmentParameteriv(GL_DEPTH_STENCIL).
2021 reuse_framebuffer_texture_attachment(fb
, BUFFER_DEPTH
,
2023 } else if (attachment
== GL_STENCIL_ATTACHMENT
&&
2024 texObj
== fb
->Attachment
[BUFFER_DEPTH
].Texture
) {
2025 /* As above, but with depth and stencil juxtasposed. */
2026 reuse_framebuffer_texture_attachment(fb
, BUFFER_STENCIL
,
2029 _mesa_set_texture_attachment(ctx
, fb
, att
, texObj
, textarget
,
2031 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
2032 /* Above we created a new renderbuffer and attached it to the
2033 * depth attachment point. Now attach it to the stencil attachment
2036 assert(att
== &fb
->Attachment
[BUFFER_DEPTH
]);
2037 reuse_framebuffer_texture_attachment(fb
,BUFFER_STENCIL
,
2042 /* Set the render-to-texture flag. We'll check this flag in
2043 * glTexImage() and friends to determine if we need to revalidate
2044 * any FBOs that might be rendering into this texture.
2045 * This flag never gets cleared since it's non-trivial to determine
2046 * when all FBOs might be done rendering to this texture. That's OK
2047 * though since it's uncommon to render to a texture then repeatedly
2048 * call glTexImage() to change images in the texture.
2050 texObj
->_RenderToTexture
= GL_TRUE
;
2053 _mesa_remove_attachment(ctx
, att
);
2054 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
2055 assert(att
== &fb
->Attachment
[BUFFER_DEPTH
]);
2056 _mesa_remove_attachment(ctx
, &fb
->Attachment
[BUFFER_STENCIL
]);
2060 invalidate_framebuffer(fb
);
2062 _glthread_UNLOCK_MUTEX(fb
->Mutex
);
2068 _mesa_FramebufferTexture1DEXT(GLenum target
, GLenum attachment
,
2069 GLenum textarget
, GLuint texture
, GLint level
)
2071 GET_CURRENT_CONTEXT(ctx
);
2076 switch (textarget
) {
2080 case GL_TEXTURE_1D_ARRAY
:
2081 error
= !ctx
->Extensions
.EXT_texture_array
;
2088 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2089 "glFramebufferTexture1DEXT(textarget=%s)",
2090 _mesa_lookup_enum_by_nr(textarget
));
2095 framebuffer_texture(ctx
, "1D", target
, attachment
, textarget
, texture
,
2101 _mesa_FramebufferTexture2DEXT(GLenum target
, GLenum attachment
,
2102 GLenum textarget
, GLuint texture
, GLint level
)
2104 GET_CURRENT_CONTEXT(ctx
);
2109 switch (textarget
) {
2113 case GL_TEXTURE_RECTANGLE
:
2114 error
= !ctx
->Extensions
.NV_texture_rectangle
;
2116 case GL_TEXTURE_CUBE_MAP_POSITIVE_X
:
2117 case GL_TEXTURE_CUBE_MAP_NEGATIVE_X
:
2118 case GL_TEXTURE_CUBE_MAP_POSITIVE_Y
:
2119 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y
:
2120 case GL_TEXTURE_CUBE_MAP_POSITIVE_Z
:
2121 case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z
:
2122 error
= !ctx
->Extensions
.ARB_texture_cube_map
;
2124 case GL_TEXTURE_2D_ARRAY
:
2125 error
= !ctx
->Extensions
.EXT_texture_array
;
2132 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2133 "glFramebufferTexture2DEXT(textarget=%s)",
2134 _mesa_lookup_enum_by_nr(textarget
));
2139 framebuffer_texture(ctx
, "2D", target
, attachment
, textarget
, texture
,
2145 _mesa_FramebufferTexture3DEXT(GLenum target
, GLenum attachment
,
2146 GLenum textarget
, GLuint texture
,
2147 GLint level
, GLint zoffset
)
2149 GET_CURRENT_CONTEXT(ctx
);
2151 if ((texture
!= 0) && (textarget
!= GL_TEXTURE_3D
)) {
2152 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2153 "glFramebufferTexture3DEXT(textarget)");
2157 framebuffer_texture(ctx
, "3D", target
, attachment
, textarget
, texture
,
2163 _mesa_FramebufferTextureLayerEXT(GLenum target
, GLenum attachment
,
2164 GLuint texture
, GLint level
, GLint layer
)
2166 GET_CURRENT_CONTEXT(ctx
);
2168 framebuffer_texture(ctx
, "Layer", target
, attachment
, 0, texture
,
2174 _mesa_FramebufferRenderbufferEXT(GLenum target
, GLenum attachment
,
2175 GLenum renderbufferTarget
,
2176 GLuint renderbuffer
)
2178 struct gl_renderbuffer_attachment
*att
;
2179 struct gl_framebuffer
*fb
;
2180 struct gl_renderbuffer
*rb
;
2181 GET_CURRENT_CONTEXT(ctx
);
2183 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2185 fb
= get_framebuffer_target(ctx
, target
);
2187 _mesa_error(ctx
, GL_INVALID_ENUM
, "glFramebufferRenderbufferEXT(target)");
2191 if (renderbufferTarget
!= GL_RENDERBUFFER_EXT
) {
2192 _mesa_error(ctx
, GL_INVALID_ENUM
,
2193 "glFramebufferRenderbufferEXT(renderbufferTarget)");
2197 if (_mesa_is_winsys_fbo(fb
)) {
2198 /* Can't attach new renderbuffers to a window system framebuffer */
2199 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glFramebufferRenderbufferEXT");
2203 att
= _mesa_get_attachment(ctx
, fb
, attachment
);
2205 _mesa_error(ctx
, GL_INVALID_ENUM
,
2206 "glFramebufferRenderbufferEXT(invalid attachment %s)",
2207 _mesa_lookup_enum_by_nr(attachment
));
2212 rb
= _mesa_lookup_renderbuffer(ctx
, renderbuffer
);
2214 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2215 "glFramebufferRenderbufferEXT(non-existant"
2216 " renderbuffer %u)", renderbuffer
);
2219 else if (rb
== &DummyRenderbuffer
) {
2220 /* This is what NVIDIA does */
2221 _mesa_error(ctx
, GL_INVALID_VALUE
,
2222 "glFramebufferRenderbufferEXT(renderbuffer %u)",
2228 /* remove renderbuffer attachment */
2232 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
&&
2233 rb
&& rb
->Format
!= MESA_FORMAT_NONE
) {
2234 /* make sure the renderbuffer is a depth/stencil format */
2235 const GLenum baseFormat
= _mesa_get_format_base_format(rb
->Format
);
2236 if (baseFormat
!= GL_DEPTH_STENCIL
) {
2237 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2238 "glFramebufferRenderbufferEXT(renderbuffer"
2239 " is not DEPTH_STENCIL format)");
2245 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2247 assert(ctx
->Driver
.FramebufferRenderbuffer
);
2248 ctx
->Driver
.FramebufferRenderbuffer(ctx
, fb
, attachment
, rb
);
2250 /* Some subsequent GL commands may depend on the framebuffer's visual
2251 * after the binding is updated. Update visual info now.
2253 _mesa_update_framebuffer_visual(ctx
, fb
);
2258 _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target
, GLenum attachment
,
2259 GLenum pname
, GLint
*params
)
2261 const struct gl_renderbuffer_attachment
*att
;
2262 struct gl_framebuffer
*buffer
;
2264 GET_CURRENT_CONTEXT(ctx
);
2266 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2268 /* The error differs in GL andd GLES. */
2269 err
= ctx
->API
== API_OPENGL
? GL_INVALID_OPERATION
: GL_INVALID_ENUM
;
2271 buffer
= get_framebuffer_target(ctx
, target
);
2273 _mesa_error(ctx
, GL_INVALID_ENUM
,
2274 "glGetFramebufferAttachmentParameterivEXT(target)");
2278 if (_mesa_is_winsys_fbo(buffer
)) {
2279 /* Page 126 (page 136 of the PDF) of the OpenGL ES 2.0.25 spec
2282 * "If the framebuffer currently bound to target is zero, then
2283 * INVALID_OPERATION is generated."
2285 * The EXT_framebuffer_object spec has the same wording, and the
2286 * OES_framebuffer_object spec refers to the EXT_framebuffer_object
2289 if (ctx
->API
!= API_OPENGL
|| !ctx
->Extensions
.ARB_framebuffer_object
) {
2290 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2291 "glGetFramebufferAttachmentParameteriv(bound FBO = 0)");
2294 /* the default / window-system FBO */
2295 att
= _mesa_get_fb0_attachment(ctx
, buffer
, attachment
);
2298 /* user-created framebuffer FBO */
2299 att
= _mesa_get_attachment(ctx
, buffer
, attachment
);
2303 _mesa_error(ctx
, GL_INVALID_ENUM
,
2304 "glGetFramebufferAttachmentParameterivEXT(attachment)");
2308 if (attachment
== GL_DEPTH_STENCIL_ATTACHMENT
) {
2309 /* the depth and stencil attachments must point to the same buffer */
2310 const struct gl_renderbuffer_attachment
*depthAtt
, *stencilAtt
;
2311 depthAtt
= _mesa_get_attachment(ctx
, buffer
, GL_DEPTH_ATTACHMENT
);
2312 stencilAtt
= _mesa_get_attachment(ctx
, buffer
, GL_STENCIL_ATTACHMENT
);
2313 if (depthAtt
->Renderbuffer
!= stencilAtt
->Renderbuffer
) {
2314 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2315 "glGetFramebufferAttachmentParameterivEXT(DEPTH/STENCIL"
2316 " attachments differ)");
2321 /* No need to flush here */
2324 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT
:
2325 *params
= _mesa_is_winsys_fbo(buffer
)
2326 ? GL_FRAMEBUFFER_DEFAULT
: att
->Type
;
2328 case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT
:
2329 if (att
->Type
== GL_RENDERBUFFER_EXT
) {
2330 *params
= att
->Renderbuffer
->Name
;
2332 else if (att
->Type
== GL_TEXTURE
) {
2333 *params
= att
->Texture
->Name
;
2336 assert(att
->Type
== GL_NONE
);
2337 if (ctx
->API
== API_OPENGL
) {
2340 _mesa_error(ctx
, GL_INVALID_ENUM
,
2341 "glGetFramebufferAttachmentParameterivEXT(pname)");
2345 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT
:
2346 if (att
->Type
== GL_TEXTURE
) {
2347 *params
= att
->TextureLevel
;
2349 else if (att
->Type
== GL_NONE
) {
2350 _mesa_error(ctx
, err
,
2351 "glGetFramebufferAttachmentParameterivEXT(pname)");
2354 _mesa_error(ctx
, GL_INVALID_ENUM
,
2355 "glGetFramebufferAttachmentParameterivEXT(pname)");
2358 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT
:
2359 if (att
->Type
== GL_TEXTURE
) {
2360 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_CUBE_MAP
) {
2361 *params
= GL_TEXTURE_CUBE_MAP_POSITIVE_X
+ att
->CubeMapFace
;
2367 else if (att
->Type
== GL_NONE
) {
2368 _mesa_error(ctx
, err
,
2369 "glGetFramebufferAttachmentParameterivEXT(pname)");
2372 _mesa_error(ctx
, GL_INVALID_ENUM
,
2373 "glGetFramebufferAttachmentParameterivEXT(pname)");
2376 case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT
:
2377 if (att
->Type
== GL_TEXTURE
) {
2378 if (att
->Texture
&& att
->Texture
->Target
== GL_TEXTURE_3D
) {
2379 *params
= att
->Zoffset
;
2385 else if (att
->Type
== GL_NONE
) {
2386 _mesa_error(ctx
, err
,
2387 "glGetFramebufferAttachmentParameterivEXT(pname)");
2390 _mesa_error(ctx
, GL_INVALID_ENUM
,
2391 "glGetFramebufferAttachmentParameterivEXT(pname)");
2394 case GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING
:
2395 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
2396 _mesa_error(ctx
, GL_INVALID_ENUM
,
2397 "glGetFramebufferAttachmentParameterivEXT(pname)");
2399 else if (att
->Type
== GL_NONE
) {
2400 _mesa_error(ctx
, err
,
2401 "glGetFramebufferAttachmentParameterivEXT(pname)");
2404 if (ctx
->Extensions
.EXT_framebuffer_sRGB
&& ctx
->Const
.sRGBCapable
) {
2405 *params
= _mesa_get_format_color_encoding(att
->Renderbuffer
->Format
);
2408 /* According to ARB_framebuffer_sRGB, we should return LINEAR
2409 * if the sRGB conversion is unsupported. */
2410 *params
= GL_LINEAR
;
2414 case GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE
:
2415 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
2416 _mesa_error(ctx
, GL_INVALID_ENUM
,
2417 "glGetFramebufferAttachmentParameterivEXT(pname)");
2420 else if (att
->Type
== GL_NONE
) {
2421 _mesa_error(ctx
, err
,
2422 "glGetFramebufferAttachmentParameterivEXT(pname)");
2425 gl_format format
= att
->Renderbuffer
->Format
;
2426 if (format
== MESA_FORMAT_S8
) {
2430 else if (format
== MESA_FORMAT_Z32_FLOAT_X24S8
) {
2431 /* depends on the attachment parameter */
2432 if (attachment
== GL_STENCIL_ATTACHMENT
) {
2440 *params
= _mesa_get_format_datatype(format
);
2444 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
2445 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
2446 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
2447 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
2448 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
2449 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
2450 if (!ctx
->Extensions
.ARB_framebuffer_object
) {
2451 _mesa_error(ctx
, GL_INVALID_ENUM
,
2452 "glGetFramebufferAttachmentParameterivEXT(pname)");
2454 else if (att
->Type
== GL_NONE
) {
2455 _mesa_error(ctx
, err
,
2456 "glGetFramebufferAttachmentParameterivEXT(pname)");
2458 else if (att
->Texture
) {
2459 const struct gl_texture_image
*texImage
=
2460 _mesa_select_tex_image(ctx
, att
->Texture
, att
->Texture
->Target
,
2463 *params
= get_component_bits(pname
, texImage
->_BaseFormat
,
2464 texImage
->TexFormat
);
2470 else if (att
->Renderbuffer
) {
2471 *params
= get_component_bits(pname
, att
->Renderbuffer
->_BaseFormat
,
2472 att
->Renderbuffer
->Format
);
2475 _mesa_problem(ctx
, "glGetFramebufferAttachmentParameterivEXT:"
2476 " invalid FBO attachment structure");
2480 _mesa_error(ctx
, GL_INVALID_ENUM
,
2481 "glGetFramebufferAttachmentParameterivEXT(pname)");
2488 _mesa_GenerateMipmapEXT(GLenum target
)
2490 struct gl_texture_image
*srcImage
;
2491 struct gl_texture_object
*texObj
;
2494 GET_CURRENT_CONTEXT(ctx
);
2496 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2497 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2505 case GL_TEXTURE_CUBE_MAP
:
2506 error
= !ctx
->Extensions
.ARB_texture_cube_map
;
2508 case GL_TEXTURE_1D_ARRAY
:
2509 case GL_TEXTURE_2D_ARRAY
:
2510 error
= !ctx
->Extensions
.EXT_texture_array
;
2517 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGenerateMipmapEXT(target=%s)",
2518 _mesa_lookup_enum_by_nr(target
));
2522 texObj
= _mesa_get_current_tex_object(ctx
, target
);
2524 if (texObj
->BaseLevel
>= texObj
->MaxLevel
) {
2529 if (texObj
->Target
== GL_TEXTURE_CUBE_MAP
&&
2530 !_mesa_cube_complete(texObj
)) {
2531 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2532 "glGenerateMipmap(incomplete cube map)");
2536 _mesa_lock_texture(ctx
, texObj
);
2538 srcImage
= _mesa_select_tex_image(ctx
, texObj
, target
, texObj
->BaseLevel
);
2540 _mesa_unlock_texture(ctx
, texObj
);
2544 if (target
== GL_TEXTURE_CUBE_MAP
) {
2546 for (face
= 0; face
< 6; face
++)
2547 ctx
->Driver
.GenerateMipmap(ctx
,
2548 GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB
+ face
,
2552 ctx
->Driver
.GenerateMipmap(ctx
, target
, texObj
);
2554 _mesa_unlock_texture(ctx
, texObj
);
2558 #if FEATURE_EXT_framebuffer_blit
2560 static const struct gl_renderbuffer_attachment
*
2561 find_attachment(const struct gl_framebuffer
*fb
,
2562 const struct gl_renderbuffer
*rb
)
2565 for (i
= 0; i
< Elements(fb
->Attachment
); i
++) {
2566 if (fb
->Attachment
[i
].Renderbuffer
== rb
)
2567 return &fb
->Attachment
[i
];
2574 * Helper function for checking if the datatypes of color buffers are
2575 * compatible for glBlitFramebuffer. From the 3.1 spec, page 198:
2577 * "GL_INVALID_OPERATION is generated if mask contains GL_COLOR_BUFFER_BIT
2578 * and any of the following conditions hold:
2579 * - The read buffer contains fixed-point or floating-point values and any
2580 * draw buffer contains neither fixed-point nor floating-point values.
2581 * - The read buffer contains unsigned integer values and any draw buffer
2582 * does not contain unsigned integer values.
2583 * - The read buffer contains signed integer values and any draw buffer
2584 * does not contain signed integer values."
2587 compatible_color_datatypes(gl_format srcFormat
, gl_format dstFormat
)
2589 GLenum srcType
= _mesa_get_format_datatype(srcFormat
);
2590 GLenum dstType
= _mesa_get_format_datatype(dstFormat
);
2592 if (srcType
!= GL_INT
&& srcType
!= GL_UNSIGNED_INT
) {
2593 assert(srcType
== GL_UNSIGNED_NORMALIZED
||
2594 srcType
== GL_SIGNED_NORMALIZED
||
2595 srcType
== GL_FLOAT
);
2596 /* Boil any of those types down to GL_FLOAT */
2600 if (dstType
!= GL_INT
&& dstType
!= GL_UNSIGNED_INT
) {
2601 assert(dstType
== GL_UNSIGNED_NORMALIZED
||
2602 dstType
== GL_SIGNED_NORMALIZED
||
2603 dstType
== GL_FLOAT
);
2604 /* Boil any of those types down to GL_FLOAT */
2608 return srcType
== dstType
;
2613 * Blit rectangular region, optionally from one framebuffer to another.
2615 * Note, if the src buffer is multisampled and the dest is not, this is
2616 * when the samples must be resolved to a single color.
2619 _mesa_BlitFramebufferEXT(GLint srcX0
, GLint srcY0
, GLint srcX1
, GLint srcY1
,
2620 GLint dstX0
, GLint dstY0
, GLint dstX1
, GLint dstY1
,
2621 GLbitfield mask
, GLenum filter
)
2623 const GLbitfield legalMaskBits
= (GL_COLOR_BUFFER_BIT
|
2624 GL_DEPTH_BUFFER_BIT
|
2625 GL_STENCIL_BUFFER_BIT
);
2626 const struct gl_framebuffer
*readFb
, *drawFb
;
2627 const struct gl_renderbuffer
*colorReadRb
, *colorDrawRb
;
2628 GET_CURRENT_CONTEXT(ctx
);
2630 ASSERT_OUTSIDE_BEGIN_END(ctx
);
2631 FLUSH_VERTICES(ctx
, _NEW_BUFFERS
);
2633 if (MESA_VERBOSE
& VERBOSE_API
)
2635 "glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d, 0x%x, %s)\n",
2636 srcX0
, srcY0
, srcX1
, srcY1
,
2637 dstX0
, dstY0
, dstX1
, dstY1
,
2638 mask
, _mesa_lookup_enum_by_nr(filter
));
2640 if (ctx
->NewState
) {
2641 _mesa_update_state(ctx
);
2644 readFb
= ctx
->ReadBuffer
;
2645 drawFb
= ctx
->DrawBuffer
;
2647 if (!readFb
|| !drawFb
) {
2648 /* This will normally never happen but someday we may want to
2649 * support MakeCurrent() with no drawables.
2654 /* check for complete framebuffers */
2655 if (drawFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
||
2656 readFb
->_Status
!= GL_FRAMEBUFFER_COMPLETE_EXT
) {
2657 _mesa_error(ctx
, GL_INVALID_FRAMEBUFFER_OPERATION_EXT
,
2658 "glBlitFramebufferEXT(incomplete draw/read buffers)");
2662 if (filter
!= GL_NEAREST
&& filter
!= GL_LINEAR
) {
2663 _mesa_error(ctx
, GL_INVALID_ENUM
, "glBlitFramebufferEXT(filter)");
2667 if (mask
& ~legalMaskBits
) {
2668 _mesa_error( ctx
, GL_INVALID_VALUE
, "glBlitFramebufferEXT(mask)");
2672 /* depth/stencil must be blitted with nearest filtering */
2673 if ((mask
& (GL_DEPTH_BUFFER_BIT
| GL_STENCIL_BUFFER_BIT
))
2674 && filter
!= GL_NEAREST
) {
2675 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2676 "glBlitFramebufferEXT(depth/stencil requires GL_NEAREST filter)");
2680 /* get color read/draw renderbuffers */
2681 if (mask
& GL_COLOR_BUFFER_BIT
) {
2682 colorReadRb
= readFb
->_ColorReadBuffer
;
2683 colorDrawRb
= drawFb
->_ColorDrawBuffers
[0];
2685 /* From the EXT_framebuffer_object spec:
2687 * "If a buffer is specified in <mask> and does not exist in both
2688 * the read and draw framebuffers, the corresponding bit is silently
2691 if ((colorReadRb
== NULL
) || (colorDrawRb
== NULL
)) {
2692 colorReadRb
= colorDrawRb
= NULL
;
2693 mask
&= ~GL_COLOR_BUFFER_BIT
;
2695 else if (!compatible_color_datatypes(colorReadRb
->Format
,
2696 colorDrawRb
->Format
)) {
2697 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2698 "glBlitFramebufferEXT(color buffer datatypes mismatch)");
2703 colorReadRb
= colorDrawRb
= NULL
;
2706 if (mask
& GL_STENCIL_BUFFER_BIT
) {
2707 struct gl_renderbuffer
*readRb
=
2708 readFb
->Attachment
[BUFFER_STENCIL
].Renderbuffer
;
2709 struct gl_renderbuffer
*drawRb
=
2710 drawFb
->Attachment
[BUFFER_STENCIL
].Renderbuffer
;
2712 /* From the EXT_framebuffer_object spec:
2714 * "If a buffer is specified in <mask> and does not exist in both
2715 * the read and draw framebuffers, the corresponding bit is silently
2718 if ((readRb
== NULL
) || (drawRb
== NULL
)) {
2719 mask
&= ~GL_STENCIL_BUFFER_BIT
;
2721 else if (_mesa_get_format_bits(readRb
->Format
, GL_STENCIL_BITS
) !=
2722 _mesa_get_format_bits(drawRb
->Format
, GL_STENCIL_BITS
)) {
2723 /* There is no need to check the stencil datatype here, because
2724 * there is only one: GL_UNSIGNED_INT.
2726 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2727 "glBlitFramebufferEXT(stencil buffer size mismatch)");
2732 if (mask
& GL_DEPTH_BUFFER_BIT
) {
2733 struct gl_renderbuffer
*readRb
=
2734 readFb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
2735 struct gl_renderbuffer
*drawRb
=
2736 drawFb
->Attachment
[BUFFER_DEPTH
].Renderbuffer
;
2738 /* From the EXT_framebuffer_object spec:
2740 * "If a buffer is specified in <mask> and does not exist in both
2741 * the read and draw framebuffers, the corresponding bit is silently
2744 if ((readRb
== NULL
) || (drawRb
== NULL
)) {
2745 mask
&= ~GL_DEPTH_BUFFER_BIT
;
2747 else if ((_mesa_get_format_bits(readRb
->Format
, GL_DEPTH_BITS
) !=
2748 _mesa_get_format_bits(drawRb
->Format
, GL_DEPTH_BITS
)) ||
2749 (_mesa_get_format_datatype(readRb
->Format
) !=
2750 _mesa_get_format_datatype(drawRb
->Format
))) {
2751 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2752 "glBlitFramebufferEXT(depth buffer format mismatch)");
2757 if (readFb
->Visual
.samples
> 0 &&
2758 drawFb
->Visual
.samples
> 0 &&
2759 readFb
->Visual
.samples
!= drawFb
->Visual
.samples
) {
2760 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2761 "glBlitFramebufferEXT(mismatched samples)");
2765 /* extra checks for multisample copies... */
2766 if (readFb
->Visual
.samples
> 0 || drawFb
->Visual
.samples
> 0) {
2767 /* src and dest region sizes must be the same */
2768 if (srcX1
- srcX0
!= dstX1
- dstX0
||
2769 srcY1
- srcY0
!= dstY1
- dstY0
) {
2770 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2771 "glBlitFramebufferEXT(bad src/dst multisample region sizes)");
2775 /* color formats must match */
2778 colorReadRb
->Format
!= colorDrawRb
->Format
) {
2779 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2780 "glBlitFramebufferEXT(bad src/dst multisample pixel formats)");
2785 if (filter
== GL_LINEAR
&& (mask
& GL_COLOR_BUFFER_BIT
)) {
2786 /* 3.1 spec, page 199:
2787 * "Calling BlitFramebuffer will result in an INVALID_OPERATION error
2788 * if filter is LINEAR and read buffer contains integer data."
2790 GLenum type
= _mesa_get_format_datatype(colorReadRb
->Format
);
2791 if (type
== GL_INT
|| type
== GL_UNSIGNED_INT
) {
2792 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2793 "glBlitFramebufferEXT(integer color type)");
2798 if (!ctx
->Extensions
.EXT_framebuffer_blit
) {
2799 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glBlitFramebufferEXT");
2805 printf("glBlitFramebuffer(%d, %d, %d, %d, %d, %d, %d, %d,"
2807 srcX0
, srcY0
, srcX1
, srcY1
,
2808 dstX0
, dstY0
, dstX1
, dstY1
,
2811 const struct gl_renderbuffer_attachment
*att
;
2813 att
= find_attachment(readFb
, colorReadRb
);
2814 printf(" Src FBO %u RB %u (%dx%d) ",
2815 readFb
->Name
, colorReadRb
->Name
,
2816 colorReadRb
->Width
, colorReadRb
->Height
);
2817 if (att
&& att
->Texture
) {
2818 printf("Tex %u tgt 0x%x level %u face %u",
2820 att
->Texture
->Target
,
2826 att
= find_attachment(drawFb
, colorDrawRb
);
2827 printf(" Dst FBO %u RB %u (%dx%d) ",
2828 drawFb
->Name
, colorDrawRb
->Name
,
2829 colorDrawRb
->Width
, colorDrawRb
->Height
);
2830 if (att
&& att
->Texture
) {
2831 printf("Tex %u tgt 0x%x level %u face %u",
2833 att
->Texture
->Target
,
2845 ASSERT(ctx
->Driver
.BlitFramebuffer
);
2846 ctx
->Driver
.BlitFramebuffer(ctx
,
2847 srcX0
, srcY0
, srcX1
, srcY1
,
2848 dstX0
, dstY0
, dstX1
, dstY1
,
2851 #endif /* FEATURE_EXT_framebuffer_blit */
2854 #if FEATURE_ARB_geometry_shader4
2856 _mesa_FramebufferTextureARB(GLenum target
, GLenum attachment
,
2857 GLuint texture
, GLint level
)
2859 GET_CURRENT_CONTEXT(ctx
);
2860 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2861 "glFramebufferTextureARB "
2862 "not implemented!");
2867 _mesa_FramebufferTextureFaceARB(GLenum target
, GLenum attachment
,
2868 GLuint texture
, GLint level
, GLenum face
)
2870 GET_CURRENT_CONTEXT(ctx
);
2871 _mesa_error(ctx
, GL_INVALID_OPERATION
,
2872 "glFramebufferTextureFaceARB "
2873 "not implemented!");
2875 #endif /* FEATURE_ARB_geometry_shader4 */