From 0b02eb7712f1272fa7f38b0af41968b53af3b5a8 Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 13 Aug 2012 00:02:23 +0300 Subject: add support for software-enhanced rendering --- plugins/gpulib/gpu.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'plugins/gpulib/gpu.c') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 46e92d1..462e301 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -9,6 +9,7 @@ */ #include +#include #include #include "gpu.h" @@ -137,8 +138,21 @@ long GPUinit(void) { int ret; ret = vout_init(); + + gpu.state.enhancement_available = 0; ret |= renderer_init(); + if (gpu.state.enhancement_available) { + if (gpu.enhancement_bufer == NULL) + gpu.enhancement_bufer = malloc(2048 * 1024 * 2 + 1024 * 512 * 2); + if (gpu.enhancement_bufer == NULL) + gpu_log("OOM for enhancement buffer\n"); + } + else if (gpu.enhancement_bufer != NULL) { + free(gpu.enhancement_bufer); + gpu.enhancement_bufer = NULL; + } + gpu.state.frame_count = &gpu.zero; gpu.state.hcnt = &gpu.zero; gpu.frameskip.active = 0; @@ -669,6 +683,7 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.hcnt = cbs->gpu_hcnt; gpu.state.frame_count = cbs->gpu_frame_count; gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace; + gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable; if (cbs->pl_vout_set_raw_vram) cbs->pl_vout_set_raw_vram(gpu.vram); -- cgit v1.2.3 From e929dec505f8d3692248fe0d42c84a37c994ad39 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 18 Aug 2012 02:37:49 +0300 Subject: psx_gpu: switch to 1024 width again. --- plugins/gpulib/gpu.c | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) (limited to 'plugins/gpulib/gpu.c') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 462e301..e133f07 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -9,7 +9,6 @@ */ #include -#include #include #include "gpu.h" @@ -138,21 +137,8 @@ long GPUinit(void) { int ret; ret = vout_init(); - - gpu.state.enhancement_available = 0; ret |= renderer_init(); - if (gpu.state.enhancement_available) { - if (gpu.enhancement_bufer == NULL) - gpu.enhancement_bufer = malloc(2048 * 1024 * 2 + 1024 * 512 * 2); - if (gpu.enhancement_bufer == NULL) - gpu_log("OOM for enhancement buffer\n"); - } - else if (gpu.enhancement_bufer != NULL) { - free(gpu.enhancement_bufer); - gpu.enhancement_bufer = NULL; - } - gpu.state.frame_count = &gpu.zero; gpu.state.hcnt = &gpu.zero; gpu.frameskip.active = 0; @@ -164,6 +150,7 @@ long GPUinit(void) long GPUshutdown(void) { + renderer_finish(); return vout_finish(); } @@ -221,6 +208,7 @@ void GPUwriteStatus(uint32_t data) gpu.screen.vres = vres[(gpu.status.reg >> 19) & 3]; update_width(); update_height(); + renderer_notify_res_change(); break; default: if ((cmd & 0xf0) == 0x10) -- cgit v1.2.3 From 9ee0fd5b333039b1140d90f935aa9299825f1e42 Mon Sep 17 00:00:00 2001 From: notaz Date: Sun, 19 Aug 2012 22:39:49 +0300 Subject: start mmap'ing vram, with hugetlb if possible --- plugins/gpulib/gpu.c | 44 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) (limited to 'plugins/gpulib/gpu.c') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index e133f07..b61bff6 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -24,7 +24,7 @@ //#define log_anomaly gpu_log #define log_anomaly(...) -struct psx_gpu gpu __attribute__((aligned(2048))); +struct psx_gpu gpu; static noinline int do_cmd_buffer(uint32_t *data, int count); static void finish_vram_transfer(int is_read); @@ -133,6 +133,22 @@ static noinline void get_gpu_info(uint32_t data) } } +// double, for overdraw guard +#define VRAM_SIZE (1024 * 512 * 2 * 2) + +static int map_vram(void) +{ + gpu.vram = gpu.mmap(VRAM_SIZE); + if (gpu.vram != NULL) { + gpu.vram += 4096 / 2; + return 0; + } + else { + fprintf(stderr, "could not map vram, expect crashes\n"); + return -1; + } +} + long GPUinit(void) { int ret; @@ -145,13 +161,26 @@ long GPUinit(void) gpu.cmd_len = 0; do_reset(); + if (gpu.mmap != NULL) { + if (map_vram() != 0) + ret = -1; + } return ret; } long GPUshutdown(void) { + long ret; + renderer_finish(); - return vout_finish(); + ret = vout_finish(); + if (gpu.vram != NULL) { + gpu.vram -= 4096 / 2; + gpu.munmap(gpu.vram, VRAM_SIZE); + } + gpu.vram = NULL; + + return ret; } void GPUwriteStatus(uint32_t data) @@ -584,13 +613,13 @@ long GPUfreeze(uint32_t type, struct GPUFreeze *freeze) case 1: // save if (gpu.cmd_len > 0) flush_cmd_buffer(); - memcpy(freeze->psxVRam, gpu.vram, sizeof(gpu.vram)); + memcpy(freeze->psxVRam, gpu.vram, 1024 * 512 * 2); memcpy(freeze->ulControl, gpu.regs, sizeof(gpu.regs)); memcpy(freeze->ulControl + 0xe0, gpu.ex_regs, sizeof(gpu.ex_regs)); freeze->ulStatus = gpu.status.reg; break; case 0: // load - memcpy(gpu.vram, freeze->psxVRam, sizeof(gpu.vram)); + memcpy(gpu.vram, freeze->psxVRam, 1024 * 512 * 2); memcpy(gpu.regs, freeze->ulControl, sizeof(gpu.regs)); memcpy(gpu.ex_regs, freeze->ulControl + 0xe0, sizeof(gpu.ex_regs)); gpu.status.reg = freeze->ulStatus; @@ -673,6 +702,13 @@ void GPUrearmedCallbacks(const struct rearmed_cbs *cbs) gpu.state.allow_interlace = cbs->gpu_neon.allow_interlace; gpu.state.enhancement_enable = cbs->gpu_neon.enhancement_enable; + gpu.mmap = cbs->mmap; + gpu.munmap = cbs->munmap; + + // delayed vram mmap + if (gpu.vram == NULL) + map_vram(); + if (cbs->pl_vout_set_raw_vram) cbs->pl_vout_set_raw_vram(gpu.vram); renderer_set_config(cbs); -- cgit v1.2.3 From c65553d0cafc353daad3fdcc0aab63bb8427a809 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 13 Nov 2012 02:28:41 +0200 Subject: fix some random corner cases --- plugins/gpulib/gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/gpulib/gpu.c') diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index b61bff6..b300c88 100644 --- a/plugins/gpulib/gpu.c +++ b/plugins/gpulib/gpu.c @@ -212,7 +212,7 @@ void GPUwriteStatus(uint32_t data) break; case 0x05: gpu.screen.x = data & 0x3ff; - gpu.screen.y = (data >> 10) & 0x3ff; + gpu.screen.y = (data >> 10) & 0x1ff; if (gpu.frameskip.set) { decide_frameskip_allow(gpu.ex_regs[3]); if (gpu.frameskip.last_flip_frame != *gpu.state.frame_count) { -- cgit v1.2.3