Skip to content

Commit ee07de2

Browse files
committed
Merge branch 'master' into libretro
2 parents 92bb759 + ed8077c commit ee07de2

13 files changed

+34
-39
lines changed

frontend/libretro.c

+9-13
Original file line numberDiff line numberDiff line change
@@ -2186,23 +2186,20 @@ static void update_variables(bool in_flight)
21862186

21872187
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
21882188
{
2189-
if (strcmp(var.value, "disabled") == 0)
2189+
if (strcmp(var.value, "force") == 0)
21902190
{
2191-
pl_rearmed_cbs.gpu_peops.iUseDither = 0;
2191+
pl_rearmed_cbs.dithering = 2;
2192+
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1;
2193+
}
2194+
else if (strcmp(var.value, "disabled") == 0)
2195+
{
2196+
pl_rearmed_cbs.dithering = 0;
21922197
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 0;
2193-
pl_rearmed_cbs.gpu_unai.dithering = 0;
2194-
#ifdef GPU_NEON
2195-
pl_rearmed_cbs.gpu_neon.allow_dithering = 0;
2196-
#endif
21972198
}
2198-
else if (strcmp(var.value, "enabled") == 0)
2199+
else
21992200
{
2200-
pl_rearmed_cbs.gpu_peops.iUseDither = 1;
2201+
pl_rearmed_cbs.dithering = 1;
22012202
pl_rearmed_cbs.gpu_peopsgl.bDrawDither = 1;
2202-
pl_rearmed_cbs.gpu_unai.dithering = 1;
2203-
#ifdef GPU_NEON
2204-
pl_rearmed_cbs.gpu_neon.allow_dithering = 1;
2205-
#endif
22062203
}
22072204
}
22082205

@@ -3648,7 +3645,6 @@ void retro_init(void)
36483645
if (environ_cb(RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE, &rumble))
36493646
rumble_cb = rumble.set_rumble_state;
36503647

3651-
pl_rearmed_cbs.gpu_peops.iUseDither = 1;
36523648
pl_rearmed_cbs.gpu_peops.dwActFixes = GPU_PEOPS_OLD_FRAME_SKIP;
36533649

36543650
SaveFuncs.open = save_open;

frontend/libretro_core_options.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -319,12 +319,13 @@ struct retro_core_option_v2_definition option_defs_us[] = {
319319
"pcsx_rearmed_dithering",
320320
"Dithering Pattern",
321321
NULL,
322-
"Enable emulation of the dithering technique used by the PSX to smooth out color banding artifacts. Increases performance requirements.",
322+
"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.",
323323
NULL,
324324
"video",
325325
{
326326
{ "disabled", NULL },
327327
{ "enabled", NULL },
328+
{ "force", "Force" },
328329
{ NULL, NULL },
329330
},
330331
#if defined(_3DS)

frontend/main.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,17 @@ void emu_set_default_config(void)
129129
Config.GpuListWalking = -1;
130130
Config.FractionalFramerate = -1;
131131

132+
pl_rearmed_cbs.dithering = 1;
132133
pl_rearmed_cbs.gpu_neon.allow_interlace = 2; // auto
133-
pl_rearmed_cbs.gpu_neon.allow_dithering = 1;
134134
pl_rearmed_cbs.gpu_neon.enhancement_enable =
135135
pl_rearmed_cbs.gpu_neon.enhancement_no_main = 0;
136136
pl_rearmed_cbs.gpu_neon.enhancement_tex_adj = 1;
137-
pl_rearmed_cbs.gpu_peops.iUseDither = 0;
138137
pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
139138
pl_rearmed_cbs.gpu_unai.old_renderer = 0;
140139
pl_rearmed_cbs.gpu_unai.ilace_force = 0;
141140
pl_rearmed_cbs.gpu_unai.lighting = 1;
142141
pl_rearmed_cbs.gpu_unai.fast_lighting = 0;
143142
pl_rearmed_cbs.gpu_unai.blending = 1;
144-
pl_rearmed_cbs.gpu_unai.dithering = 0;
145143
memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl));
146144
pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64;
147145
pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1;

frontend/menu.c

