diff --git a/Makefile b/Makefile index 68dc35d960..a8df28df7d 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.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 diff --git a/Makefile.win b/Makefile.win index d1f89d1ad3..31da5b1276 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 eb2ddd39bc..b3dc3d6239 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -18,18 +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 -#elif 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 @@ -79,64 +69,38 @@ 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 - -static void system_preinit(void) +void rarch_make_dir(const char *x, const char *name) { -#if defined(__QNX__) && !defined(HAVE_BB10) - //Initialize BPS libraries - bps_initialize(); -#elif defined(RARCH_CONSOLE) - if (frontend_ctx->init) - frontend_ctx->init(); -#endif + 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->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(); @@ -176,91 +140,19 @@ static void rarch_get_environment(int argc, char *argv[]) #endif } -static void system_shutdown(void) -{ -#if defined(__QNX__) - bps_shutdown(); -#elif defined(__APPLE__) - dispatch_async_f(dispatch_get_main_queue(), 0, apple_rarch_exited); -#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; - -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[]) #endif { - if (system_ctx_init() != 0) - return 0; + frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first(); - system_preinit(); + 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__) @@ -282,18 +174,12 @@ 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(); -#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; @@ -322,11 +208,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 } @@ -337,16 +221,14 @@ 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()) { -#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; @@ -364,9 +246,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; @@ -419,7 +300,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) @@ -427,19 +307,18 @@ 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(); -#ifdef __QNX__ - bps_shutdown(); -#endif - system_shutdown(); + if (frontend_ctx && frontend_ctx->shutdown) + frontend_ctx->shutdown(false); return 0; } diff --git a/frontend/frontend_context.c b/frontend/frontend_context.c index 9b766a9cae..24fa1dd161 100644 --- a/frontend/frontend_context.c +++ b/frontend/frontend_context.c @@ -30,6 +30,12 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(GEKKO) &frontend_ctx_gx, #endif +#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 c4b5ab720e..d9d290de59 100644 --- a/frontend/frontend_context.h +++ b/frontend/frontend_context.h @@ -32,14 +32,16 @@ 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); void (*exitspawn)(void); int (*process_args)(int argc, char *argv[]); + int (*process_events)(void); void (*exec)(const char *, bool); + void (*shutdown)(bool); // Human readable string. const char *ident; @@ -48,8 +50,14 @@ 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; +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. +#ifdef RARCH_CONSOLE +extern void rarch_make_dir(const char *x, const char *name); +#endif + #endif 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 5436468499..691232bad3 100644 --- a/frontend/menu/rmenu.c +++ b/frontend/menu/rmenu.c @@ -559,21 +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_EXIT); - 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; @@ -743,7 +736,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 +790,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; } @@ -847,7 +840,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 +855,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 +871,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(); @@ -1455,7 +1444,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; @@ -1466,7 +1454,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; } @@ -2898,10 +2885,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_apple.c b/frontend/platform/platform_apple.c new file mode 100644 index 0000000000..d3f1381c6c --- /dev/null +++ b/frontend/platform/platform_apple.c @@ -0,0 +1,107 @@ +/* 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); +} + +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 = { + environment_get, /* environment_get */ + NULL, /* init */ + NULL, /* deinit */ + NULL, /* exitspawn */ + NULL, /* process_args */ + process_events, /* process_events */ + NULL, /* exec */ + system_shutdown, /* shutdown */ + "apple", +}; diff --git a/frontend/platform/platform_gx.c b/frontend/platform/platform_gx.c index 9e39b9aee3..25a2454092 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); @@ -308,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 } @@ -444,11 +454,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 +519,17 @@ 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 */ + NULL, /* process_events */ + system_exec, /* exec */ + NULL, /* shutdown */ "gx", }; diff --git a/frontend/platform/platform_ps3.c b/frontend/platform/platform_ps3.c index 636f777d7b..d7e28c6991 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) { @@ -152,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: @@ -281,6 +276,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) @@ -437,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; @@ -469,11 +473,13 @@ 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 */ + NULL, /* process_events */ + system_exec, /* exec */ + NULL, /* shutdown */ "ps3", }; diff --git a/frontend/platform/platform_psp.c b/frontend/platform/platform_psp.c index 071ccc1c90..aa2b04c10c 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,28 +105,19 @@ 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(); } -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, +const frontend_ctx_driver_t frontend_ctx_psp = { + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + 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 new file mode 100644 index 0000000000..b83f4e30cf --- /dev/null +++ b/frontend/platform/platform_qnx.c @@ -0,0 +1,60 @@ +/* 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_qnx = { + get_environment_settings, /* get_environment_settings */ + system_init, /* init */ + 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 a6c53cf282..3f9ce746f4 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) @@ -299,18 +307,18 @@ static int system_process_args(int argc, char *argv[]) return 0; } -static void system_deinit(void) {} +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 } @@ -351,11 +359,13 @@ 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 */ + NULL, /* process_events */ + system_exec, /* exec */ + NULL, /* shutdown */ "xdk", }; diff --git a/general.h b/general.h index 552399d7fe..976cd0bd28 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, @@ -118,7 +117,6 @@ enum menu_enums MODE_INFO_DRAW, MODE_FPS_DRAW, MODE_EXTLAUNCH_MULTIMAN, - MODE_EXIT, MODE_EXITSPAWN, MODE_EXITSPAWN_START_GAME, MODE_EXITSPAWN_MULTIMAN, @@ -128,9 +126,7 @@ 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_DRAW, MODE_OSK_ENTRY_SUCCESS, MODE_OSK_ENTRY_FAIL, }; diff --git a/griffin/griffin.c b/griffin/griffin.c index 4f1c02d41e..ec79f8088b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -216,10 +216,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 @@ -462,6 +460,10 @@ 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" +#elif defined(OSX) || defined(IOS) +#include "../frontend/platform/platform_apple.c" #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) { 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"/> + + + + + + + + + + + + + + + + + + + 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 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; diff --git a/ps3/rgl/src/ps3/include/rgl-inline.h b/ps3/rgl/src/ps3/include/rgl-inline.h index cfa65241af..d7479fd8bc 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,50 +74,50 @@ 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))); \ + (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)) | ((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; \ 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; @@ -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,22 +195,22 @@ 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; #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; #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; @@ -295,13 +295,13 @@ 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; 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; @@ -312,10 +312,10 @@ 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)); + (thisContext->current)[0] = (((1) << (18)) | (CELL_GCM_NV4097_SET_TEX_COORD_CONTROL + (i) * 4)); (thisContext->current)[1] = (hwTexCtrl); (thisContext->current) += 2; } @@ -331,12 +331,12 @@ 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; } -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; @@ -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; } +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; @@ -410,7 +438,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 +447,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 +458,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 +551,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 +602,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 +623,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); @@ -785,9 +813,9 @@ static inline void rglGcmTransferData GLuint dstOffset = gmmIdToOffset(dstId) + dstIdOffset; GLuint srcOffset = gmmIdToOffset(srcId) + srcIdOffset; - (thisContext->current)[0] = (((2) << (18)) | ((0x00002184))); - (thisContext->current)[1] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ - (thisContext->current)[2] = 0xFEED0000; /* CELL_GCM_TRANSFER_LOCAL_TO_LOCAL */ + (thisContext->current)[0] = (((2) << (18)) | CELL_GCM_NV0039_SET_CONTEXT_DMA_BUFFER_IN); + (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; @@ -811,7 +839,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 +865,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 +882,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..d8b3e9236f 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; @@ -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; diff --git a/retroarch.c b/retroarch.c index 84b9e17120..147da9aeb5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -3020,17 +3020,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. 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 -};