intel: Remove struct intel_framebuffer
authorKristian Høgsberg <krh@bitplanet.net>
Sat, 2 Jan 2010 04:21:16 +0000 (23:21 -0500)
committerKristian Høgsberg <krh@bitplanet.net>
Mon, 4 Jan 2010 16:48:02 +0000 (11:48 -0500)
With the vsync fields no longer relevant and by refactoring the code
to no longer use color_rb[0-1] we can just use struct gl_framebuffer
directly.

src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_fbo.c
src/mesa/drivers/dri/intel/intel_fbo.h
src/mesa/drivers/dri/intel/intel_screen.c
src/mesa/drivers/dri/intel/intel_tex_image.c

index 2ecf67152fcc1fce64227257d4e796e5891ef0b7..046daed69dfa59db309fd3e9dfba8737f71f38b3 100644 (file)
@@ -191,10 +191,11 @@ intel_bits_per_pixel(const struct intel_renderbuffer *rb)
 void
 intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
 {
-   struct intel_framebuffer *intel_fb = drawable->driverPrivate;
+   struct gl_framebuffer *fb = drawable->driverPrivate;
    struct intel_renderbuffer *rb;
    struct intel_region *region, *depth_region;
    struct intel_context *intel = context->driverPrivate;
+   struct intel_renderbuffer *front_rb, *back_rb, *depth_rb, *stencil_rb;
    __DRIbuffer *buffers = NULL;
    __DRIscreen *screen;
    int i, count;
@@ -210,26 +211,25 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    if (screen->dri2.loader
        && (screen->dri2.loader->base.version > 2)
        && (screen->dri2.loader->getBuffersWithFormat != NULL)) {
-      struct intel_renderbuffer *depth_rb;
-      struct intel_renderbuffer *stencil_rb;
+
+      front_rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
+      back_rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
+      depth_rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
+      stencil_rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
 
       i = 0;
       if ((intel->is_front_buffer_rendering ||
           intel->is_front_buffer_reading ||
-          !intel_fb->color_rb[1])
-          && intel_fb->color_rb[0]) {
+          !back_rb) && front_rb) {
         attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-        attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[0]);
+        attachments[i++] = intel_bits_per_pixel(front_rb);
       }
 
-      if (intel_fb->color_rb[1]) {
+      if (back_rb) {
         attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-        attachments[i++] = intel_bits_per_pixel(intel_fb->color_rb[1]);
+        attachments[i++] = intel_bits_per_pixel(back_rb);
       }
 
-      depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-      stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-
       if ((depth_rb != NULL) && (stencil_rb != NULL)) {
         attachments[i++] = __DRI_BUFFER_DEPTH_STENCIL;
         attachments[i++] = intel_bits_per_pixel(depth_rb);
@@ -250,13 +250,13 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
                                                      drawable->loaderPrivate);
    } else if (screen->dri2.loader) {
       i = 0;
-      if (intel_fb->color_rb[0])
+      if (intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT))
         attachments[i++] = __DRI_BUFFER_FRONT_LEFT;
-      if (intel_fb->color_rb[1])
+      if (intel_get_renderbuffer(fb, BUFFER_BACK_LEFT))
         attachments[i++] = __DRI_BUFFER_BACK_LEFT;
-      if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH))
+      if (intel_get_renderbuffer(fb, BUFFER_DEPTH))
         attachments[i++] = __DRI_BUFFER_DEPTH;
