gallium: new pipe->texture_update() function
Called whenever texture data is changed (glTexImage, glTexSubImage, glCopyTexSubImage, etc).
This commit is contained in:
@@ -244,6 +244,7 @@ cell_create_context(struct pipe_winsys *winsys, struct cell_winsys *cws)
|
|||||||
/* textures */
|
/* textures */
|
||||||
cell->pipe.texture_create = cell_texture_create;
|
cell->pipe.texture_create = cell_texture_create;
|
||||||
cell->pipe.texture_release = cell_texture_release;
|
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.get_tex_surface = cell_get_tex_surface;
|
||||||
|
|
||||||
cell->pipe.set_sampler_texture = cell_set_sampler_texture;
|
cell->pipe.set_sampler_texture = cell_set_sampler_texture;
|
||||||
|
@@ -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()
|
* Called via pipe->get_tex_surface()
|
||||||
*/
|
*/
|
||||||
|
@@ -67,6 +67,9 @@ cell_texture_create(struct pipe_context *pipe,
|
|||||||
extern void
|
extern void
|
||||||
cell_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
|
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 *
|
extern struct pipe_surface *
|
||||||
cell_get_tex_surface(struct pipe_context *pipe,
|
cell_get_tex_surface(struct pipe_context *pipe,
|
||||||
struct pipe_texture *pt,
|
struct pipe_texture *pt,
|
||||||
|
@@ -137,15 +137,14 @@ struct pipe_context *failover_create( struct pipe_context *hw,
|
|||||||
|
|
||||||
failover_init_state_functions( failover );
|
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_copy = hw->surface_copy;
|
||||||
failover->pipe.surface_fill = hw->surface_fill;
|
failover->pipe.surface_fill = hw->surface_fill;
|
||||||
|
|
||||||
failover->pipe.texture_create = hw->texture_create;
|
failover->pipe.texture_create = hw->texture_create;
|
||||||
failover->pipe.texture_release = hw->texture_release;
|
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->pipe.flush = hw->flush;
|
||||||
|
|
||||||
failover->dirty = 0;
|
failover->dirty = 0;
|
||||||
|
@@ -302,6 +302,7 @@ struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
|
|||||||
|
|
||||||
i915->pipe.texture_create = i915_texture_create;
|
i915->pipe.texture_create = i915_texture_create;
|
||||||
i915->pipe.texture_release = i915_texture_release;
|
i915->pipe.texture_release = i915_texture_release;
|
||||||
|
i915->pipe.texture_update = i915_texture_update;
|
||||||
|
|
||||||
i915->dirty = ~0;
|
i915->dirty = ~0;
|
||||||
i915->hardware_dirty = ~0;
|
i915->hardware_dirty = ~0;
|
||||||
|
@@ -534,3 +534,10 @@ i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
|||||||
}
|
}
|
||||||
*pt = NULL;
|
*pt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
i915_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
|
||||||
|
{
|
||||||
|
/* no-op? */
|
||||||
|
}
|
||||||
|
@@ -14,4 +14,8 @@ extern void
|
|||||||
i915_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
|
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 */
|
#endif /* I915_TEXTURE_H */
|
||||||
|
@@ -224,6 +224,7 @@ struct pipe_context *brw_create(struct pipe_winsys *pipe_winsys,
|
|||||||
brw->pipe.clear = brw_clear;
|
brw->pipe.clear = brw_clear;
|
||||||
brw->pipe.texture_create = brw_texture_create;
|
brw->pipe.texture_create = brw_texture_create;
|
||||||
brw->pipe.texture_release = brw_texture_release;
|
brw->pipe.texture_release = brw_texture_release;
|
||||||
|
brw->pipe.texture_update = brw_texture_update;
|
||||||
|
|
||||||
brw_init_surface_functions(brw);
|
brw_init_surface_functions(brw);
|
||||||
brw_init_state_functions(brw);
|
brw_init_state_functions(brw);
|
||||||
|
@@ -351,3 +351,11 @@ brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
|||||||
}
|
}
|
||||||
*pt = NULL;
|
*pt = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
brw_texture_update(struct pipe_context *pipe, struct pipe_texture *texture)
|
||||||
|
{
|
||||||
|
/* no-op? */
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -12,4 +12,7 @@ brw_texture_create(struct pipe_context *pipe, const struct pipe_texture *templat
|
|||||||
extern void
|
extern void
|
||||||
brw_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
|
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
|
#endif
|
||||||
|
@@ -283,6 +283,7 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
|
|||||||
/* textures */
|
/* textures */
|
||||||
softpipe->pipe.texture_create = softpipe_texture_create;
|
softpipe->pipe.texture_create = softpipe_texture_create;
|
||||||
softpipe->pipe.texture_release = softpipe_texture_release;
|
softpipe->pipe.texture_release = softpipe_texture_release;
|
||||||
|
softpipe->pipe.texture_update = softpipe_texture_update;
|
||||||
softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
|
softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
#include "sp_context.h"
|
#include "sp_context.h"
|
||||||
#include "sp_state.h"
|
#include "sp_state.h"
|
||||||
#include "sp_texture.h"
|
#include "sp_texture.h"
|
||||||
|
#include "sp_tile_cache.h"
|
||||||
|
|
||||||
|
|
||||||
/* Simple, maximally packed layout.
|
/* 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()
|
* Called via pipe->get_tex_surface()
|
||||||
*/
|
*/
|
||||||
|
@@ -62,6 +62,10 @@ softpipe_texture_create(struct pipe_context *pipe,
|
|||||||
extern void
|
extern void
|
||||||
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt);
|
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 *
|
extern struct pipe_surface *
|
||||||
softpipe_get_tex_surface(struct pipe_context *pipe,
|
softpipe_get_tex_surface(struct pipe_context *pipe,
|
||||||
struct pipe_texture *pt,
|
struct pipe_texture *pt,
|
||||||
|
@@ -359,30 +359,37 @@ sp_flush_tile_cache(struct softpipe_context *softpipe,
|
|||||||
struct pipe_surface *ps = tc->surface;
|
struct pipe_surface *ps = tc->surface;
|
||||||
int inuse = 0, pos;
|
int inuse = 0, pos;
|
||||||
|
|
||||||
if (!ps || !ps->buffer)
|
if (ps && ps->buffer) {
|
||||||
return;
|
/* caching a drawing surface */
|
||||||
|
for (pos = 0; pos < NUM_ENTRIES; pos++) {
|
||||||
for (pos = 0; pos < NUM_ENTRIES; pos++) {
|
struct softpipe_cached_tile *tile = tc->entries + pos;
|
||||||
struct softpipe_cached_tile *tile = tc->entries + pos;
|
if (tile->x >= 0) {
|
||||||
if (tile->x >= 0) {
|
if (tc->depth_stencil) {
|
||||||
if (tc->depth_stencil) {
|
pipe_put_tile_raw(pipe, ps,
|
||||||
pipe_put_tile_raw(pipe, ps,
|
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
|
||||||
tile->x, tile->y, TILE_SIZE, TILE_SIZE,
|
tile->data.depth32, 0/*STRIDE*/);
|
||||||
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++;
|
||||||
}
|
}
|
||||||
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++;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#if TILE_CLEAR_OPTIMIZATION
|
#if TILE_CLEAR_OPTIMIZATION
|
||||||
sp_tile_cache_flush_clear(&softpipe->pipe, tc);
|
sp_tile_cache_flush_clear(&softpipe->pipe, tc);
|
||||||
#endif
|
#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
|
#if 0
|
||||||
debug_printf("flushed tiles in use: %d\n", inuse);
|
debug_printf("flushed tiles in use: %d\n", inuse);
|
||||||
|
@@ -206,6 +206,14 @@ struct pipe_context {
|
|||||||
void (*texture_release)(struct pipe_context *pipe,
|
void (*texture_release)(struct pipe_context *pipe,
|
||||||
struct pipe_texture **pt);
|
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 */
|
/** Get a surface which is a "view" into a texture */
|
||||||
struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
|
struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe,
|
||||||
struct pipe_texture *texture,
|
struct pipe_texture *texture,
|
||||||
|
@@ -67,14 +67,20 @@ update_textures(struct st_context *st)
|
|||||||
* this table before being deleted, otherwise the pointer
|
* this table before being deleted, otherwise the pointer
|
||||||
* comparison below could fail.
|
* comparison below could fail.
|
||||||
*/
|
*/
|
||||||
if (st->state.sampler_texture[unit] != stObj ||
|
if (st->state.sampler_texture[unit] != stObj) {
|
||||||
(stObj && stObj->dirtyData)) {
|
|
||||||
struct pipe_texture *pt = st_get_stobj_texture(stObj);
|
struct pipe_texture *pt = st_get_stobj_texture(stObj);
|
||||||
st->state.sampler_texture[unit] = stObj;
|
st->state.sampler_texture[unit] = stObj;
|
||||||
st->pipe->set_sampler_texture(st->pipe, unit, pt);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user