diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i915pipe/intel_fbo.c | 2 | ||||
-rw-r--r-- | src/mesa/drivers/dri/intel/intel_tex_layout.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 15 | ||||
-rw-r--r-- | src/mesa/pipe/p_state.h | 45 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_context.c | 1 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_surface.c | 42 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_surface.h | 6 |
7 files changed, 86 insertions, 27 deletions
diff --git a/src/mesa/drivers/dri/i915pipe/intel_fbo.c b/src/mesa/drivers/dri/i915pipe/intel_fbo.c index a53563f52b..0b6c6a94ee 100644 --- a/src/mesa/drivers/dri/i915pipe/intel_fbo.c +++ b/src/mesa/drivers/dri/i915pipe/intel_fbo.c @@ -578,7 +578,9 @@ intel_render_texture(GLcontext * ctx, } /* store that offset in the region */ +#if 0 st_image->mt->region->draw_offset = imageOffset; +#endif /* update drawing region, etc */ intel_draw_buffer(ctx, fb); diff --git a/src/mesa/drivers/dri/intel/intel_tex_layout.c b/src/mesa/drivers/dri/intel/intel_tex_layout.c index 344aff396f..882d9e04a2 100644 --- a/src/mesa/drivers/dri/intel/intel_tex_layout.c +++ b/src/mesa/drivers/dri/intel/intel_tex_layout.c @@ -32,6 +32,7 @@ #include "macros.h" #include "pipe/p_state.h" +#include "pipe/p_context.h" #include "intel_tex_layout.h" #include "state_tracker/st_mipmap_tree.h" @@ -472,3 +473,4 @@ i945_miptree_layout(struct pipe_context *pipe, struct pipe_mipmap_tree * mt) return GL_TRUE; } + diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index 08b9b18393..3062eda329 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -130,6 +130,10 @@ struct pipe_context { struct pipe_surface *(*surface_alloc)(struct pipe_context *pipe, GLuint format); + struct pipe_surface *(*get_tex_surface)(struct pipe_context *pipe, + struct pipe_mipmap_tree *texture, + GLuint face, GLuint level, + GLuint zslice); /* * Memory region functions @@ -230,5 +234,16 @@ pipe_region_reference(struct pipe_region **dst, struct pipe_region *src) } +static INLINE void +pipe_surface_reference(struct pipe_surface **dst, struct pipe_surface *src) +{ + assert(*dst == NULL); + if (src) { + src->refcount++; + *dst = src; + } +} + + #endif /* PIPE_CONTEXT_H */ diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h index f75d8f1957..e51b9c460f 100644 --- a/src/mesa/pipe/p_state.h +++ b/src/mesa/pipe/p_state.h @@ -245,13 +245,11 @@ struct pipe_region GLuint height; /**< in pixels */ GLubyte *map; /**< only non-NULL when region is actually mapped */ GLuint map_refcount; /**< Reference count for mapping */ - - GLuint draw_offset; /**< Offset of drawing address within the region */ }; /** - * 2D surface. + * 2D surface. This is basically a view into a pipe_region (memory buffer). * May be a renderbuffer, texture mipmap level, etc. */ struct pipe_surface @@ -259,39 +257,32 @@ struct pipe_surface struct pipe_region *region; GLuint format:5; /**< PIPE_FORMAT_x */ GLuint width, height; + GLuint offset; /**< offset from start of region, in bytes */ + GLint refcount; void *rb; /**< Ptr back to renderbuffer (temporary?) */ + + /** get block/tile of pixels from surface */ + void (*get_tile)(struct pipe_surface *ps, + GLuint x, GLuint y, GLuint w, GLuint h, GLfloat *p); + + /** put block/tile of pixels into surface */ + void (*put_tile)(struct pipe_surface *ps, + GLuint x, GLuint y, GLuint w, GLuint h, const GLfloat *p); }; -#if 0 /** - * Texture object. - * Mipmap levels, cube faces, 3D slices can be accessed as surfaces. + * surface sampler object + * XXX prototype */ -struct pipe_texture_object +struct pipe_surface_sampler { - GLuint type:2; /**< PIPE_TEXTURE_x */ - GLuint format:5; /**< PIPE_FORMAT_x */ - GLuint width:13; /**< 13 bits = 8K max size */ - GLuint height:13; - GLuint depth:13; - GLuint mipmapped:1; - - /** to access a 1D or 2D texture object as a surface */ - struct pipe_surface *(*get_2d_surface)(struct pipe_texture_object *pto, - GLuint level); - /** to access a 3D texture object as a surface */ - struct pipe_surface *(*get_3d_surface)(struct pipe_texture_object *pto, - GLuint level, GLuint slice); - /** to access a cube texture object as a surface */ - struct pipe_surface *(*get_cube_surface)(struct pipe_texture_object *pto, - GLuint face, GLuint level); - /** when finished with surface: */ - void (*release_surface)(struct pipe_texture_object *pto, - struct pipe_surface *ps); + struct pipe_sampler_state state; + struct pipe_mipmap_tree *texture; + void (*get_sample)(struct pipe_surface_sampler *sampler, + const GLfloat strq[4], GLfloat rgba[4]); }; -#endif /** 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) |