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.
This commit is contained in:
notaz 2024-10-27 01:32:40 +03:00
parent a6a0a4d316
commit 5ddc3a7a2e
32 changed files with 107 additions and 107 deletions

View File

@ -227,21 +227,24 @@ plugins/dfxvideo/gpulib_if.o: CFLAGS += -fno-strict-aliasing
plugins/dfxvideo/gpulib_if.o: plugins/dfxvideo/prim.c plugins/dfxvideo/soft.c
OBJS += plugins/dfxvideo/gpulib_if.o
endif
ifeq "$(BUILTIN_GPU)" "unai_old"
OBJS += plugins/gpu_unai_old/gpulib_if.o
ifeq "$(ARCH)" "arm"
OBJS += plugins/gpu_unai_old/gpu_arm.o
endif
plugins/gpu_unai_old/gpulib_if.o: CFLAGS += -DREARMED -O3
CC_LINK = $(CXX)
endif
ifeq "$(BUILTIN_GPU)" "unai"
OBJS += plugins/gpu_unai/gpulib_if.o
ifeq "$(ARCH)" "arm"
OBJS += plugins/gpu_unai/gpu_arm.o
endif
plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1 -O3
ifeq "$(THREAD_RENDERING)" "1"
CFLAGS += -DTHREAD_RENDERING
OBJS += plugins/gpulib/gpulib_thread_if.o
endif
ifneq "$(GPU_UNAI_NO_OLD)" "1"
OBJS += plugins/gpu_unai/old/if.o
else
CFLAGS += -DGPU_UNAI_NO_OLD
endif
plugins/gpu_unai/gpulib_if.o: CFLAGS += -DREARMED -DUSE_GPULIB=1
plugins/gpu_unai/gpulib_if.o \
plugins/gpu_unai/old/if.o: CFLAGS += -O3
CC_LINK = $(CXX)
endif

6
configure vendored
View File

@ -39,13 +39,13 @@ check_define_val()
platform_list="generic pandora maemo caanoo"
platform="generic"
builtin_gpu_list="neon peops unai unai_old"
builtin_gpu_list="neon peops unai"
dynarec_list="ari64 lightrec none"
builtin_gpu=""
sound_driver_list="oss alsa pulseaudio sdl"
sound_drivers=""
plugins="plugins/spunull/spunull.so \
plugins/dfxvideo/gpu_peops.so plugins/gpu_unai_old/gpu_unai_old.so plugins/gpu_unai/gpu_unai.so"
plugins/dfxvideo/gpu_peops.so plugins/gpu_unai/gpu_unai.so"
drc_cache_base="no"
have_armv5=""
have_armv6=""
@ -263,7 +263,7 @@ arm*)
builtin_gpu="neon"
elif [ "$have_armv7" != "yes" ]; then
# pre-ARMv7 hardware is usually not fast enough for peops
builtin_gpu="unai_old"
builtin_gpu="unai"
else
builtin_gpu="peops"
fi

View File

@ -2641,6 +2641,17 @@ static void update_variables(bool in_flight)
* pcsx_rearmed_gpu_unai_scale_hires */
pl_rearmed_cbs.gpu_unai.pixel_skip = 0;
var.key = "pcsx_rearmed_gpu_unai_old_renderer";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
if (strcmp(var.value, "enabled") == 0)
pl_rearmed_cbs.gpu_unai.old_renderer = 1;
else
pl_rearmed_cbs.gpu_unai.old_renderer = 0;
}
var.key = "pcsx_rearmed_gpu_unai_lighting";
var.value = NULL;

View File

