Skip to content

Commit

Permalink
Merge branch 'master' into libretro
Browse files Browse the repository at this point in the history
  • Loading branch information
notaz committed Dec 9, 2024
2 parents 92bb759 + ed8077c commit ee07de2
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 39 deletions.
22 changes: 9 additions & 13 deletions frontend/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -2186,23 +2186,20 @@ static void update_variables(bool in_flight)

if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "disabled") == 0)
if (strcmp(var.value, "force") == 0)
{
pl_rearmed_cbs.gpu_peops.iUseDither = 0;
pl_rearmed_cbs.dithering = 2;
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1;
}
else if (strcmp(var.value, "disabled") == 0)
{
pl_rearmed_cbs.dithering = 0;
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 0;
pl_rearmed_cbs.gpu_unai.dithering = 0;
#ifdef GPU_NEON
pl_rearmed_cbs.gpu_neon.allow_dithering = 0;
#endif
}
else if (strcmp(var.value, "enabled") == 0)
else
{
pl_rearmed_cbs.gpu_peops.iUseDither = 1;
pl_rearmed_cbs.dithering = 1;
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1;
pl_rearmed_cbs.gpu_unai.dithering = 1;
#ifdef GPU_NEON
pl_rearmed_cbs.gpu_neon.allow_dithering = 1;
#endif
}
}

Expand Down Expand Up @@ -3648,7 +3645,6 @@ void retro_init(void)
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
rumble_cb = rumble.set_rumble_state;

pl_rearmed_cbs.gpu_peops.iUseDither = 1;
pl_rearmed_cbs.gpu_peops.dwActFixes = GPU_PEOPS_OLD_FRAME_SKIP;

SaveFuncs.open = save_open;
Expand Down
3 changes: 2 additions & 1 deletion frontend/libretro_core_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,13 @@ struct retro_core_option_v2_definition option_defs_us[] = {
"pcsx_rearmed_dithering",
"Dithering Pattern",
NULL,
"Enable emulation of the dithering technique used by the PSX to smooth out color banding artifacts. Increases performance requirements.",
"Enable emulation of the dithering technique used by the PSX to smooth out color banding artifacts. \"Force\" enables it even if the game turns it off. Increases performance requirements.",
NULL,
"video",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ "force", "Force" },
{ NULL, NULL },
},
#if defined(_3DS)
Expand Down
4 changes: 1 addition & 3 deletions frontend/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,17 @@ void emu_set_default_config(void)
Config.GpuListWalking = -1;
Config.FractionalFramerate = -1;

pl_rearmed_cbs.dithering = 1;
pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto
pl_rearmed_cbs.gpu_neon.allow_dithering = 1;
pl_rearmed_cbs.gpu_neon.enhancement_enable =
pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0;
pl_rearmed_cbs.gpu_neon.enhancement_tex_adj = 1;
pl_rearmed_cbs.gpu_peops.iUseDither = 0;
pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
pl_rearmed_cbs.gpu_unai.old_renderer = 0;
pl_rearmed_cbs.gpu_unai.ilace_force = 0;
pl_rearmed_cbs.gpu_unai.lighting = 1;
pl_rearmed_cbs.gpu_unai.fast_lighting = 0;
pl_rearmed_cbs.gpu_unai.blending = 1;
pl_rearmed_cbs.gpu_unai.dithering = 0;
memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl));
pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64;
pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1;
Expand Down
10 changes: 4 additions & 6 deletions frontend/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,13 @@ static const struct {
CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]),
CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]),
CE_INTVAL_V(frameskip, 4),
CE_INTVAL_P(gpu_peops.iUseDither),
CE_INTVAL_PV(dithering, 2),
CE_INTVAL_P(gpu_peops.dwActFixes),
CE_INTVAL_P(gpu_unai.old_renderer),
CE_INTVAL_P(gpu_unai.ilace_force),
CE_INTVAL_P(gpu_unai.lighting),
CE_INTVAL_P(gpu_unai.fast_lighting),
CE_INTVAL_P(gpu_unai.blending),
CE_INTVAL_P(gpu_unai.dithering),
CE_INTVAL_P(gpu_unai.scale_hires),
CE_INTVAL_P(gpu_neon.allow_interlace),
CE_INTVAL_P(gpu_neon.enhancement_enable),
Expand Down Expand Up @@ -1427,7 +1426,6 @@ static menu_entry e_menu_plugin_gpu_neon[] =
mee_onoff_h ("Enhanced res. speed hack", 0, pl_rearmed_cbs.gpu_neon.enhancement_no_main, 1, h_gpu_neon_enhanced_hack),
mee_onoff_h ("Enh. res. texture adjust", 0, pl_rearmed_cbs.gpu_neon.enhancement_tex_adj, 1, h_gpu_neon_enhanced_texadj),
mee_enum ("Enable interlace mode", 0, pl_rearmed_cbs.gpu_neon.allow_interlace, men_gpu_interlace),
mee_onoff ("Enable dithering", 0, pl_rearmed_cbs.gpu_neon.allow_dithering, 1),
mee_end,
};

