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