diff options
author | Brian <brian.paul@tungstengraphics.com> | 2007-10-25 19:27:29 -0600 |
---|---|---|
committer | Brian <brian.paul@tungstengraphics.com> | 2007-10-25 20:35:23 -0600 |
commit | f684120417c6b3ca9e7486ffeb24fe88e428834d (patch) | |
tree | c4e9a773294e968866e601a45032f6312dab7b79 /src/mesa/pipe | |
parent | 616112ea2e0eefea356be228bff8754ee955d8b3 (diff) |
Move region_alloc() and region_release() to pipe_winsys.
This allows regions to be allocated w/out a rendering context.
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r-- | src/mesa/pipe/failover/fo_context.c | 2 | ||||
-rw-r--r-- | src/mesa/pipe/i915simple/i915_regions.c | 61 | ||||
-rw-r--r-- | src/mesa/pipe/p_context.h | 13 | ||||
-rw-r--r-- | src/mesa/pipe/p_winsys.h | 14 | ||||
-rw-r--r-- | src/mesa/pipe/softpipe/sp_region.c | 57 |
5 files changed, 18 insertions, 129 deletions
diff --git a/src/mesa/pipe/failover/fo_context.c b/src/mesa/pipe/failover/fo_context.c index 076d516583..a3a0296598 100644 --- a/src/mesa/pipe/failover/fo_context.c +++ b/src/mesa/pipe/failover/fo_context.c @@ -137,8 +137,6 @@ struct pipe_context *failover_create( struct pipe_context *hw, failover->pipe.surface_alloc = hw->surface_alloc; failover->pipe.get_tex_surface = hw->get_tex_surface; - failover->pipe.region_alloc = hw->region_alloc; - failover->pipe.region_release = hw->region_release; failover->pipe.region_map = hw->region_map; failover->pipe.region_unmap = hw->region_unmap; failover->pipe.region_data = hw->region_data; diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c index 577a6adfd8..0410446326 100644 --- a/src/mesa/pipe/i915simple/i915_regions.c +++ b/src/mesa/pipe/i915simple/i915_regions.c @@ -69,65 +69,6 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region) } } -static struct pipe_region * -i915_region_alloc(struct pipe_context *pipe, - unsigned cpp, unsigned width, unsigned height, unsigned flags) -{ - struct i915_context *i915 = i915_context( pipe ); - struct pipe_region *region = calloc(sizeof(*region), 1); - const unsigned alignment = 64; - - /* Choose a pitch to match hardware requirements - requires 64 byte - * alignment of render targets. - * - * XXX: is this ok for textures?? - * clearly want to be able to render to textures under some - * circumstances, but maybe not always a requirement. - */ - unsigned pitch; - - /* XXX is the pitch different for textures vs. drawables? */ - if (flags & PIPE_SURFACE_FLAG_TEXTURE) /* or PIPE_SURFACE_FLAG_RENDER? */ - pitch = ((cpp * width + 63) & ~63) / cpp; - else - pitch = ((cpp * width + 63) & ~63) / cpp; - - region->cpp = cpp; - region->pitch = pitch; - region->height = height; /* needed? */ - region->refcount = 1; - - region->buffer = i915->pipe.winsys->buffer_create( i915->pipe.winsys, alignment ); - - i915->pipe.winsys->buffer_data( i915->pipe.winsys, - region->buffer, - pitch * cpp * height, - NULL ); - - return region; -} - -static void -i915_region_release(struct pipe_context *pipe, struct pipe_region **region) -{ - struct i915_context *i915 = i915_context( pipe ); - - if (!*region) - return; - - assert((*region)->refcount > 0); - (*region)->refcount--; - - if ((*region)->refcount == 0) { - assert((*region)->map_refcount == 0); - - i915->pipe.winsys->buffer_reference( i915->pipe.winsys, - &((*region)->buffer), NULL ); - free(*region); - } - *region = NULL; -} - /* * XXX Move this into core Mesa? @@ -302,8 +243,6 @@ i915_init_region_functions(struct i915_context *i915) { i915->pipe.region_map = i915_region_map; i915->pipe.region_unmap = i915_region_unmap; - i915->pipe.region_alloc = i915_region_alloc; - i915->pipe.region_release = i915_region_release; i915->pipe.region_data = i915_region_data; i915->pipe.region_copy = i915_region_copy; i915->pipe.region_fill = i915_region_fill; diff --git a/src/mesa/pipe/p_context.h b/src/mesa/pipe/p_context.h index a22ea3a8a0..b9de3667e5 100644 --- a/src/mesa/pipe/p_context.h +++ b/src/mesa/pipe/p_context.h @@ -208,14 +208,7 @@ struct pipe_context { /* * Memory region functions - * Some of these may go away... */ - struct pipe_region *(*region_alloc)(struct pipe_context *pipe, - unsigned cpp, unsigned width, unsigned height, - unsigned flags); - - void (*region_release)(struct pipe_context *pipe, struct pipe_region **r); - ubyte *(*region_map)(struct pipe_context *pipe, struct pipe_region *r); void (*region_unmap)(struct pipe_context *pipe, struct pipe_region *r); @@ -225,7 +218,8 @@ struct pipe_context { unsigned dest_offset, unsigned destx, unsigned desty, const void *src, unsigned src_stride, - unsigned srcx, unsigned srcy, unsigned width, unsigned height); + unsigned srcx, unsigned srcy, + unsigned width, unsigned height); void (*region_copy)(struct pipe_context *pipe, struct pipe_region *dest, @@ -234,7 +228,8 @@ struct pipe_context { struct pipe_region *src, /* don't make this const - need to map/unmap */ unsigned src_offset, - unsigned srcx, unsigned srcy, unsigned width, unsigned height); + unsigned srcx, unsigned srcy, + unsigned width, unsigned height); void (*region_fill)(struct pipe_context *pipe, struct pipe_region *dst, diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h index 7e5d394a90..3b04c44733 100644 --- a/src/mesa/pipe/p_winsys.h +++ b/src/mesa/pipe/p_winsys.h @@ -50,6 +50,13 @@ struct pipe_buffer_handle; * driver and the hardware driver about the format of command buffers, * etc. */ + + +struct pipe_region; + +/** Opaque type */ +struct pipe_buffer_handle; + struct pipe_winsys { /** @@ -63,6 +70,13 @@ struct pipe_winsys const char *, ... ); + struct pipe_region *(*region_alloc)(struct pipe_winsys *ws, + unsigned cpp, unsigned width, + unsigned height, unsigned flags); + + void (*region_release)(struct pipe_winsys *ws, struct pipe_region **r); + + /** * The buffer manager is modeled after the dri_bufmgr interface, which * in turn is modeled after the ARB_vertex_buffer_object extension, diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c index 4317a9ea1b..80a67dcabc 100644 --- a/src/mesa/pipe/softpipe/sp_region.c +++ b/src/mesa/pipe/softpipe/sp_region.c @@ -38,16 +38,6 @@ #include "pipe/p_defines.h" -/** - * Round n up to next multiple. - */ -static INLINE unsigned -round_up(unsigned n, unsigned multiple) -{ - return (n + multiple - 1) & ~(multiple - 1); -} - - static ubyte * sp_region_map(struct pipe_context *pipe, struct pipe_region *region) @@ -79,51 +69,6 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region) } } -static struct pipe_region * -sp_region_alloc(struct pipe_context *pipe, - unsigned cpp, unsigned width, unsigned height, unsigned flags) -{ - struct softpipe_context *sp = softpipe_context( pipe ); - struct pipe_region *region = CALLOC_STRUCT(pipe_region); - const unsigned alignment = 64; - - region->cpp = cpp; - region->pitch = round_up(width, alignment / cpp); - region->height = height; - region->refcount = 1; - - assert(region->pitch > 0); - - region->buffer = sp->pipe.winsys->buffer_create( sp->pipe.winsys, alignment ); - - /* NULL data --> just allocate the space */ - sp->pipe.winsys->buffer_data( sp->pipe.winsys, - region->buffer, - region->pitch * cpp * height, - NULL ); - return region; -} - -static void -sp_region_release(struct pipe_context *pipe, struct pipe_region **region) -{ - struct softpipe_context *sp = softpipe_context( pipe ); - - if (!*region) - return; - - assert((*region)->refcount > 0); - (*region)->refcount--; - - if ((*region)->refcount == 0) { - assert((*region)->map_refcount == 0); - - sp->pipe.winsys->buffer_reference( sp->pipe.winsys, - &((*region)->buffer), NULL ); - free(*region); - } - *region = NULL; -} /** @@ -313,8 +258,6 @@ sp_init_region_functions(struct softpipe_context *sp) { sp->pipe.region_map = sp_region_map; sp->pipe.region_unmap = sp_region_unmap; - sp->pipe.region_alloc = sp_region_alloc; - sp->pipe.region_release = sp_region_release; sp->pipe.region_data = sp_region_data; sp->pipe.region_copy = sp_region_copy; sp->pipe.region_fill = sp_region_fill; |