This allows regions to be allocated w/out a rendering context.
+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 )
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),
#include "renderbuffer.h"
#include "pipe/p_state.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "state_tracker/st_context.h"
struct pipe_context *pipe = ctx->st->pipe;
if (!xrb->St.surface->region) {
int w = 1, h = 1;
- xrb->St.surface->region = pipe->region_alloc(pipe, 1, w, h, 0x0);
+ xrb->St.surface->region = pipe->winsys->region_alloc(pipe->winsys,
+ 1, w, h, 0x0);
}
}
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "pipe/softpipe/sp_context.h"
#include "pipe/softpipe/sp_clear.h"
#include "pipe/softpipe/sp_tile_cache.h"
* functions.
*/
if (pipe)
- xms->surface.surface.region = pipe->region_alloc(pipe, 1, 0, 0, 0x0);
+ xms->surface.surface.region = pipe->winsys->region_alloc(pipe->winsys,
+ 1, 0, 0, 0x0);
return &xms->surface.surface;
}
}
+
+/**
+ * Round n up to next multiple.
+ */
+static INLINE unsigned
+round_up(unsigned n, unsigned multiple)
+{
+ return (n + multiple - 1) & ~(multiple - 1);
+}
+
+
+static struct pipe_region *
+xm_region_alloc(struct pipe_winsys *winsys,
+ unsigned cpp, unsigned width, unsigned height, unsigned flags)
+{
+ 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 = winsys->buffer_create( winsys, alignment )
+;
+
+ /* NULL data --> just allocate the space */
+ winsys->buffer_data( winsys,
+ region->buffer,
+ region->pitch * cpp * height,
+ NULL );
+ return region;
+}
+
+
+static void
+xm_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 xmesa_pipe_winsys
{
struct pipe_winsys winsys;
xws->winsys.buffer_data = xm_buffer_data;
xws->winsys.buffer_subdata = xm_buffer_subdata;
xws->winsys.buffer_get_subdata = xm_buffer_get_subdata;
+
+ xws->winsys.region_alloc = xm_region_alloc;
+ xws->winsys.region_release = xm_region_release;
+
xws->winsys.flush_frontbuffer = xm_flush_frontbuffer;
xws->winsys.wait_idle = xm_wait_idle;
xws->winsys.printf = xm_printf;
struct pipe_context *
xmesa_create_softpipe(XMesaContext xmesa)
{
- struct xm_winsys *isws = CALLOC_STRUCT( xm_winsys );
+ struct xm_winsys *xm_ws = CALLOC_STRUCT( xm_winsys );
- /* Fill in this struct with callbacks that softpipe will need to
- * communicate with the window system, buffer manager, etc.
- *
- * Softpipe would be happy with a malloc based memory manager, but
- * the SwapBuffers implementation in this winsys driver requires
- * that rendering be done to an appropriate xm_buffer.
- */
-#if 0
- isws->sws.create_buffer = xm_create_buffer;
- isws->sws.buffer_map = xm_buffer_map;
- isws->sws.buffer_unmap = xm_buffer_unmap;
- isws->sws.buffer_reference = xm_buffer_reference;
- isws->sws.buffer_unreference = xm_buffer_unreference;
- isws->sws.buffer_data = xm_buffer_data;
- isws->sws.buffer_subdata = xm_buffer_subdata;
- isws->sws.buffer_get_subdata = xm_buffer_get_subdata;
-#endif
-
/* Create the softpipe context:
*/
- return softpipe_create( xmesa_create_pipe_winsys(xmesa), &isws->sws );
+ return softpipe_create( xmesa_create_pipe_winsys(xmesa), &xm_ws->sws );
}
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;
}
}
-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?
{
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;
/*
* 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);
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,
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,
* driver and the hardware driver about the format of command buffers,
* etc.
*/
+
+
+struct pipe_region;
+
+/** Opaque type */
+struct pipe_buffer_handle;
+
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,
#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)
}
}
-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;
-}
/**
{
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;
#include "st_format.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
#include "shader/prog_instruction.h"
cpp = st_sizeof_format(pipeFormat);
/* allocate texture region/storage */
- mt->region = st->pipe->region_alloc(st->pipe, cpp, width, height, flags);
+ mt->region = st->pipe->winsys->region_alloc(st->pipe->winsys,
+ cpp, width, height, flags);
mt->target = PIPE_TEXTURE_2D;
mt->internal_format = GL_RGBA;
static void
free_mipmap_tree(struct pipe_context *pipe, struct pipe_mipmap_tree *mt)
{
- pipe->region_release(pipe, &mt->region);
+ pipe->winsys->region_release(pipe->winsys, &mt->region);
free(mt);
}
/* allocate texture region/storage */
- mt->region = pipe->region_alloc(pipe, cpp, width, height, flags);
+ mt->region = pipe->winsys->region_alloc(pipe->winsys,
+ cpp, width, height, flags);
pitch = mt->region->pitch;
/* map texture region */
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "st_context.h"
#include "st_cb_fbo.h"
#include "st_cb_texture.h"
struct pipe_region *r = strb->surface->region;
while (r->map)
pipe->region_unmap(pipe, r);
- pipe->region_release(pipe, &strb->surface->region);
+ pipe->winsys->region_release(pipe->winsys, &strb->surface->region);
}
- strb->surface->region = pipe->region_alloc(pipe, cpp, width, height, flags);
+ strb->surface->region = pipe->winsys->region_alloc(pipe->winsys, cpp,
+ width, height, flags);
if (!strb->surface->region)
return GL_FALSE; /* out of memory, try s/w buffer? */
ASSERT(strb);
if (strb && strb->surface) {
if (strb->surface->region) {
- pipe->region_release(pipe, &strb->surface->region);
+ pipe->winsys->region_release(pipe->winsys, &strb->surface->region);
}
free(strb->surface);
}
#include "pipe/p_state.h"
#include "pipe/p_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#define DBG if(0) printf
ok = pipe->mipmap_tree_layout(pipe, mt);
if (ok) {
/* note: it's OK to pass 'pitch' as 'width' here: */
- mt->region = pipe->region_alloc(pipe, mt->cpp, mt->pitch,
- mt->total_height, flags);
+ mt->region = pipe->winsys->region_alloc(pipe->winsys, mt->cpp, mt->pitch,
+ mt->total_height, flags);
mt->pitch = mt->region->pitch; /*XXX NEW */
}
DBG("%s deleting %p\n", __FUNCTION__, (void *) *mt);
- pipe->region_release(pipe, &((*mt)->region));
+ pipe->winsys->region_release(pipe->winsys, &((*mt)->region));
for (i = 0; i < MAX_TEXTURE_LEVELS; i++)
if ((*mt)->level[i].image_offset)