summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri/i965/intel_upload.c
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2014-03-02 23:09:20 -0800
committerKenneth Graunke <kenneth@whitecape.org>2014-03-18 10:39:04 -0700
commit91f4528da620de6518db8f85e6a08c88687d0269 (patch)
tree098f70ff0a049402b96bb3d2582b0943cbcce558 /src/mesa/drivers/dri/i965/intel_upload.c
parentb8b4e280b47888898143b09404e71a51663ac59c (diff)
downloadexternal_mesa3d-91f4528da620de6518db8f85e6a08c88687d0269.zip
external_mesa3d-91f4528da620de6518db8f85e6a08c88687d0269.tar.gz
external_mesa3d-91f4528da620de6518db8f85e6a08c88687d0269.tar.bz2
i965/upload: Refactor open-coded ALIGN-like computations.
Sadly, we can't use actual ALIGN(), since that only supports power-of-two values for the alignment parameter. Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_upload.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_upload.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_upload.c b/src/mesa/drivers/dri/i965/intel_upload.c
index ac16dcc..ec3109b 100644
--- a/src/mesa/drivers/dri/i965/intel_upload.c
+++ b/src/mesa/drivers/dri/i965/intel_upload.c
@@ -45,6 +45,12 @@
#define INTEL_UPLOAD_SIZE (64*1024)
+/**
+ * Like ALIGN(), but works with a non-power-of-two alignment.
+ */
+#define ALIGN_NPOT(value, alignment) \
+ (((value) + (alignment) - 1) / (alignment) * (alignment))
+
void
intel_upload_finish(struct brw_context *brw)
{
@@ -83,7 +89,7 @@ intel_upload_data(struct brw_context *brw,
{
GLuint base, delta;
- base = (brw->upload.offset + align - 1) / align * align;
+ base = ALIGN_NPOT(brw->upload.offset, align);
if (brw->upload.bo == NULL || base + size > brw->upload.bo->size) {
wrap_buffers(brw, size);
base = 0;
@@ -124,7 +130,7 @@ intel_upload_map(struct brw_context *brw, GLuint size, GLuint align)
GLuint base, delta;
char *ptr;
- base = (brw->upload.offset + align - 1) / align * align;
+ base = ALIGN_NPOT(brw->upload.offset, align);
if (brw->upload.bo == NULL || base + size > brw->upload.bo->size) {
wrap_buffers(brw, size);
base = 0;
@@ -163,7 +169,7 @@ intel_upload_unmap(struct brw_context *brw,
{
GLuint base;
- base = (brw->upload.offset + align - 1) / align * align;
+ base = ALIGN_NPOT(brw->upload.offset, align);
if (size > sizeof(brw->upload.buffer)) {
drm_intel_bo_subdata(brw->upload.bo, base, size, ptr);
free((void*)ptr);