Skip to content

Commit 2163da5

Browse files
committed
merge gpu_unai with gpu_unai_old
Can now switch between them during gameplay. Specify GPU_UNAI_NO_OLD=1 to prevent compiling this in to save memory or whatever. No big endian support.
1 parent d196572 commit 2163da5

32 files changed

+103
-107
lines changed

Makefile

+8-9
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,6 @@ CFLAGS += -DTHREAD_RENDERING
255255
OBJS += plugins/gpulib/gpulib_thread_if.o
256256
endif
257257
endif
258-
ifeq "$(BUILTIN_GPU)" "unai_old"
259-
OBJS += plugins/gpu_unai_old/gpulib_if.o
260-
ifeq "$(ARCH)" "arm"
261-
OBJS += plugins/gpu_unai_old/gpu_arm.o
262-
endif
263-
plugins/gpu_unai_old/gpulib_if.o: CFLAGS += -DREARMED -O3
264-
CC_LINK = $(CXX)
265-
endif
266258

267259
ifeq "$(BUILTIN_GPU)" "unai"
268260
CFLAGS += -DGPU_UNAI
@@ -275,7 +267,14 @@ ifeq "$(THREAD_RENDERING)" "1"
275267
CFLAGS += -DTHREAD_RENDERING
276268
OBJS += plugins/gpulib/gpulib_thread_if.o
277269
endif
278-
plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1 -O3
270+
ifneq "$(GPU_UNAI_NO_OLD)" "1"
271+
OBJS += plugins/gpu_unai/old/if.o
272+
else
273+
CFLAGS += -DGPU_UNAI_NO_OLD
274+
endif
275+
plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1
276+
plugins/gpu_unai/gpulib_if.o \
277+
plugins/gpu_unai/old/if.o: CFLAGS += -O3
279278
CC_LINK = $(CXX)
280279
endif
281280

configure

+3-3
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ check_define_val()
3939

4040
platform_list="generic pandora maemo caanoo"
4141
platform="generic"
42-
builtin_gpu_list="neon peops unai unai_old"
42+
builtin_gpu_list="neon peops unai"
4343
dynarec_list="ari64 lightrec none"
4444
builtin_gpu=""
4545
sound_driver_list="oss alsa pulseaudio sdl"
4646
sound_drivers=""
4747
plugins="plugins/spunull/spunull.so \
48-
plugins/dfxvideo/gpu_peops.so plugins/gpu_unai_old/gpu_unai_old.so plugins/gpu_unai/gpu_unai.so"
48+
plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
4949
drc_cache_base="no"
5050
have_armv5=""
5151
have_armv6=""
@@ -263,7 +263,7 @@ arm*)
263263
builtin_gpu="neon"
264264
elif [ "$have_armv7" != "yes" ]; then
265265
# pre-ARMv7 hardware is usually not fast enough for peops
266-
builtin_gpu="unai_old"
266+
builtin_gpu="unai"
267267
else
268268
builtin_gpu="peops"
269269
fi

frontend/libretro.c

+11
Original file line numberDiff line numberDiff line change
@@ -2641,6 +2641,17 @@ static void update_variables(bool in_flight)
26412641
* pcsx_rearmed_gpu_unai_scale_hires */
26422642
pl_rearmed_cbs.gpu_unai.pixel_skip = 0;
26432643

2644+
var.key = "pcsx_rearmed_gpu_unai_old_renderer";
2645+
var.value = NULL;
2646+
2647+
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
2648+
{
2649+
if (strcmp(var.value, "enabled") == 0)
2650+
pl_rearmed_cbs.gpu_unai.old_renderer = 1;
2651+
else
2652+
pl_rearmed_cbs.gpu_unai.old_renderer = 0;
2653+
}
2654+
26442655
var.key = "pcsx_rearmed_gpu_unai_lighting";
26452656
var.value = NULL;
26462657

frontend/libretro_core_options.h

