summaryrefslogtreecommitdiff
path: root/lib/igt_rand.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-07-03 09:42:38 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-07-03 11:23:05 +0100
commit376b813e7c60826357034f4ea40ffada514fbdc3 (patch)
tree12d829ab778cd16e0b41eea88d8153163e624485 /lib/igt_rand.c
parent3e765840129a17b462565f7b48dfe9d9792b292f (diff)
igt/gem_exec_gttfill: Reduce overhead in setting up filler batches
Since all the batches start with the same content, we can reuse the same buf to fill them. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'lib/igt_rand.c')
-rw-r--r--lib/igt_rand.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/igt_rand.c b/lib/igt_rand.c
new file mode 100644
index 00000000..a3298a9f
--- /dev/null
+++ b/lib/igt_rand.c
@@ -0,0 +1,19 @@
+#include "igt_rand.h"
+
+static uint32_t state = 0x12345678;
+
+uint32_t
+hars_petruska_f54_1_random_seed(uint32_t new_state)
+{
+ uint32_t old_state = state;
+ state = new_state;
+ return old_state;
+}
+
+uint32_t
+hars_petruska_f54_1_random_unsafe(void)
+{
+#define rol(x,k) ((x << k) | (x >> (32-k)))
+ return state = (state ^ rol (state, 5) ^ rol (state, 24)) + 0x37798849;
+#undef rol
+}