gallium: new pipe->texture_update() function
authorBrian <brian.paul@tungstengraphics.com>
Wed, 20 Feb 2008 20:24:52 +0000 (13:24 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Wed, 20 Feb 2008 20:24:52 +0000 (13:24 -0700)
Called whenever texture data is changed (glTexImage, glTexSubImage,
glCopyTexSubImage, etc).

16 files changed:
src/gallium/drivers/cell/ppu/cell_context.c
src/gallium/drivers/cell/ppu/cell_texture.c
src/gallium/drivers/cell/ppu/cell_texture.h
src/gallium/drivers/failover/fo_context.c
src/gallium/drivers/i915simple/i915_context.c
src/gallium/drivers/i915simple/i915_texture.c
src/gallium/drivers/i915simple/i915_texture.h
src/gallium/drivers/i965simple/brw_context.c
src/gallium/drivers/i965simple/brw_tex_layout.c
src/gallium/drivers/i965simple/brw_tex_layout.h
src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_texture.c
src/gallium/drivers/softpipe/sp_texture.h
src/gallium/drivers/softpipe/sp_tile_cache.c
src/gallium/include/pipe/p_context.h
src/mesa/state_tracker/st_atom_texture.c

index e1eb22f4685b6e22a2e3a649b9097ce588fa6bd3..b6ba14578c64c868a9b3e47804d96998327f44a2 100644 (file)
@@ -244,6 +244,7 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
    /* textures */
    cell->pipe.texture_create = cell_texture_create;
    cell->pipe.texture_release = cell_texture_release;
+   cell->pipe.texture_update = cell_texture_update;
    cell->pipe.get_tex_surface = cell_get_tex_surface;
 
    cell->pipe.set_sampler_texture = cell_set_sampler_texture;
index c8ef36002f7376d6ae615f477737ad17271a1f20..4629eb13201900cb12eded60c02fd52c8e9dacc8 100644 (file)
@@ -128,6 +128,14 @@ cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
 }
 
 
+void
+cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+   /* XXX TO DO:  re-tile the texture data ... */
+
+}
+
+
 /**
  * Called via pipe->get_tex_surface()
  */
index 0264fed88e68232785dd7665f0f9395fb27cb14a..07e81582f40fedbccc7b2e52e76b905114fda2b4 100644 (file)
@@ -67,6 +67,9 @@ cell_texture_create(struct pipe_context *pipe,
 extern void
 cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
 
+extern void
+cell_texture_update(struct pipe_context *pipe, struct pipe_texture *texture);
+
 extern struct pipe_surface *
 cell_get_tex_surface(struct pipe_context *pipe,
                      struct pipe_texture *pt,
index 7ce4a7df17e2ddbf4704ddbc59859e6eaf0f641c..156f7399b031495c24e27702f0bbada438a909fc 100644 (file)
@@ -137,15 +137,14 @@ struct pipe_context *failover_create( struct pipe_context *hw,
 
    failover_init_state_functions( failover );
 
-#if 0
-   failover->pipe.surface_alloc = hw->surface_alloc;
-#endif
-   failover->pipe.get_tex_surface = hw->get_tex_surface;
-
    failover->pipe.surface_copy = hw->surface_copy;
    failover->pipe.surface_fill = hw->surface_fill;
+
    failover->pipe.texture_create = hw->texture_create;
    failover->pipe.texture_release = hw->texture_release;
+   failover->pipe.texture_update = hw->texture_update;
+   failover->pipe.get_tex_surface = hw->get_tex_surface;
+
    failover->pipe.flush = hw->flush;
 
    failover->dirty = 0;
index 7f71f8fd4f5d88a3a0dae1c44d86bc102e3b6873..97773f1256805f8c36a2f7354ea98ec98180a8db 100644 (file)
@@ -302,6 +302,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
 
    i915->pipe.texture_create = i915_texture_create;
    i915->pipe.texture_release = i915_texture_release;
+   i915->pipe.texture_update = i915_texture_update;
 
    i915->dirty = ~0;
    i915->hardware_dirty = ~0;
index 6d37ae3d7477a07ee90869c4d8c4eeb3f286eb96..4ba76d19adcb5d1e5400043f59b3d3ab25e693fa 100644 (file)
@@ -534,3 +534,10 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
    }
    *pt = NULL;
 }
+
+
+void
+i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+   /* no-op? */
+}
index 330d111dc789aae8119965043c0c5ad820a5d196..03129775520935786af58a54139cdea11b74bc45 100644 (file)
@@ -14,4 +14,8 @@ extern void
 i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
 
 
