aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornotaz2011-11-19 22:26:46 +0200
committernotaz2011-11-19 22:26:46 +0200
commitadb4b2c6fff620ecd65e3786a2f961413507c1a4 (patch)
tree24812da67e427412ad8e70ecb3ae750ac984d4f1
parent6f2ee2becb1eb33cac685594f13468cef4d09684 (diff)
downloadpcsx_rearmed-adb4b2c6fff620ecd65e3786a2f961413507c1a4.tar.gz
pcsx_rearmed-adb4b2c6fff620ecd65e3786a2f961413507c1a4.tar.bz2
pcsx_rearmed-adb4b2c6fff620ecd65e3786a2f961413507c1a4.zip
gpu_neon: add a test
..that works with vram and display list dumps to produce output
-rw-r--r--plugins/gpu_neon/Makefile.test33
-rw-r--r--plugins/gpu_neon/test.c107
2 files changed, 140 insertions, 0 deletions
diff --git a/plugins/gpu_neon/Makefile.test b/plugins/gpu_neon/Makefile.test
new file mode 100644
index 0000000..952f508
--- /dev/null
+++ b/plugins/gpu_neon/Makefile.test
@@ -0,0 +1,33 @@
+CC = $(CROSS_COMPILE)gcc
+CXX = $(CROSS_COMPILE)g++
+CC_ = $(CROSS_COMPILE)gcc
+
+ARCH = $(shell $(CC) -v 2>&1 | grep -i 'target:' | awk '{print $$2}' | awk -F '-' '{print $$1}')
+
+CFLAGS += -ggdb -Wall
+CFLAGS += -O2
+ifeq "$(ARCH)" "arm"
+CFLAGS += -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp
+endif
+ifeq "$(ARCH)" "x86_64"
+CFLAGS += -m32
+endif
+
+# test_neon
+TARGETS = test_peops test_unai
+SRC += test.c
+
+all: $(TARGETS)
+
+test_neon: SRC += psx_gpu_if.c
+test_neon: CFLAGS += -fno-strict-aliasing
+test_peops: SRC += peops_if.c
+test_peops: CFLAGS += -fno-strict-aliasing
+test_unai: SRC += unai_if.cpp
+test_unai: CC_ = $(CXX)
+
+$(TARGETS): $(SRC)
+ $(CC_) -o $@ $(SRC) $(CFLAGS) $(LDFLAGS)
+
+clean:
+ $(RM) $(TARGETS)
diff --git a/plugins/gpu_neon/test.c b/plugins/gpu_neon/test.c
new file mode 100644
index 0000000..be271b6
--- /dev/null
+++ b/plugins/gpu_neon/test.c
@@ -0,0 +1,107 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "gpu.h"
+
+static inline unsigned int pcnt_get(void)
+{
+ unsigned int val;
+#ifdef __ARM_ARCH_7A__
+ asm volatile("mrc p15, 0, %0, c9, c13, 0" : "=r"(val));
+#else
+ val = 0;
+#endif
+ return val;
+}
+
+static inline void pcnt_init(void)
+{
+#ifdef __ARM_ARCH_7A__
+ int v;
+ asm volatile("mrc p15, 0, %0, c9, c12, 0" : "=r"(v));
+ v |= 5; // master enable, ccnt reset
+ v &= ~8; // ccnt divider 0
+ asm volatile("mcr p15, 0, %0, c9, c12, 0" :: "r"(v));
+ // enable cycle counter
+ asm volatile("mcr p15, 0, %0, c9, c12, 1" :: "r"(1<<31));
+#endif
+}
+
+const unsigned char cmd_lengths[256] =
+{
+ 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 3, 3, 3, 3, 6, 6, 6, 6, 4, 4, 4, 4, 8, 8, 8, 8, // 20
+ 5, 5, 5, 5, 8, 8, 8, 8, 7, 7, 7, 7, 11, 11, 11, 11,
+ 2, 2, 2, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3, // 40
+ 3, 3, 3, 3, 0, 0, 0, 0, 4, 4, 4, 4, 4, 4, 4, 4,
+ 2, 2, 2, 2, 3, 3, 3, 3, 1, 1, 1, 1, 2, 2, 2, 2, // 60
+ 1, 1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2,
+ 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 80
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // a0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // c0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // e0
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+struct psx_gpu gpu __attribute__((aligned(64)));
+
+typedef struct
+{
+ uint16_t vram[1024 * 512];
+ uint32_t gpu_register[15];
+ uint32_t status;
+} gpu_dump_struct;
+
+static gpu_dump_struct state;
+
+int main(int argc, char *argv[])
+{
+ unsigned int start_cycles;
+ uint32_t *list;
+ int size;
+ FILE *state_file;
+ FILE *list_file;
+ FILE *out_file;
+
+ if (argc != 3 && argc != 4)
+ {
+ printf("usage:\n%s <state> <list> [vram_out]\n", argv[0]);
+ return 1;
+ }
+
+ state_file = fopen(argv[1], "rb");
+ fread(&state, 1, sizeof(gpu_dump_struct), state_file);
+ fclose(state_file);
+
+ list_file = fopen(argv[2], "rb");
+ fseek(list_file, 0, SEEK_END);
+ size = ftell(list_file);
+ fseek(list_file, 0, SEEK_SET);
+
+ list = (uint32_t *)malloc(size);
+ fread(list, 1, size, list_file);
+ fclose(list_file);
+
+ pcnt_init();
+ renderer_init();
+ memcpy(gpu.vram, state.vram, sizeof(gpu.vram));
+
+ start_cycles = pcnt_get();
+
+ do_cmd_list(list, size / 4);
+ renderer_flush_queues();
+
+ printf("%u\n", pcnt_get() - start_cycles);
+
+ if (argc >= 4) {
+ out_file = fopen(argv[3], "wb");
+ fwrite(gpu.vram, 1, sizeof(gpu.vram), out_file);
+ fclose(out_file);
+ }
+
+ return 0;
+}