summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe/sp_texture.c
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-02-29 13:24:31 +1100
committerBen Skeggs <[email protected]>2008-02-29 13:24:31 +1100
commit8c77e6f674206ef34ab15026b08e495209dcd4ea (patch)
tree7d21d99eee6970b340bc7a3afedeadfc99dd5745 /src/gallium/drivers/softpipe/sp_texture.c
parent68ef52886263690632552ae187a4673945c2ab74 (diff)
parentebe3b34ad225e320a09bb4069ce4d24808386327 (diff)
Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_texture.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c84
1 files changed, 51 insertions, 33 deletions
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 6ba0f09e0a1..c605ed925b2 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -80,22 +80,24 @@ softpipe_texture_layout(struct softpipe_texture * spt)
}
-struct pipe_texture *
-softpipe_texture_create(struct pipe_context *pipe,
- const struct pipe_texture *templat)
+static struct pipe_texture *
+softpipe_texture_create_screen(struct pipe_screen *screen,
+ const struct pipe_texture *templat)
{
+ struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = CALLOC_STRUCT(softpipe_texture);
if (!spt)
return NULL;
spt->base = *templat;
spt->base.refcount = 1;
+ spt->base.screen = screen;
softpipe_texture_layout(spt);
- spt->buffer = pipe->winsys->buffer_create(pipe->winsys, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- spt->buffer_size);
+ spt->buffer = ws->buffer_create(ws, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ spt->buffer_size);
if (!spt->buffer) {
FREE(spt);
return NULL;
@@ -107,8 +109,9 @@ softpipe_texture_create(struct pipe_context *pipe,
}
-void
-softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
+static void
+softpipe_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
{
if (!*pt)
return;
@@ -124,7 +127,7 @@ softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
DBG("%s deleting %p\n", __FUNCTION__, (void *) spt);
*/
- pipe_buffer_reference(pipe->winsys, &spt->buffer, NULL);
+ pipe_buffer_reference(screen->winsys, &spt->buffer, NULL);
FREE(spt);
}
@@ -132,38 +135,22 @@ 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()
- */
-struct pipe_surface *
-softpipe_get_tex_surface(struct pipe_context *pipe,
- struct pipe_texture *pt,
- unsigned face, unsigned level, unsigned zslice)
+static struct pipe_surface *
+softpipe_get_tex_surface_screen(struct pipe_screen *screen,
+ struct pipe_texture *pt,
+ unsigned face, unsigned level, unsigned zslice)
{
+ struct pipe_winsys *ws = screen->winsys;
struct softpipe_texture *spt = softpipe_texture(pt);
struct pipe_surface *ps;
assert(level <= pt->last_level);
- ps = pipe->winsys->surface_alloc(pipe->winsys);
+ ps = ws->surface_alloc(ws);
if (ps) {
assert(ps->refcount);
assert(ps->winsys);
- pipe_buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ pipe_buffer_reference(ws, &ps->buffer, spt->buffer);
ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
@@ -175,10 +162,41 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
ps->offset += ((pt->target == PIPE_TEXTURE_CUBE) ? face : zslice) *
(pt->compressed ? ps->height/4 : ps->height) *
ps->width * ps->cpp;
- } else {
+ }
+ else {
assert(face == 0);
assert(zslice == 0);
}
}
return ps;
}
+
+
+static 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]);
+ }
+ }
+}
+
+
+void
+softpipe_init_texture_funcs( struct softpipe_context *softpipe )
+{
+ softpipe->pipe.texture_update = softpipe_texture_update;
+}
+
+
+void
+softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
+{
+ screen->texture_create = softpipe_texture_create_screen;
+ screen->texture_release = softpipe_texture_release_screen;
+ screen->get_tex_surface = softpipe_get_tex_surface_screen;
+}