summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/softpipe/sp_texture.c
diff options
context:
space:
mode:
authorBrian <[email protected]>2008-02-27 09:47:46 -0700
committerBrian <[email protected]>2008-02-27 09:47:46 -0700
commit4f36cf5858a7e53181c3578685675e15fbfcbb82 (patch)
tree5067a58e3f441b3028a9526d9eb9ace76445c739 /src/gallium/drivers/softpipe/sp_texture.c
parentef6c82b0c13573df1aab7acd6f4f9ef9076f421f (diff)
gallium: implement pipe_screen for softpipe driver
Diffstat (limited to 'src/gallium/drivers/softpipe/sp_texture.c')
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c57
1 files changed, 49 insertions, 8 deletions
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 15945219612..f0e8350a4a1 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -80,23 +80,34 @@ softpipe_texture_layout(struct softpipe_texture * spt)
}
+/* XXX temporary */
static struct pipe_texture *
softpipe_texture_create(struct pipe_context *pipe,
const struct pipe_texture *templat)
{
+ return pipe->screen->texture_create(pipe->screen, 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.pipe = pipe;
+ spt->base.pipe = NULL;
+ 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;
@@ -108,9 +119,18 @@ softpipe_texture_create(struct pipe_context *pipe,
}
+/* XXX temporary */
static void
softpipe_texture_release(struct pipe_context *pipe, struct pipe_texture **pt)
{
+ return pipe->screen->texture_release(pipe->screen, pt);
+}
+
+
+static void
+softpipe_texture_release_screen(struct pipe_screen *screen,
+ struct pipe_texture **pt)
+{
if (!*pt)
return;
@@ -125,7 +145,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);
}
@@ -150,21 +170,32 @@ softpipe_texture_update(struct pipe_context *pipe,
/**
* Called via pipe->get_tex_surface()
*/
+/* XXX temporary */
static struct pipe_surface *
softpipe_get_tex_surface(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level, unsigned zslice)
{
+ return pipe->screen->get_tex_surface(pipe->screen, pt, face, level, 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];
@@ -176,7 +207,8 @@ 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);
}
@@ -194,3 +226,12 @@ softpipe_init_texture_funcs( struct softpipe_context *softpipe )
softpipe->pipe.texture_update = softpipe_texture_update;
softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
}
+
+
+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;
+}