gem_exec_faulting_reloc: use iterator for batchbuffer
authorBen Widawsky <benjamin.widawsky@intel.com>
Wed, 9 Oct 2013 00:36:21 +0000 (17:36 -0700)
committerBen Widawsky <benjamin.widawsky@intel.com>
Wed, 9 Oct 2013 19:51:21 +0000 (12:51 -0700)
This will help keep the code clean for new platforms which might have
differently sized relocations.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
tests/gem_exec_faulting_reloc.c

index d25bd5e..ef801ed 100644 (file)
@@ -67,11 +67,12 @@ static int gem_linear_blt(uint32_t *batch,
        igt_assert(height <= 1<<16);
 
        if (height) {
-               b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
-               b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024);
-               b[2] = 0;
-               b[3] = height << 16 | (4*1024);
-               b[4] = 0;
+               int i = 0;
+               b[i++] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
+               b[i++] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024);
+               b[i++] = 0;
+               b[i++] = height << 16 | (4*1024);
+               b[i++] = 0;
                reloc->offset = (b-batch+4) * sizeof(uint32_t);
                reloc->delta = 0;
                reloc->target_handle = dst;
@@ -80,9 +81,9 @@ static int gem_linear_blt(uint32_t *batch,
                reloc->presumed_offset = 0;
                reloc++;
 
-               b[5] = 0;
-               b[6] = 16*1024;
-               b[7] = 0;
+               b[i++] = 0;
+               b[i++] = 16*1024;
+               b[i++] = 0;
                reloc->offset = (b-batch+7) * sizeof(uint32_t);
                reloc->delta = 0;
                reloc->target_handle = src;
@@ -96,11 +97,12 @@ static int gem_linear_blt(uint32_t *batch,
        }
        
        if (length) {
-               b[0] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
-               b[1] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024);
-               b[2] = height << 16;
-               b[3] = (1+height) << 16 | (length / 4);
-               b[4] = 0;
+               int i = 0;
+               b[i++] = COPY_BLT_CMD | BLT_WRITE_ALPHA | BLT_WRITE_RGB;
+               b[i++] = 0xcc << 16 | 1 << 25 | 1 << 24 | (16*1024);
+               b[i++] = height << 16;
+               b[i++] = (1+height) << 16 | (length / 4);
+               b[i++] = 0;
                reloc->offset = (b-batch+4) * sizeof(uint32_t);
                reloc->delta = 0;
                reloc->target_handle = dst;
@@ -109,9 +111,9 @@ static int gem_linear_blt(uint32_t *batch,
                reloc->presumed_offset = 0;
                reloc++;
 
-               b[5] = height << 16;
-               b[6] = 16*1024;
-               b[7] = 0;
+               b[i++] = height << 16;
+               b[i++] = 16*1024;
+               b[i++] = 0;
                reloc->offset = (b-batch+7) * sizeof(uint32_t);
                reloc->delta = 0;
                reloc->target_handle = src;