+16
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,22 @@ struct retro_core_option_v2_definition option_defs_us[] = {
726726
},
727727
"disabled",
728728
},
729+
#ifndef GPU_UNAI_NO_OLD
730+
{
731+
"pcsx_rearmed_gpu_unai_old_renderer",
732+
"(GPU) Old renderer",
733+
"Old renderer",
734+
"This enables faster, but less accurate code.",
735+
NULL,
736+
"gpu_unai",
737+
{
738+
{ "disabled", NULL },
739+
{ "enabled", NULL },
740+
{ NULL, NULL},
741+
},
742+
"disabled",
743+
},
744+
#endif
729745
{
730746
"pcsx_rearmed_gpu_unai_blending",
731747
"(GPU) Texture Blending",

frontend/main.c

+1-3
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,13 @@ void emu_set_default_config(void)
136136
pl_rearmed_cbs.gpu_neon.enhancement_tex_adj = 1;
137137
pl_rearmed_cbs.gpu_peops.iUseDither = 0;
138138
pl_rearmed_cbs.gpu_peops.dwActFixes = 1<<7;
139+
pl_rearmed_cbs.gpu_unai.old_renderer = 0;
139140
pl_rearmed_cbs.gpu_unai.ilace_force = 0;
140141
pl_rearmed_cbs.gpu_unai.pixel_skip = 0;
141142
pl_rearmed_cbs.gpu_unai.lighting = 1;
142143
pl_rearmed_cbs.gpu_unai.fast_lighting = 0;
143144
pl_rearmed_cbs.gpu_unai.blending = 1;
144145
pl_rearmed_cbs.gpu_unai.dithering = 0;
145-
pl_rearmed_cbs.gpu_unai_old.abe_hack =
146-
pl_rearmed_cbs.gpu_unai_old.no_light =
147-
pl_rearmed_cbs.gpu_unai_old.no_blend = 0;
148146
memset(&pl_rearmed_cbs.gpu_peopsgl, 0, sizeof(pl_rearmed_cbs.gpu_peopsgl));
149147
pl_rearmed_cbs.gpu_peopsgl.iVRamSize = 64;
150148
pl_rearmed_cbs.gpu_peopsgl.iTexGarbageCollection = 1;

frontend/menu.c

+3-24
Original file line numberDiff line numberDiff line change
@@ -443,10 +443,7 @@ static const struct {
443443
CE_INTVAL_V(frameskip, 4),
444444
CE_INTVAL_P(gpu_peops.iUseDither),
445445
CE_INTVAL_P(gpu_peops.dwActFixes),
446-
CE_INTVAL_P(gpu_unai_old.lineskip),
447-
CE_INTVAL_P(gpu_unai_old.abe_hack),
448-
CE_INTVAL_P(gpu_unai_old.no_light),
449-
CE_INTVAL_P(gpu_unai_old.no_blend),
446+
CE_INTVAL_P(gpu_unai.old_renderer),
450447
CE_INTVAL_P(gpu_unai.ilace_force),
451448
CE_INTVAL_P(gpu_unai.pixel_skip),
452449
CE_INTVAL_P(gpu_unai.lighting),
@@ -1444,24 +1441,9 @@ static int menu_loop_plugin_gpu_neon(int id, int keys)
14441441

14451442
#endif
14461443

1447-
static menu_entry e_menu_plugin_gpu_unai_old[] =
1448-
{
1449-
mee_onoff ("Skip every 2nd line", 0, pl_rearmed_cbs.gpu_unai_old.lineskip, 1),
1450-
mee_onoff ("Abe's Odyssey hack", 0, pl_rearmed_cbs.gpu_unai_old.abe_hack, 1),
1451-
mee_onoff ("Disable lighting", 0, pl_rearmed_cbs.gpu_unai_old.no_light, 1),
1452-
mee_onoff ("Disable blending", 0, pl_rearmed_cbs.gpu_unai_old.no_blend, 1),
1453-
mee_end,
1454-
};
1455-
1456-
static int menu_loop_plugin_gpu_unai_old(int id, int keys)
1457-
{
1458-
int sel = 0;
1459-
me_loop(e_menu_plugin_gpu_unai_old, &sel);
1460-
return 0;
1461-
}
1462-
14631444
static menu_entry e_menu_plugin_gpu_unai[] =
14641445
{
1446+
mee_onoff ("Old renderer", 0, pl_rearmed_cbs.gpu_unai.old_renderer, 1),
14651447
mee_onoff ("Interlace", 0, pl_rearmed_cbs.gpu_unai.ilace_force, 1),
14661448
mee_onoff ("Dithering", 0, pl_rearmed_cbs.gpu_unai.dithering, 1),
14671449
mee_onoff ("Lighting", 0, pl_rearmed_cbs.gpu_unai.lighting, 1),
@@ -1579,15 +1561,13 @@ static const char h_plugin_gpu[] =
15791561
"builtin_gpu is the NEON GPU, very fast and accurate\n"
15801562
#endif
15811563
"gpu_peops is Pete's soft GPU, slow but accurate\n"
1582-
"gpu_unai_old is from old PCSX4ALL, fast but glitchy\n"
1583-
"gpu_unai is newer, more accurate but slower\n"
1564+
"gpu_unai is the GPU renderer from PCSX4ALL\n"
15841565
"gpu_gles Pete's hw GPU, uses 3D chip but is glitchy\n"
15851566
"must save config and reload the game if changed";
15861567
static const char h_plugin_spu[] = "spunull effectively disables sound\n"
15871568
"must save config and reload the game if changed";
15881569
static const char h_gpu_peops[] = "Configure P.E.Op.S. SoftGL Driver V1.17";
15891570
static const char h_gpu_peopsgl[]= "Configure P.E.Op.S. MesaGL Driver V1.78";
1590-
static const char h_gpu_unai_old[] = "Configure Unai/PCSX4ALL Team GPU plugin (old)";
15911571
static const char h_gpu_unai[] = "Configure Unai/PCSX4ALL Team plugin (new)";
15921572
static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1.7";
15931573

@@ -1600,7 +1580,6 @@ static menu_entry e_menu_plugin_options[] =
16001580
mee_handler_h ("Configure built-in GPU plugin", menu_loop_plugin_gpu_neon, h_gpu_neon),
16011581
#endif
16021582
mee_handler_h ("Configure gpu_peops plugin", menu_loop_plugin_gpu_peops, h_gpu_peops),
1603-
mee_handler_h ("Configure gpu_unai_old GPU plugin", menu_loop_plugin_gpu_unai_old, h_gpu_unai_old),
16041583
mee_handler_h ("Configure gpu_unai GPU plugin", menu_loop_plugin_gpu_unai, h_gpu_unai),
16051584
mee_handler_h ("Configure gpu_gles GPU plugin", menu_loop_plugin_gpu_peopsgl, h_gpu_peopsgl),
16061585
mee_handler_h ("Configure built-in SPU plugin", menu_loop_plugin_spu, h_spu),

frontend/plugin_lib.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,7 @@ struct rearmed_cbs {
9494
int dwFrameRateTicks;
9595
} gpu_peops;
9696
struct {
97-
int abe_hack;
98-
int no_light, no_blend;
99-
int lineskip;
100-
} gpu_unai_old;
101-
struct {
97+
int old_renderer;
10298
int ilace_force;
10399
int pixel_skip;
104100
int lighting;

plugins/gpu_unai/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ CFLAGS += -DUSE_GPULIB=1
88
include ../../config.mak
99

1010
SRC_STANDALONE += gpu.cpp
11-
SRC_GPULIB += gpulib_if.cpp
11+
SRC_GPULIB += gpulib_if.cpp old/if.cpp
1212

1313
ifeq "$(ARCH)" "arm"
1414
SRC += gpu_arm.S

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 old_renderer:1;
4950

5051
//senquack Only PCSX Rearmed's version of gpu_unai had this, and I
5152
// don't think it's necessary. It would require adding 'AH' flag to

plugins/gpu_unai/gpu_fixedpoint.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,14 @@ INLINE float FloatInv(const float x)
7575
///////////////////////////////////////////////////////////////////////////
7676
// --- BEGIN INVERSE APPROXIMATION SECTION ---
7777
///////////////////////////////////////////////////////////////////////////
78-
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
78+
#if defined(GPU_UNAI_USE_INT_DIV_MULTINV) || !defined(GPU_UNAI_NO_OLD)
7979

8080
// big precision inverse table.
8181
#define TABLE_BITS 16
8282
s32 s_invTable[(1<<TABLE_BITS)];
83+
#endif
8384

85+
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
8486
//senquack - MIPS32 happens to have same instruction/format:
8587
#if defined(__arm__) || (__mips == 32)
8688
INLINE u32 Log2(u32 x) { u32 res; asm("clz %0,%1" : "=r" (res) : "r" (x)); return 32-res; }

plugins/gpu_unai/gpulib_if.cpp

+19-3
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include <stdlib.h>
2626
#include <string.h>
2727
#include "../gpulib/gpu.h"
28+
#include "old/if.h"
2829

2930
#ifdef THREAD_RENDERING
3031
#include "../gpulib/gpulib_thread_if.h"
@@ -68,6 +69,12 @@
6869

6970
/////////////////////////////////////////////////////////////////////////////
7071

72+
#ifndef GPU_UNAI_NO_OLD
73+
#define IS_OLD_RENDERER() gpu_unai.config.old_renderer
74+
#else
75+
#define IS_OLD_RENDERER() false
76+
#endif
77+
7178
#define DOWNSCALE_VRAM_SIZE (1024 * 512 * 2 * 2 + 4096)
7279

7380
INLINE void scale_640_to_320(le16_t *dest, const le16_t *src, bool isRGB24) {
@@ -247,7 +254,7 @@ int renderer_init(void)
247254
//gpu_unai.config.enableAbbeyHack = gpu_unai_config_ext.abe_hack;
248255
gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
249256

250-
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
257+
#if defined(GPU_UNAI_USE_INT_DIV_MULTINV) || !defined(GPU_UNAI_NO_OLD)
251258
// s_invTable
252259
for(int i=1;i<=(1<<TABLE_BITS);++i)
253260
{
@@ -403,6 +410,9 @@ int do_cmd_list(u32 *list_, int list_len,
403410
le32_t *list_start = list;
404411
le32_t *list_end = list + list_len;
405412

413+
if (IS_OLD_RENDERER())
414+
return oldunai_do_cmd_list(list_, list_len, cycles_sum_out, cycles_last, last_cmd);
415+
406416
//TODO: set ilace_mask when resolution changes instead of every time,
407417
// eliminate #ifdef below.
408418
gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
@@ -825,8 +835,12 @@ int do_cmd_list(u32 *list_, int list_len,
825835

826836
void renderer_sync_ecmds(u32 *ecmds)
827837
{
828-
int dummy;
829-
do_cmd_list(&ecmds[1], 6, &dummy, &dummy, &dummy);
838+
if (!IS_OLD_RENDERER()) {
839+
int dummy;
840+
do_cmd_list(&ecmds[1], 6, &dummy, &dummy, &dummy);
841+
}
842+
else
843+
oldunai_renderer_sync_ecmds(ecmds);
830844
}
831845

832846
void renderer_update_caches(int x, int y, int w, int h, int state_changed)
@@ -846,6 +860,7 @@ void renderer_set_interlace(int enable, int is_odd)
846860
void renderer_set_config(const struct rearmed_cbs *cbs)
847861
{
848862
gpu_unai.vram = (le16_t *)gpu.vram;
863+
gpu_unai.config.old_renderer = cbs->gpu_unai.old_renderer;
849864
gpu_unai.config.ilace_force = cbs->gpu_unai.ilace_force;
850865
gpu_unai.config.pixel_skip = cbs->gpu_unai.pixel_skip;
851866
gpu_unai.config.lighting = cbs->gpu_unai.lighting;
@@ -860,6 +875,7 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
860875
} else {
861876
unmap_downscale_buffer();
862877
}
878+
oldunai_renderer_set_config(cbs);
863879
}
864880

865881
void renderer_sync(void)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

plugins/gpu_unai_old/gpu_fixedpoint.h plugins/gpu_unai/old/gpu_fixedpoint.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ typedef s32 fixed;
3939
#define fixed_HALF ((fixed)((1<<FIXED_BITS)>>1))
4040

4141
// big precision inverse table.
42-
s32 s_invTable[(1<<TABLE_BITS)];
42+
extern s32 s_invTable[(1<<TABLE_BITS)];
4343

4444
INLINE fixed i2x(const int _x) { return ((_x)<<FIXED_BITS); }
4545
INLINE fixed x2i(const fixed _x) { return ((_x)>>FIXED_BITS); }
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)