i965: Hack in avoidance of c++ reserved keyword in libdrm.
[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_DEPTH_COMPONENT16:
141 rb->Format = MESA_FORMAT_Z16;
142 rb->DataType = GL_UNSIGNED_SHORT;
143 break;
144 case GL_STENCIL_INDEX:
145 case GL_STENCIL_INDEX1_EXT:
146 case GL_STENCIL_INDEX4_EXT:
147 case GL_STENCIL_INDEX8_EXT:
148 case GL_STENCIL_INDEX16_EXT:
149 case GL_DEPTH_COMPONENT:
150 case GL_DEPTH_COMPONENT24:
151 case GL_DEPTH_COMPONENT32:
152 case GL_DEPTH_STENCIL_EXT:
153 case GL_DEPTH24_STENCIL8_EXT:
154 /* alloc a depth+stencil buffer */
155 rb->Format = MESA_FORMAT_S8_Z24;
156 rb->DataType = GL_UNSIGNED_INT_24_8_EXT;
157 break;
158 default:
159 _mesa_problem(ctx,
160 "Unexpected format in intel_alloc_renderbuffer_storage");
161 return GL_FALSE;
162 }
163
164 rb->_BaseFormat = _mesa_base_fbo_format(ctx, internalFormat);
165 cpp = _mesa_get_format_bytes(rb->Format);
166
167 intel_flush(ctx);
168
169 /* free old region */
170 if (irb->region) {
171 intel_region_release(&irb->region);
172 }
173
174 /* allocate new memory region/renderbuffer */
175
176 /* alloc hardware renderbuffer */
177 DBG("Allocating %d x %d Intel RBO\n", width, height);
178
179 irb->region = intel_region_alloc(intel->intelScreen, I915_TILING_NONE, cpp,
180 width, height, GL_TRUE);
181 if (!irb->region)
182 return GL_FALSE; /* out of memory? */
183
184 ASSERT(irb->region->buffer);
185
186 rb->Width = width;
187 rb->Height = height;
188
189 return GL_TRUE;
190 }
191
192
193 #if FEATURE_OES_EGL_image
194 static void
195 intel_image_target_renderbuffer_storage(GLcontext *ctx,
196 struct gl_renderbuffer *rb,
197 void *image_handle)
198 {
199 struct intel_context *intel = intel_context(ctx);
200 struct intel_renderbuffer *irb;
201 __DRIscreen *screen;
202 __DRIimage *image;
203
204 screen = intel->intelScreen->driScrnPriv;
205 image = screen->dri2.image->lookupEGLImage(intel->driContext, image_handle,
206 intel->driContext->loaderPrivate);
207 if (image == NULL)
208 return;
209
210 irb = intel_renderbuffer(rb);
211 if (irb->region)
212 intel_region_release(&irb->region);
213 intel_region_reference(&irb->region, image->region);
214
215 rb->InternalFormat = image->internal_format;
216 rb->Width = image->region->width;
217 rb->Height = image->region->height;
218 rb->Format = image->format;
219 rb->DataType = image->data_type;
220 rb->_BaseFormat = _mesa_base_fbo_format(&intel->ctx,
221 image->internal_format);
222 }
223 #endif
224
225 /**
226 * Called for each hardware renderbuffer when a _window_ is resized.
227 * Just update fields.
228 * Not used for user-created renderbuffers!
229 */
230 static GLboolean
231 intel_alloc_window_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
232 GLenum internalFormat, GLuint width, GLuint height)
233 {
234 ASSERT(rb->Name == 0);
235 rb->Width = width;
236 rb->Height = height;
237 rb->InternalFormat = internalFormat;
238
239 return GL_TRUE;
240 }
241
242
243 static void
244 intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
245 GLuint width, GLuint height)
246 {
247 int i;
248
249 _mesa_resize_framebuffer(ctx, fb, width, height);
250
251 fb->Initialized = GL_TRUE; /* XXX remove someday */
252
253 if (fb->Name != 0) {
254 return;
255 }
256
257
258 /* Make sure all window system renderbuffers are up to date */
259 for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
260 struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
261
262 /* only resize if size is changing */
263 if (rb && (rb->Width != width || rb->Height != height)) {
264 rb->AllocStorage(ctx, rb, rb->InternalFormat, width, height);
265 }
266 }
267 }
268
269
270 /** Dummy function for gl_renderbuffer::AllocStorage() */
271 static GLboolean
272 intel_nop_alloc_storage(GLcontext * ctx, struct gl_renderbuffer *rb,
273 GLenum internalFormat, GLuint width, GLuint height)
274 {
275 _mesa_problem(ctx, "intel_op_alloc_storage should never be called.");
276 return GL_FALSE;
277 }
278
279
280 void
281 intel_renderbuffer_set_region(struct intel_context *intel,
282 struct intel_renderbuffer *rb,
283 struct intel_region *region)
284 {
285 struct intel_region *old;
286
287 old = rb->region;
288 rb->region = NULL;
289 intel_region_reference(&rb->region, region);
290 intel_region_release(&old);
291 }
292
293
294 /**
295 * Create a new intel_renderbuffer which corresponds to an on-screen window,
296 * not a user-created renderbuffer.
297 */
298 struct intel_renderbuffer *
299 intel_create_renderbuffer(gl_format format)
300 {
301 GET_CURRENT_CONTEXT(ctx);
302
303 struct intel_renderbuffer *irb;
304
305 irb = CALLOC_STRUCT(intel_renderbuffer);
306 if (!irb) {
307 _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
308 return NULL;
309 }
310
311 _mesa_init_renderbuffer(&irb->Base, 0);
312 irb->Base.ClassID = INTEL_RB_CLASS;
313
314 switch (format) {
315 case MESA_FORMAT_RGB565:
316 irb->Base._BaseFormat = GL_RGB;
317 irb->Base.DataType = GL_UNSIGNED_BYTE;
318 break;
319 case MESA_FORMAT_XRGB8888:
320 irb->Base._BaseFormat = GL_RGB;
321 irb->Base.DataType = GL_UNSIGNED_BYTE;
322 break;
323 case MESA_FORMAT_ARGB8888:
324 irb->Base._BaseFormat = GL_RGBA;
325 irb->Base.DataType = GL_UNSIGNED_BYTE;
326 break;
327 case MESA_FORMAT_Z16:
328 irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
329 irb->Base.DataType = GL_UNSIGNED_SHORT;
330 break;
331 case MESA_FORMAT_X8_Z24:
332 irb->Base._BaseFormat = GL_DEPTH_COMPONENT;
333 irb->Base.DataType = GL_UNSIGNED_INT;
334 break;
335 case MESA_FORMAT_S8_Z24:
336 irb->Base._BaseFormat = GL_DEPTH_STENCIL;
337 irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
338 break;
339 case MESA_FORMAT_A8:
340 irb->Base._BaseFormat = GL_ALPHA;
341 irb->Base.DataType = GL_UNSIGNED_BYTE;
342 break;
343 default:
344 _mesa_problem(NULL,
345 "Unexpected intFormat in intel_create_renderbuffer");
346 free(irb);
347 return NULL;
348 }
349
350 irb->Base.Format = format;
351 irb->Base.InternalFormat = irb->Base._BaseFormat;
352
353 /* intel-specific methods */
354 irb->Base.Delete = intel_delete_renderbuffer;
355 irb->Base.AllocStorage = intel_alloc_window_storage;
356 irb->Base.GetPointer = intel_get_pointer;
357
358 return irb;
359 }
360
361
362 /**
363 * Create a new renderbuffer object.
364 * Typically called via glBindRenderbufferEXT().
365 */
366 static struct gl_renderbuffer *
367 intel_new_renderbuffer(GLcontext * ctx, GLuint name)
368 {
369 /*struct intel_context *intel = intel_context(ctx); */
370 struct intel_renderbuffer *irb;
371
372 irb = CALLOC_STRUCT(intel_renderbuffer);
373 if (!irb) {
374 _mesa_error(ctx, GL_OUT_OF_MEMORY, "creating renderbuffer");
375 return NULL;
376 }
377
378 _mesa_init_renderbuffer(&irb->Base, name);
379 irb->Base.ClassID = INTEL_RB_CLASS;
380
381 /* intel-specific methods */
382 irb->Base.Delete = intel_delete_renderbuffer;
383 irb->Base.AllocStorage = intel_alloc_renderbuffer_storage;
384 irb->Base.GetPointer = intel_get_pointer;
385 /* span routines set in alloc_storage function */
386
387 return &irb->Base;
388 }
389
390
391 /**
392 * Called via glBindFramebufferEXT().
393 */
394 static void
395 intel_bind_framebuffer(GLcontext * ctx, GLenum target,
396 struct gl_framebuffer *fb, struct gl_framebuffer *fbread)
397 {
398 if (target == GL_FRAMEBUFFER_EXT || target == GL_DRAW_FRAMEBUFFER_EXT) {
399 intel_draw_buffer(ctx, fb);
400 }
401 else {
402 /* don't need to do anything if target == GL_READ_FRAMEBUFFER_EXT */
403 }
404 }
405
406
407 /**
408 * Called via glFramebufferRenderbufferEXT().
409 */
410 static void
411 intel_framebuffer_renderbuffer(GLcontext * ctx,
412 struct gl_framebuffer *fb,
413 GLenum attachment, struct gl_renderbuffer *rb)
414 {
415 DBG("Intel FramebufferRenderbuffer %u %u\n", fb->Name, rb ? rb->Name : 0);
416
417 intel_flush(ctx);
418
419 _mesa_framebuffer_renderbuffer(ctx, fb, attachment, rb);
420 intel_draw_buffer(ctx, fb);
421 }
422
423
424 static GLboolean
425 intel_update_wrapper(GLcontext *ctx, struct intel_renderbuffer *irb,
426 struct gl_texture_image *texImage)
427 {
428 if (texImage->TexFormat == MESA_FORMAT_ARGB8888) {
429 irb->Base.DataType = GL_UNSIGNED_BYTE;
430 DBG("Render to RGBA8 texture OK\n");
431 }
432 else if (texImage->TexFormat == MESA_FORMAT_XRGB8888) {
433 irb->Base.DataType = GL_UNSIGNED_BYTE;
434 DBG("Render to XGBA8 texture OK\n");
435 }
436 else if (texImage->TexFormat == MESA_FORMAT_RGB565) {
437 irb->Base.DataType = GL_UNSIGNED_BYTE;
438 DBG("Render to RGB5 texture OK\n");
439 }
440 else if (texImage->TexFormat == MESA_FORMAT_ARGB1555) {
441 irb->Base.DataType = GL_UNSIGNED_BYTE;
442 DBG("Render to ARGB1555 texture OK\n");
443 }
444 else if (texImage->TexFormat == MESA_FORMAT_ARGB4444) {
445 irb->Base.DataType = GL_UNSIGNED_BYTE;
446 DBG("Render to ARGB4444 texture OK\n");
447 }
448 else if (texImage->TexFormat == MESA_FORMAT_A8) {
449 irb->Base.DataType = GL_UNSIGNED_BYTE;
450 DBG("Render to A8 texture OK\n");
451 }
452 else if (texImage->TexFormat == MESA_FORMAT_Z16) {
453 irb->Base.DataType = GL_UNSIGNED_SHORT;
454 DBG("Render to DEPTH16 texture OK\n");
455 }
456 else if (texImage->TexFormat == MESA_FORMAT_S8_Z24) {
457 irb->Base.DataType = GL_UNSIGNED_INT_24_8_EXT;
458 DBG("Render to DEPTH_STENCIL texture OK\n");
459 }
460 else {
461 DBG("Render to texture BAD FORMAT %s\n",
462 _mesa_get_format_name(texImage->TexFormat));
463 return GL_FALSE;
464 }
465
466 irb->Base.Format = texImage->TexFormat;
467
468 irb->Base.InternalFormat = texImage->InternalFormat;
469 irb->Base._BaseFormat = _mesa_base_fbo_format(ctx, irb->Base.InternalFormat);
470 irb->Base.Width = texImage->Width;
471 irb->Base.Height = texImage->Height;
472
473 irb->Base.Delete = intel_delete_renderbuffer;
474 irb->Base.AllocStorage = intel_nop_alloc_storage;
475
476 return GL_TRUE;
477 }
478
479
480 /**
481 * When glFramebufferTexture[123]D is called this function sets up the
482 * gl_renderbuffer wrapper around the texture image.
483 * This will have the region info needed for hardware rendering.
484 */
485 static struct intel_renderbuffer *
486 intel_wrap_texture(GLcontext * ctx, struct gl_texture_image *texImage)
487 {
488 const GLuint name = ~0; /* not significant, but distinct for debugging */
489 struct intel_renderbuffer *irb;
490
491 /* make an intel_renderbuffer to wrap the texture image */
492 irb = CALLOC_STRUCT(intel_renderbuffer);
493 if (!irb) {
494 _mesa_error(ctx, GL_OUT_OF_MEMORY, "glFramebufferTexture");
495 return NULL;
496 }
497
498 _mesa_init_renderbuffer(&irb->Base, name);
499 irb->Base.ClassID = INTEL_RB_CLASS;
500
501 if (!intel_update_wrapper(ctx, irb, texImage)) {
502 free(irb);
503 return NULL;
504 }
505
506 return irb;
507 }
508
509
510 /**
511 * Called by glFramebufferTexture[123]DEXT() (and other places) to
512 * prepare for rendering into texture memory. This might be called
513 * many times to choose different texture levels, cube faces, etc
514 * before intel_finish_render_texture() is ever called.
515 */
516 static void
517 intel_render_texture(GLcontext * ctx,
518 struct gl_framebuffer *fb,
519 struct gl_renderbuffer_attachment *att)
520 {
521 struct gl_texture_image *newImage
522 = att->Texture->Image[att->CubeMapFace][att->TextureLevel];
523 struct intel_renderbuffer *irb = intel_renderbuffer(att->Renderbuffer);
524 struct intel_texture_image *intel_image;
525 GLuint dst_x, dst_y;
526
527 (void) fb;
528
529 ASSERT(newImage);
530
531 intel_image = intel_texture_image(newImage);
532 if (!intel_image->mt) {
533 /* Fallback on drawing to a texture that doesn't have a miptree
534 * (has a border, width/height 0, etc.)
535 */
536 _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
537 _mesa_render_texture(ctx, fb, att);
538 return;
539 }
540 else if (!irb) {
541 irb = intel_wrap_texture(ctx, newImage);
542 if (irb) {
543 /* bind the wrapper to the attachment point */
544 _mesa_reference_renderbuffer(&att->Renderbuffer, &irb->Base);
545 }
546 else {
547 /* fallback to software rendering */
548 _mesa_render_texture(ctx, fb, att);
549 return;
550 }
551 }
552
553 if (!intel_update_wrapper(ctx, irb, newImage)) {
554 _mesa_reference_renderbuffer(&att->Renderbuffer, NULL);
555 _mesa_render_texture(ctx, fb, att);
556 return;
557 }
558
559 DBG("Begin render texture tid %lx tex=%u w=%d h=%d refcount=%d\n",
560 _glthread_GetID(),
561 att->Texture->Name, newImage->Width, newImage->Height,
562 irb->Base.RefCount);
563
564 /* point the renderbufer's region to the texture image region */
565 if (irb->region != intel_image->mt->region) {
566 if (irb->region)
567 intel_region_release(&irb->region);
568 intel_region_reference(&irb->region, intel_image->mt->region);
569 }
570
571 /* compute offset of the particular 2D image within the texture region */
572 intel_miptree_get_image_offset(intel_image->mt,
573 att->TextureLevel,
574 att->CubeMapFace,
575 att->Zoffset,
576 &dst_x, &dst_y);
577
578 intel_image->mt->region->draw_offset = (dst_y * intel_image->mt->region->pitch +
579 dst_x) * intel_image->mt->cpp;
580 intel_image->mt->region->draw_x = dst_x;
581 intel_image->mt->region->draw_y = dst_y;
582 intel_image->used_as_render_target = GL_TRUE;
583
584 /* update drawing region, etc */
585 intel_draw_buffer(ctx, fb);
586 }
587
588
589 /**
590 * Called by Mesa when rendering to a texture is done.
591 */
592 static void
593 intel_finish_render_texture(GLcontext * ctx,
594 struct gl_renderbuffer_attachment *att)
595 {
596 struct intel_context *intel = intel_context(ctx);
597 struct gl_texture_object *tex_obj = att->Texture;
598 struct gl_texture_image *image =
599 tex_obj->Image[att->CubeMapFace][att->TextureLevel];
600 struct intel_texture_image *intel_image = intel_texture_image(image);
601
602 /* Flag that this image may now be validated into the object's miptree. */
603 intel_image->used_as_render_target = GL_FALSE;
604
605 /* Since we've (probably) rendered to the texture and will (likely) use
606 * it in the texture domain later on in this batchbuffer, flush the
607 * batch. Once again, we wish for a domain tracker in libdrm to cover
608 * usage inside of a batchbuffer like GEM does in the kernel.
609 */
610 intel_batchbuffer_emit_mi_flush(intel->batch);
611 }
612
613 /**
614 * Do additional "completeness" testing of a framebuffer object.
615 */
616 static void
617 intel_validate_framebuffer(GLcontext *ctx, struct gl_framebuffer *fb)
618 {
619 const struct intel_renderbuffer *depthRb =
620 intel_get_renderbuffer(fb, BUFFER_DEPTH);
621 const struct intel_renderbuffer *stencilRb =
622 intel_get_renderbuffer(fb, BUFFER_STENCIL);
623 int i;
624
625 if (depthRb && stencilRb && stencilRb != depthRb) {
626 if (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Type == GL_TEXTURE &&
627 ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Type == GL_TEXTURE &&
628 (ctx->DrawBuffer->Attachment[BUFFER_DEPTH].Texture->Name ==
629 ctx->DrawBuffer->Attachment[BUFFER_STENCIL].Texture->Name)) {
630 /* OK */
631 } else {
632 /* we only support combined depth/stencil buffers, not separate
633 * stencil buffers.
634 */
635 DBG("Only supports combined depth/stencil (found %s, %s)\n",
636 depthRb ? _mesa_get_format_name(depthRb->Base.Format): "NULL",
637 stencilRb ? _mesa_get_format_name(stencilRb->Base.Format): "NULL");
638 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
639 }
640 }
641
642 for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
643 struct gl_renderbuffer *rb = ctx->DrawBuffer->_ColorDrawBuffers[i];
644 struct intel_renderbuffer *irb = intel_renderbuffer(rb);
645
646 if (rb == NULL)
647 continue;
648
649 if (irb == NULL) {
650 DBG("software rendering renderbuffer\n");
651 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
652 continue;
653 }
654
655 switch (irb->Base.Format) {
656 case MESA_FORMAT_ARGB8888:
657 case MESA_FORMAT_XRGB8888:
658 case MESA_FORMAT_RGB565:
659 case MESA_FORMAT_ARGB1555:
660 case MESA_FORMAT_ARGB4444:
661 case MESA_FORMAT_A8:
662 break;
663 default:
664 fb->_Status = GL_FRAMEBUFFER_UNSUPPORTED_EXT;
665 }
666 }
667 }
668
669
670 /**
671 * Do one-time context initializations related to GL_EXT_framebuffer_object.
672 * Hook in device driver functions.
673 */
674 void
675 intel_fbo_init(struct intel_context *intel)
676 {
677 intel->ctx.Driver.NewFramebuffer = intel_new_framebuffer;
678 intel->ctx.Driver.NewRenderbuffer = intel_new_renderbuffer;
679 intel->ctx.Driver.BindFramebuffer = intel_bind_framebuffer;
680 intel->ctx.Driver.FramebufferRenderbuffer = intel_framebuffer_renderbuffer;
681 intel->ctx.Driver.RenderTexture = intel_render_texture;
682 intel->ctx.Driver.FinishRenderTexture = intel_finish_render_texture;
683 intel->ctx.Driver.ResizeBuffers = intel_resize_buffers;
684 intel->ctx.Driver.ValidateFramebuffer = intel_validate_framebuffer;
685 intel->ctx.Driver.BlitFramebuffer = _mesa_meta_BlitFramebuffer;
686
687 #if FEATURE_OES_EGL_image
688 intel->ctx.Driver.EGLImageTargetRenderbufferStorage =
689 intel_image_target_renderbuffer_storage;
690 #endif
691 }