From: notaz Date: Wed, 3 Jan 2024 00:36:58 +0000 (+0200) Subject: gpu_neon: make enh. res. texturing hack optional X-Git-Tag: r24l~9 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af1601fa2cd5e348d2c10395731534f55130b51d;p=pcsx_rearmed.git gpu_neon: make enh. res. texturing hack optional until something better is figured out, if ever libretro/pcsx_rearmed#815 --- diff --git a/frontend/libretro.c b/frontend/libretro.c index d361be15..7b29a23a 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -2101,10 +2101,21 @@ static void update_variables(bool in_flight) if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) { - if (strcmp(var.value, "disabled") == 0) - pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0; - else if (strcmp(var.value, "enabled") == 0) + if (strcmp(var.value, "enabled") == 0) pl_rearmed_cbs.gpu_neon.enhancement_no_main = 1; + else + pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0; + } + + var.value = NULL; + var.key = "pcsx_rearmed_neon_enhancement_tex_adj"; + + if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value) + { + if (strcmp(var.value, "enabled") == 0) + pl_rearmed_cbs.gpu_neon.enhancement_tex_adj = 1; + else + pl_rearmed_cbs.gpu_neon.enhancement_tex_adj = 0; } #endif diff --git a/frontend/libretro_core_options.h b/frontend/libretro_core_options.h index a0cd2ac1..a5816ca5 100644 --- a/frontend/libretro_core_options.h +++ b/frontend/libretro_core_options.h @@ -510,6 +510,20 @@ struct retro_core_option_v2_definition option_defs_us[] = { }, "disabled", }, + { + "pcsx_rearmed_neon_enhancement_tex_adj", + "(GPU) Enhanced Resolution Texture Adjustment", + "Enhanced Resolution Texture Adjustment", + "(Hack) Attempts to solve some texturing issues is some games, but causes new ones in others.", + NULL, + "gpu_neon", + { + { "disabled", NULL }, + { "enabled", NULL }, + { NULL, NULL }, + }, + "disabled", + }, #endif /* GPU_NEON */ #ifdef GPU_PEOPS { diff --git a/frontend/menu.c b/frontend/menu.c index e6c15402..51cb3771 100644 --- a/frontend/menu.c +++ b/frontend/menu.c @@ -450,6 +450,7 @@ static const struct { CE_INTVAL_P(gpu_neon.allow_interlace), CE_INTVAL_P(gpu_neon.enhancement_enable), CE_INTVAL_P(gpu_neon.enhancement_no_main), + CE_INTVAL_P(gpu_neon.enhancement_tex_adj), CE_INTVAL_P(gpu_peopsgl.bDrawDither), CE_INTVAL_P(gpu_peopsgl.iFilterType), CE_INTVAL_P(gpu_peopsgl.iFrameTexType), @@ -1414,6 +1415,7 @@ static menu_entry e_menu_plugin_gpu_neon[] = mee_enum ("Enable interlace mode", 0, pl_rearmed_cbs.gpu_neon.allow_interlace, men_gpu_interlace), mee_onoff_h ("Enhanced resolution", 0, pl_rearmed_cbs.gpu_neon.enhancement_enable, 1, h_gpu_neon_enhanced), mee_onoff_h ("Enhanced res. speed hack", 0, pl_rearmed_cbs.gpu_neon.enhancement_no_main, 1, h_gpu_neon_enhanced_hack), + mee_onoff ("Enh. res. texture adjust", 0, pl_rearmed_cbs.gpu_neon.enhancement_tex_adj, 1), mee_end, }; diff --git a/frontend/plugin_lib.h b/frontend/plugin_lib.h index 4eab8660..5733ca24 100644 --- a/frontend/plugin_lib.h +++ b/frontend/plugin_lib.h @@ -85,6 +85,7 @@ struct rearmed_cbs { int enhancement_enable; int enhancement_no_main; int allow_dithering; + int enhancement_tex_adj; } gpu_neon; struct { int iUseDither; diff --git a/plugins/gpu_neon/psx_gpu/psx_gpu.h b/plugins/gpu_neon/psx_gpu/psx_gpu.h index 88f3df51..6964a629 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu.h +++ b/plugins/gpu_neon/psx_gpu/psx_gpu.h @@ -200,9 +200,12 @@ typedef struct u16 enhancement_scanout_eselect; // eviction selector u16 enhancement_current_buf; + u32 hack_disable_main:1; + u32 hack_texture_adj:1; + // Align up to 64 byte boundary to keep the upcoming buffers cache line // aligned, also make reachable with single immediate addition - u8 reserved_a[188 + 9*4 - 9*sizeof(void *)]; + u8 reserved_a[184 + 9*4 - 9*sizeof(void *)]; // 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 44fce93a..d81b7078 100644 --- a/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c +++ b/plugins/gpu_neon/psx_gpu/psx_gpu_parse.c @@ -1018,8 +1018,6 @@ void scale2x_tiles8(void *dst, const void *src, int w8, int h) } #endif -static int disable_main_render; - // simple check for a case where no clipping is used // - now handled by adjusting the viewport static int check_enhanced_range(psx_gpu_struct *psx_gpu, int x, int y) @@ -1065,6 +1063,7 @@ static void patch_v(vertex_struct *vertex_ptrs, int count, int old, int new) vertex_ptrs[i].v = new; } +// this sometimes does more harm than good, like in PE2 static void uv_hack(vertex_struct *vertex_ptrs, int vertex_count) { int i, u[4], v[4]; @@ -1103,7 +1102,7 @@ static void do_triangle_enhanced(psx_gpu_struct *psx_gpu, if (!prepare_triangle(psx_gpu, vertexes, vertex_ptrs)) return; - if (!disable_main_render) + if (!psx_gpu->hack_disable_main) render_triangle_p(psx_gpu, vertex_ptrs, current_command); if (!check_enhanced_range(psx_gpu, vertex_ptrs[0]->x, vertex_ptrs[2]->x)) @@ -1322,7 +1321,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv(2, 10); get_vertex_data_xy_uv(3, 14); - uv_hack(vertexes, 4); + if (psx_gpu->hack_texture_adj) + uv_hack(vertexes, 4); do_quad_enhanced(psx_gpu, vertexes, current_command); gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_t()); break; @@ -1375,7 +1375,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size, get_vertex_data_xy_uv_rgb(2, 12); get_vertex_data_xy_uv_rgb(3, 18); - uv_hack(vertexes, 4); + if (psx_gpu->hack_texture_adj) + uv_hack(vertexes, 4); do_quad_enhanced(psx_gpu, vertexes, current_command); gput_sum(cpu_cycles_sum, cpu_cycles, gput_quad_base_gt()); break; diff --git a/plugins/gpu_neon/psx_gpu_if.c b/plugins/gpu_neon/psx_gpu_if.c index 313f1f01..6e7e5fd7 100644 --- a/plugins/gpu_neon/psx_gpu_if.c +++ b/plugins/gpu_neon/psx_gpu_if.c @@ -235,7 +235,8 @@ void renderer_set_config(const struct rearmed_cbs *cbs) egpu.dither_table[3] = dither_table_row(3, -1, 2, -2); } - disable_main_render = cbs->gpu_neon.enhancement_no_main; + egpu.hack_disable_main = cbs->gpu_neon.enhancement_no_main; + egpu.hack_texture_adj = cbs->gpu_neon.enhancement_tex_adj; if (gpu.state.enhancement_enable) { if (gpu.mmap != NULL && egpu.enhancement_buf_ptr == NULL) map_enhancement_buffer();