@ -726,6 +726,22 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"disabled",
},
#ifndef GPU_UNAI_NO_OLD
{
"pcsx_rearmed_gpu_unai_old_renderer",
"(GPU) Old renderer",
"Old renderer",
"This enables faster, but less accurate code.",
NULL,
"gpu_unai",
{
{ "disabled", NULL },
{ "enabled", NULL },
{ NULL, NULL},
},
"disabled",
},
#endif
{
"pcsx_rearmed_gpu_unai_blending",
"(GPU) Texture Blending",

View File

@ -136,15 +136,13 @@ void emu_set_default_config(void)
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.pixel_skip = 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;
pl_rearmed_cbs.gpu_unai_old.abe_hack =
pl_rearmed_cbs.gpu_unai_old.no_light =
pl_rearmed_cbs.gpu_unai_old.no_blend = 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;

View File

@ -443,10 +443,7 @@ static const struct {
CE_INTVAL_V(frameskip, 4),
CE_INTVAL_P(gpu_peops.iUseDither),
CE_INTVAL_P(gpu_peops.dwActFixes),
CE_INTVAL_P(gpu_unai_old.lineskip),
CE_INTVAL_P(gpu_unai_old.abe_hack),
CE_INTVAL_P(gpu_unai_old.no_light),
CE_INTVAL_P(gpu_unai_old.no_blend),
CE_INTVAL_P(gpu_unai.old_renderer),
CE_INTVAL_P(gpu_unai.ilace_force),
CE_INTVAL_P(gpu_unai.pixel_skip),
CE_INTVAL_P(gpu_unai.lighting),
@ -1444,24 +1441,9 @@ static int menu_loop_plugin_gpu_neon(int id, int keys)
#endif
static menu_entry e_menu_plugin_gpu_unai_old[] =
{
mee_onoff ("Skip every 2nd line", 0, pl_rearmed_cbs.gpu_unai_old.lineskip, 1),
mee_onoff ("Abe's Odyssey hack", 0, pl_rearmed_cbs.gpu_unai_old.abe_hack, 1),
mee_onoff ("Disable lighting", 0, pl_rearmed_cbs.gpu_unai_old.no_light, 1),
mee_onoff ("Disable blending", 0, pl_rearmed_cbs.gpu_unai_old.no_blend, 1),
mee_end,
};
static int menu_loop_plugin_gpu_unai_old(int id, int keys)
{
int sel = 0;
me_loop(e_menu_plugin_gpu_unai_old, &sel);
return 0;
}
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),
@ -1579,15 +1561,13 @@ static const char h_plugin_gpu[] =
"builtin_gpu is the NEON GPU, very fast and accurate\n"
#endif
"gpu_peops is Pete's soft GPU, slow but accurate\n"
"gpu_unai_old is from old PCSX4ALL, fast but glitchy\n"
"gpu_unai is newer, more accurate but slower\n"
"gpu_unai is the GPU renderer from PCSX4ALL\n"
"gpu_gles Pete's hw GPU, uses 3D chip but is glitchy\n"
"must save config and reload the game if changed";
static const char h_plugin_spu[] = "spunull effectively disables sound\n"
"must save config and reload the game if changed";
static const char h_gpu_peops[] = "Configure P.E.Op.S. SoftGL Driver V1.17";
static const char h_gpu_peopsgl[]= "Configure P.E.Op.S. MesaGL Driver V1.78";
static const char h_gpu_unai_old[] = "Configure Unai/PCSX4ALL Team GPU plugin (old)";
static const char h_gpu_unai[] = "Configure Unai/PCSX4ALL Team plugin (new)";
static const char h_spu[] = "Configure built-in P.E.Op.S. Sound Driver V1.7";
@ -1600,7 +1580,6 @@ static menu_entry e_menu_plugin_options[] =
mee_handler_h ("Configure built-in GPU plugin", menu_loop_plugin_gpu_neon, h_gpu_neon),
#endif
mee_handler_h ("Configure gpu_peops plugin", menu_loop_plugin_gpu_peops, h_gpu_peops),
mee_handler_h ("Configure gpu_unai_old GPU plugin", menu_loop_plugin_gpu_unai_old, h_gpu_unai_old),
mee_handler_h ("Configure gpu_unai GPU plugin", menu_loop_plugin_gpu_unai, h_gpu_unai),
mee_handler_h ("Configure gpu_gles GPU plugin", menu_loop_plugin_gpu_peopsgl, h_gpu_peopsgl),
mee_handler_h ("Configure built-in SPU plugin", menu_loop_plugin_spu, h_spu),

View File

@ -94,11 +94,7 @@ struct rearmed_cbs {
int dwFrameRateTicks;
} gpu_peops;
struct {
int abe_hack;
int no_light, no_blend;
int lineskip;
} gpu_unai_old;
struct {
int old_renderer;
int ilace_force;
int pixel_skip;
int lighting;

View File

@ -8,7 +8,7 @@ CFLAGS += -DUSE_GPULIB=1
include ../../config.mak
SRC_STANDALONE += gpu.cpp
SRC_GPULIB += gpulib_if.cpp
SRC_GPULIB += gpulib_if.cpp old/if.cpp
ifeq "$(ARCH)" "arm"
SRC += gpu_arm.S

View File

@ -46,6 +46,7 @@ struct gpu_unai_config_t {
uint8_t fast_lighting:1;
uint8_t blending:1;
uint8_t dithering:1;
uint8_t old_renderer:1;
//senquack Only PCSX Rearmed's version of gpu_unai had this, and I
// don't think it's necessary. It would require adding 'AH' flag to

View File

@ -75,12 +75,14 @@ INLINE float FloatInv(const float x)
///////////////////////////////////////////////////////////////////////////
// --- BEGIN INVERSE APPROXIMATION SECTION ---
///////////////////////////////////////////////////////////////////////////
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
#if defined(GPU_UNAI_USE_INT_DIV_MULTINV) || !defined(GPU_UNAI_NO_OLD)
// big precision inverse table.
#define TABLE_BITS 16
s32 s_invTable[(1<<TABLE_BITS)];
#endif
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
//senquack - MIPS32 happens to have same instruction/format:
#if defined(__arm__) || (__mips == 32)
INLINE u32 Log2(u32 x) { u32 res; asm("clz %0,%1" : "=r" (res) : "r" (x)); return 32-res; }

View File

@ -25,6 +25,7 @@
#include <stdlib.h>
#include <string.h>
#include "../gpulib/gpu.h"
#include "old/if.h"
#ifdef THREAD_RENDERING
#include "../gpulib/gpulib_thread_if.h"
@ -68,6 +69,12 @@
/////////////////////////////////////////////////////////////////////////////
#ifndef GPU_UNAI_NO_OLD
#define IS_OLD_RENDERER() gpu_unai.config.old_renderer
#else
#define IS_OLD_RENDERER() false
#endif
#define DOWNSCALE_VRAM_SIZE (1024 * 512 * 2 * 2 + 4096)
INLINE void scale_640_to_320(le16_t *dest, const le16_t *src, bool isRGB24) {
@ -247,7 +254,7 @@ int renderer_init(void)
//gpu_unai.config.enableAbbeyHack = gpu_unai_config_ext.abe_hack;
gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
#ifdef GPU_UNAI_USE_INT_DIV_MULTINV
#if defined(GPU_UNAI_USE_INT_DIV_MULTINV) || !defined(GPU_UNAI_NO_OLD)
// s_invTable
for(int i=1;i<=(1<<TABLE_BITS);++i)
{
@ -403,6 +410,9 @@ int do_cmd_list(u32 *list_, int list_len,
le32_t *list_start = list;
le32_t *list_end = list + list_len;
if (IS_OLD_RENDERER())
return oldunai_do_cmd_list(list_, list_len, cycles_sum_out, cycles_last, last_cmd);
//TODO: set ilace_mask when resolution changes instead of every time,
// eliminate #ifdef below.
gpu_unai.ilace_mask = gpu_unai.config.ilace_force;
@ -825,9 +835,13 @@ breakloop:
void renderer_sync_ecmds(u32 *ecmds)
{
if (!IS_OLD_RENDERER()) {
int dummy;
do_cmd_list(&ecmds[1], 6, &dummy, &dummy, &dummy);
}
else
oldunai_renderer_sync_ecmds(ecmds);
}
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)
void renderer_set_config(const struct rearmed_cbs *cbs)
{
gpu_unai.vram = (le16_t *)gpu.vram;
gpu_unai.config.old_renderer = cbs->gpu_unai.old_renderer;
gpu_unai.config.ilace_force = cbs->gpu_unai.ilace_force;
gpu_unai.config.pixel_skip = cbs->gpu_unai.pixel_skip;
gpu_unai.config.lighting = cbs->gpu_unai.lighting;
@ -860,6 +875,7 @@ void renderer_set_config(const struct rearmed_cbs *cbs)
} else {
unmap_downscale_buffer();
}
oldunai_renderer_set_config(cbs);
}
void renderer_sync(void)

View File

@ -39,7 +39,7 @@ typedef s32 fixed;
#define fixed_HALF ((fixed)((1<<FIXED_BITS)>>1))
// big precision inverse table.
s32 s_invTable[(1<<TABLE_BITS)];
extern s32 s_invTable[(1<<TABLE_BITS)];
INLINE fixed i2x(const int _x) { return ((_x)<<FIXED_BITS); }
INLINE fixed x2i(const fixed _x) { return ((_x)>>FIXED_BITS); }

View File

@ -22,8 +22,9 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "../gpulib/gpu.h"
#include "../../gpulib/gpu.h"
#include "arm_features.h"
#include "if.h"
#define u8 uint8_t
#define s8 int8_t
@ -50,7 +51,8 @@ static bool blend = true; /* blending */
static bool FrameToRead = false; /* load image in progress */
static bool FrameToWrite = false; /* store image in progress */
static bool enableAbbeyHack = false; /* Abe's Odyssey hack */
//static bool enableAbbeyHack = false; /* Abe's Odyssey hack */
#define enableAbbeyHack false
static u8 BLEND_MODE;
static u8 TEXT_MODE;
@ -136,10 +138,11 @@ static u32 GPU_GP1;
/////////////////////////////////////////////////////////////////////////////
int renderer_init(void)
void oldunai_renderer_init(void)
{
GPU_FrameBuffer = (u16 *)gpu.vram;
#if 0 // shared with "new" unai
// s_invTable
for(int i=1;i<=(1<<TABLE_BITS);++i)
{
@ -151,30 +154,17 @@ int renderer_init(void)
#endif
s_invTable[i-1]=s32(v);
}
return 0;
}
void renderer_finish(void)
{
}
void renderer_notify_res_change(void)
{
}
void renderer_notify_scanout_change(int x, int y)
{
#endif
}
extern const unsigned char cmd_lengths[256];
int do_cmd_list(uint32_t *list, int list_len,
int oldunai_do_cmd_list(uint32_t *list, int list_len,
int *cycles_sum_out, int *cycles_last, int *last_cmd)
{
unsigned int cmd = 0, len, i;
unsigned int *list_start = list;
unsigned int *list_end = list + list_len;
uint32_t *list_start = list;
uint32_t *list_end = list + list_len;
linesInterlace = force_interlace;
#ifdef HAVE_PRE_ARMV7 /* XXX */
@ -521,34 +511,22 @@ breakloop:
return list - list_start;
}
void renderer_sync_ecmds(uint32_t *ecmds)
void oldunai_renderer_sync_ecmds(uint32_t *ecmds)
{
int dummy;
do_cmd_list(&ecmds[1], 6, &dummy, &dummy, &dummy);
}
void renderer_update_caches(int x, int y, int w, int h, int state_changed)
{
}
void renderer_flush_queues(void)
{
}
void renderer_set_interlace(int enable, int is_odd)
{
}
#ifndef TEST
#include "../../frontend/plugin_lib.h"
#include "../../../frontend/plugin_lib.h"
void renderer_set_config(const struct rearmed_cbs *cbs)
void oldunai_renderer_set_config(const struct rearmed_cbs *cbs)
{
force_interlace = cbs->gpu_unai_old.lineskip;
enableAbbeyHack = cbs->gpu_unai_old.abe_hack;
light = !cbs->gpu_unai_old.no_light;
blend = !cbs->gpu_unai_old.no_blend;
force_interlace = cbs->gpu_unai.ilace_force;
//enableAbbeyHack = cbs->gpu_unai_old.abe_hack;
light = cbs->gpu_unai.lighting;
blend = cbs->gpu_unai.blending;
GPU_FrameBuffer = (u16 *)gpu.vram;
}

18
plugins/gpu_unai/old/if.h Normal file
View File

@ -0,0 +1,18 @@
#ifndef GPU_UNAI_NO_OLD
struct rearmed_cbs;
void oldunai_renderer_init(void);
int oldunai_do_cmd_list(uint32_t *list, int list_len,
int *cycles_sum_out, int *cycles_last, int *last_cmd);
void oldunai_renderer_sync_ecmds(uint32_t *ecmds);
void oldunai_renderer_set_config(const struct rearmed_cbs *cbs);
#else
#define oldunai_renderer_init()
#define oldunai_do_cmd_list(...) 0
#define oldunai_renderer_sync_ecmds(x)
#define oldunai_renderer_set_config(x)
#endif

View File

@ -1,16 +0,0 @@
CFLAGS += -ggdb -Wall -O3 -ffast-math
CFLAGS += -DREARMED
CFLAGS += -I../../include
include ../../config.mak
SRC_STANDALONE += gpu.cpp
SRC_GPULIB += gpulib_if.cpp
ifeq "$(ARCH)" "arm"
SRC += gpu_arm.s
endif
#BIN_STANDALONE = gpuPCSX4ALL.so
BIN_GPULIB = gpu_unai_old.so
include ../gpulib/gpulib.mak

View File

@ -89,8 +89,6 @@ builtin_gpu - this is either Exophase's ARM NEON GPU (accurate and fast,
gpu_peops or gpu_unai (depends on compile options).
gpu_peops.so - P.E.Op.S. soft GPU, reasonably accurate but slow
(also found with older emulators on PC)
gpu_unai_old.so- Unai's plugin from PCSX4ALL project. Faster than P.E.Op.S.
but has some glitches (old version).
gpu_gles.so - experimental port of P.E.Op.S. MesaGL plugin to OpenGL ES.
Occasionally faster but has lots of glitches and seems to
be rather unstable (may crash the driver/system).