summaryrefslogtreecommitdiff
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <brian@i915.localnet.net>2007-08-07 13:13:41 -0600
committerBrian <brian@i915.localnet.net>2007-08-07 13:13:41 -0600
commitb23f358cbc36a2b6a9e7609290a7458fa48f7ccb (patch)
treeb993aff460f679f2c28b06e5f123f90d687255d8 /src/mesa/pipe/softpipe
parent281dad225947b4f00bfc5e785d92d2a7c2f06afe (diff)
sketch out new pipe surface/sampler types
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c1
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c42
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.h6
3 files changed, 49 insertions, 0 deletions
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 139afde376..264f3d6e58 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -201,6 +201,7 @@ struct pipe_context *softpipe_create( struct softpipe_winsys *sws )
softpipe->pipe.get_occlusion_counter = softpipe_get_occlusion_counter;
softpipe->pipe.mipmap_tree_layout = softpipe_mipmap_tree_layout;
+ softpipe->pipe.get_tex_surface = softpipe_get_tex_surface;
softpipe->quad.polygon_stipple = sp_quad_polygon_stipple_stage(softpipe);
softpipe->quad.shade = sp_quad_shade_stage(softpipe);
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index 819243ae6e..6512f1d789 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -351,12 +351,54 @@ sp_surface_alloc(struct pipe_context *pipe, GLenum format)
return NULL;
sps->surface.format = format;
+ sps->surface.refcount = 1;
init_quad_funcs(sps);
return &sps->surface;
}
+
+
+
+/**
+ * Called via pipe->get_tex_surface()
+ * XXX is this in the right place?
+ */
+struct pipe_surface *
+softpipe_get_tex_surface(struct pipe_context *pipe,
+ struct pipe_mipmap_tree *mt,
+ GLuint face, GLuint level, GLuint zslice)
+{
+ struct pipe_surface *ps;
+ GLuint offset; /* in bytes */
+
+ offset = mt->level[level].level_offset;
+
+ if (mt->target == GL_TEXTURE_CUBE_MAP_ARB) {
+ offset += mt->level[level].image_offset[face] * mt->cpp;
+ }
+ else if (mt->target == GL_TEXTURE_3D) {
+ offset += mt->level[level].image_offset[zslice] * mt->cpp;
+ }
+ else {
+ assert(face == 0);
+ assert(zslice == 0);
+ }
+
+ ps = pipe->surface_alloc(pipe, mt->internal_format);
+ if (ps) {
+ assert(ps->format);
+ assert(ps->refcount);
+ ps->region = mt->region;
+ ps->width = mt->level[level].width;
+ ps->height = mt->level[level].height;
+ ps->offset = offset;
+ }
+ return ps;
+}
+
+
void
sp_init_surface_functions(struct softpipe_context *sp)
{
diff --git a/src/mesa/pipe/softpipe/sp_surface.h b/src/mesa/pipe/softpipe/sp_surface.h
index 6782bba376..90086c327f 100644
--- a/src/mesa/pipe/softpipe/sp_surface.h
+++ b/src/mesa/pipe/softpipe/sp_surface.h
@@ -85,6 +85,12 @@ struct softpipe_surface {
};
+extern struct pipe_surface *
+softpipe_get_tex_surface(struct pipe_context *pipe,
+ struct pipe_mipmap_tree *mt,
+ GLuint face, GLuint level, GLuint zslice);
+
+
/** Cast wrapper */
static INLINE struct softpipe_surface *
softpipe_surface(struct pipe_surface *ps)