Cell: new ROUNDUP16() macro
authorBrian <brian.paul@tungstengraphics.com>
Fri, 25 Jan 2008 01:26:37 +0000 (18:26 -0700)
committerBrian <brian.paul@tungstengraphics.com>
Fri, 25 Jan 2008 15:20:09 +0000 (08:20 -0700)
src/mesa/pipe/cell/common.h
src/mesa/pipe/cell/spu/spu_main.c

index b9a00cc..5c437da 100644 (file)
@@ -43,6 +43,9 @@
    assert((((unsigned long) (ptr)) & 0xf) == 0);
 
 
+/** round up value to next multiple of 16 */
+#define ROUNDUP16(k)  (((k) + 0xf) & ~0xf)
+
 
 #define TILE_SIZE 32
 
index 03dbef0..1d0de7b 100644 (file)
@@ -234,7 +234,7 @@ cmd_render(const struct cell_command_render *render)
    if (total_index_bytes < 16)
       total_index_bytes = 16;
    else
-      total_index_bytes = (total_index_bytes + 15) & ~0xf; /* multiple of 16 */
+      total_index_bytes = ROUNDUP16(total_index_bytes);
 
    /*
    printf("VBUF: indices at %p,  vertices at %p  total_vertex_bytes %u  ind_bytes %u\n",
@@ -457,10 +457,9 @@ cmd_batch(uint opcode)
 
    ASSERT_ALIGN16(spu.init.batch_buffers[buf]);
 
-   size = (size + 0xf) & ~0xf;
+   size = ROUNDUP16(size);
 
-   ASSERT(size % 16 == 0);
-   ASSERT((unsigned int) spu.init.batch_buffers[buf] % 16 == 0);
+   ASSERT_ALIGN16(spu.init.batch_buffers[buf]);
 
    mfc_get(buffer,  /* dest */
            (unsigned int) spu.init.batch_buffers[buf],  /* src */