From 40d5fcc4720b923cf48669b4df82c23f9f9533da Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 16:36:55 +0200 Subject: [PATCH 01/23] Add shutdown to frontend_context.c - bake frontend_context in for all versions --- Makefile | 1 + Makefile.win | 1 + frontend/frontend.c | 53 +++++++++++--------------------- frontend/frontend_context.h | 1 + frontend/platform/platform_gx.c | 21 ++++++------- frontend/platform/platform_ps3.c | 17 +++++----- frontend/platform/platform_psp.c | 17 +++++----- frontend/platform/platform_xdk.c | 15 +++++---- 8 files changed, 52 insertions(+), 74 deletions(-) diff --git a/Makefile b/Makefile index af0873898a..184f81b194 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,7 @@ include config.mk TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch OBJ = frontend/frontend.o \ + frontend/frontend_context.o \ retroarch.o \ file.o \ file_path.o \ diff --git a/Makefile.win b/Makefile.win index 862bb534ca..780ba3fb8c 100644 --- a/Makefile.win +++ b/Makefile.win @@ -2,6 +2,7 @@ TARGET = retroarch.exe JTARGET = tools/retroarch-joyconfig.exe OBJ = frontend/frontend.o \ + frontend/frontend_context.o \ retroarch.o \ file.o \ file_path.o \ diff --git a/frontend/frontend.c b/frontend/frontend.c index 8410ae43f9..bb7f5880a8 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -18,10 +18,8 @@ #include "../conf/config_file.h" #include "../file.h" -#if defined(RARCH_CONSOLE) #include "frontend_context.h" frontend_ctx_driver_t *frontend_ctx; -#endif #if defined(__QNX__) #include @@ -94,17 +92,6 @@ static bool libretro_install_core(const char *path_prefix, } #endif -static void system_preinit(void) -{ -#if defined(__QNX__) && !defined(HAVE_BB10) - //Initialize BPS libraries - bps_initialize(); -#elif defined(RARCH_CONSOLE) - if (frontend_ctx->init) - frontend_ctx->init(); -#endif -} - static void rarch_get_environment(int argc, char *argv[]) { #if defined(__QNX__) && !defined(HAVE_BB10) @@ -125,7 +112,7 @@ static void rarch_get_environment(int argc, char *argv[]) #endif g_extern.verbose = true; - if (frontend_ctx->get_environment_settings) + if (frontend_ctx && frontend_ctx->get_environment_settings) frontend_ctx->get_environment_settings(argc, argv); MAKE_DIR(default_paths.port_dir, "port_dir"); @@ -184,16 +171,6 @@ static void system_shutdown(void) #endif } -static int system_ctx_init(void) -{ -#ifdef RARCH_CONSOLE - if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL) - return -1; -#endif - - return 0; -} - #if defined(__APPLE__) static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER; @@ -250,10 +227,16 @@ void* rarch_main(void* args) int rarch_main(int argc, char *argv[]) #endif { - if (system_ctx_init() != 0) - return 0; + if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL) + RARCH_WARN("Could not find valid frontend context.\n"); - system_preinit(); +#if defined(__QNX__) && !defined(HAVE_BB10) + //Initialize BPS libraries + bps_initialize(); +#endif + + if (frontend_ctx && frontend_ctx->init) + frontend_ctx->init(); #if !defined(__APPLE__) rarch_main_clear_state(); @@ -290,9 +273,10 @@ int rarch_main(int argc, char *argv[]) menu_init(); -#ifdef RARCH_CONSOLE - if (frontend_ctx->process_args) + if (frontend_ctx && frontend_ctx->process_args) frontend_ctx->process_args(argc, argv); + +#ifdef RARCH_CONSOLE g_extern.lifecycle_mode_state |= 1ULL << MODE_LOAD_GAME; #else g_extern.lifecycle_mode_state |= 1ULL << MODE_GAME; @@ -336,10 +320,9 @@ int rarch_main(int argc, char *argv[]) { #ifdef RARCH_CONSOLE driver.input->poll(NULL); - +#endif if (driver.video_poke->set_aspect_ratio) driver.video_poke->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx); -#endif while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()) { @@ -413,7 +396,6 @@ int rarch_main(int argc, char *argv[]) rarch_perf_log(); #endif -#ifdef RARCH_CONSOLE #if defined(HAVE_LOGGER) logger_shutdown(); #elif defined(HAVE_FILE_LOGGER) @@ -421,12 +403,13 @@ int rarch_main(int argc, char *argv[]) fclose(g_extern.log_file); g_extern.log_file = NULL; #endif - if (frontend_ctx->deinit) + + if (frontend_ctx && frontend_ctx->deinit) frontend_ctx->deinit(); - if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN) && frontend_ctx->exitspawn) + if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN) && frontend_ctx + && frontend_ctx->exitspawn) frontend_ctx->exitspawn(); -#endif rarch_main_clear_state(); diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index c4b5ab720e..0a417da946 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -40,6 +40,7 @@ typedef struct frontend_ctx_driver int (*process_args)(int argc, char *argv[]); void (*exec)(const char *, bool); + void (*shutdown)(bool); // Human readable string. const char *ident; diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 9e39b9aee3..7844c5952d 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -444,11 +444,13 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) argv->length = len; DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length); } +#endif // WARNING: after we move any data into EXECUTE_ADDR, we can no longer use any // heap memory and are restricted to the stack only static void system_exec(const char *path, bool should_load_game) { +#ifdef HW_RVL char game_path[PATH_MAX]; RARCH_LOG("Attempt to load executable: [%s] %d.\n", path, sizeof(game_path)); @@ -507,19 +509,16 @@ static void system_exec(const char *path, bool should_load_game) RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR); SYS_ResetSystem(SYS_SHUTDOWN,0,0); __lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR); -} #endif +} const frontend_ctx_driver_t frontend_ctx_gx = { - get_environment_settings, - system_init, - system_deinit, - system_exitspawn, - system_process_args, -#ifdef HW_RVL - system_exec, -#else - NULL, -#endif + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + system_deinit, /* deinit */ + system_exitspawn, /* exitspawn */ + system_process_args, /* process_args */ + system_exec, /* exec */ + NULL, /* shutdown */ "gx", }; diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 636f777d7b..3928aaf1fb 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -110,13 +110,9 @@ static void salamander_init_settings(void) } if (!config_file_exists || !strcmp(default_paths.libretro_path, "")) - { find_and_set_first_file(); - } else - { RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path); - } if (!config_file_exists) { @@ -469,11 +465,12 @@ static void system_exec(const char *path, bool should_load_game) } const frontend_ctx_driver_t frontend_ctx_ps3 = { - get_environment_settings, - system_init, - system_deinit, - system_exitspawn, - system_process_args, - system_exec, + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + system_deinit, /* deinit */ + system_exitspawn, /* exitspawn */ + system_process_args, /* process_args */ + system_exec, /* exec */ + NULL, /* shutdown */ "ps3", }; diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index 071ccc1c90..c8a90f6fe9 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -109,16 +109,13 @@ static void system_deinit(void) sceKernelExitGame(); } -static void system_exitspawn(void) -{ -} - const frontend_ctx_driver_t frontend_ctx_xdk = { - get_environment_settings, - system_init, - system_deinit, - system_exitspawn, - system_process_args, - NULL, + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + system_deinit, /* deinit */ + NULL, /* exitspawn */ + system_process_args, /* process_args */ + NULL, /* exec */ + NULL, /* shutdown */ "psp", }; diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index a6c53cf282..2182fcb0bb 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -299,8 +299,6 @@ static int system_process_args(int argc, char *argv[]) return 0; } -static void system_deinit(void) {} - static void system_exitspawn(void) { #ifdef IS_SALAMANDER @@ -351,11 +349,12 @@ static void system_exec(const char *path, bool should_load_game) } const frontend_ctx_driver_t frontend_ctx_xdk = { - get_environment_settings, - system_init, - system_deinit, - system_exitspawn, - system_process_args, - system_exec, + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + NULL, /* deinit */ + system_exitspawn, /* exitspawn */ + system_process_args, /* process_args */ + system_exec, /* exec */ + NULL, /* shutdown */ "xdk", }; From 2c7986f4fcc8f9251da8a8e4ed8b42192397e1b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:02:13 +0200 Subject: [PATCH 02/23] Add frontend_context.c to MSVC solution as well --- msvc/msvc-2010/RetroArch-msvc2010.vcxproj | 2 + .../RetroArch-msvc2010.vcxproj.filters | 254 ------------------ 2 files changed, 2 insertions(+), 254 deletions(-) delete mode 100644 msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj index 0df57f9551..17c46dec6d 100644 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj +++ b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj @@ -262,6 +262,8 @@ + + diff --git a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters b/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters deleted file mode 100644 index 83ab26421d..0000000000 --- a/msvc/msvc-2010/RetroArch-msvc2010.vcxproj.filters +++ /dev/null @@ -1,254 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - {ddc648c9-0965-4fbf-bfcd-4ece568acebe} - - - {547c32fb-8ea0-46d7-a80c-9dad57f9893e} - - - {67110ea9-781d-4a95-a61e-79864b7a8cec} - - - {7aabbafd-18bf-4c51-abf8-01cefd46b2e3} - - - {51dd4d92-c39d-4eb3-83a1-54ebb63bcf00} - - - {7ca1fa21-74fe-4fc2-afff-92b1c2fd15ed} - - - {7b1aab1c-310c-48fd-b699-e3a6e69b0b8c} - - - {9c758b58-d6ce-4b66-8b17-8cc7ceb78c82} - - - {eaaf6f28-b845-41f3-8211-e069a1ac1063} - - - {ae4f70af-fc87-4c8d-84a5-b2c4cd57e722} - - - {a1975595-d469-4d96-81bf-d6a4f0be32f5} - - - {a1302353-aa00-4f85-a62f-3c40160a5fa3} - - - {a3ec9cd6-b3f2-4711-9585-e09c8dbb63ef} - - - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files - - - Source Files\audio - - - Source Files\audio - - - Source Files\audio - - - Source Files\gfx\context - - - Source Files\gfx - - - Source Files\gfx - - - Source Files\gfx - - - Source Files\gfx - - - Source Files\gfx - - - Source Files\input - - - Source Files\input - - - Source Files\conf - - - Source Files\compat - - - Source Files\gfx\scaler - - - Source Files\gfx\scaler - - - Source Files\gfx\scaler - - - Source Files\gfx\scaler - - - Source Files\gfx\math - - - Source Files\gfx\math - - - Source Files\gfx\d3d9 - - - Source Files\gfx\d3d9 - - - Source Files\gfx - - - Source Files\gfx\fonts - - - Source Files\audio - - - Source Files\gfx\fonts - - - Source Files\gfx\fonts - - - Source Files\gfx\fonts - - - Source Files\audio - - - Source Files\compat - - - Source Files\audio - - - Source Files - - - Source Files\gfx - - - Source Files - - - Source Files\gfx\rpng - - - Source Files\deps - - - Source Files\gfx - - - Source Files\input - - - Source Files - - - Source Files\gfx - - - Source Files - - - Source Files\rgui - - - Source Files\rgui - - - Source Files - - - Source Files\rgui - - - - - Header Files - - - - - Resource Files - - - \ No newline at end of file From 003635499ffc2c1cd29b71df8fc7df3102c65ab6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:16:46 +0200 Subject: [PATCH 03/23] Add QNX frontend context file --- frontend/frontend.c | 67 ++++++++++++-------------------- frontend/frontend_context.c | 3 ++ frontend/frontend_context.h | 7 +++- frontend/platform/platform_gx.c | 8 ++++ frontend/platform/platform_ps3.c | 8 ++++ frontend/platform/platform_psp.c | 17 ++++---- frontend/platform/platform_qnx.c | 59 ++++++++++++++++++++++++++++ frontend/platform/platform_xdk.c | 8 ++++ griffin/griffin.c | 2 + 9 files changed, 127 insertions(+), 52 deletions(-) create mode 100644 frontend/platform/platform_qnx.c diff --git a/frontend/frontend.c b/frontend/frontend.c index bb7f5880a8..256f71f0ca 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -21,9 +21,7 @@ #include "frontend_context.h" frontend_ctx_driver_t *frontend_ctx; -#if defined(__QNX__) -#include -#elif defined(__APPLE__) +#if defined(__APPLE__) #include #include #include "../apple/RetroArch/rarch_wrapper.h" @@ -76,53 +74,40 @@ static bool libretro_install_core(const char *path_prefix, return true; } -#define MAKE_DIR(x, name) { \ - RARCH_LOG("Checking directory name %s [%s]\n", name, x); \ - if (strlen(x) > 0) \ - { \ - if (!path_is_directory((x)) )\ - { \ - RARCH_WARN("Directory \"%s\" does not exists, creating\n", (x)); \ - if (mkdir((x), 0777) != 0) \ - { \ - RARCH_ERR("Could not create directory \"%s\"\n", (x)); \ - } \ - } \ - } \ +#endif + +#ifdef RARCH_CONSOLE +void rarch_make_dir(const char *x, const char *name) +{ + RARCH_LOG("Checking directory name %s [%s]\n", name, x); + if (strlen(x) > 0) + { + if (!path_is_directory(x)) + { + RARCH_WARN("Directory \"%s\" does not exists, creating\n", x); + if (mkdir((x), 0777) != 0) + RARCH_ERR("Could not create directory \"%s\"\n", x); + } + } } #endif static void rarch_get_environment(int argc, char *argv[]) { -#if defined(__QNX__) && !defined(HAVE_BB10) - strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro)); - strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path)); - strlcpy(g_settings.video.shader_dir, "app/native/shaders_glsl", sizeof(g_settings.video.shader_dir)); - - config_load(); - g_extern.verbose = true; -#elif defined(RARCH_CONSOLE) + #if defined(HAVE_LOGGER) - g_extern.verbose = true; logger_init(); #elif defined(HAVE_FILE_LOGGER) - g_extern.verbose = true; g_extern.log_file = fopen("/retroarch-log.txt", "w"); #endif - g_extern.verbose = true; - if (frontend_ctx && frontend_ctx->get_environment_settings) - frontend_ctx->get_environment_settings(argc, argv); - - MAKE_DIR(default_paths.port_dir, "port_dir"); - MAKE_DIR(default_paths.system_dir, "system_dir"); - MAKE_DIR(default_paths.savestate_dir, "savestate_dir"); - MAKE_DIR(default_paths.sram_dir, "sram_dir"); - MAKE_DIR(default_paths.input_presets_dir, "input_presets_dir"); + if (frontend_ctx && frontend_ctx->environment_get) + frontend_ctx->environment_get(argc, argv); config_load(); +#if defined(RARCH_CONSOLE) init_libretro_sym(false); rarch_init_system_info(); @@ -164,9 +149,10 @@ static void rarch_get_environment(int argc, char *argv[]) static void system_shutdown(void) { -#if defined(__QNX__) - bps_shutdown(); -#elif defined(__APPLE__) + if (frontend_ctx && frontend_ctx->shutdown) + frontend_ctx->shutdown(true); + +#if defined(__APPLE__) dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); #endif } @@ -230,11 +216,6 @@ int rarch_main(int argc, char *argv[]) if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL) RARCH_WARN("Could not find valid frontend context.\n"); -#if defined(__QNX__) && !defined(HAVE_BB10) - //Initialize BPS libraries - bps_initialize(); -#endif - if (frontend_ctx && frontend_ctx->init) frontend_ctx->init(); diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index 9b766a9cae..1b51d9a90f 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -30,6 +30,9 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(GEKKO) &frontend_ctx_gx, #endif +#if defined(__QNX__) + &frontend_ctx_qnx, +#endif }; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index 0a417da946..19c42c8934 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -32,7 +32,7 @@ typedef struct frontend_ctx_driver { - void (*get_environment_settings)(int argc, char *argv[]); + void (*environment_get)(int argc, char *argv[]); void (*init)(void); void (*deinit)(void); @@ -49,8 +49,13 @@ typedef struct frontend_ctx_driver extern const frontend_ctx_driver_t frontend_ctx_gx; extern const frontend_ctx_driver_t frontend_ctx_ps3; extern const frontend_ctx_driver_t frontend_ctx_xdk; +extern const frontend_ctx_driver_t frontend_ctx_qnx; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize. const frontend_ctx_driver_t *frontend_ctx_init_first(void); // Finds first suitable driver and initializes. +#ifdef RARCH_CONSOLE +extern void rarch_make_dir(const char *x, const char *name); +#endif + #endif diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 7844c5952d..09fe66d390 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -265,6 +265,14 @@ static void get_environment_settings(int argc, char *argv[]) else gx_rom_path[0] = '\0'; #endif + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } extern void __exception_setreload(int t); diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 3928aaf1fb..70a29ba855 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -277,6 +277,14 @@ static void get_environment_settings(int argc, char *argv[]) snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir); #endif } + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } static void system_init(void) diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index c8a90f6fe9..83e5caaf46 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -67,6 +67,14 @@ static void get_environment_settings(int argc, char *argv[]) snprintf(default_paths.input_presets_dir, sizeof(default_paths.input_presets_dir), "%s/presets", default_paths.core_dir); snprintf(default_paths.border_dir, sizeof(default_paths.border_dir), "%s/borders", default_paths.core_dir); snprintf(g_extern.config_path, sizeof(g_extern.config_path), "%s/retroarch.cfg", default_paths.port_dir); + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } int callback_thread(SceSize args, void *argp) @@ -97,13 +105,6 @@ static void system_init(void) setup_callback(); } -static int system_process_args(int argc, char *argv[]) -{ - (void)argc; - (void)argv; - return 0; -} - static void system_deinit(void) { sceKernelExitGame(); @@ -114,7 +115,7 @@ const frontend_ctx_driver_t frontend_ctx_xdk = { system_init, /* init */ system_deinit, /* deinit */ NULL, /* exitspawn */ - system_process_args, /* process_args */ + NULL, /* process_args */ NULL, /* exec */ NULL, /* shutdown */ "psp", diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c new file mode 100644 index 0000000000..b8dee63622 --- /dev/null +++ b/frontend/platform/platform_qnx.c @@ -0,0 +1,59 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include + +#include +#include "../../boolean.h" +#include +#include + +static void get_environment_settings(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + +/* FIXME - should this apply for both BB10 and PB? */ +#if defined(__QNX__) && !defined(HAVE_BB10) + strlcpy(g_settings.libretro, "app/native/lib", sizeof(g_settings.libretro)); + strlcpy(g_extern.config_path, "app/native/retroarch.cfg", sizeof(g_extern.config_path)); + strlcpy(g_settings.video.shader_dir, "app/native/shaders_glsl", sizeof(g_settings.video.shader_dir)); +#endif +} + +static void system_init(void) +{ +/* FIXME - should this apply for both BB10 and PB? */ +#if defined(__QNX__) && !defined(HAVE_BB10) + bps_initialize(); +#endif +} + +static void system_shutdown(void) +{ + bps_shutdown(); +} + +const frontend_ctx_driver_t frontend_ctx_xdk = { + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + NULL, /* exec */ + system_shutdown, /* shutdown */ + "qnx", +}; diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 2182fcb0bb..17c9ff7eec 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -247,6 +247,14 @@ static void get_environment_settings(int argc, char *argv[]) strlcpy(default_paths.system_dir, "game:\\system", sizeof(default_paths.system_dir)); strlcpy(default_paths.filebrowser_startup_dir, "game:", sizeof(default_paths.filebrowser_startup_dir)); #endif + +#ifndef IS_SALAMANDER + rarch_make_dir(default_paths.port_dir, "port_dir"); + rarch_make_dir(default_paths.system_dir, "system_dir"); + rarch_make_dir(default_paths.savestate_dir, "savestate_dir"); + rarch_make_dir(default_paths.sram_dir, "sram_dir"); + rarch_make_dir(default_paths.input_presets_dir, "input_presets_dir"); +#endif } static void system_init(void) diff --git a/griffin/griffin.c b/griffin/griffin.c index a20f74cd0d..3ccaaea4b0 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -456,6 +456,8 @@ FRONTEND #include "../frontend/platform/platform_xdk.c" #elif defined(PSP) #include "../frontend/platform/platform_psp.c" +#elif defined(__QNX__) +#include "../frontend/platform/platform_qnx.c" #endif /*============================================================ From ad7884e441a70da52e61a007b028328d8c07f390 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:18:18 +0200 Subject: [PATCH 04/23] frontend.c - cut down on one ifdef --- frontend/frontend.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index 256f71f0ca..f40252ae3e 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -74,9 +74,6 @@ static bool libretro_install_core(const char *path_prefix, return true; } -#endif - -#ifdef RARCH_CONSOLE void rarch_make_dir(const char *x, const char *name) { RARCH_LOG("Checking directory name %s [%s]\n", name, x); @@ -90,6 +87,7 @@ void rarch_make_dir(const char *x, const char *name) } } } + #endif static void rarch_get_environment(int argc, char *argv[]) From 484c5b83413a25ad123e1ab38b765eb601dd97c1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:30:05 +0200 Subject: [PATCH 05/23] frontend.c - cleanups --- frontend/frontend.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index f40252ae3e..5b161db490 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -145,16 +145,6 @@ static void rarch_get_environment(int argc, char *argv[]) #endif } -static void system_shutdown(void) -{ - if (frontend_ctx && frontend_ctx->shutdown) - frontend_ctx->shutdown(true); - -#if defined(__APPLE__) - dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); -#endif -} - #if defined(__APPLE__) static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER; @@ -211,8 +201,7 @@ void* rarch_main(void* args) int rarch_main(int argc, char *argv[]) #endif { - if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL) - RARCH_WARN("Could not find valid frontend context.\n"); + frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); if (frontend_ctx && frontend_ctx->init) frontend_ctx->init(); @@ -392,7 +381,12 @@ int rarch_main(int argc, char *argv[]) rarch_main_clear_state(); - system_shutdown(); + if (frontend_ctx && frontend_ctx->shutdown) + frontend_ctx->shutdown(true); + +#if defined(__APPLE__) + dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); +#endif return 0; } From a9dd629fe6423149c01dddab2fbf390e7f43b8b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:32:15 +0200 Subject: [PATCH 06/23] Uniquely name each frontend context driver --- frontend/platform/platform_psp.c | 2 +- frontend/platform/platform_qnx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index 83e5caaf46..02b419601b 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -110,7 +110,7 @@ static void system_deinit(void) sceKernelExitGame(); } -const frontend_ctx_driver_t frontend_ctx_xdk = { +const frontend_ctx_driver_t frontend_ctx_psp = { get_environment_settings, /* get_environment_settings */ system_init, /* init */ system_deinit, /* deinit */ diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c index b8dee63622..3f3533c65a 100644 --- a/frontend/platform/platform_qnx.c +++ b/frontend/platform/platform_qnx.c @@ -47,7 +47,7 @@ static void system_shutdown(void) bps_shutdown(); } -const frontend_ctx_driver_t frontend_ctx_xdk = { +const frontend_ctx_driver_t frontend_ctx_qnx = { get_environment_settings, /* get_environment_settings */ system_init, /* init */ NULL, /* deinit */ From ac8f57e679662163b5a1db6cf071c631f8b29c81 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:40:21 +0200 Subject: [PATCH 07/23] Add platform_apple.c frontend driver --- frontend/frontend.c | 80 +++---------------------- frontend/frontend_context.c | 3 + frontend/frontend_context.h | 1 + frontend/platform/platform_apple.c | 95 ++++++++++++++++++++++++++++++ griffin/griffin.c | 2 + 5 files changed, 109 insertions(+), 72 deletions(-) create mode 100644 frontend/platform/platform_apple.c diff --git a/frontend/frontend.c b/frontend/frontend.c index 5b161db490..8c3ab8ab8f 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -21,12 +21,6 @@ #include "frontend_context.h" frontend_ctx_driver_t *frontend_ctx; -#if defined(__APPLE__) -#include -#include -#include "../apple/RetroArch/rarch_wrapper.h" -#endif - #if defined(HAVE_RGUI) || defined(HAVE_RMENU) || defined(HAVE_RMENU_XUI) #define HAVE_MENU #else @@ -146,56 +140,6 @@ static void rarch_get_environment(int argc, char *argv[]) } #if defined(__APPLE__) -static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER; - -static struct -{ - void (*function)(void*); - void* userdata; -} apple_event_queue[16]; - -static uint32_t apple_event_queue_size; - -void apple_frontend_post_event(void (*fn)(void*), void* userdata) -{ - pthread_mutex_lock(&apple_event_queue_lock); - - if (apple_event_queue_size < 16) - { - apple_event_queue[apple_event_queue_size].function = fn; - apple_event_queue[apple_event_queue_size].userdata = userdata; - apple_event_queue_size ++; - } - - pthread_mutex_unlock(&apple_event_queue_lock); -} - -static void apple_free_main_wrap(struct rarch_main_wrap* wrap) -{ - if (wrap) - { - free((char*)wrap->libretro_path); - free((char*)wrap->rom_path); - free((char*)wrap->sram_path); - free((char*)wrap->state_path); - free((char*)wrap->config_path); - } - - free(wrap); -} - -static void process_events(void) -{ - pthread_mutex_lock(&apple_event_queue_lock); - - for (int i = 0; i < apple_event_queue_size; i ++) - apple_event_queue[i].function(apple_event_queue[i].userdata); - - apple_event_queue_size = 0; - - pthread_mutex_unlock(&apple_event_queue_lock); -} - void* rarch_main(void* args) #else int rarch_main(int argc, char *argv[]) @@ -273,11 +217,9 @@ int rarch_main(int argc, char *argv[]) #if defined(RARCH_CONSOLE) || defined(__QNX__) g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU); #else -#if defined(__APPLE__) - // This needs to be here to tell the GUI thread that the emulator loop has stopped, - // the (void*)1 makes it display the 'Failed to load game' message. - dispatch_async_f(dispatch_get_main_queue(), (void*)1, apple_rarch_exited); -#endif + if (frontend_ctx && frontend_ctx->shutdown) + frontend_ctx->shutdown(true); + return 1; #endif } @@ -294,9 +236,8 @@ int rarch_main(int argc, char *argv[]) while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate()) { -#if defined(__APPLE__) - process_events(); -#endif + if (frontend_ctx && frontend_ctx->process_events) + frontend_ctx->process_events(); if (!(g_extern.lifecycle_mode_state & (1ULL << MODE_GAME))) break; @@ -314,9 +255,8 @@ int rarch_main(int argc, char *argv[]) while (!g_extern.system.shutdown && menu_iterate()) { -#if defined(__APPLE__) - process_events(); -#endif + if (frontend_ctx && frontend_ctx->process_events) + frontend_ctx->process_events(); if (!(g_extern.lifecycle_mode_state & (1ULL << MODE_MENU))) break; @@ -382,11 +322,7 @@ int rarch_main(int argc, char *argv[]) rarch_main_clear_state(); if (frontend_ctx && frontend_ctx->shutdown) - frontend_ctx->shutdown(true); - -#if defined(__APPLE__) - dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); -#endif + frontend_ctx->shutdown(false); return 0; } diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index 1b51d9a90f..24fa1dd161 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -33,6 +33,9 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(__QNX__) &frontend_ctx_qnx, #endif +#if defined(IOS) || defined(OSX) + &frontend_ctx_apple, +#endif }; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index 19c42c8934..f5334412c6 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -50,6 +50,7 @@ extern const frontend_ctx_driver_t frontend_ctx_gx; extern const frontend_ctx_driver_t frontend_ctx_ps3; extern const frontend_ctx_driver_t frontend_ctx_xdk; extern const frontend_ctx_driver_t frontend_ctx_qnx; +extern const frontend_ctx_driver_t frontend_ctx_apple; const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); // Finds driver with ident. Does not initialize. const frontend_ctx_driver_t *frontend_ctx_init_first(void); // Finds first suitable driver and initializes. diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c new file mode 100644 index 0000000000..49f0b418c7 --- /dev/null +++ b/frontend/platform/platform_apple.c @@ -0,0 +1,95 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * Copyright (C) 2011-2013 - Daniel De Matteis + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include +#include +#include "../apple/RetroArch/rarch_wrapper.h" + +#include +#include "../../boolean.h" +#include +#include + +static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER; + +static struct +{ + void (*function)(void*); + void* userdata; +} apple_event_queue[16]; + +static uint32_t apple_event_queue_size; + +void apple_frontend_post_event(void (*fn)(void*), void* userdata) +{ + pthread_mutex_lock(&apple_event_queue_lock); + + if (apple_event_queue_size < 16) + { + apple_event_queue[apple_event_queue_size].function = fn; + apple_event_queue[apple_event_queue_size].userdata = userdata; + apple_event_queue_size ++; + } + + pthread_mutex_unlock(&apple_event_queue_lock); +} + +static void apple_free_main_wrap(struct rarch_main_wrap* wrap) +{ + if (wrap) + { + free((char*)wrap->libretro_path); + free((char*)wrap->rom_path); + free((char*)wrap->sram_path); + free((char*)wrap->state_path); + free((char*)wrap->config_path); + } + + free(wrap); +} + +static void process_events(void) +{ + pthread_mutex_lock(&apple_event_queue_lock); + + for (int i = 0; i < apple_event_queue_size; i ++) + apple_event_queue[i].function(apple_event_queue[i].userdata); + + apple_event_queue_size = 0; + + pthread_mutex_unlock(&apple_event_queue_lock); +} + +static void system_shutdown(bool force) +{ + /* force set to true makes it display the 'Failed to load game' message. */ + if (force) + dispatch_async_f(dispatch_get_main_queue(), (void*)1, apple_rarch_exited); + else + dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); +} + +const frontend_ctx_driver_t frontend_ctx_apple = { + NULL, /* get_environment_settings */ + NULL, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + process_events, /* process_events */ + NULL, /* exec */ + system_shutdown, /* shutdown */ + "apple", +}; diff --git a/griffin/griffin.c b/griffin/griffin.c index 3ccaaea4b0..83a206f2d1 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -458,6 +458,8 @@ FRONTEND #include "../frontend/platform/platform_psp.c" #elif defined(__QNX__) #include "../frontend/platform/platform_qnx.c" +#elif defined(OSX) || defined(IOS) +#include "../frontend/platform/platform_apple.c" #endif /*============================================================ From e19d2320b25c0cd752c5ff990c309feb7d3e53e0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:42:09 +0200 Subject: [PATCH 08/23] (frontend_context) Implement process_events --- frontend/frontend_context.h | 1 + frontend/platform/platform_gx.c | 1 + frontend/platform/platform_ps3.c | 1 + frontend/platform/platform_psp.c | 1 + frontend/platform/platform_qnx.c | 1 + frontend/platform/platform_xdk.c | 1 + 6 files changed, 6 insertions(+) diff --git a/frontend/frontend_context.h b/frontend/frontend_context.h index f5334412c6..d9d290de59 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -39,6 +39,7 @@ typedef struct frontend_ctx_driver void (*exitspawn)(void); int (*process_args)(int argc, char *argv[]); + int (*process_events)(void); void (*exec)(const char *, bool); void (*shutdown)(bool); diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 09fe66d390..cb313af8ba 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -526,6 +526,7 @@ const frontend_ctx_driver_t frontend_ctx_gx = { system_deinit, /* deinit */ system_exitspawn, /* exitspawn */ system_process_args, /* process_args */ + NULL, /* process_events */ system_exec, /* exec */ NULL, /* shutdown */ "gx", diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 70a29ba855..95e3d0ad1d 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -478,6 +478,7 @@ const frontend_ctx_driver_t frontend_ctx_ps3 = { system_deinit, /* deinit */ system_exitspawn, /* exitspawn */ system_process_args, /* process_args */ + NULL, /* process_events */ system_exec, /* exec */ NULL, /* shutdown */ "ps3", diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index 02b419601b..aa2b04c10c 100644 --- a/frontend/platform/platform_psp.c +++ b/frontend/platform/platform_psp.c @@ -116,6 +116,7 @@ const frontend_ctx_driver_t frontend_ctx_psp = { system_deinit, /* deinit */ NULL, /* exitspawn */ NULL, /* process_args */ + NULL, /* process_events */ NULL, /* exec */ NULL, /* shutdown */ "psp", diff --git a/frontend/platform/platform_qnx.c b/frontend/platform/platform_qnx.c index 3f3533c65a..b83f4e30cf 100644 --- a/frontend/platform/platform_qnx.c +++ b/frontend/platform/platform_qnx.c @@ -53,6 +53,7 @@ const frontend_ctx_driver_t frontend_ctx_qnx = { NULL, /* deinit */ NULL, /* exitspawn */ NULL, /* process_args */ + NULL, /* process_events */ NULL, /* exec */ system_shutdown, /* shutdown */ "qnx", diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index 17c9ff7eec..d021b8230b 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -362,6 +362,7 @@ const frontend_ctx_driver_t frontend_ctx_xdk = { NULL, /* deinit */ system_exitspawn, /* exitspawn */ system_process_args, /* process_args */ + NULL, /* process_events */ system_exec, /* exec */ NULL, /* shutdown */ "xdk", From 29b13676c5682639cf618c67838f95331c7c0714 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 17:45:56 +0200 Subject: [PATCH 09/23] (Apple) Implement environment_get in Apple frontend context driver --- frontend/frontend.c | 10 ---------- frontend/platform/platform_apple.c | 18 +++++++++++++++--- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/frontend/frontend.c b/frontend/frontend.c index 8c3ab8ab8f..39a092d28b 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -150,11 +150,8 @@ int rarch_main(int argc, char *argv[]) if (frontend_ctx && frontend_ctx->init) frontend_ctx->init(); -#if !defined(__APPLE__) rarch_main_clear_state(); rarch_get_environment(argc, argv); -#endif - #if !defined(RARCH_CONSOLE) #if defined(__APPLE__) @@ -176,13 +173,6 @@ int rarch_main(int argc, char *argv[]) #endif #ifdef HAVE_MENU -#ifdef IOS - char* system_directory = ios_get_rarch_system_directory(); - strlcpy(g_extern.savestate_dir, system_directory, sizeof(g_extern.savestate_dir)); - strlcpy(g_extern.savefile_dir, system_directory, sizeof(g_extern.savefile_dir)); - free(system_directory); -#endif - menu_init(); if (frontend_ctx && frontend_ctx->process_args) diff --git a/frontend/platform/platform_apple.c b/frontend/platform/platform_apple.c index 49f0b418c7..d3f1381c6c 100644 --- a/frontend/platform/platform_apple.c +++ b/frontend/platform/platform_apple.c @@ -9,8 +9,7 @@ * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. + * * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ @@ -82,8 +81,21 @@ static void system_shutdown(bool force) dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); } +static void environment_get(int argc, char *argv[]) +{ + (void)argc; + (void)argv; + +#ifdef IOS + char* system_directory = ios_get_rarch_system_directory(); + strlcpy(g_extern.savestate_dir, system_directory, sizeof(g_extern.savestate_dir)); + strlcpy(g_extern.savefile_dir, system_directory, sizeof(g_extern.savefile_dir)); + free(system_directory); +#endif +} + const frontend_ctx_driver_t frontend_ctx_apple = { - NULL, /* get_environment_settings */ + environment_get, /* environment_get */ NULL, /* init */ NULL, /* deinit */ NULL, /* exitspawn */ From 248d4e8084492c71fe90493cd119d5ecd388e6f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:12:46 +0200 Subject: [PATCH 10/23] Get rid of MODE_OSK_DRAW --- frontend/menu/rmenu.c | 4 ++-- general.h | 1 - ps3/ps3_input.c | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 5436468499..0d63d14b12 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -743,7 +743,7 @@ static bool osk_callback_enter_rsound(void *data) return false; do_exit: - g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_DRAW) | (1ULL << MODE_OSK_ENTRY_SUCCESS) | + g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_ENTRY_SUCCESS) | (1ULL << MODE_OSK_ENTRY_FAIL)); return true; } @@ -797,7 +797,7 @@ static bool osk_callback_enter_filename(void *data) return false; do_exit: - g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_DRAW) | (1ULL << MODE_OSK_ENTRY_SUCCESS) | + g_extern.lifecycle_mode_state &= ~((1ULL << MODE_OSK_ENTRY_SUCCESS) | (1ULL << MODE_OSK_ENTRY_FAIL)); return true; } diff --git a/general.h b/general.h index 4b191fc2e4..6aa9edb74a 100644 --- a/general.h +++ b/general.h @@ -130,7 +130,6 @@ enum menu_enums MODE_VIDEO_PAL_TEMPORAL_ENABLE, MODE_VIDEO_PAL_VSYNC_BLOCK, MODE_AUDIO_CUSTOM_BGM_ENABLE, - MODE_OSK_DRAW, MODE_OSK_ENTRY_SUCCESS, MODE_OSK_ENTRY_FAIL, }; diff --git a/ps3/ps3_input.c b/ps3/ps3_input.c index 8fd719383a..0995219d8f 100644 --- a/ps3/ps3_input.c +++ b/ps3/ps3_input.c @@ -366,7 +366,6 @@ bool oskutil_start(oskutil_params *params) goto do_deinit; params->flags |= OSK_IN_USE; - g_extern.lifecycle_mode_state |= (1ULL << MODE_OSK_DRAW); return true; From 3e3e6ed97604dd1c2a9759785b0442ca773a3de4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:14:29 +0200 Subject: [PATCH 11/23] Get rid of MODE_VIDEO_PAL_VSYNC_BLOCK --- frontend/menu/rmenu.c | 4 ---- general.h | 1 - 2 files changed, 5 deletions(-) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 0d63d14b12..f7c537c13c 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -847,7 +847,6 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_ENABLE); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE); - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_VSYNC_BLOCK); } @@ -863,12 +862,10 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE); - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_VSYNC_BLOCK); } else { g_extern.lifecycle_mode_state |= (1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE); - g_extern.lifecycle_mode_state |= (1ULL << MODE_VIDEO_PAL_VSYNC_BLOCK); } driver.video->restart(); @@ -881,7 +878,6 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t if (g_extern.lifecycle_mode_state & (1ULL << MODE_VIDEO_PAL_ENABLE)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_TEMPORAL_ENABLE); - g_extern.lifecycle_mode_state &= ~(1ULL << MODE_VIDEO_PAL_VSYNC_BLOCK); driver.video->restart(); rgui_init_textures(); diff --git a/general.h b/general.h index 6aa9edb74a..e5ebba7264 100644 --- a/general.h +++ b/general.h @@ -128,7 +128,6 @@ enum menu_enums MODE_VIDEO_SOFT_FILTER_ENABLE, MODE_VIDEO_PAL_ENABLE, MODE_VIDEO_PAL_TEMPORAL_ENABLE, - MODE_VIDEO_PAL_VSYNC_BLOCK, MODE_AUDIO_CUSTOM_BGM_ENABLE, MODE_OSK_ENTRY_SUCCESS, MODE_OSK_ENTRY_FAIL, From 2323cee6a72baeed1e3de368c539b86f33ab0710 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:34:06 +0200 Subject: [PATCH 12/23] Get rid of MODE_EXIT --- frontend/menu/menu_common.c | 1 - frontend/menu/rgui.c | 4 ---- frontend/menu/rmenu.c | 6 ------ frontend/menu/rmenu_xui.cpp | 2 -- frontend/platform/platform_ps3.c | 1 - general.h | 1 - retroarch.c | 6 ------ 7 files changed, 21 deletions(-) diff --git a/frontend/menu/menu_common.c b/frontend/menu/menu_common.c index f075683262..0b73efc303 100644 --- a/frontend/menu/menu_common.c +++ b/frontend/menu/menu_common.c @@ -458,7 +458,6 @@ void load_menu_game_history(unsigned game_index) #if !defined( HAVE_DYNAMIC) && defined(RARCH_CONSOLE) g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN_START_GAME); #elif defined(HAVE_DYNAMIC) diff --git a/frontend/menu/rgui.c b/frontend/menu/rgui.c index 918cb1c543..2093953cd6 100644 --- a/frontend/menu/rgui.c +++ b/frontend/menu/rgui.c @@ -246,7 +246,6 @@ rgui_handle_t *rgui_init(void) /* TODO - should be refactored - perhaps don't do rarch_fail but instead * exit program */ g_extern.lifecycle_mode_state &= ~((1ULL << MODE_MENU) | (1ULL << MODE_GAME)); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); return NULL; } @@ -1063,7 +1062,6 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r sizeof(g_extern.fullpath)); #endif g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); return -1; } @@ -1079,7 +1077,6 @@ static int rgui_settings_toggle_setting(rgui_handle_t *rgui, unsigned setting, r if (action == RGUI_ACTION_OK) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); return -1; } break; @@ -2654,7 +2651,6 @@ int rgui_iterate(rgui_handle_t *rgui) fill_pathname_join(g_extern.fullpath, default_paths.core_dir, SALAMANDER_FILE, sizeof(g_extern.fullpath)); g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); ret = -1; #endif diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index f7c537c13c..289adde983 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -564,7 +564,6 @@ static int select_file(void *data, uint64_t input) if (rgui->menu_type == LIBRETRO_CHOICE) { strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); return -1; } @@ -1451,7 +1450,6 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME_EXIT); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN_MULTIMAN); return -1; @@ -1462,7 +1460,6 @@ static int set_setting_action(uint8_t menu_type, unsigned switchvalue, uint64_t if (input & (1ULL << DEVICE_NAV_B)) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_MENU_INGAME_EXIT); return -1; } @@ -2894,10 +2891,7 @@ int rgui_input_postprocess(void *data, uint64_t old_state) device_ptr->ctx_driver->check_window(&quit, &resize, &width, &height, frame_count); if (quit) - { - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); ret = -1; - } if (g_extern.lifecycle_mode_state & (1ULL << MODE_MENU_INGAME_EXIT)) { diff --git a/frontend/menu/rmenu_xui.cpp b/frontend/menu/rmenu_xui.cpp index b06f3eb58a..8b41252f44 100644 --- a/frontend/menu/rmenu_xui.cpp +++ b/frontend/menu/rmenu_xui.cpp @@ -1224,7 +1224,6 @@ HRESULT CRetroArchCoreBrowser::OnNotifyPress( HXUIOBJ hObjPressed, BOOL& bHandle { snprintf(g_settings.libretro, sizeof(g_settings.libretro), "%s\\%s", rgui->browser->current_dir.directory_path, str_buffer); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); process_input_ret = -1; } @@ -1409,7 +1408,6 @@ HRESULT CRetroArchMain::OnControlNavigate(XUIMessageControlNavigate *pControlNav if (input == XUI_CONTROL_NAVIGATE_OK) { g_extern.lifecycle_mode_state &= ~(1ULL << MODE_GAME); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); process_input_ret = -1; } break; diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 95e3d0ad1d..cba95985e4 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -148,7 +148,6 @@ static void callback_sysutil_exit(uint64_t status, uint64_t param, void *userdat case CELL_SYSUTIL_REQUEST_EXITGAME: gl->quitting = true; g_extern.lifecycle_mode_state &= ~((1ULL << MODE_MENU) | (1ULL << MODE_GAME)); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); break; #ifdef HAVE_OSKUTIL case CELL_SYSUTIL_OSKDIALOG_LOADED: diff --git a/general.h b/general.h index e5ebba7264..ea34936330 100644 --- a/general.h +++ b/general.h @@ -118,7 +118,6 @@ enum menu_enums MODE_INFO_DRAW, MODE_FPS_DRAW, MODE_EXTLAUNCH_MULTIMAN, - MODE_EXIT, MODE_EXITSPAWN, MODE_EXITSPAWN_START_GAME, MODE_EXITSPAWN_MULTIMAN, diff --git a/retroarch.c b/retroarch.c index 7005d50d06..ecd6bf9d6d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2985,17 +2985,11 @@ bool rarch_main_iterate(void) // SHUTDOWN on consoles should exit RetroArch completely. if (g_extern.system.shutdown) - { - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); return false; - } // Time to drop? if (input_key_pressed_func(RARCH_QUIT_KEY) || !video_alive_func()) - { - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXIT); return false; - } if (check_enter_rgui()) return false; // Enter menu, don't exit. From dea236a5692352488538e6cb191e48ca7ea2b495 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:40:02 +0200 Subject: [PATCH 13/23] Get rid of MODE_INIT --- general.h | 1 - 1 file changed, 1 deletion(-) diff --git a/general.h b/general.h index ea34936330..89834a87ba 100644 --- a/general.h +++ b/general.h @@ -109,7 +109,6 @@ enum menu_enums { MODE_GAME = 0, MODE_LOAD_GAME, - MODE_INIT, MODE_MENU, MODE_MENU_WIDESCREEN, MODE_MENU_HD, From 31ea0a78cda9b054b8ded7a559b9db8685f01e19 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:46:21 +0200 Subject: [PATCH 14/23] (Vita) Remove this as long as it's useless --- vita/vita_video.c | 534 ---------------------------------------------- 1 file changed, 534 deletions(-) delete mode 100644 vita/vita_video.c diff --git a/vita/vita_video.c b/vita/vita_video.c deleted file mode 100644 index fd5fa91fd5..0000000000 --- a/vita/vita_video.c +++ /dev/null @@ -1,534 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2013 - Hans-Kristian Arntzen - * Copyright (C) 2011-2013 - Daniel De Matteis - * - * RetroArch is free software: you can redistribute it and/or modify it under the terms - * of the GNU General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . - */ - -/* DONE: - * - Context creation (mostly) - * TODO: - * - Shader code - * - Texture reinitialization (16bpp support, etc) - * - Viewports - * - Implement video frame logic inbetween Begin/End - * - Actually run and test this to make sure it does work - */ - -#include "../psp/sdk_defines.h" -#include "../general.h" -#include "../driver.h" - -#define MALLOC_PARAMS_FRAGMENT_FLAG (1 << 0) -#define MALLOC_PARAMS_VERTEX_FLAG (1 << 1) - -#define GXM_ALIGN(x, a) (((x) + ((a) - 1)) & ~((a) - 1)) - -#define DISPLAY_BUFFER_COUNT 3 -#define DISPLAY_BUFFER_SIZE (GXM_ALIGN(PSP_PITCH_PIXELS * PSP_FB_HEIGHT * 4, 1024 * 1024)) -#define DISPLAY_MAX_PENDING_SWAPS 2 - -typedef struct vita_video -{ - SceGxmContext *gxm_ctx; - void *context_host_mem; - void *disp_buf_data[DISPLAY_BUFFER_COUNT]; - SceUID disp_buf_uid[DISPLAY_BUFFER_COUNT]; - SceGxmColorSurface disp_surface[DISPLAY_BUFFER_COUNT]; - SceGxmSyncObject *disp_buf_sync[DISPLAY_BUFFER_COUNT]; - SceGxmShaderPatcher *shader_patcher; - SceGxmRenderTarget *rt; - SceUID vid_rb_uid; - SceUID vtx_rb_uid; - SceUID fp_rb_uid; - SceUID patcher_buf_id; - SceUID patcher_vertex_usse_uid; - SceUID patcher_fragment_usse_uid; - SceUID shader_patcher; - SceUID fp_usse_rb_uid; - SceUID patcher_buf_uid; - unsigned disp_back_buf_index; - unsigned disp_front_buf_index; -} vita_video_t; - -typedef struct -{ - uint32_t *address; -} DisplayData; - -static void *malloc_gpu(SceKernelMemBlockType type, uint32_t size, - uint32_t attribs, SceUID *uid, uint32_t params, uint32_t *offset) -{ - int ret = SCE_OK; - - if (type == SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RWDATA) - size = GXM_ALIGN(size, 262144); - else - size = GXM_ALIGN(size, 4096); - - if(((params & MALLOC_PARAMS_FRAGMENT_FLAG) == MALLOC_PARAMS_FRAGMENT_FLAG) || - ((params & MALLOC_PARAMS_VERTEX_FLAG) == MALLOC_PARAMS_VERTEX_FLAG)) - type = SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE; - - *uid = sceKernelAllocMemBlock("basic", type, size, NULL); - - if (uid != SCE_OK) - goto error; - - void *mem = NULL; - - ret = sceKernelGetMemBlockBase(*uid, &mem); - - if (ret != SCE_OK) - goto error; - - if((params & MALLOC_PARAMS_FRAGMENT_FLAG) == MALLOC_PARAMS_FRAGMENT_FLAG) - ret = sceGxmMapFragmentUsseMemory(mem, size, offset); - else if((params & MALLOC_PARAMS_VERTEX_FLAG) == MALLOC_PARAMS_VERTEX_FLAG) - ret = sceGxmMapVertexUsseMemory(mem, size, offset); - else - ret = sceGxmMapMemory(mem, size, attribs); - - if (ret != SCE_OK) - goto error; - - return mem; -error: - RARCH_ERR("Error during GPU memory allocation.\n"); - return NULL; -} - -static void free_gpu(SceUID uid, uint32_t params) -{ - int ret = SCE_OK; - - void *mem = NULL; - ret = sceKernelGetMemBlockBase(uid, &mem); - - if (ret != SCE_OK) - goto error; - - if((params & MALLOC_PARAMS_FRAGMENT_FLAG) == MALLOC_PARAMS_FRAGMENT_FLAG) - ret = sceGxmUnmapFragmentUsseMemory(mem); - else if((params & MALLOC_PARAMS_VERTEX_FLAG) == MALLOC_PARAMS_VERTEX_FLAG) - ret = sceGxmUnmapVertexUsseMemory(mem); - else - ret = sceGxmUnmapMemory(mem); - - if (ret != SCE_OK) - goto error; - - ret = sceKernelFreeMemBlock(uid); - - if (ret != SCE_OK) - goto error; - -error: - RARCH_ERR("Error during GPU memory deallocation.\n"); -} - -static void vita_gfx_init_fbo(void *data, const video_info_t *video) -{ - vita_video_t *vid = (vita_video_t*)driver.video_data; - - SceGxmRenderTargetParams rtparams; - memset(&rtparams, 0, sizeof(SceGxmRenderTargetParams)); - - rtparams.flags = 0; - rtparams.width = PSP_FB_WIDTH; - rtparams.height = PSP_FB_HEIGHT; - rtparams.scenesPerFrame = 1; - rtparams.multisampleMode = SCE_GXM_MULTISAMPLE_NONE; - rtparams.multisampleLocations = 0; - rtparams.hostMem = NULL; - rtparams.hostMemSize = 0; - rtparams.driverMemBlock = -1; - - // compute size - uint32_t host_mem_size, driver_mem_size; - sceGxmGetRenderTargetMemSizes(&rtparams, &host_mem_size, &driver_mem_size); - - rtparams.hostMem = malloc(host_mem_size); - rtparams.hostMemSize = host_mem_size; - rtparams.driverMemBlock = sceKernelAllocMemBlock( - "SampleRT", - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - driver_mem_sie, NULL); - - int ret = sceGxmCreateRenderTarget(&rtparams, &vid->rt); - - return ret; -} - -static void disp_callback(const void *callback_data) -{ - int ret = SCE_OK; - -#if defined(SN_TARGET_PSP2) - SceDisplayFrameBuf framebuf; - - const DisplayData *display_data = (const DisplayData*)callback_data; - - memset(&framebuf, 0, sizeof(SceDisplayFrameBuf)); - - framebuf.size = sizeof(SceDisplayFrameBuf); - framebuf.base = display_data->address; - framebuf.pitch = PSP_PITCH_PIXELS; - framebuf.pixelformat = PSP_DISPLAY_PIXELFORMAT_8888; - framebuf.width = PSP_FB_WIDTH; - framebuf.height = PSP_FB_HEIGHT; - - ret = DisplaySetFrameBuf(&framebuf, PSP_FB_WIDTH, PSP_DISPLAY_PIXELFORMAT_8888, SCE_DISPLAY_UPDATETIMING_NEXTVSYNC); -#elif defined(PSP) - ret = DisplaySetFrameBuf(&display_data->address, PSP_FB_WIDTH, PSP_DISPLAY_PIXELFORMAT_8888, SCE_DISPLAY_UPDATETIMING_NEXTVSYNC); -#endif - - /* TODO - Don't bother with error checking for now in here */ - - // Block until swap has occurred and the old buffer is no longer displayed - ret = sceDisplayWaitSetFrameBuf(); -} - -static void *patcher_host_alloc(void *user_data, uint32_t size) -{ - (void)user_data; - return malloc(size); -} - -static void patcher_host_free(void *user_data, void *mem) -{ - (void)user_data; - free(mem); -} - -static int vita_gfx_init_shader_patcher(const video_info_t *video) -{ - ps2p_video_t *vid = (vita_video_t*)driver.video_data; - - SceGxmShaderPatcherParams patcher_params; - uint32_t patcherVertexUsseOffset, patcherFragmentUsseOffset; - - memset(&patcher_params, 0, sizeof(SceGxmShaderPatcherParams)); - patcher_params.userData = NULL; - patcher_params.hostAllocCallback = &patcher_host_alloc; - patcher_params.hostFreeCallback = &patcher_host_free; - patcher_params.bufferAllocCallback = NULL; - patcher_params.bufferreeCallback = NULL; - patcher_params.bufferMem = malloc_gpu( - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - 64 * 1024, - SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, - &vid->patcher_buf_uid, 0, NULL); - patcher_params.bufferMemSize = 64 * 1024; - patcher_params.vertexUsseAllocCallback = NULL; - patcher_params.vertexUsseFreeCallback = NULL; - patcher_params.vertexUsseMem = malloc_gpu( - 0, - 64 * 1024, - 0, - &vid->patcher_vertex_usse_uid, - MALLOC_PARAMS_VERTEX_FLAG, - &patcherVertexUsseOffset); - patcher_params.vertexUsseMemSize = 64 * 1024; - patcher_params.vertexUsseOffset = patcherVertexUsseOffset; - patcher_params.fragmentUsseAllocCallback = NULL; - patcher_params.fragmentUsseFreeCallback = NULL; - patcher_params.fragmentUsseMem = malloc_gpu( - 0, - 64 * 1024, - 0, - &vid->patcher_fragment_usse_uid, - MALLOC_PARAMS_FRAGMENT_FLAG, - &patcherFragmentUsseOffset); - patcher_params.fragmentUsseMemSize = 64 * 1024; - patcher_params.fragmentUsseOffset = patcherFragmentUsseOffset; - - int ret = sceGxmShaderPatcherCreate(&patcher_params, &vid->shader_patcher); - - return ret; -} - -static void vita_gfx_init_sync_objects(const video_info_t *video) -{ - vita_video_t *vid = (vita_video_t*)driver.video_data; - - for (unsigned i = 0; i < DISPLAY_BUFFER_COUNT; ++i) - { - vid->disp_buf_data[i] = malloc_gpu( - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - DISPLAY_BUFFER_SIZE, - SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE, - &vid->disp_buf_uid[i], 0, NULL); - - int ret = sceGxmColorSurfaceInit( - &vid->disp_surface[i], - SCE_GXM_COLOR_FORMAT_A8B8G8R8, //TODO - Add toggle between 16bpp and 32bpp here - SCE_GXM_COLOR_SURFACE_LINEAR, - SCE_GXM_COLOR_SURFACE_SCALE_NONE, - SCE_GXM_OUTPUT_REGISTER_SIZE_32BIT, - PSP_FB_WIDTH, - PSP_FB_HEIGHT, - PSP_PITCH_PIXELS, - vid->disp_buf_data[i]); - - if(ret != SCE_OK) - { - RARCH_ERR("Initialization of color surface %d failed.\n", i); - } - else - { - ret = sceGxmSyncObjectCreate(&vid->disp_buffer_sync[i]); - - if(ret != SCE_OK) - RARCH_ERR("Initialization of sync object %d failed.\n"); - } - } -} - -static void *vita_gfx_init(const video_info_t *video, - const input_driver_t **input, void **input_data) -{ - *input = NULL; - *input_data = NULL; - (void)video; - - if (driver.video_data) - { - vita_video_t *vid = (vita_video_t*)driver.video_data; - - /* TODO - Reinitialize textures here */ - - return driver.video_data; - } - - vita_video_t *vid = (vita_video_t*)calloc(1, sizeof(vita_video_t)); - - if (!vid) - goto error; - - driver.video_data = vid; - - int ret; - SceGxmInitializeParams params; - memset(¶ms, 0, sizeof(SceGxmInitializeParams)); - - params.flags = 0; - params.displayQueueMaxPendingCount = DISPLAY_MAX_PENDING_SWAPS; - params.displayQueueCallback = disp_callback; - params.displayQueueCallbackDataSize = sizeof(DisplayData); - params.parameterBufferSize = SCE_GXM_DEFAULT_PARAMETER_BUFFER_SIZE; - - ret = sceGxmInitialize(¶ms); - - if(ret != SCE_OK) - goto error; - - SceGxmContextParams ctx_params; - memset(&ctx_params, 0, sizeof(SceGxmContextParams)); - - uint32_t fp_usse_ring_buffer_offset; - - vid->context_host_mem = malloc(SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE); - - ctx_params.hostMem = vid->context_host_mem; - ctx_params.hostMemSize = SCE_GXM_MINIMUM_CONTEXT_HOST_MEM_SIZE; - ctx_params.vdmRingBufferMem = malloc_gpu( - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE, - SCE_GXM_MEMORY_ATTRIB_READ, - &vid->rb_uid, 0, NULL); - ctx_params.vdmRingBufferMemSize = SCE_GXM_DEFAULT_VDM_RING_BUFFER_SIZE; - ctx_params.vertexRingBufferMem = malloc_gpu( - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE, - SCE_GXM_MEMORY_ATTRIB_READ, - &vid->vtx_rb_uid, 0, NULL); - ctx_params.vertexRingBufferMemSize = SCE_GXM_DEFAULT_VERTEX_RING_BUFFER_SIZE; - ctx_params.fragmentRingBufferMem = malloc_gpu( - SCE_KERNEL_MEMBLOCK_TYPE_USER_RWDATA_UNCACHE, - SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE, - SCE_GXM_MEMORY_ATTRIB_READ, - &vid->fp_rb_uid, 0, NULL); - ctx_params.fragmentRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_RING_BUFFER_SIZE; - ctx_params.fragmentUsseRingBufferMem = malloc_gpu( - 0, - SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE, - 0, - &vid->fp_usse_rb_uid, - MALLOC_PARAMS_FRAGMENT_FLAG, - &fp_usse_ring_buffer_offset); - ctx_params.fragmentUsseRingBufferMemSize = SCE_GXM_DEFAULT_FRAGMENT_USSE_RING_BUFFER_SIZE; - ctx_params.fragmentUsseRingBufferOffset = vid->fp_rb_uid; - - vid->gxm_ctx = NULL; - - ret = sceGxmCreateContext(&ctx_params, &vid->gxm_ctx); - - if (ret != SCE_OK) - goto error; - - if((vita_gfx_init_fbo()) != SCE_OK) - goto error; - else - RARCH_LOG("FBO initialized successfully.\n"); - - if((vita_gfx_init_shader_patcher()) != SCE_OK) - goto error; - else - RARCH_LOG("Shader patcher initialized successfully.\n"); - - vita_gfx_init_sync_objects(video); - - /* Clear display buffer for first swap */ - memset(vid->disp_buf_data[vid>disp_front_buf_index], 0x00, DISPLAY_BUFFER_SIZE); - - /* Swap to the current front buffer with Vsync */ - disp_callback(NULL); - - return vid; -error: - RARCH_ERR("Vita libgxm video could not be initialized.\n"); - return (void*)-1; -} - -static inline void vita_gfx_swap(void) -{ - vita_video_t *vid = (vita_video_t*)driver.video_data; - - DisplayData display_data; - - display_data.address = vid->disp_buf_data[vid->disp_back_buf_index]; - - /* queue swap for this frame */ - - int ret = sceGxmDisplayQueueAddEntry( - vid->disp_buffer_sync[vid->disp_front_buf_index], - vid->disp_buffer_sync[vid->disp_back_buf_index], - &display_data); - - vid->disp_front_buf_index = vid->disp_back_buf_index; - vid->disp_back_buf_index = (vid->disp_back_buf_index + 1) & DISPLAY_BUFFER_COUNT; -} - -static bool vita_gfx_frame(void *data, const void *frame, - unsigned width, unsigned height, unsigned pitch, const char *msg) -{ - (void)data; - (void)frame; - (void)width; - (void)height; - (void)pitch; - (void)msg; - - vita_video_t *vid = (vita_video_t*)data; - - sceGxmBeginScene(vid->gcm_ctx, 0, vid->rt, NULL, - NULL, vid->disp_buf_sync[vid->disp_back_buf_index]); - - /* TODO - code comes inbetween */ - - sceGxmEndScene(vid->gxm_ctx, NULL, NULL); - - /* notify end of frame */ - sceGxmPadHeartBeat(&vid->disp_surface[vid->disp_back_buf_index], vid->disp_buf_sync[vid->disp_back_buf_index]); - - vita_gfx_swap(); - - return true; -} - -static void vita_gfx_set_nonblock_state(void *data, bool toggle) -{ - (void)data; - (void)toggle; -} - -static bool vita_gfx_alive(void *data) -{ - (void)data; - return true; -} - -static bool vita_gfx_focus(void *data) -{ - (void)data; - return true; -} - -static void vita_gfx_free(void *data) -{ - (void)data; - void *hostmem; - int ret; - SceUID drivermemblock; - - /* TDO: error checking */ - - vita_video_t *vid = (vita_video_t*)driver.video_data; - - sceGxmFinish(vid->gxm_ctx); - - ret = sceGxmRenderTargetGetHostMem(vid->rt, &hostmem); - - ret = sceGxmRenderTargetGetDriverMemBlock(vid->rt, &drivermemblock); - - ret = sceGxmDestroyRenderTarget(vid->rt); - - sceKernelFreeMemBlock(drivermemblock); - free(hostmem); - - // wait until display queue is finished before deallocating display buffers - int ret = sceGxmDisplayQueueFinish(); - - for (int i = 0; i < DISPLAY_BUFFER_COUNT; ++i) - { - free_gpu(vid->disp_buf_uid[i], 0); - ret = sceGxmSyncObjectDestroy(vid->disp_buf_sync[i]); - } - - ret = sceGxmShaderPatcherDestroy(vid->shader_patcher); - - free_gpu(vid->patcher_fragment_usse_uid, MALLOC_PARAMS_FRAGMENT_FLAG); - free_gpu(vid->patcher_vertex_usse_uid, MALLOC_PARAMS_VERTEX_FLAG); - free_gpu(vid->patcher_buf_uid, 0); - - ret = sceGxmDestroyContext(vid->gxm_ctx); - - free_gpu(vid->fp_rb_uid, MALLOC_PARAMS_FRAGMENT_FLAG); - free_gpu(vid->vtx_rb_uid, MALLOC_PARAMS_VERTEX_FLAG); - free_gpu(vid->vid_rb_uid, 0); - - free(vid->context_host_mem, 0); - - sceGxmTerminate(); -} - -#ifdef RARCH_CONSOLE -static void vita_gfx_start(void) {} -static void vita_gfx_restart(void) {} -#endif - -const video_driver_t video_vita = { - vita_gfx_init, - vita_gfx_frame, - vita_gfx_set_nonblock_state, - vita_gfx_alive, - vita_gfx_focus, - NULL, - vita_gfx_free, - "vita", - -#ifdef RARCH_CONSOLE - vita_gfx_start, - vita_gfx_restart, -#endif -}; From 46e7cb4f7a821463674b7363929d85edbf7dc491 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 20:47:00 +0200 Subject: [PATCH 15/23] (Vita) Remove Vita stub --- griffin/griffin.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/griffin/griffin.c b/griffin/griffin.c index 83a206f2d1..fd5e28a352 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -210,10 +210,8 @@ VIDEO DRIVER #if defined(GEKKO) #include "../gx/gx_video.c" -#elif defined(SN_TARGET_PSP2) -#include "../vita/vita_video.c" -//#elif defined(PSP) -//#include "../psp1/psp1_video.c" +#elif defined(PSP) +#include "../psp1/psp1_video.c" #elif defined(XENON) #include "../xenon/xenon360_video.c" #endif From db9462bc495114e3ec1679651e47393362ee3bb8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 21:38:38 +0200 Subject: [PATCH 16/23] (GX) Build fixes --- frontend/platform/platform_gx.c | 8 +++++--- frontend/platform/platform_xdk.c | 6 ++++-- gx/gx_video.c | 11 ----------- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index cb313af8ba..25a2454092 100644 --- a/frontend/platform/platform_gx.c +++ b/frontend/platform/platform_gx.c @@ -316,20 +316,22 @@ static void system_init(void) #endif } +static void system_exec(const char *path, bool should_load_game); + static void system_exitspawn(void) { #if defined(IS_SALAMANDER) - rarch_console_exec(default_paths.libretro_path, gx_rom_path[0] != '\0' ? true : false); + system_exec(default_paths.libretro_path, gx_rom_path[0] != '\0' ? true : false); #elif defined(HW_RVL) bool should_load_game = false; if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN_START_GAME)) should_load_game = true; - rarch_console_exec(g_settings.libretro, should_load_game); + system_exec(g_settings.libretro, should_load_game); // direct loading failed (out of memory), try to jump to salamander then load the correct core char boot_dol[PATH_MAX]; snprintf(boot_dol, sizeof(boot_dol), "%s/boot.dol", default_paths.core_dir); - rarch_console_exec(boot_dol, should_load_game); + system_exec(boot_dol, should_load_game); #endif } diff --git a/frontend/platform/platform_xdk.c b/frontend/platform/platform_xdk.c index d021b8230b..3f9ce746f4 100644 --- a/frontend/platform/platform_xdk.c +++ b/frontend/platform/platform_xdk.c @@ -307,16 +307,18 @@ static int system_process_args(int argc, char *argv[]) return 0; } +static void system_exec(const char *path, bool should_load_game); + static void system_exitspawn(void) { #ifdef IS_SALAMANDER - rarch_console_exec(default_paths.libretro_path, false); + system_exec(default_paths.libretro_path, false); #else bool should_load_game = false; if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN_START_GAME)) should_load_game = true; - rarch_console_exec(g_settings.libretro, should_load_game); + system_exec(g_settings.libretro, should_load_game); #endif } diff --git a/gx/gx_video.c b/gx/gx_video.c index 1c8024097b..27190521c2 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -1012,17 +1012,6 @@ static void gx_set_rotation(void *data, unsigned orientation) gx->should_resize = true; } -static bool gx_set_shader(void *data, enum rarch_shader_type type, const char *path) -{ - (void)data; - (void)type; - (void)path; - (void)index; - - RARCH_WARN("Shader support is not implemented for GX.\n"); - return false; -} - static void gx_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { From 806e07db5d2a552333d242daf5903005b1fe7433 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 21:50:20 +0200 Subject: [PATCH 17/23] (Salamander) GX build fix --- Makefile.wii.salamander | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index 87049c1d5c..fa303bd71c 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -39,7 +39,7 @@ LIBS := -lfat -lwiiuse -logc -lbte APP_BOOTER_DIR = wii/app_booter -OBJ = frontend/frontend_salamander.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj +OBJ = frontend/frontend_salamander.o frontend/frontend_context.o file_path.o compat/compat.o conf/config_file.o $(APP_BOOTER_DIR)/app_booter.binobj ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER From a5e62bbfdada28f2203b9bddec8322c8e3991e14 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 27 Jul 2013 21:52:53 +0200 Subject: [PATCH 18/23] Add frontend_context to Salamander MSVC solutions --- .../RetroArch-Salamander.vcxproj | 1 + .../RetroArch-Salamander.vcxproj.filters | 7 ++-- .../RetroArch-Salamander.vcproj | 33 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj index 81806c2062..22deb9854c 100644 --- a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj +++ b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj @@ -267,6 +267,7 @@ + diff --git a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj.filters b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj.filters index a6d585dc89..a91550e51c 100644 --- a/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj.filters +++ b/msvc/RetroArch-360-Salamander/RetroArch-Salamander.vcxproj.filters @@ -26,8 +26,11 @@ Source Files - + + Source Files + + Source Files - \ No newline at end of file + diff --git a/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj b/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj index b3d6dc0dfd..7478eec73c 100644 --- a/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj +++ b/msvc/RetroArch-Xbox1-Salamander/RetroArch-Salamander.vcproj @@ -404,6 +404,39 @@ CompileAs="2"/> + + + + + + + + + + + + + + + + + Date: Sat, 27 Jul 2013 22:33:57 +0200 Subject: [PATCH 19/23] (PS3) Fix core loading --- frontend/platform/platform_ps3.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index cba95985e4..d7e28c6991 100644 --- a/frontend/platform/platform_ps3.c +++ b/frontend/platform/platform_ps3.c @@ -440,7 +440,8 @@ static void system_exec(const char *path, bool should_load_game) RARCH_LOG("Attempt to load executable: [%s].\n", path); char spawn_data[256]; char game_path[256]; - (void)game_path; + game_path[0] = '\0'; + for(unsigned int i = 0; i < sizeof(spawn_data); ++i) spawn_data[i] = i & 0xff; From 49f3078e729d23068cbdb5ef7120791a8953d8cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jul 2013 01:34:29 +0200 Subject: [PATCH 20/23] (RGL PS3) Dehardcode some magic numbers --- ps3/rgl/src/ps3/include/rgl-inline.h | 46 ++++++++++++++-------------- ps3/rgl/src/ps3/rgl_ps3.cpp | 2 +- ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 4 +-- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index cfa65241af..24c09a2856 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -27,41 +27,41 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) #define SUBPIXEL_ADJUST (0.5/(1<current[0] = (((4) << (18)) | ((0x00001c00) + (index) * 16)); \ + thisContext->current[0] = (((4) << (18)) | (CELL_GCM_NV4097_SET_VERTEX_DATA4F_M + (index) * 16)); \ __builtin_memcpy(&thisContext->current[1], v, sizeof(float)*4); \ thisContext->current += 5; #define rglGcmSetVertexDataArray(thisContext, index, frequency, stride, size, type, location, offset) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001740) + ((index)) * 4)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_VERTEX_DATA_ARRAY_FORMAT + ((index)) * 4)); \ (thisContext->current)[1] = ((((frequency)) << 16) | (((stride)) << 8) | (((size)) << 4) | ((type))); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001680) + ((index)) * 4)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_VERTEX_DATA_ARRAY_OFFSET + ((index)) * 4)); \ (thisContext->current)[1] = ((((location)) << 31) | (offset)); \ (thisContext->current) += 2; #define rglGcmSetInlineTransferPointer(thisContext, offset, count, pointer) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x0000630C))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_OFFSET_DESTIN); \ (thisContext->current)[1] = (offset & ~63); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((2) << (18)) | ((0x00006300))); \ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV3062_SET_COLOR_FORMAT); \ (thisContext->current)[1] = (CELL_GCM_TRANSFER_SURFACE_FORMAT_Y32); \ (thisContext->current)[2] = ((0x1000) | ((0x1000) << 16)); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((3) << (18)) | ((0x0000A304))); \ + (thisContext->current)[0] = (((3) << (18)) | CELL_GCM_NV308A_POINT); \ (thisContext->current)[1] = (((0) << 16) | ((offset & 63) >> 2)); \ (thisContext->current)[2] = (((1) << 16) | (count)); \ (thisContext->current)[3] = (((1) << 16) | (count)); \ (thisContext->current) += 4; \ - thisContext->current[0] = ((((count + 1) & ~1) << (18)) | ((0x0000A400))); \ + thisContext->current[0] = ((((count + 1) & ~1) << (18)) | CELL_GCM_NV308A_COLOR); \ thisContext->current += 1; \ pointer = thisContext->current; \ thisContext->current += ((count + 1) & ~1); #define rglGcmSetWriteBackEndLabel(thisContext, index, value) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d6c))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SEMAPHORE_OFFSET); \ (thisContext->current)[1] = 0x10 * index; /* offset */ \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d70))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_BACK_END_WRITE_SEMAPHORE_RELEASE); \ (thisContext->current)[1] = ( value & 0xff00ff00) | ((value >> 16) & 0xff) | (((value >> 0 ) & 0xff) << 16); \ (thisContext->current) += 2; @@ -74,21 +74,21 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current) += 2; #define rglGcmSetInvalidateVertexCache(thisContext) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001710))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_CACHE_FILE); \ (thisContext->current)[1] = 0; \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_FILE); \ (thisContext->current)[1] = 0; \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_FILE); \ (thisContext->current)[1] = 0; \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001714))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_FILE); \ (thisContext->current)[1] = 0; \ (thisContext->current) += 2; #define rglGcmSetClearSurface(thisContext, mask) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d94))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_CLEAR_SURFACE); \ (thisContext->current)[1] = (mask); \ (thisContext->current) += 2; \ (thisContext->current)[0] = (((1) << (18)) | ((0x00000100))); \ @@ -111,13 +111,13 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current) += 2; #define rglGcmInlineTransfer(thisContext, dstOffset, srcAdr, sizeInWords, location) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00006188))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN); \ (thisContext->current)[1] = ((0xFEED0000) + location); \ (thisContext->current) += 2; \ cellGcmSetInlineTransferUnsafeInline(thisContext, dstOffset, srcAdr, sizeInWords); #define rglGcmSetClearColor(thisContext, color) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d90))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_COLOR_CLEAR_VALUE); \ (thisContext->current)[1] = (color); \ (thisContext->current) += 2; @@ -205,7 +205,7 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current) += 2; #define rglGcmSetZMinMaxControl(thisContext, cullNearFarEnable, zclampEnable, cullIgnoreW) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d78))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_ZMIN_MAX_CONTROL); \ (thisContext->current)[1] = ((cullNearFarEnable) | ((zclampEnable) << 4) | ((cullIgnoreW)<<8)); \ (thisContext->current) += 2; @@ -295,7 +295,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC uint32_t texMaskCentroid; uint32_t i; - (thisContext->current)[0] = (((1) << (18)) | ((0x000008e4))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SHADER_PROGRAM); (thisContext->current)[1] = ((location+1) | (rawData)); (thisContext->current) += 2; @@ -312,7 +312,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC for(i=0; texMask; i++) { - if (texMask&1) + if (texMask & 1) { uint32_t hwTexCtrl = (texMask2D & 1) | ((texMaskCentroid & 1) << 4); (thisContext->current)[0] = (((1) << (18)) | ((0x00000b40) + (i) * 4)); @@ -785,7 +785,7 @@ static inline void rglGcmTransferData GLuint dstOffset = gmmIdToOffset(dstId) + dstIdOffset; GLuint srcOffset = gmmIdToOffset(srcId) + srcIdOffset; - (thisContext->current)[0] = (((2) << (18)) | ((0x00002184))); + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV0039_SET_CONTEXT_DMA_BUFFER_IN); (thisContext->current)[1] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current)[2] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current) += 3; @@ -811,7 +811,7 @@ static inline void rglGcmTransferData { cols = (colCount > CL0039_MAX_LINES) ? CL0039_MAX_LINES : colCount; - (thisContext->current)[0] = (((8) << (18)) | ((0x0000230C))); + (thisContext->current)[0] = (((8) << (18)) | CELL_GCM_NV0039_OFFSET_IN); (thisContext->current)[1] = (srcOffset + (bytesPerRow - colCount)); (thisContext->current)[2] = (dstOffset + (bytesPerRow - colCount)); (thisContext->current)[3] = (0); @@ -837,7 +837,7 @@ static inline void rglGcmTransferData { cols = (colCount > CL0039_MAX_LINES) ? CL0039_MAX_LINES : colCount; - (thisContext->current)[0] = (((8) << (18)) | ((0x0000230C))); + (thisContext->current)[0] = (((8) << (18)) | CELL_GCM_NV0039_OFFSET_IN); (thisContext->current)[1] = (srcOffset + (bytesPerRow - colCount)); (thisContext->current)[2] = (dstOffset + (bytesPerRow - colCount)); (thisContext->current)[3] = (srcPitch); @@ -854,7 +854,7 @@ static inline void rglGcmTransferData } } - (thisContext->current)[0] = (((1) << (18)) | ((0x00002310))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV0039_OFFSET_OUT); (thisContext->current)[1] = (0); (thisContext->current) += 2; } diff --git a/ps3/rgl/src/ps3/rgl_ps3.cpp b/ps3/rgl/src/ps3/rgl_ps3.cpp index 9326970e05..f28b8e1c4d 100644 --- a/ps3/rgl/src/ps3/rgl_ps3.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3.cpp @@ -3130,7 +3130,7 @@ GLAPI void RGL_EXPORT psglSwap (void) rglGcmDriver *driver = (rglGcmDriver*)_CurrentDevice->rasterDriver; float * __restrict v = (float*)driver->sharedVPConstants; - thisContext->current[0] = (((33) << (18)) | ((0x00001efc))); + thisContext->current[0] = (((33) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_CONSTANT_LOAD); thisContext->current[1] = 0; __builtin_memcpy(&thisContext->current[2], v, sizeof(float)*16); diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index 9451b18ca5..793045fd77 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -188,7 +188,7 @@ template static void setVectorTypeSharedvpIndex (void *data, const voi memcpy(driver->sharedVPConstants + resource * 4 * sizeof( float ), dst, 4 * sizeof(float)); - thisContext->current[0] = (((5) << (18)) | ((0x00001efc))); + thisContext->current[0] = (((5) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_CONSTANT_LOAD); thisContext->current[1] = resource; thisContext->current += 2; @@ -214,7 +214,7 @@ template static void setVectorTypeSharedvpIndexArray (void *data, cons memcpy(driver->sharedVPConstants + resource * 4 * sizeof( float ), dst, 4 * sizeof(float)); - thisContext->current[0] = (((5) << (18)) | ((0x00001efc))); + thisContext->current[0] = (((5) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_CONSTANT_LOAD); thisContext->current[1] = resource; thisContext->current += 2; From bdf9c5eecdc67e07b291e3e392b73f65f68f2965 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jul 2013 02:31:21 +0200 Subject: [PATCH 21/23] (RGL PS3) More magic number dehardcoding --- ps3/rgl/src/ps3/include/rgl-inline.h | 122 +++++++++++++-------------- ps3/rgl/src/ps3/rgl_ps3_raster.cpp | 15 +++- 2 files changed, 73 insertions(+), 64 deletions(-) diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 24c09a2856..63ac4228c5 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -91,28 +91,28 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_CLEAR_SURFACE); \ (thisContext->current)[1] = (mask); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000100))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_NO_OPERATION); \ (thisContext->current)[1] = 0; \ (thisContext->current) += 2; #define rglGcmSetTextureControl(thisContext, index, enable, minlod, maxlod, maxaniso) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001a0c) + 0x20 * ((index)))); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_CONTROL0 + 0x20 * ((index)))); \ (thisContext->current)[1] = ((((0) << 2) | ((maxaniso)) << 4) | (((maxlod)) << 7) | (((minlod)) << 19) | ((enable) << 31)); \ (thisContext->current) += 2; #define rglGcmSetTextureRemap(thisContext, index, remap) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001a10) + ((index)) * 32)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_CONTROL1 + ((index)) * 32)); \ (thisContext->current)[1] = (remap); \ (thisContext->current) += 2; #define rglGcmSetTransferLocation(thisContext, location) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00006188))); \ - (thisContext->current)[1] = ((0xFEED0000) + location); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + location); \ (thisContext->current) += 2; #define rglGcmInlineTransfer(thisContext, dstOffset, srcAdr, sizeInWords, location) \ (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN); \ - (thisContext->current)[1] = ((0xFEED0000) + location); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + location); \ (thisContext->current) += 2; \ cellGcmSetInlineTransferUnsafeInline(thisContext, dstOffset, srcAdr, sizeInWords); @@ -128,27 +128,27 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) imagerect = texture->height | (texture->width << 16); \ control1 = texture->remap; \ control3 = texture->pitch | (texture->depth << 20); \ - (thisContext->current)[0] = (((2) << (18)) | ((0x00001a00) + ((index)) * 32)); \ + (thisContext->current)[0] = (((2) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_OFFSET + ((index)) * 32)); \ (thisContext->current)[1] = (offset); \ (thisContext->current)[2] = (format); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001a18) + ((index)) * 32)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_IMAGE_RECT + ((index)) * 32)); \ (thisContext->current)[1] = (imagerect); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001840) + ((index)) * 4)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_CONTROL3 + ((index)) * 4)); \ (thisContext->current)[1] = (control3); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001a10) + ((index)) * 32)); \ + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEXTURE_CONTROL1 + ((index)) * 32)); \ (thisContext->current)[1] = (control1); \ (thisContext->current) += 2; #define rglGcmSetUserClipPlaneControl(thisContext, plane0, plane1, plane2, plane3, plane4, plane5) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001478))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_USER_CLIP_PLANE_CONTROL); \ (thisContext->current)[1] = ((plane0) | ((plane1) << 4) | ((plane2) << 8) | ((plane3) << 12) | ((plane4) << 16) | ((plane5) << 20)); \ (thisContext->current) += 2; #define rglGcmSetInvalidateTextureCache(thisContext, value) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001fd8))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_INVALIDATE_L2); \ (thisContext->current)[1] = (value); \ (thisContext->current) += 2; @@ -165,15 +165,15 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) s[1].f = scale[1]; \ s[2].f = scale[2]; \ s[3].f = scale[3]; \ - (thisContext->current)[0] = (((2) << (18)) | ((0x00000a00))); \ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV4097_SET_VIEWPORT_HORIZONTAL); \ (thisContext->current)[1] = (((x)) | (((w)) << 16)); \ (thisContext->current)[2] = (((y)) | (((h)) << 16)); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((2) << (18)) | ((0x00000394))); \ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV4097_SET_CLIP_MIN); \ (thisContext->current)[1] = (d0.u); \ (thisContext->current)[2] = (d1.u); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((8) << (18)) | ((0x00000a20))); \ + (thisContext->current)[0] = (((8) << (18)) | CELL_GCM_NV4097_SET_VIEWPORT_OFFSET); \ (thisContext->current)[1] = (o[0].u); \ (thisContext->current)[2] = (o[1].u); \ (thisContext->current)[3] = (o[2].u); \ @@ -183,7 +183,7 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current)[7] = (s[2].u); \ (thisContext->current)[8] = (s[3].u); \ (thisContext->current) += 9; \ - (thisContext->current)[0] = (((8) << (18)) | ((0x00000a20))); \ + (thisContext->current)[0] = (((8) << (18)) | CELL_GCM_NV4097_SET_VIEWPORT_OFFSET); \ (thisContext->current)[1] = (o[0].u); \ (thisContext->current)[2] = (o[1].u); \ (thisContext->current)[3] = (o[2].u); \ @@ -195,12 +195,12 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current) += 9; #define rglGcmSetDitherEnable(thisContext, enable) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000300))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_DITHER_ENABLE); \ (thisContext->current)[1] = (enable); \ (thisContext->current) += 2; #define rglGcmSetReferenceCommand(thisContext, ref) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000050))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV406E_SET_REFERENCE); \ (thisContext->current)[1] = (ref); \ (thisContext->current) += 2; @@ -210,7 +210,7 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current) += 2; #define rglGcmSetVertexAttribOutputMask(thisContext, mask) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001ff4))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK); \ (thisContext->current)[1] = (mask); \ (thisContext->current) += 2; @@ -220,7 +220,7 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) thisContext->current += count; #define rglGcmSetAntiAliasingControl(thisContext, enable, alphaToCoverage, alphaToOne, sampleMask) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d7c))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_ANTI_ALIASING_CONTROL); \ (thisContext->current)[1] = ((enable) | ((alphaToCoverage) << 4) | ((alphaToOne) << 8) | ((sampleMask) << 16)); \ (thisContext->current) += 2; @@ -240,20 +240,20 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) fifo->lastSWReferenceFlushed = fifo->lastSWReferenceWritten; #define rglGcmSetSurface(thisContext, surface, origin, pixelCenter, log2Width, log2Height) \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000194))); \ - (thisContext->current)[1] = ((0xFEED0000)+surface->colorLocation[0]); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_CONTEXT_DMA_COLOR_A); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + surface->colorLocation[0]); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x0000018c))); \ - (thisContext->current)[1] = ((0xFEED0000)+surface->colorLocation[1]); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_CONTEXT_DMA_COLOR_B); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + surface->colorLocation[1]); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((2) << (18)) | ((0x000001b4))); \ - (thisContext->current)[1] = ((0xFEED0000)+surface->colorLocation[2]); \ - (thisContext->current)[2] = ((0xFEED0000)+surface->colorLocation[3]); \ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV4097_SET_CONTEXT_DMA_COLOR_C); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + surface->colorLocation[2]); \ + (thisContext->current)[2] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + surface->colorLocation[3]); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000198))); \ - (thisContext->current)[1] = ((0xFEED0000)+surface->depthLocation); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_CONTEXT_DMA_ZETA); \ + (thisContext->current)[1] = (CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER + surface->depthLocation); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((6) << (18)) | ((0x00000208))); \ + (thisContext->current)[0] = (((6) << (18)) | CELL_GCM_NV4097_SET_SURFACE_FORMAT); \ (thisContext->current)[1] = ((surface->colorFormat) | ((surface->depthFormat) << 5) | ((surface->type) << 8) | ((surface->antialias) << 12) | ((log2Width) << 16) | ((log2Height) << 24)); \ (thisContext->current)[2] = (surface->colorPitch[0]); \ (thisContext->current)[3] = (surface->colorOffset[0]); \ @@ -261,26 +261,26 @@ static inline GLuint rglPlatformGetBitsPerPixel (GLenum internalFormat) (thisContext->current)[5] = (surface->colorOffset[1]); \ (thisContext->current)[6] = (surface->colorPitch[1]); \ (thisContext->current) += 7; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x0000022c))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SURFACE_PITCH_Z); \ (thisContext->current)[1] = (surface->depthPitch); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((4) << (18)) | ((0x00000280))); \ + (thisContext->current)[0] = (((4) << (18)) | CELL_GCM_NV4097_SET_SURFACE_PITCH_C); \ (thisContext->current)[1] = (surface->colorPitch[2]); \ (thisContext->current)[2] = (surface->colorPitch[3]); \ (thisContext->current)[3] = (surface->colorOffset[2]); \ (thisContext->current)[4] = (surface->colorOffset[3]); \ (thisContext->current) += 5; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00000220))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SURFACE_COLOR_TARGET); \ (thisContext->current)[1] = ((surface->colorTarget)); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x000002b8))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_WINDOW_OFFSET); \ (thisContext->current)[1] = ((surface->x) | ((surface->y) << 16)); \ (thisContext->current) += 2; \ - (thisContext->current)[0] = (((2) << (18)) | ((0x00000200))); \ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV4097_SET_SURFACE_CLIP_HORIZONTAL); \ (thisContext->current)[1] = ((surface->x) | ((surface->width) << 16)); \ (thisContext->current)[2] = ((surface->y) | ((surface->height) << 16)); \ (thisContext->current) += 3; \ - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d88))); \ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SHADER_WINDOW); \ (thisContext->current)[1] = ((surface->height - (((surface->height) & 0x1000) >> 12)) | ((origin) << 12) | ((pixelCenter) << 16)); \ (thisContext->current) += 2; @@ -301,7 +301,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC inMask = conf->attributeInputMask; - (thisContext->current)[0] = (((1) << (18)) | ((0x00001ff4))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_VERTEX_ATTRIB_OUTPUT_MASK); (thisContext->current)[1] = (inMask); (thisContext->current) += 2; @@ -315,7 +315,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC if (texMask & 1) { uint32_t hwTexCtrl = (texMask2D & 1) | ((texMaskCentroid & 1) << 4); - (thisContext->current)[0] = (((1) << (18)) | ((0x00000b40) + (i) * 4)); + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEX_COORD_CONTROL + (i) * 4)); (thisContext->current)[1] = (hwTexCtrl); (thisContext->current) += 2; } @@ -331,7 +331,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC registerCount = 2; shCtrl0 = conf->fragmentControl | (registerCount << 24); - (thisContext->current)[0] = (((1) << (18)) | ((0x00001d60))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_SHADER_CONTROL); (thisContext->current)[1] = (shCtrl0); (thisContext->current) += 2; } @@ -349,16 +349,16 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u loop = count / (2047); rest = count % (2047); - (thisContext->current)[0] = (((3) << (18)) | ((0x00001714)) | (0x40000000)); + (thisContext->current)[0] = (((3) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_FILE | (0x40000000)); (thisContext->current)[1] = 0; (thisContext->current)[2] = 0; (thisContext->current)[3] = 0; ; (thisContext->current) += 4; - (thisContext->current)[0] = (((1) << (18)) | ((0x00001808))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_BEGIN_END); (thisContext->current)[1] = ((mode)); (thisContext->current) += 2; - (thisContext->current)[0] = (((1) << (18)) | ((0x00001814))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_DRAW_ARRAYS); (thisContext->current)[1] = ((first) | ((lcount)<<24)); (thisContext->current) += 2; first += lcount + 1; @@ -367,7 +367,7 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u for(i=0;icurrent[0] = ((((2047)) << (18)) | ((0x00001814)) | (0x40000000)); + thisContext->current[0] = ((((2047)) << (18)) | CELL_GCM_NV4097_DRAW_ARRAYS | (0x40000000)); thisContext->current++; for(j=0;j<(2047);j++) @@ -380,7 +380,7 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u if(rest) { - thisContext->current[0] = (((rest) << (18)) | ((0x00001814)) | (0x40000000)); + thisContext->current[0] = (((rest) << (18)) | CELL_GCM_NV4097_DRAW_ARRAYS | (0x40000000)); thisContext->current++; for(j=0;jcurrent)[0] = (((1) << (18)) | ((0x00001808))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_BEGIN_END); (thisContext->current)[1] = (0); (thisContext->current) += 2; } @@ -410,7 +410,7 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon loop = instCount / 8; rest = (instCount % 8) * 4; - (thisContext->current)[0] = (((2) << (18)) | ((0x00001e9c))); + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_PROGRAM_LOAD); (thisContext->current)[1] = (instIndex); (thisContext->current)[2] = (instIndex); (thisContext->current) += 3; @@ -419,7 +419,7 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon for (i = 0; i < loop; i++) { - thisContext->current[0] = (((32) << (18)) | ((0x00000b80))); + thisContext->current[0] = (((32) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_PROGRAM); __builtin_memcpy(&thisContext->current[1], &rawData[0], sizeof(uint32_t)*16); __builtin_memcpy(&thisContext->current[17], &rawData[16], sizeof(uint32_t)*16); @@ -430,18 +430,18 @@ static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisCon if (rest > 0) { - thisContext->current[0] = (((rest) << (18)) | ((0x00000b80))); + thisContext->current[0] = (((rest) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_PROGRAM); for (j = 0; j < rest; j++) thisContext->current[j+1] = rawData[j]; thisContext->current += (1 + rest); } - (thisContext->current)[0] = (((1) << (18)) | ((0x00001ff0))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_VERTEX_ATTRIB_INPUT_MASK); (thisContext->current)[1] = ((conf->attributeInputMask)); (thisContext->current) += 2; - (thisContext->current)[0] = (((1) << (18)) | ((0x00001ef8))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_TRANSFORM_TIMEOUT); if (conf->registerCount <= 32) (thisContext->current)[1] = ((0xFFFF) | ((32) << 16)); @@ -523,16 +523,16 @@ static inline void rglGcmFifoGlViewport(void *data, GLclampf zNear, GLclampf zFa static inline void rglGcmSetTransferImage(struct CellGcmContextData *thisContext, uint8_t mode, uint32_t dstOffset, uint32_t dstPitch, uint32_t dstX, uint32_t dstY, uint32_t srcOffset, uint32_t srcPitch, uint32_t srcX, uint32_t srcY, uint32_t width, uint32_t height, uint32_t bytesPerPixel) { - (thisContext->current)[0] = (((1) << (18)) | ((0x00006188))); - (thisContext->current)[1] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_CONTEXT_DMA_IMAGE_DESTIN); + (thisContext->current)[1] = CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current) += 2; - (thisContext->current)[0] = (((1) << (18)) | ((0x0000C184))); - (thisContext->current)[1] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3089_SET_CONTEXT_DMA_IMAGE); + (thisContext->current)[1] = CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current) += 2; - (thisContext->current)[0] = (((1) << (18)) | ((0x0000C198))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3089_SET_CONTEXT_SURFACE); (thisContext->current)[1] = ((0x313371C3)); (thisContext->current) += 2; @@ -574,16 +574,16 @@ static inline void rglGcmSetTransferImage(struct CellGcmContextData *thisContext uint32_t srcBlockOffset = bytesPerPixel * (srcX + x-dstX) + srcPitch * (srcY + y-dstY); uint32_t safeDstBltWidth = (dstBltWidth < 16) ? 16 : (dstBltWidth + 1) & ~1; - (thisContext->current)[0] = (((1) << (18)) | ((0x0000630C))); + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV3062_SET_OFFSET_DESTIN); (thisContext->current)[1] = dstOffset + dstBlockOffset; (thisContext->current) += 2; - (thisContext->current)[0] = (((2) << (18)) | ((0x00006300))); + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV3062_SET_COLOR_FORMAT); (thisContext->current)[1] = (dstFormat); (thisContext->current)[2] = ((dstPitch) | ((dstPitch) << 16)); (thisContext->current) += 3; - (thisContext->current)[0] = (((9) << (18)) | ((0x0000C2FC))); + (thisContext->current)[0] = (((9) << (18)) | CELL_GCM_NV3089_SET_COLOR_CONVERSION); (thisContext->current)[1] = (CELL_GCM_TRANSFER_CONVERSION_TRUNCATE); (thisContext->current)[2] = (srcFormat); (thisContext->current)[3] = (CELL_GCM_TRANSFER_OPERATION_SRCCOPY); @@ -595,7 +595,7 @@ static inline void rglGcmSetTransferImage(struct CellGcmContextData *thisContext (thisContext->current)[9] = 1048576; (thisContext->current) += 10; - (thisContext->current)[0] = (((4) << (18)) | ((0x0000C400))); + (thisContext->current)[0] = (((4) << (18)) | CELL_GCM_NV3089_IMAGE_IN_SIZE); (thisContext->current)[1] = (((dstBltHeight) << 16) | (safeDstBltWidth)); (thisContext->current)[2] = ((srcPitch) | ((CELL_GCM_TRANSFER_ORIGIN_CORNER) << 16) | ((CELL_GCM_TRANSFER_INTERPOLATOR_ZOH) << 24)); (thisContext->current)[3] = (srcOffset + srcBlockOffset); @@ -786,8 +786,8 @@ static inline void rglGcmTransferData GLuint srcOffset = gmmIdToOffset(srcId) + srcIdOffset; (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV0039_SET_CONTEXT_DMA_BUFFER_IN); - (thisContext->current)[1] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ - (thisContext->current)[2] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ + (thisContext->current)[1] = CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ + (thisContext->current)[2] = CELL_GCM_CONTEXT_DMA_MEMORY_FRAME_BUFFER; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ (thisContext->current) += 3; uint32_t colCount; diff --git a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp index 793045fd77..d8b3e9236f 100644 --- a/ps3/rgl/src/ps3/rgl_ps3_raster.cpp +++ b/ps3/rgl/src/ps3/rgl_ps3_raster.cpp @@ -1814,9 +1814,18 @@ GLAPI void APIENTRY glDrawArrays (GLenum mode, GLint first, GLsizei count) // set 3 consts { GLfloat v2[12]; - v2[0] = value[0];v2[1] = value[3];v2[2] = value[6];v2[3] = 0; - v2[4] = value[1];v2[5] = value[4];v2[6] = value[7];v2[7] = 0; - v2[8] = value[2];v2[9] = value[5];v2[10] = value[8];v2[11] = 0; + v2[0] = value[0]; + v2[1] = value[3]; + v2[2] = value[6]; + v2[3] = 0; + v2[4] = value[1]; + v2[5] = value[4]; + v2[6] = value[7]; + v2[7] = 0; + v2[8] = value[2]; + v2[9] = value[5]; + v2[10] = value[8]; + v2[11] = 0; GCM_FUNC( cellGcmSetVertexProgramParameterBlock, parameterResource->resource, 3, v2 ); } break; From 29f0fd27bf0c679b4e1783128b775899ea44816c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jul 2013 02:51:47 +0200 Subject: [PATCH 22/23] (RGL PS3) Speedhacked render path for rglGcmSetDrawArrays --- ps3/rgl/src/ps3/include/rgl-inline.h | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index 63ac4228c5..d7479fd8bc 100644 --- a/ps3/rgl/src/ps3/include/rgl-inline.h +++ b/ps3/rgl/src/ps3/include/rgl-inline.h @@ -336,7 +336,7 @@ static inline void rglGcmSetFragmentProgramLoad(struct CellGcmContextData *thisC (thisContext->current) += 2; } -static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, uint8_t mode, +static void rglGcmSetDrawArraysSlow(struct CellGcmContextData *thisContext, uint8_t mode, uint32_t first, uint32_t count) { uint32_t lcount; @@ -396,6 +396,34 @@ static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, u (thisContext->current) += 2; } +static inline void rglGcmSetDrawArrays(struct CellGcmContextData *thisContext, uint8_t mode, + uint32_t first, uint32_t count) +{ + if (mode == GL_TRIANGLE_STRIP && first == 0 && count == 4) + { + (thisContext->current)[0] = (((3) << (18)) | CELL_GCM_NV4097_INVALIDATE_VERTEX_FILE | (0x40000000)); + (thisContext->current)[1] = 0; + (thisContext->current)[2] = 0; + (thisContext->current)[3] = 0; + (thisContext->current) += 4; + + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_BEGIN_END); + (thisContext->current)[1] = ((mode)); + (thisContext->current) += 2; + + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_DRAW_ARRAYS); + (thisContext->current)[1] = ((first) | (3 <<24)); + (thisContext->current) += 2; + first += 4; + + (thisContext->current)[0] = (((1) << (18)) | CELL_GCM_NV4097_SET_BEGIN_END); + (thisContext->current)[1] = (0); + (thisContext->current) += 2; + } + else + rglGcmSetDrawArraysSlow(thisContext, mode, first, count); +} + static inline void rglGcmSetVertexProgramLoad(struct CellGcmContextData *thisContext, const CellCgbVertexProgramConfiguration *conf, const void *ucode) { const uint32_t *rawData; From 52a160a74448d3e0be92647476aacf4a21471ed3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 28 Jul 2013 04:51:55 +0200 Subject: [PATCH 23/23] (RMenu) Cleanups in select_file --- frontend/menu/rmenu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/frontend/menu/rmenu.c b/frontend/menu/rmenu.c index 289adde983..691232bad3 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -559,20 +559,14 @@ static int select_file(void *data, uint64_t input) driver.video_poke->set_texture_frame(driver.video_data, menu_texture->pixels, true, menu_texture->width, menu_texture->height, 1.0f); break; - } - - if (rgui->menu_type == LIBRETRO_CHOICE) - { - strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); - g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); - return -1; + case LIBRETRO_CHOICE: + strlcpy(g_settings.libretro, path, sizeof(g_settings.libretro)); + g_extern.lifecycle_mode_state |= (1ULL << MODE_EXITSPAWN); + return -1; } pop_menu_stack = true; } - - if (!ret) - msg_queue_push(g_extern.msg_queue, "INFO - You need to restart RetroArch.", 1, 180); } else if ((input & (1ULL << DEVICE_NAV_X)) || (input & (1ULL << DEVICE_NAV_MENU))) pop_menu_stack = true;