summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2008-02-20 13:24:52 -0700
committerBrian <brian.paul@tungstengraphics.com>2008-02-20 13:24:52 -0700
commitd5640a2dbdc4454d0405f2cd5b18fc49b1ca7694 (patch)
tree5e0ed97d89f54d9f40c1911f926ead5a65c7e37d
parent1d45787d4a70c55e7fa899d13b9139430e2fa3e2 (diff)
gallium: new pipe->texture_update() function
Called whenever texture data is changed (glTexImage, glTexSubImage, glCopyTexSubImage, etc).
-rw-r--r--src/gallium/drivers/cell/ppu/cell_context.c1
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c8
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.h3
-rw-r--r--src/gallium/drivers/failover/fo_context.c9
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c1
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c7
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.h4
-rw-r--r--src/gallium/drivers/i965simple/brw_context.c1
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c8
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.h3
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c1
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c15
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.h4
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c45
-rw-r--r--src/gallium/include/pipe/p_context.h8
-rw-r--r--src/mesa/state_tracker/st_atom_texture.c14
16 files changed, 104 insertions, 28 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_context.c b/src/gallium/drivers/cell/ppu/cell_context.c
index e1eb22f468..b6ba14578c 100644
--- a/src/gallium/drivers/cell/ppu/cell_context.c
+++ b/src/gallium/drivers/cell/ppu/cell_context.c
@@ -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;
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index c8ef36002f..4629eb1320 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -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()
*/
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.h b/src/gallium/drivers/cell/ppu/cell_texture.h
index 0264fed88e..07e81582f4 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.h
+++ b/src/gallium/drivers/cell/ppu/cell_texture.h
@@ -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,
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 7ce4a7df17..156f7399b0 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -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;
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index 7f71f8fd4f..97773f1256 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -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;
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 6d37ae3d74..4ba76d19ad 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -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? */
+}
diff --git a/src/gallium/drivers/i915simple/i915_texture.h b/src/gallium/drivers/i915simple/i915_texture.h
index 330d111dc7..0312977552 100644
--- a/src/gallium/drivers/i915simple/i915_texture.h
+++ b/src/gallium/drivers/i915simple/i915_texture.h
@@ -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 */
diff --git a/src/gallium/drivers/i965simple/brw_context.c b/src/gallium/drivers/i965simple/brw_context.c
index 5e58701e91..2e2380a8d6 100644
--- a/src/gallium/drivers/i965simple/brw_context.c
+++ b/src/gallium/drivers/i965simple/brw_context.c
@@ -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);
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 90561f1307..220591da9a 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -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? */
+}
+
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.h b/src/gallium/drivers/i965simple/brw_tex_layout.h
index cfd6b1ef3a..7d118d0fa8 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.h
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.h
@@ -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
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index 254c6adca4..316020cba6 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -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;
/*
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 6de7a9b543..8f31f05e47 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -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()
*/
diff --git a/src/gallium/drivers/softpipe/sp_texture.h b/src/gallium/drivers/softpipe/sp_texture.h
index fa646c0de9..50fc100427 100644
--- a/src/gallium/drivers/softpipe/sp_texture.h
+++ b/src/gallium/drivers/softpipe/sp_texture.h
@@ -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,
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 9ed3c5072d..da30dd6c48 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -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);
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
index 39f95695fb..036c4c8964 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -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,
diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c
index 9fead7e314..a4ac726816 100644
--- a/src/mesa/state_tracker/st_atom_texture.c
+++ b/src/mesa/state_tracker/st_atom_texture.c
@@ -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;
+ }
+
}
}