summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/i915simple/i915_surface.c3
-rw-r--r--src/mesa/pipe/p_winsys.h18
-rw-r--r--src/mesa/pipe/softpipe/sp_surface.c4
-rw-r--r--src/mesa/pipe/xlib/xm_winsys.c41
4 files changed, 46 insertions, 20 deletions
diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c
index bd6fd32704f..f93a75b0f0c 100644
--- a/src/mesa/pipe/i915simple/i915_surface.c
+++ b/src/mesa/pipe/i915simple/i915_surface.c
@@ -238,11 +238,12 @@ i915_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
- ps = pipe->winsys->surface_alloc(pipe->winsys, pt->format);
+ ps = pipe->winsys->surface_alloc(pipe->winsys);
if (ps) {
assert(ps->format);
assert(ps->refcount);
pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, tex->buffer);
+ ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
diff --git a/src/mesa/pipe/p_winsys.h b/src/mesa/pipe/p_winsys.h
index 1418af69186..aa9362ec0ba 100644
--- a/src/mesa/pipe/p_winsys.h
+++ b/src/mesa/pipe/p_winsys.h
@@ -76,16 +76,16 @@ struct pipe_winsys
const char *, ... );
- /**
- * flags is bitmask of PIPE_SURFACE_FLAG_RENDER, PIPE_SURFACE_FLAG_TEXTURE
- */
- unsigned (*surface_pitch)(struct pipe_winsys *ws, unsigned cpp,
- unsigned with, unsigned flags);
-
/** allocate a new surface (no context dependency) */
- struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws,
- enum pipe_format format);
-
+ struct pipe_surface *(*surface_alloc)(struct pipe_winsys *ws);
+
+ /** allocate storage for a pipe_surface */
+ int (*surface_alloc_storage)(struct pipe_winsys *ws,
+ struct pipe_surface *surf,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned flags);
+
void (*surface_release)(struct pipe_winsys *ws, struct pipe_surface **s);
diff --git a/src/mesa/pipe/softpipe/sp_surface.c b/src/mesa/pipe/softpipe/sp_surface.c
index 55b8b85ef2b..3ef3db9f1f2 100644
--- a/src/mesa/pipe/softpipe/sp_surface.c
+++ b/src/mesa/pipe/softpipe/sp_surface.c
@@ -576,11 +576,11 @@ softpipe_get_tex_surface(struct pipe_context *pipe,
assert(zslice == 0);
}
- ps = pipe->winsys->surface_alloc(pipe->winsys, pt->format);
+ ps = pipe->winsys->surface_alloc(pipe->winsys);
if (ps) {
- assert(ps->format);
assert(ps->refcount);
pipe->winsys->buffer_reference(pipe->winsys, &ps->buffer, spt->buffer);
+ ps->format = pt->format;
ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
diff --git a/src/mesa/pipe/xlib/xm_winsys.c b/src/mesa/pipe/xlib/xm_winsys.c
index b090d8927c4..ad31f4498e5 100644
--- a/src/mesa/pipe/xlib/xm_winsys.c
+++ b/src/mesa/pipe/xlib/xm_winsys.c
@@ -388,11 +388,38 @@ round_up(unsigned n, unsigned multiple)
return (n + multiple - 1) & ~(multiple - 1);
}
-static unsigned
-xm_surface_pitch(struct pipe_winsys *winsys, unsigned cpp, unsigned width,
- unsigned flags)
+static int
+xm_surface_alloc_storage(struct pipe_winsys *winsys,
+ struct pipe_surface *surf,
+ unsigned width, unsigned height,
+ enum pipe_format format,
+ unsigned flags)
{
- return round_up(width, 64 / cpp);
+ const unsigned alignment = 64;
+ int ret;
+
+ surf->width = width;
+ surf->height = height;
+ surf->format = format;
+ surf->cpp = pf_get_size(format);
+ surf->pitch = round_up(width, alignment / surf->cpp);
+
+ assert(!surf->buffer);
+ surf->buffer = winsys->buffer_create(winsys, alignment, 0, 0);
+ if(!surf->buffer)
+ return -1;
+
+ ret = winsys->buffer_data(winsys,
+ surf->buffer,
+ surf->pitch * surf->cpp * height,
+ NULL,
+ 0);
+ if(ret) {
+ winsys->buffer_reference(winsys, &surf->buffer, NULL);
+ return ret;
+ }
+
+ return 0;
}
@@ -401,14 +428,12 @@ xm_surface_pitch(struct pipe_winsys *winsys, unsigned cpp, unsigned width,
* renderbuffers, etc.
*/
static struct pipe_surface *
-xm_surface_alloc(struct pipe_winsys *ws, enum pipe_format pipeFormat)
+xm_surface_alloc(struct pipe_winsys *ws)
{
struct xmesa_surface *xms = CALLOC_STRUCT(xmesa_surface);
assert(ws);
- assert(pipeFormat);
- xms->surface.format = pipeFormat;
xms->surface.refcount = 1;
xms->surface.winsys = ws;
@@ -463,8 +488,8 @@ xmesa_get_pipe_winsys(void)
ws->buffer_subdata = xm_buffer_subdata;
ws->buffer_get_subdata = xm_buffer_get_subdata;
- ws->surface_pitch = xm_surface_pitch;
ws->surface_alloc = xm_surface_alloc;
+ ws->surface_alloc_storage = xm_surface_alloc_storage;
ws->surface_release = xm_surface_release;
ws->flush_frontbuffer = xm_flush_frontbuffer;