i965: Mostly fix glsl-max-varyings.
[mesa.git] / src / mesa / drivers / dri / intel / intel_fbo.c
1 /**************************************************************************
2 *
3 * Copyright 2006 Tungsten Graphics, Inc., Cedar Park, Texas.
4 * All Rights Reserved.
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
16 * of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 *
26 **************************************************************************/
27
28
29 #include "main/imports.h"
30 #include "main/macros.h"
31 #include "main/mtypes.h"
32 #include "main/fbobject.h"
33 #include "main/framebuffer.h"
34 #include "main/renderbuffer.h"
35 #include "main/context.h"
36 #include "main/texrender.h"
37 #include "drivers/common/meta.h"
38
39 #include "intel_context.h"
40 #include "intel_batchbuffer.h"
41 #include "intel_buffers.h"
42 #include "intel_fbo.h"
43 #include "intel_mipmap_tree.h"
44 #include "intel_regions.h"
45
46 #define FILE_DEBUG_FLAG DEBUG_FBO
47
48
49 /**
50 * Create a new framebuffer object.
51 */
52 static struct gl_framebuffer *
53 intel_new_framebuffer(GLcontext * ctx, GLuint name)
54 {
55 /* Only drawable state in intel_framebuffer at this time, just use Mesa's
56 * class
57 */
58 return _mesa_new_framebuffer(ctx, name);
59 }
60
61
62 /** Called by gl_renderbuffer::Delete() */
63 static void
64 intel_delete_renderbuffer(struct gl_renderbuffer *rb)
65 {
66 GET_CURRENT_CONTEXT(ctx);
67 struct intel_context *intel = intel_context(ctx);
68 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
69
70 ASSERT(irb);
71
72 if (intel && irb->region) {
73 intel_region_release(&irb->region);
74 }
75
76 free(irb);
77 }
78
79
80 /**
81 * Return a pointer to a specific pixel in a renderbuffer.
82 */
83 static void *
84 intel_get_pointer(GLcontext * ctx, struct gl_renderbuffer *rb,
85 GLint x, GLint y)
86 {
87 /* By returning NULL we force all software rendering to go through
88 * the span routines.
89 */
90 return NULL;
91 }
92
93
94 /**
95 * Called via glRenderbufferStorageEXT() to set the format and allocate
96 * storage for a user-created renderbuffer.
97 */
98 static GLboolean
99 intel_alloc_renderbuffer_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
100 GLenum internalFormat,
101 GLuint width, GLuint height)
102 {
103 struct intel_context *intel = intel_context(ctx);
104 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
105 int cpp;
106
107 ASSERT(rb->Name != 0);
108
109 switch (internalFormat) {
110 case GL_R3_G3_B2:
111 case GL_RGB4:
112 case GL_RGB5:
113 rb->Format = MESA_FORMAT_RGB565;
114 rb->DataType = GL_UNSIGNED_BYTE;
115 break;
116 case GL_RGB:
117 case GL_RGB8:
118 case GL_RGB10:
119 case GL_RGB12:
120 case GL_RGB16:
121 rb->Format = MESA_FORMAT_XRGB8888;
122 rb->DataType = GL_UNSIGNED_BYTE;
123 break;
124 case GL_RGBA:
125 case GL_RGBA2:
126 case GL_RGBA4:
127 case GL_RGB5_A1:
128 case GL_RGBA8:
129 case GL_RGB10_A2:
130 case GL_RGBA12:
131 case GL_RGBA16:
132 rb->Format = MESA_FORMAT_ARGB8888;
133 rb->DataType = GL_UNSIGNED_BYTE;
134 break;
135 case GL_ALPHA:
136 case GL_ALPHA8:
137 rb->Format = MESA_FORMAT_A8;
138 rb->DataType = GL_UNSIGNED_BYTE;
139 break;
140 case GL_STENCIL_INDEX:
141 case GL_STENCIL_INDEX1_EXT:
142 case GL_STENCIL_INDEX4_EXT:
143 case GL_STENCIL_INDEX8_EXT:
144 case GL_STENCIL_INDEX16_EXT:
145 /* alloc a depth+stencil buffer */
146 rb->Format = MESA_FORMAT_S8_Z24;
147 rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
148 break;
149 case GL_DEPTH_COMPONENT16:
150 rb->Format = MESA_FORMAT_Z16;
151 rb->DataType = GL_UNSIGNED_SHORT;
152 break;
153 case GL_DEPTH_COMPONENT:
154 case GL_DEPTH_COMPONENT24:
155 case GL_DEPTH_COMPONENT32:
156 rb->Format = MESA_FORMAT_S8_Z24;
157 rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
158 break;
159 case GL_DEPTH_STENCIL_EXT:
160 case GL_DEPTH24_STENCIL8_EXT:
161 rb->Format = MESA_FORMAT_S8_Z24;
162 rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
163 break;
164 default:
165 _mesa_problem(ctx,
166 "Unexpected format in intel_alloc_renderbuffer_storage");
167 return GL_FALSE;
168 }
169
170 rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
171 cpp = _mesa_get_format_bytes(rb->Format);
172
173 intel_flush(ctx);
174
175 /* free old region */
176 if (irb->region) {
177 intel_region_release(&irb->region);
178 }
179
180 /* allocate new memory region/renderbuffer */
181
182 /* alloc hardware renderbuffer */
183 DBG("Allocating %d x %d Intel RBO\n", width, height);
184
185 irb->region = intel_region_alloc(intel, I915_TILING_NONE, cpp,
186 width, height, GL_TRUE);
187 if (!irb->region)
188 return GL_FALSE; /* out of memory? */
189
190 ASSERT(irb->region->buffer);
191
192 rb->Width = width;
193 rb->Height = height;
194
195 return GL_TRUE;
196 }
197
198
199 #if FEATURE_OES_EGL_image
200 static void
201 intel_image_target_renderbuffer_storage(GLcontext *ctx,
202 struct gl_renderbuffer *rb,
203 void *image_handle)
204 {
205 struct intel_context *intel = intel_context(ctx);
206 struct intel_renderbuffer *irb;
207 __DRIscreen *screen;
208 __DRIimage *image;
209
210 screen = intel->intelScreen->driScrnPriv;
211 image = screen->dri2.image->lookupEGLImage(intel->driContext, image_handle,
212 intel->driContext->loaderPrivate);
213 if (image == NULL)
214 return;
215
216 irb = intel_renderbuffer(rb);
217 if (irb->region)
218 intel_region_release(&irb->region);
219 intel_region_reference(&irb->region, image->region);
220
221 rb->InternalFormat = image->internal_format;
222 rb->Width = image->region->width;
223 rb->Height = image->region->height;
224 rb->Format = image->format;
225 rb->DataType = image->data_type;
226 rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
227 image->internal_format);
228 }
229 #endif
230
231 /**
232 * Called for each hardware renderbuffer when a _window_ is resized.
233 * Just update fields.
234 * Not used for user-created renderbuffers!
235 */
236 static GLboolean
237 intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
238 GLenum internalFormat, GLuint width, GLuint height)
239 {
240 ASSERT(rb->Name == 0);
241 rb->Width = width;
242 rb->Height = height;
243 rb->InternalFormat = internalFormat;
244
245 return GL_TRUE;
246 }
247
248
249 static void
250 intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
251 GLuint width, GLuint height)
252 {
253 int i;
254
255 _mesa_resize_framebuffer(ctx, fb, width, height);
256
257 fb->Initialized = GL_TRUE; /* XXX remove someday */
258
259 if (fb->Name != 0) {
260 return;
261 }
262
263
264 /* Make sure all window system renderbuffers are up to date */
265 for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
266 struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
267
268 /* only resize if size is changing */
269 if (rb && (rb->Width != width || rb->Height != height)) {
270 rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
271 }
272 }
273 }
274
275
276 /** Dummy function for gl_renderbuffer::AllocStorage() */
277 static GLboolean
278 intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
279 GLenum internalFormat, GLuint width, GLuint height)
280 {
281 _mesa_problem(ctx, "intel_op_alloc_storage should never be called.");
282 return GL_FALSE;
283 }
284
285
286 void
287 intel_renderbuffer_set_region(struct intel_context *intel,
288 struct intel_renderbuffer *rb,
289 struct intel_region *region)
290 {
291 struct intel_region *old;
292
293 old = rb->region;
294 rb->region = NULL;
295 intel_region_reference(&rb->region, region);
296 intel_region_release(&old);
297 }
298
299
300 /**
301 * Create a new intel_renderbuffer which corresponds to an on-screen window,
302 * not a user-created renderbuffer.
303 */
304 struct intel_renderbuffer *
305 intel_create_renderbuffer(gl_format format)
306 {
307 GET_CURRENT_CONTEXT(ctx);
308
309 struct intel_renderbuffer *irb;
310
311 irb = CALLOC_STRUCT(intel_renderbuffer);
312 if (!irb) {
313 _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
314 return NULL;
315 }
316
317 _mesa_init_renderbuffer(&irb->Base, 0);
318 irb->Base.ClassID = INTEL_RB_CLASS;
319
320 switch (format) {
321 case MESA_FORMAT_RGB565:
322 irb->Base._BaseFormat = GL_RGB;
323 irb->Base.DataType = GL_UNSIGNED_BYTE;
324 break;
325 case MESA_FORMAT_XRGB8888:
326 irb->Base._BaseFormat = GL_RGB;
327 irb->Base.DataType = GL_UNSIGNED_BYTE;
328 break;
329 case MESA_FORMAT_ARGB8888:
330 irb->Base._BaseFormat = GL_RGBA;
331 irb->Base.DataType = GL_UNSIGNED_BYTE;
332 break;
333 case MESA_FORMAT_Z16:
334 irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
335 irb->Base.DataType = GL_UNSIGNED_SHORT;
336 break;
337 case MESA_FORMAT_X8_Z24:
338 irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
339 irb->Base.DataType = GL_UNSIGNED_INT;
340 break;
341 case MESA_FORMAT_S8_Z24:
342 irb->Base._BaseFormat = GL_DEPTH_STENCIL;
343 irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
344 break;
345 case MESA_FORMAT_A8:
346 irb->Base._BaseFormat = GL_ALPHA;
347 irb->Base.DataType = GL_UNSIGNED_BYTE;
348 break;
349 default:
350 _mesa_problem(NULL,
351 "Unexpected intFormat in intel_create_renderbuffer");
352 free(irb);
353 return NULL;
354 }
355
356 irb->Base.Format = format;
357 irb->Base.InternalFormat = irb->Base._BaseFormat;
358
359 /* intel-specific methods */
360 irb->Base.Delete = intel_delete_renderbuffer;
361 irb->Base.AllocStorage = intel_alloc_window_storage;
362 irb->Base.GetPointer = intel_get_pointer;
363
364 return irb;
365 }
366
367
368 /**
369 * Create a new renderbuffer object.
370 * Typically called via glBindRenderbufferEXT().
371 */
372 static struct gl_renderbuffer *
373 intel_new_renderbuffer(GLcontext * ctx, GLuint name)
374 {
375 /*struct intel_context *intel = intel_context(ctx); */
376 struct intel_renderbuffer *irb;
377
378 irb = CALLOC_STRUCT(intel_renderbuffer);
379 if (!irb) {
380 _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
381 return NULL;
382 }
383
384 _mesa_init_renderbuffer(&irb->Base, name);
385 irb->Base.ClassID = INTEL_RB_CLASS;
386
387 /* intel-specific methods */
388 irb->Base.Delete = intel_delete_renderbuffer;
389 irb->Base.AllocStorage = intel_alloc_renderbuffer_storage;
390 irb->Base.GetPointer = intel_get_pointer;
391 /* span routines set in alloc_storage function */
392
393 return &irb->Base;
394 }
395
396
397 /**
398 * Called via glBindFramebufferEXT().
399 */
400 static void
401 intel_bind_framebuffer(GLcontext * ctx, GLenum target,
402 struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
403 {
404 if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
405 intel_draw_buffer(ctx, fb);
406 }
407 else {
408 /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
409 }
410 }
411
412
413 /**
414 * Called via glFramebufferRenderbufferEXT().
415 */
416 static void
417 intel_framebuffer_renderbuffer(GLcontext * ctx,
418 struct gl_framebuffer *fb,
419 GLenum attachment, struct gl_renderbuffer *rb)
420 {
421 DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
422
423 intel_flush(ctx);
424
425 _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
426 intel_draw_buffer(ctx, fb);
427 }
428
429
430 static GLboolean
431 intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
432 struct gl_texture_image *texImage)
433 {
434 if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
435 irb->Base.DataType = GL_UNSIGNED_BYTE;
436 DBG("Render to RGBA8 texture OK\n");
437 }
438 else if (texImage->TexFormat == MESA_FORMAT_XRGB8888) {
439 irb->Base.DataType = GL_UNSIGNED_BYTE;
440 DBG("Render to XGBA8 texture OK\n");
441 }
442 else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
443 irb->Base.DataType = GL_UNSIGNED_BYTE;
444 DBG("Render to RGB5 texture OK\n");
445 }
446 else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
447 irb->Base.DataType = GL_UNSIGNED_BYTE;
448 DBG("Render to ARGB1555 texture OK\n");
449 }
450 else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
451 irb->Base.DataType = GL_UNSIGNED_BYTE;
452 DBG("Render to ARGB4444 texture OK\n");
453 }
454 else if (texImage->TexFormat == MESA_FORMAT_A8) {
455 irb->Base.DataType = GL_UNSIGNED_BYTE;
456 DBG("Render to A8 texture OK\n");
457 }
458 else if (texImage->TexFormat == MESA_FORMAT_Z16) {
459 irb->Base.DataType = GL_UNSIGNED_SHORT;
460 DBG("Render to DEPTH16 texture OK\n");
461 }
462 else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
463 irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
464 DBG("Render to DEPTH_STENCIL texture OK\n");
465 }
466 else {
467 DBG("Render to texture BAD FORMAT %s\n",
468 _mesa_get_format_name(texImage->TexFormat));
469 return GL_FALSE;
470 }
471
472 irb->Base.Format = texImage->TexFormat;
473
474 irb->Base.InternalFormat = texImage->InternalFormat;
475 irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);
476 irb->Base.Width = texImage->Width;
477 irb->Base.Height = texImage->Height;
478
479 irb->Base.Delete = intel_delete_renderbuffer;
480 irb->Base.AllocStorage = intel_nop_alloc_storage;
481
482 return GL_TRUE;
483 }
484
485
486 /**
487 * When glFramebufferTexture[123]D is called this function sets up the
488 * gl_renderbuffer wrapper around the texture image.
489 * This will have the region info needed for hardware rendering.
490 */
491 static struct intel_renderbuffer *
492 intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
493 {
494 const GLuint name = ~0; /* not significant, but distinct for debugging */
495 struct intel_renderbuffer *irb;
496
497 /* make an intel_renderbuffer to wrap the texture image */
498 irb = CALLOC_STRUCT(intel_renderbuffer);
499 if (!irb) {
500 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture");
501 return NULL;
502 }
503
504 _mesa_init_renderbuffer(&irb->Base, name);
505 irb->Base.ClassID = INTEL_RB_CLASS;
506
507 if (!intel_update_wrapper(ctx, irb, texImage)) {
508 free(irb);
509 return NULL;
510 }
511
512 return irb;
513 }
514
515
516 /**
517 * Called by glFramebufferTexture[123]DEXT() (and other places) to
518 * prepare for rendering into texture memory. This might be called
519 * many times to choose different texture levels, cube faces, etc
520 * before intel_finish_render_texture() is ever called.
521 */
522 static void
523 intel_render_texture(GLcontext * ctx,
524 struct gl_framebuffer *fb,
525 struct gl_renderbuffer_attachment *att)
526 {
527 struct gl_texture_image *newImage
528 = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
529 struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
530 struct intel_texture_image *intel_image;
531 GLuint dst_x, dst_y;
532
533 (void) fb;
534
535 ASSERT(newImage);
536
537 intel_image = intel_texture_image(newImage);
538 if (!intel_image->mt) {
539 /* Fallback on drawing to a texture that doesn't have a miptree
540 * (has a border, width/height 0, etc.)
541 */
542 _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
543 _mesa_render_texture(ctx, fb, att);
544 return;
545 }
546 else if (!irb) {
547 irb = intel_wrap_texture(ctx, newImage);
548 if (irb) {
549 /* bind the wrapper to the attachment point */
550 _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
551 }
552 else {
553 /* fallback to software rendering */
554 _mesa_render_texture(ctx, fb, att);
555 return;
556 }
557 }
558
559 if (!intel_update_wrapper(ctx, irb, newImage)) {
560 _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
561 _mesa_render_texture(ctx, fb, att);
562 return;
563 }
564
565 DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
566 _glthread_GetID(),
567 att->Texture->Name, newImage->Width, newImage->Height,
568 irb->Base.RefCount);
569
570 /* point the renderbufer's region to the texture image region */
571 if (irb->region != intel_image->mt->region) {
572 if (irb->region)
573 intel_region_release(&irb->region);
574 intel_region_reference(&irb->region, intel_image->mt->region);
575 }
576
577 /* compute offset of the particular 2D image within the texture region */
578 intel_miptree_get_image_offset(intel_image->mt,
579 att->TextureLevel,
580 att->CubeMapFace,
581 att->Zoffset,
582 &dst_x, &dst_y);
583
584 intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->region->pitch +
585 dst_x) * intel_image->mt->cpp;
586 intel_image->mt->region->draw_x = dst_x;
587 intel_image->mt->region->draw_y = dst_y;
588 intel_image->used_as_render_target = GL_TRUE;
589
590 /* update drawing region, etc */
591 intel_draw_buffer(ctx, fb);
592 }
593
594
595 /**
596 * Called by Mesa when rendering to a texture is done.
597 */
598 static void
599 intel_finish_render_texture(GLcontext * ctx,
600 struct gl_renderbuffer_attachment *att)
601 {
602 struct intel_context *intel = intel_context(ctx);
603 struct gl_texture_object *tex_obj = att->Texture;
604 struct gl_texture_image *image =
605 tex_obj->Image[att->CubeMapFace][att->TextureLevel];
606 struct intel_texture_image *intel_image = intel_texture_image(image);
607
608 /* Flag that this image may now be validated into the object's miptree. */
609 intel_image->used_as_render_target = GL_FALSE;
610
611 /* Since we've (probably) rendered to the texture and will (likely) use
612 * it in the texture domain later on in this batchbuffer, flush the
613 * batch. Once again, we wish for a domain tracker in libdrm to cover
614 * usage inside of a batchbuffer like GEM does in the kernel.
615 */
616 intel_batchbuffer_emit_mi_flush(intel->batch);
617 }
618
619 /**
620 * Do additional "completeness" testing of a framebuffer object.
621 */
622 static void
623 intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
624 {
625 const struct intel_renderbuffer *depthRb =
626 intel_get_renderbuffer(fb, BUFFER_DEPTH);
627 const struct intel_renderbuffer *stencilRb =
628 intel_get_renderbuffer(fb, BUFFER_STENCIL);
629 int i;
630
631 if (depthRb && stencilRb && stencilRb != depthRb) {
632 if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE &&
633 ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE &&
634 (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Texture->Name ==
635 ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Texture->Name)) {
636 /* OK */
637 } else {
638 /* we only support combined depth/stencil buffers, not separate
639 * stencil buffers.
640 */
641 DBG("Only supports combined depth/stencil (found %s, %s)\n",
642 depthRb ? _mesa_get_format_name(depthRb->Base.Format): "NULL",
643 stencilRb ? _mesa_get_format_name(stencilRb->Base.Format): "NULL");
644 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
645 }
646 }
647
648 for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
649 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i];
650 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
651
652 if (rb == NULL)
653 continue;
654
655 if (irb == NULL) {
656 DBG("software rendering renderbuffer\n");
657 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
658 continue;
659 }
660
661 switch (irb->Base.Format) {
662 case MESA_FORMAT_ARGB8888:
663 case MESA_FORMAT_XRGB8888:
664 case MESA_FORMAT_RGB565:
665 case MESA_FORMAT_ARGB1555:
666 case MESA_FORMAT_ARGB4444:
667 case MESA_FORMAT_A8:
668 break;
669 default:
670 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
671 }
672 }
673 }
674
675
676 /**
677 * Do one-time context initializations related to GL_EXT_framebuffer_object.
678 * Hook in device driver functions.
679 */
680 void
681 intel_fbo_init(struct intel_context *intel)
682 {
683 intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer;
684 intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
685 intel->ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
686 intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
687 intel->ctx.Driver.RenderTexture = intel_render_texture;
688 intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
689 intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
690 intel->ctx.Driver.ValidateFramebuffer = intel_validate_framebuffer;
691 intel->ctx.Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer;
692
693 #if FEATURE_OES_EGL_image
694 intel->ctx.Driver.EGLImageTargetRenderbufferStorage =
695 intel_image_target_renderbuffer_storage;
696 #endif
697 }