+extern void
+i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture);
+
+
 #endif /* I915_TEXTURE_H */
index 5e58701e91cc7911e2ee05f99fbbd4134ca7119a..2e2380a8d6f60d0a6f285c5d815dcc326b62b516 100644 (file)
@@ -224,6 +224,7 @@ struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
    brw->pipe.clear = brw_clear;
    brw->pipe.texture_create  = brw_texture_create;
    brw->pipe.texture_release = brw_texture_release;
+   brw->pipe.texture_update = brw_texture_update;
 
    brw_init_surface_functions(brw);
    brw_init_state_functions(brw);
index 90561f1307d671cc3dceececdd65ad88e9fa56b8..220591da9a43e2257dd863b2e6806e73e3800538 100644 (file)
@@ -351,3 +351,11 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
    }
    *pt = NULL;
 }
+
+
+void
+brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
+{
+   /* no-op? */
+}
+
index cfd6b1ef3ae66c5fa46310cc2fc58c370eec56e4..7d118d0fa89f129ee31090818790f33e104884d7 100644 (file)
@@ -12,4 +12,7 @@ brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat
 extern void
 brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
 
+extern void
+brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture);
+
 #endif
index 254c6adca4404e089a4ac03cd57028c5f8a198ec..316020cba633e42130f0de81f2aed1e87ba89285 100644 (file)
@@ -283,6 +283,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
    /* textures */
    softpipe->pipe.texture_create = softpipe_texture_create;
    softpipe->pipe.texture_release = softpipe_texture_release;
+   softpipe->pipe.texture_update = softpipe_texture_update;
    softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
 
    /*
index 6de7a9b543bd22efafc4e36f42bfb53d1dc66d1c..8f31f05e478feff7ab567e4c02d53c8ff0631572 100644 (file)
@@ -39,6 +39,7 @@
 #include "sp_context.h"
 #include "sp_state.h"
 #include "sp_texture.h"
+#include "sp_tile_cache.h"
 
 
 /* Simple, maximally packed layout.
@@ -128,6 +129,20 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
 }
 
 
+void
+softpipe_texture_update(struct pipe_context *pipe,
+                        struct pipe_texture *texture)
+{
+   struct softpipe_context *softpipe = softpipe_context(pipe);
+   uint unit;
+   for (unit = 0; unit < PIPE_MAX_SAMPLERS; unit++) {
+      if (softpipe->texture[unit] == texture) {
+         sp_flush_tile_cache(softpipe, softpipe->tex_cache[unit]);
+      }
+   }
+}
+
+
 /**
  * Called via pipe->get_tex_surface()
  */