+4-6
Original file line numberDiff line numberDiff line change
@@ -441,14 +441,13 @@ static const struct {
441441
CE_INTVAL_N("adev0_is_nublike", in_adev_is_nublike[0]),
442442
CE_INTVAL_N("adev1_is_nublike", in_adev_is_nublike[1]),
443443
CE_INTVAL_V(frameskip, 4),
444-
CE_INTVAL_P(gpu_peops.iUseDither),
444+
CE_INTVAL_PV(dithering, 2),
445445
CE_INTVAL_P(gpu_peops.dwActFixes),
446446
CE_INTVAL_P(gpu_unai.old_renderer),
447447
CE_INTVAL_P(gpu_unai.ilace_force),
448448
CE_INTVAL_P(gpu_unai.lighting),
449449
CE_INTVAL_P(gpu_unai.fast_lighting),
450450
CE_INTVAL_P(gpu_unai.blending),
451-
CE_INTVAL_P(gpu_unai.dithering),
452451
CE_INTVAL_P(gpu_unai.scale_hires),
453452
CE_INTVAL_P(gpu_neon.allow_interlace),
454453
CE_INTVAL_P(gpu_neon.enhancement_enable),
@@ -1427,7 +1426,6 @@ static menu_entry e_menu_plugin_gpu_neon[] =
14271426
mee_onoff_h ("Enhanced res. speed hack", 0, pl_rearmed_cbs.gpu_neon.enhancement_no_main, 1, h_gpu_neon_enhanced_hack),
14281427
mee_onoff_h ("Enh. res. texture adjust", 0, pl_rearmed_cbs.gpu_neon.enhancement_tex_adj, 1, h_gpu_neon_enhanced_texadj),
14291428
mee_enum ("Enable interlace mode", 0, pl_rearmed_cbs.gpu_neon.allow_interlace, men_gpu_interlace),
1430-
mee_onoff ("Enable dithering", 0, pl_rearmed_cbs.gpu_neon.allow_dithering, 1),
14311429
mee_end,
14321430
};
14331431

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

14611458

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

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

