st/dri: flush_frontbuffer, allocate_textures for dri1
authorGeorge Sapountzis <gsapountzis@gmail.com>
Thu, 25 Mar 2010 15:01:52 +0000 (17:01 +0200)
committerGeorge Sapountzis <gsapountzis@gmail.com>
Thu, 25 Mar 2010 15:01:52 +0000 (17:01 +0200)
* ptex is get by flush_frontbuffer, similar to swap_buffers
* comment for allocate_textures
* texture_mask is managed at the st_fb level

src/gallium/state_trackers/dri/dri1.c
src/gallium/state_trackers/dri/dri1.h
src/gallium/state_trackers/dri/dri_st_api.c

index 240bc69efd5a6d7fed7dfb3a143406559f9ebf5c..9108d41bd945fc1edc4f6aa76a6ba5b4df9bf8c5 100644 (file)
@@ -318,23 +318,23 @@ dri1_copy_to_front(struct dri_context *ctx,
 }
 
 void
 }
 
 void
-dri1_flush_frontbuffer(struct dri_drawable *drawable,
-                       struct pipe_texture *ptex)
+dri1_flush_frontbuffer(struct dri_drawable *draw,
+                       enum st_attachment_type statt)
 {
 {
-   struct st_api *stapi = dri_get_st_api();
-   struct dri_screen *screen = dri_screen(drawable->sPriv);
+   struct dri_context *ctx = dri_get_current();
+   struct dri_screen *screen = dri_screen(draw->sPriv);
    struct pipe_screen *pipe_screen = screen->pipe_screen;
    struct pipe_screen *pipe_screen = screen->pipe_screen;
-   struct dri_context *ctx;
    struct pipe_fence_handle *dummy_fence;
    struct pipe_fence_handle *dummy_fence;
-   struct st_context_iface *st = stapi->get_current(stapi);
-
-   if (!st)
-      return;
+   struct pipe_texture *ptex;
 
 
-   ctx = (struct dri_context *) st->st_manager_private;
+   if (!ctx)
+      return;                         /* For now */
 
 
-   dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence);
-   pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+   ptex = draw->textures[statt];
+   if (ptex) {
+      dri1_copy_to_front(ctx, ptex, ctx->dPriv, NULL, &dummy_fence);
+      pipe_screen->fence_reference(pipe_screen, &dummy_fence, NULL);
+   }
 
    /**
     * FIXME: Do we need swap throttling here?
 
    /**
     * FIXME: Do we need swap throttling here?
@@ -399,17 +399,31 @@ dri1_copy_sub_buffer(__DRIdrawable * dPriv, int x, int y, int w, int h)
    }
 }
 
    }
 }
 
+/**
+ * Allocate framebuffer attachments.
+ *
+ * During fixed-size operation, the function keeps allocating new attachments
+ * as they are requested. Unused attachments are not removed, not until the
+ * framebuffer is resized or destroyed.
+ */
 void
 dri1_allocate_textures(struct dri_drawable *drawable,
 void
 dri1_allocate_textures(struct dri_drawable *drawable,
-                       unsigned width, unsigned height,
                        unsigned mask)
 {
    struct dri_screen *screen = dri_screen(drawable->sPriv);
    struct pipe_texture templ;
                        unsigned mask)
 {
    struct dri_screen *screen = dri_screen(drawable->sPriv);
    struct pipe_texture templ;
+   unsigned width, height;
+   boolean resized;
    int i;
 
    int i;
 
+   width  = drawable->dPriv->w;
+   height = drawable->dPriv->h;
+
+   resized = (drawable->old_w != width ||
+              drawable->old_h != height);
+
    /* remove outdated textures */
    /* remove outdated textures */
-   if (drawable->old_w != width || drawable->old_h != height) {
+   if (resized) {
       for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
          pipe_texture_reference(&drawable->textures[i], NULL);
    }
       for (i = 0; i < ST_ATTACHMENT_COUNT; i++)
          pipe_texture_reference(&drawable->textures[i], NULL);
    }
@@ -427,9 +441,6 @@ dri1_allocate_textures(struct dri_drawable *drawable,
 
       /* the texture already exists or not requested */
       if (drawable->textures[i] || !(mask & (1 << i))) {
 
       /* the texture already exists or not requested */
       if (drawable->textures[i] || !(mask & (1 << i))) {
-         /* remember the texture */
-         if (drawable->textures[i])
-            mask |= (1 << i);
          continue;
       }
 
          continue;
       }
 
@@ -462,7 +473,6 @@ dri1_allocate_textures(struct dri_drawable *drawable,
 
    drawable->old_w = width;
    drawable->old_h = height;
 
    drawable->old_w = width;
    drawable->old_h = height;
-   drawable->texture_mask = mask;
 }
 
 static void
 }
 
 static void
index e83571e57bec9d3e6cc285a1c1e70411ac6e8f0f..f1004281b54c4085033700cbcb253313c3c83801 100644 (file)
@@ -45,11 +45,10 @@ dri1_init_screen(__DRIscreen * sPriv);
 
 void
 dri1_flush_frontbuffer(struct dri_drawable *drawable,
 
 void
 dri1_flush_frontbuffer(struct dri_drawable *drawable,
-                       struct pipe_texture *ptex);
+                       enum st_attachment_type statt);
 
 void
 dri1_allocate_textures(struct dri_drawable *drawable,
 
 void
 dri1_allocate_textures(struct dri_drawable *drawable,
-                       unsigned width, unsigned height,
                        unsigned mask);
 
 void dri1_swap_buffers(__DRIdrawable * dPriv);
                        unsigned mask);
 
 void dri1_swap_buffers(__DRIdrawable * dPriv);
index e721e55459de847dcdff11487e5fed70ed9d562c..2cdfd257b011fc24a33e8e5dbe855b4a50e79be7 100644 (file)
@@ -285,8 +285,7 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
    if (drawable->texture_stamp != drawable->dPriv->lastStamp ||
        (statt_mask & ~drawable->texture_mask)) {
       if (__dri1_api_hooks) {
    if (drawable->texture_stamp != drawable->dPriv->lastStamp ||
        (statt_mask & ~drawable->texture_mask)) {
       if (__dri1_api_hooks) {
-         dri1_allocate_textures(drawable,
-               drawable->dPriv->w, drawable->dPriv->h, statt_mask);
+         dri1_allocate_textures(drawable, statt_mask);
       }
       else {
          __DRIbuffer *buffers;
       }
       else {
          __DRIbuffer *buffers;
@@ -296,6 +295,12 @@ dri_st_framebuffer_validate(struct st_framebuffer_iface *stfbi,
          dri_drawable_process_buffers(drawable, buffers, num_buffers);
       }
 
          dri_drawable_process_buffers(drawable, buffers, num_buffers);
       }
 
+      /* add existing textures */
+      for (i = 0; i < ST_ATTACHMENT_COUNT; i++) {
+         if (drawable->textures[i])
+            statt_mask |= (1 << i);
+      }
+
       drawable->texture_stamp = drawable->dPriv->lastStamp;
       drawable->texture_mask = statt_mask;
    }
       drawable->texture_stamp = drawable->dPriv->lastStamp;
       drawable->texture_mask = statt_mask;
    }
@@ -321,9 +326,7 @@ dri_st_framebuffer_flush_front(struct st_framebuffer_iface *stfbi,
       drawable->sPriv->dri2.loader;
 
    if (__dri1_api_hooks) {
       drawable->sPriv->dri2.loader;
 
    if (__dri1_api_hooks) {
-      struct pipe_texture *ptex = drawable->textures[statt];
-      if (ptex)
-         dri1_flush_frontbuffer(drawable, ptex);
+      dri1_flush_frontbuffer(drawable, statt);
       return TRUE;
    }
 
       return TRUE;
    }