index fa646c0de9f93d20bca02a591abfec2acf9f13fa..50fc10042747f9e315f87a539be1b6c1d521c511 100644 (file)
@@ -62,6 +62,10 @@ softpipe_texture_create(struct pipe_context *pipe,
 extern void
 softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
 
+extern void
+softpipe_texture_update(struct pipe_context *pipe,
+                        struct pipe_texture *texture);
+
 extern struct pipe_surface *
 softpipe_get_tex_surface(struct pipe_context *pipe,
                          struct pipe_texture *pt,
index 9ed3c5072d018dc1a8abfeb16e1f3a6504f05bd1..da30dd6c4847f8ebbf2c901cf0fe995b08ff327f 100644 (file)
@@ -359,30 +359,37 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
    struct pipe_surface *ps = tc->surface;
    int inuse = 0, pos;
 
-   if (!ps || !ps->buffer)
-      return;
-
-   for (pos = 0; pos < NUM_ENTRIES; pos++) {
-      struct softpipe_cached_tile *tile = tc->entries + pos;
-      if (tile->x >= 0) {
-         if (tc->depth_stencil) {
-            pipe_put_tile_raw(pipe, ps,
-                           tile->x, tile->y, TILE_SIZE, TILE_SIZE,
-                           tile->data.depth32, 0/*STRIDE*/);
-         }
-         else {
-            pipe_put_tile_rgba(pipe, ps,
-                               tile->x, tile->y, TILE_SIZE, TILE_SIZE,
-                               (float *) tile->data.color);
+   if (ps && ps->buffer) {
+      /* caching a drawing surface */
+      for (pos = 0; pos < NUM_ENTRIES; pos++) {
+         struct softpipe_cached_tile *tile = tc->entries + pos;
+         if (tile->x >= 0) {
+            if (tc->depth_stencil) {
+               pipe_put_tile_raw(pipe, ps,
+                              tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+                              tile->data.depth32, 0/*STRIDE*/);
+            }
+            else {
+               pipe_put_tile_rgba(pipe, ps,
+                                  tile->x, tile->y, TILE_SIZE, TILE_SIZE,
+                                  (float *) tile->data.color);
+            }
+            tile->x = tile->y = -1;  /* mark as empty */
+            inuse++;
          }
-         tile->x = tile->y = -1;  /* mark as empty */
-         inuse++;
       }
-   }
 
 #if TILE_CLEAR_OPTIMIZATION
-   sp_tile_cache_flush_clear(&softpipe->pipe, tc);
+      sp_tile_cache_flush_clear(&softpipe->pipe, tc);
 #endif
+   }
+   else if (tc->texture) {
+      /* caching a texture, mark all entries as embpy */
+      for (pos = 0; pos < NUM_ENTRIES; pos++) {
+         tc->entries[pos].x = -1;
+      }
+      tc->tex_face = -1;
+   }
 
 #if 0
    debug_printf("flushed tiles in use: %d\n", inuse);
index 39f95695fb68f142087c89289dbbaf137ad8099c..036c4c89649b1ae514140f265f4253cf5251cf69 100644 (file)
@@ -206,6 +206,14 @@ struct pipe_context {
    void (*texture_release)(struct pipe_context *pipe,
                           struct pipe_texture **pt);
 
+   /**
+    * Called when texture data is changed.
+    * Note: we could pass some hints about which mip levels or cube faces
+    * have changed...
+    */
+   void (*texture_update)(struct pipe_context *pipe,
+                          struct pipe_texture *texture);
+
    /** Get a surface which is a "view" into a texture */
    struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
                                            struct pipe_texture *texture,
index 9fead7e314d9ed54759b237a9b7353035c8974de..a4ac72681608f85eb0974205d60d4f961c99ea76 100644 (file)
@@ -67,14 +67,20 @@ update_textures(struct st_context *st)
        * this table before being deleted, otherwise the pointer
        * comparison below could fail.
        */
-      if (st->state.sampler_texture[unit] != stObj ||
-          (stObj && stObj->dirtyData)) {
+      if (st->state.sampler_texture[unit] != stObj) {
          struct pipe_texture *pt = st_get_stobj_texture(stObj);
          st->state.sampler_texture[unit] = stObj;
          st->pipe->set_sampler_texture(st->pipe, unit, pt);
-         if (stObj)
-            stObj->dirtyData = GL_FALSE;
       }
+
+      stObj = st->state.sampler_texture[unit];
+
+      if (stObj && stObj->dirtyData) {
+         struct pipe_texture *pt = st_get_stobj_texture(stObj);
+         st->pipe->texture_update(st->pipe, pt);
+         stObj->dirtyData = GL_FALSE;
+      }
+
    }
 }