1549+
static const char *men_gpu_dithering[] = { "OFF", "ON", "Force", NULL };
1550+
15541551
static const char h_bios[] = "HLE is simulated BIOS. BIOS selection is saved in\n"
15551552
"savestates and can't be changed there. Must save\n"
15561553
"config and reload the game for change to take effect";
@@ -1572,6 +1569,7 @@ static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1
15721569
static menu_entry e_menu_plugin_options[] =
15731570
{
15741571
mee_enum_h ("BIOS", 0, bios_sel, bioses, h_bios),
1572+
mee_enum ("GPU Dithering", 0, pl_rearmed_cbs.dithering, men_gpu_dithering),
15751573
mee_enum_h ("GPU plugin", 0, gpu_plugsel, gpu_plugins, h_plugin_gpu),
15761574
mee_enum_h ("SPU plugin", 0, spu_plugsel, spu_plugins, h_plugin_spu),
15771575
#ifdef BUILTIN_GPU_NEON

frontend/plugin_lib.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,14 @@ struct rearmed_cbs {
8080
unsigned int flip_cnt; // increment manually if not using pl_vout_flip
8181
unsigned int only_16bpp; // platform is 16bpp-only
8282
unsigned int thread_rendering;
83+
unsigned int dithering; // 0 off, 1 on, 2 force
8384
struct {
8485
int allow_interlace; // 0 off, 1 on, 2 guess
8586
int enhancement_enable;
8687
int enhancement_no_main;
87-
int allow_dithering;
8888
int enhancement_tex_adj;
8989
} gpu_neon;
9090
struct {
91-
int iUseDither;
9291
int dwActFixes;
9392
float fFrameRateHz;
9493
int dwFrameRateTicks;
@@ -99,7 +98,6 @@ struct rearmed_cbs {
9998
int lighting;
10099
int fast_lighting;
101100
int blending;
102-
int dithering;
103101
int scale_hires;
104102
} gpu_unai;
105103
struct {

plugins/dfxvideo/gpulib_if.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ void renderer_notify_update_lace(int updated)
496496

497497
void renderer_set_config(const struct rearmed_cbs *cbs)
498498
{
499-
iUseDither = cbs->gpu_peops.iUseDither;
499+
iUseDither = cbs->dithering;
500500
dwActFixes = cbs->gpu_peops.dwActFixes;
501501
if (cbs->pl_set_gpu_caps)
502502
cbs->pl_set_gpu_caps(0);

plugins/gpu_neon/psx_gpu/psx_gpu.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ typedef struct
208208
u16 enhancement_scanout_eselect; // eviction selector
209209
u16 enhancement_current_buf;
210210

211+
u32 allow_dithering:1;
212+
u32 force_dithering:1;
211213
u32 hack_disable_main:1;
212214
u32 hack_texture_adj:1;
213215

@@ -226,7 +228,6 @@ typedef struct
226228
u8 texture_4bpp_cache[32][256 * 256];
227229
u8 texture_8bpp_even_cache[16][256 * 256];
228230
u8 texture_8bpp_odd_cache[16][256 * 256];
229-
int use_dithering;
230231
} psx_gpu_struct;
231232

232233
typedef struct __attribute__((aligned(16)))

plugins/gpu_neon/psx_gpu/psx_gpu_parse.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -661,7 +661,8 @@ u32 gpu_parse(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
661661
case 0xE1:
662662
set_texture(psx_gpu, list[0]);
663663

664-
if(list[0] & (1 << 9))
664+
if ((psx_gpu->allow_dithering && (list[0] & (1 << 9)))
665+
|| psx_gpu->force_dithering)
665666
psx_gpu->render_state_base |= RENDER_STATE_DITHER;
666667
else
667668
psx_gpu->render_state_base &= ~RENDER_STATE_DITHER;
@@ -1588,7 +1589,8 @@ u32 gpu_parse_enhanced(psx_gpu_struct *psx_gpu, u32 *list, u32 size,
15881589
case 0xE1:
15891590
set_texture(psx_gpu, list[0]);
15901591

1591-
if(list[0] & (1 << 9))
1592+
if ((psx_gpu->allow_dithering && (list[0] & (1 << 9)))
1593+
|| psx_gpu->force_dithering)
15921594
psx_gpu->render_state_base |= RENDER_STATE_DITHER;
15931595
else
15941596
psx_gpu->render_state_base &= ~RENDER_STATE_DITHER;

plugins/gpu_neon/psx_gpu_if.c

+5-2
Original file line numberDiff line numberDiff line change
@@ -223,8 +223,10 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
223223
if (cbs->pl_set_gpu_caps)
224224
cbs->pl_set_gpu_caps(GPU_CAP_SUPPORTS_2X);
225225

226-
egpu.use_dithering = cbs->gpu_neon.allow_dithering;
227-
if(!egpu.use_dithering) {
226+
egpu.allow_dithering = cbs->dithering;
227+
egpu.force_dithering = cbs->dithering >> 1;
228+
/*
229+
if (!egpu.allow_dithering) {
228230
egpu.dither_table[0] = dither_table_row(0, 0, 0, 0);
229231
egpu.dither_table[1] = dither_table_row(0, 0, 0, 0);
230232
egpu.dither_table[2] = dither_table_row(0, 0, 0, 0);
@@ -235,6 +237,7 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
235237
egpu.dither_table[2] = dither_table_row(-3, 1, -4, 0);
236238
egpu.dither_table[3] = dither_table_row(3, -1, 2, -2);
237239
}
240+
*/
238241

239242
egpu.hack_disable_main = cbs->gpu_neon.enhancement_no_main;
240243
egpu.hack_texture_adj = cbs->gpu_neon.enhancement_tex_adj;

plugins/gpu_unai/gpu.h

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct gpu_unai_config_t {
4646
uint8_t fast_lighting:1;
4747
uint8_t blending:1;
4848
uint8_t dithering:1;
49+
uint8_t force_dithering:1;
4950
uint8_t old_renderer:1;
5051

5152
//senquack Only PCSX Rearmed's version of gpu_unai had this, and I

plugins/gpu_unai/gpu_unai.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,9 @@ static inline bool DitheringEnabled()
360360
return gpu_unai.config.dithering;
361361
}
362362

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

372368
static inline bool ProgressiveInterlaceEnabled()

plugins/gpu_unai/gpulib_if.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -883,8 +883,9 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
883883
gpu_unai.config.lighting = cbs->gpu_unai.lighting;
884884
gpu_unai.config.fast_lighting = cbs->gpu_unai.fast_lighting;
885885
gpu_unai.config.blending = cbs->gpu_unai.blending;
886-
gpu_unai.config.dithering = cbs->gpu_unai.dithering;
887886
gpu_unai.config.scale_hires = cbs->gpu_unai.scale_hires;
887+
gpu_unai.config.dithering = cbs->dithering != 0;
888+
gpu_unai.config.force_dithering = cbs->dithering >> 1;
888889

889890
gpu.state.downscale_enable = gpu_unai.config.scale_hires;
890891
if (gpu_unai.config.scale_hires) {

plugins/gpulib/gpulib_thread_if.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ static void *video_thread_main(void *arg) {
7878

7979
#if defined(__arm__) && defined(__ARM_FP)
8080
// RunFast mode
81-
u32 fpscr = ~0;
81+
uint32_t fpscr = ~0;
8282
__asm__ volatile("vmrs %0, fpscr" : "=r"(fpscr));
8383
fpscr &= ~0x00009f9f;
8484
fpscr |= 0x03000000; // DN | FZ

0 commit comments

Comments
 (0)