Expand All @@ -1444,7 +1442,6 @@ static menu_entry e_menu_plugin_gpu_unai[] =
{
mee_onoff ("Old renderer", 0, pl_rearmed_cbs.gpu_unai.old_renderer, 1),
mee_onoff ("Interlace", 0, pl_rearmed_cbs.gpu_unai.ilace_force, 1),
mee_onoff ("Dithering", 0, pl_rearmed_cbs.gpu_unai.dithering, 1),
mee_onoff ("Lighting", 0, pl_rearmed_cbs.gpu_unai.lighting, 1),
mee_onoff ("Fast lighting", 0, pl_rearmed_cbs.gpu_unai.fast_lighting, 1),
mee_onoff ("Blending", 0, pl_rearmed_cbs.gpu_unai.blending, 1),
Expand All @@ -1459,7 +1456,6 @@ static int menu_loop_plugin_gpu_unai(int id, int keys)
}


static const char *men_gpu_dithering[] = { "None", "Game dependant", "Always", NULL };
//static const char h_gpu_0[] = "Needed for Chrono Cross";
static const char h_gpu_1[] = "Capcom fighting games";
static const char h_gpu_2[] = "Black screens in Lunar";
Expand All @@ -1472,7 +1468,6 @@ static const char h_gpu_10[] = "Toggle busy flags after drawing";

static menu_entry e_menu_plugin_gpu_peops[] =
{
mee_enum ("Dithering", 0, pl_rearmed_cbs.gpu_peops.iUseDither, men_gpu_dithering),
// mee_onoff_h ("Odd/even bit hack", 0, pl_rearmed_cbs.gpu_peops.dwActFixes, 1<<0, h_gpu_0),
mee_onoff_h ("Expand screen width", 0, pl_rearmed_cbs.gpu_peops.dwActFixes, 1<<1, h_gpu_1),
mee_onoff_h ("Ignore brightness color", 0, pl_rearmed_cbs.gpu_peops.dwActFixes, 1<<2, h_gpu_2),
Expand Down Expand Up @@ -1551,6 +1546,8 @@ static int menu_loop_plugin_spu(int id, int keys)
return 0;
}

static const char *men_gpu_dithering[] = { "OFF", "ON", "Force", NULL };