-      if (intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL))
+      if (intel_get_renderbuffer(fb, BUFFER_STENCIL))
         attachments[i++] = __DRI_BUFFER_STENCIL;
 
       buffers = (*screen->dri2.loader->getBuffers)(drawable,
@@ -289,32 +289,32 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
    for (i = 0; i < count; i++) {
        switch (buffers[i].attachment) {
        case __DRI_BUFFER_FRONT_LEFT:
-          rb = intel_fb->color_rb[0];
+          rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
           region_name = "dri2 front buffer";
           break;
 
        case __DRI_BUFFER_FAKE_FRONT_LEFT:
-          rb = intel_fb->color_rb[0];
+          rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
           region_name = "dri2 fake front buffer";
           break;
 
        case __DRI_BUFFER_BACK_LEFT:
-          rb = intel_fb->color_rb[1];
+          rb = intel_get_renderbuffer(fb, BUFFER_BACK_LEFT);
           region_name = "dri2 back buffer";
           break;
 
        case __DRI_BUFFER_DEPTH:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+          rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
           region_name = "dri2 depth buffer";
           break;
 
        case __DRI_BUFFER_DEPTH_STENCIL:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
+          rb = intel_get_renderbuffer(fb, BUFFER_DEPTH);
           region_name = "dri2 depth / stencil buffer";
           break;
 
        case __DRI_BUFFER_STENCIL:
-          rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+          rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
           region_name = "dri2 stencil buffer";
           break;
 
@@ -361,7 +361,7 @@ intel_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable)
        intel_region_release(&region);
 
        if (buffers[i].attachment == __DRI_BUFFER_DEPTH_STENCIL) {
-         rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
+         rb = intel_get_renderbuffer(fb, BUFFER_STENCIL);
          if (rb != NULL) {
             struct intel_region *stencil_region = NULL;
 
@@ -883,9 +883,8 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
    }
 
    if (driContextPriv) {
-      struct intel_framebuffer *intel_fb =
-        (struct intel_framebuffer *) driDrawPriv->driverPrivate;
-      GLframebuffer *readFb = (GLframebuffer *) driReadPriv->driverPrivate;
+      struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+      struct gl_framebuffer *readFb = driReadPriv->driverPrivate;
  
       intel_update_renderbuffers(driContextPriv, driDrawPriv);
       if (driDrawPriv != driReadPriv)
@@ -898,10 +897,10 @@ intelMakeCurrent(__DRIcontext * driContextPriv,
         driUpdateFramebufferSize(&intel->ctx, driReadPriv);
       }
 
-      _mesa_make_current(&intel->ctx, &intel_fb->Base, readFb);
-
+      _mesa_make_current(&intel->ctx, fb, readFb);
       intel->driReadDrawable = driReadPriv;
-      intel_draw_buffer(&intel->ctx, &intel_fb->Base);
+      intel->driDrawable = driDrawPriv;
+      intel_draw_buffer(&intel->ctx, fb);
    }
    else {
       _mesa_make_current(NULL, NULL, NULL);
index 32c43ae1858b4a2066c90e3258a416192f88a42d..d58ffd95fa6fef38f26d43193bf70b5342fdb61a 100644 (file)
@@ -222,7 +222,6 @@ static void
 intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
                     GLuint width, GLuint height)
 {
-   struct intel_framebuffer *intel_fb = (struct intel_framebuffer*)fb;
    int i;
 
    _mesa_resize_framebuffer(ctx, fb, width, height);
@@ -233,9 +232,10 @@ intel_resize_buffers(GLcontext *ctx, struct gl_framebuffer *fb,
       return;
    }
 
+
    /* Make sure all window system renderbuffers are up to date */
-   for (i = 0; i < 2; i++) {
-      struct gl_renderbuffer *rb = &intel_fb->color_rb[i]->Base;
+   for (i = BUFFER_FRONT_LEFT; i <= BUFFER_BACK_RIGHT; i++) {
+      struct gl_renderbuffer *rb = fb->Attachment[i].Renderbuffer;
 
       /* only resize if size is changing */
       if (rb && (rb->Width != width || rb->Height != height)) {
index 72c31f9ba58a06c88442c91bc668d541c2f768ad..586dbbbb25a198863ea957cf52d0758f77907df9 100644 (file)
 
 struct intel_context;
 
-/**
- * Intel framebuffer, derived from gl_framebuffer.
- */
-struct intel_framebuffer
-{
-   struct gl_framebuffer Base;
-
-   struct intel_renderbuffer *color_rb[2];
-};
-
-
 /**
  * Intel renderbuffer, derived from gl_renderbuffer.
  */
@@ -109,7 +98,7 @@ intel_fbo_init(struct intel_context *intel);
 
 
 extern void
-intel_flip_renderbuffers(struct intel_framebuffer *intel_fb);
+intel_flip_renderbuffers(struct gl_framebuffer *fb);
 
 
 static INLINE struct intel_region *
index 2d189972047a8ec912da8781ecaa1e0c9c928e17..e735bdfddeebbb19027bab38065d4d01c49fc2af 100644 (file)
@@ -159,6 +159,8 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
                   __DRIdrawable * driDrawPriv,
                   const __GLcontextModes * mesaVis, GLboolean isPixmap)
 {
+   struct intel_renderbuffer *rb;
+
    if (isPixmap) {
       return GL_FALSE;          /* not implemented */
    }
@@ -167,12 +169,12 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
                              mesaVis->depthBits != 24);
       gl_format rgbFormat;
 
-      struct intel_framebuffer *intel_fb = CALLOC_STRUCT(intel_framebuffer);
+      struct gl_framebuffer *fb = CALLOC_STRUCT(gl_framebuffer);
 
-      if (!intel_fb)
+      if (!fb)
         return GL_FALSE;
 
-      _mesa_initialize_framebuffer(&intel_fb->Base, mesaVis);
+      _mesa_initialize_framebuffer(fb, mesaVis);
 
       if (mesaVis->redBits == 5)
         rgbFormat = MESA_FORMAT_RGB565;
@@ -182,16 +184,12 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
         rgbFormat = MESA_FORMAT_ARGB8888;
 
       /* setup the hardware-based renderbuffers */
-      intel_fb->color_rb[0] = intel_create_renderbuffer(rgbFormat);
-      _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_FRONT_LEFT,
-                            &intel_fb->color_rb[0]->Base);
+      rb = intel_create_renderbuffer(rgbFormat);
+      _mesa_add_renderbuffer(fb, BUFFER_FRONT_LEFT, &rb->Base);
 
       if (mesaVis->doubleBufferMode) {
-        intel_fb->color_rb[1] = intel_create_renderbuffer(rgbFormat);
-
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_BACK_LEFT,
-                               &intel_fb->color_rb[1]->Base);
-
+        rb = intel_create_renderbuffer(rgbFormat);
+         _mesa_add_renderbuffer(fb, BUFFER_BACK_LEFT, &rb->Base);
       }
 
       if (mesaVis->depthBits == 24) {
@@ -200,32 +198,29 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
            struct intel_renderbuffer *depthStencilRb
               = intel_create_renderbuffer(MESA_FORMAT_S8_Z24);
            /* note: bind RB to two attachment points */
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
-                                  &depthStencilRb->Base);
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_STENCIL,
-                                  &depthStencilRb->Base);
+           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthStencilRb->Base);
+           _mesa_add_renderbuffer(fb, BUFFER_STENCIL, &depthStencilRb->Base);
         } else {
            struct intel_renderbuffer *depthRb
               = intel_create_renderbuffer(MESA_FORMAT_X8_Z24);
-           _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH,
-                                  &depthRb->Base);
+           _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
         }
       }
       else if (mesaVis->depthBits == 16) {
          /* just 16-bit depth buffer, no hw stencil */
          struct intel_renderbuffer *depthRb
            = intel_create_renderbuffer(MESA_FORMAT_Z16);
-         _mesa_add_renderbuffer(&intel_fb->Base, BUFFER_DEPTH, &depthRb->Base);
+         _mesa_add_renderbuffer(fb, BUFFER_DEPTH, &depthRb->Base);
       }
 
       /* now add any/all software-based renderbuffers we may need */
