From: notaz Date: Fri, 17 Aug 2012 23:37:49 +0000 (+0300) Subject: psx_gpu: switch to 1024 width again. X-Git-Tag: r16~15^2~18 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e929dec505f8d3692248fe0d42c84a37c994ad39;p=pcsx_rearmed.git psx_gpu: switch to 1024 width again. --- diff --git a/plugins/dfxvideo/gpulib_if.c b/plugins/dfxvideo/gpulib_if.c index 12aa0a3f..6f425bdd 100644 --- a/plugins/dfxvideo/gpulib_if.c +++ b/plugins/dfxvideo/gpulib_if.c @@ -294,6 +294,14 @@ int renderer_init(void) return 0; } +void renderer_finish(void) +{ +} + +void renderer_notify_res_change(void) +{ +} + extern const unsigned char cmd_lengths[256]; int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) diff --git a/plugins/gpu-gles/gpulib_if.c b/plugins/gpu-gles/gpulib_if.c index c25ad8bb..09dc2009 100644 --- a/plugins/gpu-gles/gpulib_if.c +++ b/plugins/gpu-gles/gpulib_if.c @@ -500,6 +500,14 @@ int renderer_init(void) return 0; } +void renderer_finish(void) +{ +} + +void renderer_notify_res_change(void) +{ +} + extern const unsigned char cmd_lengths[256]; // XXX: mostly dupe code from soft peops diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.c b/plugins/gpu_neon/psx_gpu/psx_gpu.c index 28ebcf51..092125b0 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.c @@ -3118,14 +3118,6 @@ static void render_triangle_p(psx_gpu_struct *psx_gpu, } } } - if(psx_gpu->render_mode & RENDER_DOUBLE_MODE) - { - u32 i; - for(i = 0; i < psx_gpu->num_spans; i++) - { - psx_gpu->span_edge_data[i].y *= 2; - } - } u32 render_state = flags & (RENDER_FLAGS_MODULATE_TEXELS | RENDER_FLAGS_BLEND | @@ -4519,6 +4511,9 @@ void render_block_fill_enh(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y, if((width == 0) || (height == 0)) return; + if(width > 1024) + width = 1024; + u32 r = color & 0xFF; u32 g = (color >> 8) & 0xFF; u32 b = (color >> 16) & 0xFF; @@ -4526,9 +4521,9 @@ void render_block_fill_enh(psx_gpu_struct *psx_gpu, u32 color, u32 x, u32 y, psx_gpu->mask_msb; u32 color_32bpp = color_16bpp | (color_16bpp << 16); - u32 *vram_ptr = (u32 *)(psx_gpu->vram_out_ptr + x + (y * 2048)); + u32 *vram_ptr = (u32 *)(psx_gpu->vram_out_ptr + x + (y * 1024)); - u32 pitch = 2048 / 2 - (width / 2); + u32 pitch = 1024 / 2 - (width / 2); u32 num_width; while(height) @@ -4671,6 +4666,8 @@ void initialize_psx_gpu(psx_gpu_struct *psx_gpu, u16 *vram) psx_gpu->dither_table[3] = dither_table_row(3, -1, 2, -2); psx_gpu->primitive_type = PRIMITIVE_TYPE_UNKNOWN; + + psx_gpu->enhancement_x_threshold = 256; } u64 get_us(void) diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.h b/plugins/gpu_neon/psx_gpu/psx_gpu.h index 7252dc2b..fc5b566d 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.h +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.h @@ -57,7 +57,6 @@ typedef enum { RENDER_INTERLACE_ENABLED = 0x1, RENDER_INTERLACE_ODD = 0x2, - RENDER_DOUBLE_MODE = 0x4, } render_mode_enum; typedef struct @@ -183,6 +182,8 @@ typedef struct // enhancement stuff u16 *enhancement_buf_ptr; + u16 *enhancement_current_buf_ptr; + u32 enhancement_x_threshold; s16 saved_viewport_start_x; s16 saved_viewport_start_y; s16 saved_viewport_end_x; @@ -190,7 +191,7 @@ typedef struct // Align up to 64 byte boundary to keep the upcoming buffers cache line // aligned, also make reachable with single immediate addition - u8 reserved_a[236]; + u8 reserved_a[228]; // 8KB block_struct blocks[MAX_BLOCKS_PER_ROW]; diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c index 1c449eac..54f5614f 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -750,23 +750,30 @@ breakloop: return list - list_start; } +#define select_enhancement_buf(psx_gpu) { \ + u32 _x, _b; \ + _x = psx_gpu->saved_viewport_start_x + 8; \ + for (_b = 0; _x >= psx_gpu->enhancement_x_threshold; _b++) \ + _x -= psx_gpu->enhancement_x_threshold; \ + psx_gpu->enhancement_current_buf_ptr = \ + psx_gpu->enhancement_buf_ptr + _b * 1024 * 1024; \ +} + #define enhancement_disable() { \ psx_gpu->vram_out_ptr = psx_gpu->vram_ptr; \ psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x; \ psx_gpu->viewport_start_y = psx_gpu->saved_viewport_start_y; \ psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x; \ psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y; \ - psx_gpu->render_mode &= ~RENDER_DOUBLE_MODE; \ psx_gpu->uvrgb_phase = 0x8000; \ } #define enhancement_enable() { \ - psx_gpu->vram_out_ptr = psx_gpu->enhancement_buf_ptr; \ + psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr; \ psx_gpu->viewport_start_x = psx_gpu->saved_viewport_start_x * 2; \ psx_gpu->viewport_start_y = psx_gpu->saved_viewport_start_y * 2; \ psx_gpu->viewport_end_x = psx_gpu->saved_viewport_end_x * 2; \ psx_gpu->viewport_end_y = psx_gpu->saved_viewport_end_y * 2; \ - psx_gpu->render_mode |= RENDER_DOUBLE_MODE; \ psx_gpu->uvrgb_phase = 0x1000; \ } @@ -913,6 +920,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c psx_gpu->saved_viewport_start_y = psx_gpu->viewport_start_y; psx_gpu->saved_viewport_end_x = psx_gpu->viewport_end_x; psx_gpu->saved_viewport_end_y = psx_gpu->viewport_end_y; + select_enhancement_buf(psx_gpu); for(; list < list_end; list += 1 + command_length) { @@ -944,7 +952,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c do_fill(psx_gpu, x, y, width, height, color); - psx_gpu->vram_out_ptr = psx_gpu->enhancement_buf_ptr; + psx_gpu->vram_out_ptr = psx_gpu->enhancement_current_buf_ptr; x *= 2; y *= 2; width *= 2; @@ -1357,6 +1365,7 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, u32 *last_c psx_gpu->viewport_start_y = (list[0] >> 10) & 0x1FF; psx_gpu->saved_viewport_start_x = psx_gpu->viewport_start_x; psx_gpu->saved_viewport_start_y = psx_gpu->viewport_start_y; + select_enhancement_buf(psx_gpu); #ifdef TEXTURE_CACHE_4BPP psx_gpu->viewport_mask = diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c index d42f83a8..250aa8c7 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -43,10 +43,27 @@ int renderer_init(void) { initialize_psx_gpu(&egpu, gpu.vram); ex_regs = gpu.ex_regs; - gpu.state.enhancement_available = 1; + + if (gpu.enhancement_bufer == NULL) { + // currently we use 4x 1024*1024 buffers instead of single 2048*1024 + // to be able to reuse 1024-width code better (triangle setup, + // dithering phase, lines). + gpu.enhancement_bufer = malloc(1024 * 1024 * 2 * 4); + if (gpu.enhancement_bufer == NULL) + printf("OOM for enhancement buffer\n"); + } + egpu.enhancement_buf_ptr = gpu.enhancement_bufer; + return 0; } +void renderer_finish(void) +{ + free(gpu.enhancement_bufer); + gpu.enhancement_bufer = NULL; + egpu.enhancement_buf_ptr = NULL; +} + void renderer_sync_ecmds(uint32_t *ecmds) { gpu_parse(&egpu, ecmds + 1, 6 * 4, NULL); @@ -71,10 +88,14 @@ void renderer_set_interlace(int enable, int is_odd) egpu.render_mode |= RENDER_INTERLACE_ODD; } +void renderer_notify_res_change(void) +{ + egpu.enhancement_x_threshold = gpu.screen.hres; +} + #include "../../frontend/plugin_lib.h" void renderer_set_config(const struct rearmed_cbs *cbs) { - egpu.enhancement_buf_ptr = gpu.enhancement_bufer; disable_main_render = cbs->gpu_neon.enhancement_no_main; } diff --git a/plugins/gpu_unai/gpulib_if.cpp b/plugins/gpu_unai/gpulib_if.cpp index 38e7ce1a..2f741ad2 100644 --- a/plugins/gpu_unai/gpulib_if.cpp +++ b/plugins/gpu_unai/gpulib_if.cpp @@ -154,6 +154,14 @@ int renderer_init(void) return 0; } +void renderer_finish(void) +{ +} + +void renderer_notify_res_change(void) +{ +} + extern const unsigned char cmd_lengths[256]; int do_cmd_list(unsigned int *list, int list_len, int *last_cmd) diff --git a/plugins/gpulib/gpu.c b/plugins/gpulib/gpu.c index 462e301a..e133f07e 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) diff --git a/plugins/gpulib/gpu.h b/plugins/gpulib/gpu.h index f5143957..5ad2a461 100644 --- a/plugins/gpulib/gpu.h +++ b/plugins/gpulib/gpu.h @@ -67,7 +67,6 @@ struct psx_gpu { uint32_t old_interlace:1; uint32_t allow_interlace:2; uint32_t blanked:1; - uint32_t enhancement_available:1; uint32_t enhancement_enable:1; uint32_t enhancement_active:1; uint32_t *frame_count; @@ -90,7 +89,7 @@ struct psx_gpu { uint32_t last_flip_frame; uint32_t pending_fill[3]; } frameskip; - void *enhancement_bufer; + uint16_t *enhancement_bufer; }; extern struct psx_gpu gpu; @@ -102,11 +101,13 @@ int do_cmd_list(uint32_t *list, int count, int *last_cmd); struct rearmed_cbs; int renderer_init(void); +void renderer_finish(void); void renderer_sync_ecmds(uint32_t * ecmds); void renderer_update_caches(int x, int y, int w, int h); void renderer_flush_queues(void); void renderer_set_interlace(int enable, int is_odd); void renderer_set_config(const struct rearmed_cbs *config); +void renderer_notify_res_change(void); int vout_init(void); int vout_finish(void); diff --git a/plugins/gpulib/vout_pl.c b/plugins/gpulib/vout_pl.c index 51310343..cbd80349 100644 --- a/plugins/gpulib/vout_pl.c +++ b/plugins/gpulib/vout_pl.c @@ -68,18 +68,19 @@ static void blit(void) uint8_t *dest; dest = (uint8_t *)screen_buf; - if (dest == NULL) + if (dest == NULL || w == 0 || stride == 0) return; if (gpu.state.enhancement_active) { - vram = gpu.enhancement_bufer; + // this layout is gpu_neon specific.. + vram = gpu.enhancement_bufer + + (x + 8) / stride * 1024 * 1024; x *= 2; y *= 2; w *= 2; h *= 2; stride *= 2; - vram_stride = 2048; - vram_mask = 2048 * 1024 - 1; + vram_mask = 1024 * 1024 - 1; } fb_offs = y * vram_stride + x;