summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
diff options
context:
space:
mode:
authorBrian <brian.paul@tungstengraphics.com>2007-10-25 19:27:29 -0600
committerBrian <brian.paul@tungstengraphics.com>2007-10-25 20:35:23 -0600
commitf684120417c6b3ca9e7486ffeb24fe88e428834d (patch)
treec4e9a773294e968866e601a45032f6312dab7b79 /src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
parent616112ea2e0eefea356be228bff8754ee955d8b3 (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/drivers/dri/intel_winsys/intel_winsys_i915.c')
-rw-r--r--src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
index f6eb050152..c481495309 100644
--- a/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
+++ b/src/mesa/drivers/dri/intel_winsys/intel_winsys_i915.c
@@ -120,6 +120,64 @@ static void intel_i915_batch_flush( struct i915_winsys *sws )
+static struct pipe_region *
+intel_i915_region_alloc(struct pipe_winsys *winsys,
+ unsigned cpp, unsigned width,
+ unsigned height, unsigned flags)
+{
+ 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 = winsys->buffer_create( winsys, alignment );
+
+ winsys->buffer_data( winsys,
+ region->buffer,
+ pitch * cpp * height,
+ NULL );
+
+ return region;
+}
+
+static void
+intel_i915_region_release(struct pipe_winsys *winsys,
+ struct pipe_region **region)
+{
+ if (!*region)
+ return;
+
+ assert((*region)->refcount > 0);
+ (*region)->refcount--;
+
+ if ((*region)->refcount == 0) {
+ assert((*region)->map_refcount == 0);
+
+ winsys->buffer_reference( winsys,
+ &((*region)->buffer), NULL );
+ free(*region);
+ }
+ *region = NULL;
+}
+
struct pipe_context *
intel_create_i915simple( struct intel_context *intel )
@@ -135,6 +193,9 @@ intel_create_i915simple( struct intel_context *intel )
iws->winsys.batch_flush = intel_i915_batch_flush;
iws->intel = intel;
+ iws->winsys.region_alloc = intel_i915_region_alloc;
+ iws->winsys.region_release = intel_i915_region_release;
+
/* Create the i915simple context:
*/
return i915_create( intel_create_pipe_winsys(intel),