summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/softpipe
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-10 12:37:20 -0600
committerBrian <[email protected]>2007-08-10 13:03:57 -0600
commitda9178c73088982b9f422187cf782ae5ab6b64ce (patch)
tree8e62ab88e02316e7e71d1c50036c898fb26691b1 /src/mesa/pipe/softpipe
parent48f853f73f7bb46e8c977e551fd66a39e50935ee (diff)
alignment/pitch/width clean-ups
Diffstat (limited to 'src/mesa/pipe/softpipe')
-rw-r--r--src/mesa/pipe/softpipe/sp_region.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mesa/pipe/softpipe/sp_region.c b/src/mesa/pipe/softpipe/sp_region.c
index 1db508f028f..142d121047b 100644
--- a/src/mesa/pipe/softpipe/sp_region.c
+++ b/src/mesa/pipe/softpipe/sp_region.c
@@ -36,6 +36,16 @@
#include "sp_region.h"
+/**
+ * Round n up to next multiple.
+ */
+static INLINE unsigned
+round_up(unsigned n, unsigned multiple)
+{
+ return (n + multiple - 1) & ~(multiple - 1);
+}
+
+
static void
sp_region_idle(struct pipe_context *pipe, struct pipe_region *region)
{
@@ -70,23 +80,24 @@ sp_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
static struct pipe_region *
sp_region_alloc(struct pipe_context *pipe,
- GLuint cpp, GLuint pitch, GLuint height, GLbitfield flags)
+ GLuint cpp, GLuint width, GLuint height, GLbitfield flags)
{
struct softpipe_context *sp = softpipe_context( pipe );
struct pipe_region *region = calloc(sizeof(*region), 1);
+ const unsigned alignment = 64;
region->cpp = cpp;
- region->pitch = pitch;
- region->height = height; /* needed? */
+ region->pitch = round_up(width, alignment / cpp);
+ region->height = height;
region->refcount = 1;
- region->buffer = sp->winsys->create_buffer( sp->winsys, 64 );
+ region->buffer = sp->winsys->create_buffer( sp->winsys, alignment );
+ /* NULL data --> just allocate the space */
sp->winsys->buffer_data( sp->winsys,
region->buffer,
- pitch * cpp * height,
+ region->pitch * cpp * height,
NULL );
-
return region;
}