summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:37:01 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:37:01 +0000
commite4c140c4d4d00c16d99b15ee6677cbd2e3364031 (patch)
tree96364a9f799341ef8dff3d1534f1de0eb3a559b1 /lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c
parent10010c14c68222d4056694bf3643ee969d18cd4f (diff)
Import Mesa 13.0.2
Diffstat (limited to 'lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c')
-rw-r--r--lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c67
1 files changed, 38 insertions, 29 deletions
diff --git a/lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c b/lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c
index 9e1ff9e5f..1e60f6aff 100644
--- a/lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c
+++ b/lib/mesa/src/gallium/drivers/radeon/r600_test_dma.c
@@ -26,10 +26,26 @@
#include "r600_pipe_common.h"
#include "util/u_surface.h"
-#include "util/rand_xor.h"
static uint64_t seed_xorshift128plus[2];
+/* Super fast random number generator.
+ *
+ * This rand_xorshift128plus function by Sebastiano Vigna belongs
+ * to the public domain.
+ */
+static uint64_t rand_xorshift128plus(void)
+{
+ uint64_t *s = seed_xorshift128plus;
+
+ uint64_t s1 = s[0];
+ const uint64_t s0 = s[1];
+ s[0] = s0;
+ s1 ^= s1 << 23;
+ s[1] = s1 ^ s0 ^ (s1 >> 18) ^ (s0 >> 5);
+ return s[1] + s0;
+}
+
#define RAND_NUM_SIZE 8
/* The GPU blits are emulated on the CPU using these CPU textures. */
@@ -75,10 +91,8 @@ static void set_random_pixels(struct pipe_context *ctx,
assert(t->stride % RAND_NUM_SIZE == 0);
assert(cpu->stride % RAND_NUM_SIZE == 0);
- for (x = 0; x < size; x++) {
- *ptr++ = *ptr_cpu++ =
- rand_xorshift128plus(seed_xorshift128plus);
- }
+ for (x = 0; x < size; x++)
+ *ptr++ = *ptr_cpu++ = rand_xorshift128plus();
}
}
@@ -135,24 +149,18 @@ static enum pipe_format get_format_from_bpp(int bpp)
}
}
-static const char *array_mode_to_string(struct r600_common_screen *rscreen,
- struct radeon_surf *surf)
+static const char *array_mode_to_string(unsigned mode)
{
- if (rscreen->chip_class >= GFX9) {
- /* TODO */
+ switch (mode) {
+ case RADEON_SURF_MODE_LINEAR_ALIGNED:
+ return "LINEAR_ALIGNED";
+ case RADEON_SURF_MODE_1D:
+ return "1D_TILED_THIN1";
+ case RADEON_SURF_MODE_2D:
+ return "2D_TILED_THIN1";
+ default:
+ assert(0);
return " UNKNOWN";
- } else {
- switch (surf->u.legacy.level[0].mode) {
- case RADEON_SURF_MODE_LINEAR_ALIGNED:
- return "LINEAR_ALIGNED";
- case RADEON_SURF_MODE_1D:
- return "1D_TILED_THIN1";
- case RADEON_SURF_MODE_2D:
- return "2D_TILED_THIN1";
- default:
- assert(0);
- return " UNKNOWN";
- }
}
}
@@ -189,7 +197,8 @@ void r600_test_dma(struct r600_common_screen *rscreen)
/* the seed for random test parameters */
srand(0x9b47d95b);
/* the seed for random pixel data */
- s_rand_xorshift128plus(seed_xorshift128plus, false);
+ seed_xorshift128plus[0] = 0x3bffb83978e24f88;
+ seed_xorshift128plus[1] = 0x9238d5d56c71cd35;
iterations = 1000000000; /* just kill it when you are bored */
num_partial_copies = 30;
@@ -283,16 +292,16 @@ void r600_test_dma(struct r600_common_screen *rscreen)
printf("%4u: dst = (%5u x %5u x %u, %s), "
" src = (%5u x %5u x %u, %s), bpp = %2u, ",
i, tdst.width0, tdst.height0, tdst.array_size,
- array_mode_to_string(rscreen, &rdst->surface),
+ array_mode_to_string(rdst->surface.level[0].mode),
tsrc.width0, tsrc.height0, tsrc.array_size,
- array_mode_to_string(rscreen, &rsrc->surface), bpp);
+ array_mode_to_string(rsrc->surface.level[0].mode), bpp);
fflush(stdout);
/* set src pixels */
set_random_pixels(ctx, src, &src_cpu);
/* clear dst pixels */
- rctx->clear_buffer(ctx, dst, 0, rdst->surface.surf_size, 0, true);
+ rctx->clear_buffer(ctx, dst, 0, rdst->surface.bo_size, 0, true);
memset(dst_cpu.ptr, 0, dst_cpu.layer_stride * tdst.array_size);
/* preparation */
@@ -322,8 +331,8 @@ void r600_test_dma(struct r600_common_screen *rscreen)
dstz = rand() % (tdst.array_size - depth + 1);
/* special code path to hit the tiled partial copies */
- if (!rsrc->surface.is_linear &&
- !rdst->surface.is_linear &&
+ if (rsrc->surface.level[0].mode >= RADEON_SURF_MODE_1D &&
+ rdst->surface.level[0].mode >= RADEON_SURF_MODE_1D &&
rand() & 1) {
if (max_width < 8 || max_height < 8)
continue;
@@ -350,8 +359,8 @@ void r600_test_dma(struct r600_common_screen *rscreen)
}
/* special code path to hit out-of-bounds reads in L2T */
- if (rsrc->surface.is_linear &&
- !rdst->surface.is_linear &&
+ if (rsrc->surface.level[0].mode == RADEON_SURF_MODE_LINEAR_ALIGNED &&
+ rdst->surface.level[0].mode >= RADEON_SURF_MODE_1D &&
rand() % 4 == 0) {
srcx = 0;
srcy = 0;