static const char h_bios[] = "HLE is simulated BIOS. BIOS selection is saved in\n"
"savestates and can't be changed there. Must save\n"
"config and reload the game for change to take effect";
Expand All @@ -1572,6 +1569,7 @@ static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1
static menu_entry e_menu_plugin_options[] =
{
mee_enum_h ("BIOS", 0, bios_sel, bioses, h_bios),
mee_enum ("GPU Dithering", 0, pl_rearmed_cbs.dithering, men_gpu_dithering),
mee_enum_h ("GPU plugin", 0, gpu_plugsel, gpu_plugins, h_plugin_gpu),
mee_enum_h ("SPU plugin", 0, spu_plugsel, spu_plugins, h_plugin_spu),
#ifdef BUILTIN_GPU_NEON
Expand Down
4 changes: 1 addition & 3 deletions frontend/plugin_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@ struct rearmed_cbs {
unsigned int flip_cnt; // increment manually if not using pl_vout_flip
unsigned int only_16bpp; // platform is 16bpp-only
unsigned int thread_rendering;
unsigned int dithering; // 0 off, 1 on, 2 force
struct {
int allow_interlace; // 0 off, 1 on, 2 guess
int enhancement_enable;
int enhancement_no_main;
int allow_dithering;
int enhancement_tex_adj;
} gpu_neon;
struct {
int iUseDither;
int dwActFixes;
float fFrameRateHz;
int dwFrameRateTicks;
Expand All @@ -99,7 +98,6 @@ struct rearmed_cbs {
int lighting;
int fast_lighting;
int blending;
int dithering;
int scale_hires;
} gpu_unai;
struct {
Expand Down
2 changes: 1 addition & 1 deletion plugins/dfxvideo/gpulib_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ void renderer_notify_update_lace(int updated)

void renderer_set_config(const struct rearmed_cbs *cbs)
{
iUseDither = cbs->gpu_peops.iUseDither;
iUseDither = cbs->dithering;
dwActFixes = cbs->gpu_peops.dwActFixes;
if (cbs->pl_set_gpu_caps)
cbs->pl_set_gpu_caps(0);
Expand Down
3 changes: 2 additions & 1 deletion plugins/gpu_neon/psx_gpu/psx_gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ typedef struct
u16 enhancement_scanout_eselect; // eviction selector
u16 enhancement_current_buf;

u32 allow_dithering:1;
u32 force_dithering:1;
u32 hack_disable_main:1;
u32 hack_texture_adj:1;

Expand All @@ -226,7 +228,6 @@ typedef struct
u8 texture_4bpp_cache[32][256 * 256];
u8 texture_8bpp_even_cache[16][256 * 256];
u8 texture_8bpp_odd_cache[16][256 * 256];
int use_dithering;
} psx_gpu_struct;

typedef struct __attribute__((aligned(16)))
Expand Down
6 changes: 4 additions & 2 deletions plugins/gpu_neon/psx_gpu/psx_gpu_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,8 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
case 0xE1:
set_texture(psx_gpu, list[0]);

if(list[0] & (1 << 9))
if ((psx_gpu->allow_dithering && (list[0] & (1 << 9)))
|| psx_gpu->force_dithering)
psx_gpu->render_state_base |= RENDER_STATE_DITHER;
else
psx_gpu->render_state_base &= ~RENDER_STATE_DITHER;
Expand Down Expand Up @@ -1588,7 +1589,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
case 0xE1:
set_texture(psx_gpu, list[0]);

if(list[0] & (1 << 9))
if ((psx_gpu->allow_dithering && (list[0] & (1 << 9)))
|| psx_gpu->force_dithering)
psx_gpu->render_state_base |= RENDER_STATE_DITHER;
else
psx_gpu->render_state_base &= ~RENDER_STATE_DITHER;
Expand Down
7 changes: 5 additions & 2 deletions plugins/gpu_neon/psx_gpu_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,10 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
if (cbs->pl_set_gpu_caps)
cbs->pl_set_gpu_caps(GPU_CAP_SUPPORTS_2X);

egpu.use_dithering = cbs->gpu_neon.allow_dithering;
if(!egpu.use_dithering) {
egpu.allow_dithering = cbs->dithering;
egpu.force_dithering = cbs->dithering >> 1;
/*
if (!egpu.allow_dithering) {
egpu.dither_table[0] = dither_table_row(0, 0, 0, 0);
egpu.dither_table[1] = dither_table_row(0, 0, 0, 0);
egpu.dither_table[2] = dither_table_row(0, 0, 0, 0);
Expand All @@ -235,6 +237,7 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
egpu.dither_table[2] = dither_table_row(-3, 1, -4, 0);
egpu.dither_table[3] = dither_table_row(3, -1, 2, -2);
}
*/

egpu.hack_disable_main = cbs->gpu_neon.enhancement_no_main;
egpu.hack_texture_adj = cbs->gpu_neon.enhancement_tex_adj;
Expand Down
1 change: 1 addition & 0 deletions plugins/gpu_unai/gpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ struct gpu_unai_config_t {
uint8_t fast_lighting:1;
uint8_t blending:1;
uint8_t dithering:1;
uint8_t force_dithering:1;
uint8_t old_renderer:1;

//senquack Only PCSX Rearmed's version of gpu_unai had this, and I
Expand Down
6 changes: 1 addition & 5 deletions plugins/gpu_unai/gpu_unai.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,13 +360,9 @@ static inline bool DitheringEnabled()
return gpu_unai.config.dithering;
}

// For now, this is just for development/experimentation purposes..
// If modified to return true, it will allow ignoring the status register
// bit 9 setting (dither enable). It will still restrict dithering only
// to Gouraud-shaded or texture-blended polys.
static inline bool ForcedDitheringEnabled()
{
return false;
return gpu_unai.config.force_dithering;
}

static inline bool ProgressiveInterlaceEnabled()
Expand Down
3 changes: 2 additions & 1 deletion plugins/gpu_unai/gpulib_if.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,8 +883,9 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
gpu_unai.config.lighting = cbs->gpu_unai.lighting;
gpu_unai.config.fast_lighting = cbs->gpu_unai.fast_lighting;
gpu_unai.config.blending = cbs->gpu_unai.blending;
gpu_unai.config.dithering = cbs->gpu_unai.dithering;
gpu_unai.config.scale_hires = cbs->gpu_unai.scale_hires;
gpu_unai.config.dithering = cbs->dithering != 0;
gpu_unai.config.force_dithering = cbs->dithering >> 1;

gpu.state.downscale_enable = gpu_unai.config.scale_hires;
if (gpu_unai.config.scale_hires) {
Expand Down
2 changes: 1 addition & 1 deletion plugins/gpulib/gpulib_thread_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ static void *video_thread_main(void *arg) {

#if defined(__arm__) && defined(__ARM_FP)
// RunFast mode
u32 fpscr = ~0;
uint32_t fpscr = ~0;
__asm__ volatile("vmrs %0, fpscr" : "=r"(fpscr));
fpscr &= ~0x00009f9f;
fpscr |= 0x03000000; // DN | FZ
Expand Down

0 comments on commit ee07de2

Please sign in to comment.