-      _mesa_add_soft_renderbuffers(&intel_fb->Base,
+      _mesa_add_soft_renderbuffers(fb,
                                    GL_FALSE, /* never sw color */
                                    GL_FALSE, /* never sw depth */
                                    swStencil, mesaVis->accumRedBits > 0,
                                    GL_FALSE, /* never sw alpha */
                                    GL_FALSE  /* never sw aux */ );
-      driDrawPriv->driverPrivate = (void *) intel_fb;
+      driDrawPriv->driverPrivate = fb;
 
       return GL_TRUE;
    }
@@ -234,31 +229,9 @@ intelCreateBuffer(__DRIscreen * driScrnPriv,
 static void
 intelDestroyBuffer(__DRIdrawable * driDrawPriv)
 {
-   struct intel_framebuffer *intel_fb = driDrawPriv->driverPrivate;
-   struct intel_renderbuffer *depth_rb;
-   struct intel_renderbuffer *stencil_rb;
-
-   if (intel_fb) {
-      if (intel_fb->color_rb[0]) {
-         intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL);
-      }
-
-      if (intel_fb->color_rb[1]) {
-         intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL);
-      }
-
-      depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH);
-      if (depth_rb) {
-         intel_renderbuffer_set_region(depth_rb, NULL);
-      }
-
-      stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL);
-      if (stencil_rb) {
-         intel_renderbuffer_set_region(stencil_rb, NULL);
-      }
-   }
-
-   _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL);
+    struct gl_framebuffer *fb = driDrawPriv->driverPrivate;
+  
+    _mesa_reference_framebuffer(&fb, NULL);
 }
 
 /* There are probably better ways to do this, such as an
index 498d944c52ba1af6541ba017a7aed8e0ab5a7d45..307669f87ec780365f672e5a5dacc2b3775db466 100644 (file)
@@ -725,7 +725,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
                   GLint glx_texture_format,
                   __DRIdrawable *dPriv)
 {
-   struct intel_framebuffer *intel_fb = dPriv->driverPrivate;
+   struct gl_framebuffer *fb = dPriv->driverPrivate;
    struct intel_context *intel = pDRICtx->driverPrivate;
    GLcontext *ctx = &intel->ctx;
    struct intel_texture_object *intelObj;
@@ -744,7 +744,7 @@ intelSetTexBuffer2(__DRIcontext *pDRICtx, GLint target,
 
    intel_update_renderbuffers(pDRICtx, dPriv);
 
-   rb = intel_fb->color_rb[0];
+   rb = intel_get_renderbuffer(fb, BUFFER_FRONT_LEFT);
    /* If the region isn't set, then intel_update_renderbuffers was unable
     * to get the buffers for the drawable.
     */