mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Use the app cache directory on Android for the shader cache.
This commit is contained in:
parent
e92beb619c
commit
b39206f922
15 changed files with 47 additions and 32 deletions
|
@ -411,6 +411,7 @@ public:
|
|||
std::string memStickDirectory;
|
||||
std::string flash0Directory;
|
||||
std::string internalDataDirectory;
|
||||
std::string appCacheDirectory;
|
||||
|
||||
// Data for upgrade prompt
|
||||
std::string upgradeMessage; // The actual message from the server is currently not used, need a translation mechanism. So this just acts as a flag.
|
||||
|
|
|
@ -579,6 +579,11 @@ std::string GetSysDirectory(PSPDirectories directoryType) {
|
|||
return g_Config.memStickDirectory + "PSP/PPSSPP_STATE/";
|
||||
case DIRECTORY_CACHE:
|
||||
return g_Config.memStickDirectory + "PSP/SYSTEM/CACHE/";
|
||||
case DIRECTORY_APP_CACHE:
|
||||
if (!g_Config.appCacheDirectory.empty()) {
|
||||
return g_Config.appCacheDirectory;
|
||||
}
|
||||
return g_Config.memStickDirectory + "PSP/SYSTEM/CACHE/";
|
||||
// Just return the memory stick root if we run into some sort of problem.
|
||||
default:
|
||||
ERROR_LOG(FILESYS, "Unknown directory type.");
|
||||
|
|
|
@ -45,6 +45,7 @@ enum PSPDirectories {
|
|||
DIRECTORY_DUMP,
|
||||
DIRECTORY_SAVESTATE,
|
||||
DIRECTORY_CACHE,
|
||||
DIRECTORY_APP_CACHE, // Use the OS app cache if available
|
||||
};
|
||||
|
||||
class GraphicsContext;
|
||||
|
|
|
@ -462,8 +462,8 @@ GLES_GPU::GLES_GPU(GraphicsContext *ctx)
|
|||
// Load shader cache.
|
||||
std::string discID = g_paramSFO.GetValueString("DISC_ID");
|
||||
if (discID.size()) {
|
||||
File::CreateFullPath(GetSysDirectory(DIRECTORY_CACHE));
|
||||
shaderCachePath_ = GetSysDirectory(DIRECTORY_CACHE) + "/" + g_paramSFO.GetValueString("DISC_ID") + ".shadercache";
|
||||
File::CreateFullPath(GetSysDirectory(DIRECTORY_APP_CACHE));
|
||||
shaderCachePath_ = GetSysDirectory(DIRECTORY_APP_CACHE) + "/" + g_paramSFO.GetValueString("DISC_ID") + ".glshadercache";
|
||||
shaderManager_->LoadAndPrecompile(shaderCachePath_);
|
||||
}
|
||||
}
|
||||
|
@ -473,6 +473,9 @@ GLES_GPU::~GLES_GPU() {
|
|||
shaderManager_->ClearCache(true);
|
||||
depalShaderCache_.Clear();
|
||||
fragmentTestCache_.Clear();
|
||||
if (!shaderCachePath_.empty()) {
|
||||
shaderManager_->Save(shaderCachePath_);
|
||||
}
|
||||
delete shaderManager_;
|
||||
shaderManager_ = nullptr;
|
||||
|
||||
|
@ -740,7 +743,7 @@ void GLES_GPU::BeginFrameInternal() {
|
|||
}
|
||||
|
||||
// Save the cache from time to time. TODO: How often?
|
||||
if (shaderCachePath_.size() && (gpuStats.numFlips & 1023) == 0) {
|
||||
if (!shaderCachePath_.empty() && (gpuStats.numFlips & 1023) == 0) {
|
||||
shaderManager_->Save(shaderCachePath_);
|
||||
}
|
||||
|
||||
|
|
|
@ -1022,6 +1022,7 @@ void ShaderManager::LoadAndPrecompile(const std::string &filename) {
|
|||
double end = time_now_d();
|
||||
|
||||
NOTICE_LOG(G3D, "Compiled and linked %d programs (%d vertex, %d fragment) in %0.1f milliseconds", header.numLinkedPrograms, header.numVertexShaders, header.numFragmentShaders, 1000 * (end - start));
|
||||
NOTICE_LOG(G3D, "Loaded the shader cache from '%s'", filename.c_str());
|
||||
diskCacheDirty_ = false;
|
||||
}
|
||||
|
||||
|
@ -1029,6 +1030,10 @@ void ShaderManager::Save(const std::string &filename) {
|
|||
if (!diskCacheDirty_) {
|
||||
return;
|
||||
}
|
||||
if (!linkedShaderCache_.size()) {
|
||||
return;
|
||||
}
|
||||
INFO_LOG(G3D, "Saving the shader cache to '%s'", filename.c_str());
|
||||
FILE *f = File::OpenCFile(filename, "wb");
|
||||
if (!f) {
|
||||
// Can't save, give up for now.
|
||||
|
|
|
@ -286,8 +286,7 @@ bool CheckFontIsUsable(const wchar_t *fontFace) {
|
|||
}
|
||||
#endif
|
||||
|
||||
void NativeInit(int argc, const char *argv[],
|
||||
const char *savegame_directory, const char *external_directory, bool fs) {
|
||||
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs) {
|
||||
#ifdef ANDROID_NDK_PROFILER
|
||||
setenv("CPUPROFILE_FREQUENCY", "500", 1);
|
||||
setenv("CPUPROFILE", "/sdcard/gmon.out", 1);
|
||||
|
@ -299,7 +298,7 @@ void NativeInit(int argc, const char *argv[],
|
|||
|
||||
bool skipLogo = false;
|
||||
setlocale( LC_ALL, "C" );
|
||||
std::string user_data_path = savegame_directory;
|
||||
std::string user_data_path = savegame_dir;
|
||||
pendingMessages.clear();
|
||||
#ifdef IOS
|
||||
user_data_path += "/";
|
||||
|
@ -318,22 +317,22 @@ void NativeInit(int argc, const char *argv[],
|
|||
#else
|
||||
VFSRegister("", new DirectoryAssetReader("assets/"));
|
||||
#endif
|
||||
VFSRegister("", new DirectoryAssetReader(savegame_directory));
|
||||
VFSRegister("", new DirectoryAssetReader(savegame_dir));
|
||||
|
||||
#if defined(MOBILE_DEVICE) || !defined(USING_QT_UI)
|
||||
host = new NativeHost();
|
||||
#endif
|
||||
|
||||
#if defined(ANDROID)
|
||||
g_Config.internalDataDirectory = savegame_directory;
|
||||
g_Config.internalDataDirectory = savegame_dir;
|
||||
// Maybe there should be an option to use internal memory instead, but I think
|
||||
// that for most people, using external memory (SDCard/USB Storage) makes the
|
||||
// most sense.
|
||||
g_Config.memStickDirectory = std::string(external_directory) + "/";
|
||||
g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
|
||||
g_Config.memStickDirectory = std::string(external_dir) + "/";
|
||||
g_Config.flash0Directory = std::string(external_dir) + "/flash0/";
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) || defined(MAEMO) || defined(IOS)
|
||||
g_Config.memStickDirectory = user_data_path;
|
||||
g_Config.flash0Directory = std::string(external_directory) + "/flash0/";
|
||||
g_Config.flash0Directory = std::string(external_dir) + "/flash0/";
|
||||
#elif !defined(_WIN32)
|
||||
std::string config;
|
||||
if (getenv("XDG_CONFIG_HOME") != NULL)
|
||||
|
@ -357,7 +356,7 @@ void NativeInit(int argc, const char *argv[],
|
|||
g_Config.AddSearchPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
|
||||
g_Config.SetDefaultPath(g_Config.memStickDirectory + "PSP/SYSTEM/");
|
||||
g_Config.Load();
|
||||
g_Config.externalDirectory = external_directory;
|
||||
g_Config.externalDirectory = external_dir;
|
||||
#endif
|
||||
|
||||
#ifdef ANDROID
|
||||
|
@ -428,9 +427,9 @@ void NativeInit(int argc, const char *argv[],
|
|||
#ifndef _WIN32
|
||||
if (g_Config.currentDirectory == "") {
|
||||
#if defined(ANDROID)
|
||||
g_Config.currentDirectory = external_directory;
|
||||
g_Config.currentDirectory = external_dir;
|
||||
#elif defined(BLACKBERRY) || defined(__SYMBIAN32__) || defined(MAEMO) || defined(IOS) || defined(_WIN32)
|
||||
g_Config.currentDirectory = savegame_directory;
|
||||
g_Config.currentDirectory = savegame_dir;
|
||||
#else
|
||||
if (getenv("HOME") != NULL)
|
||||
g_Config.currentDirectory = getenv("HOME");
|
||||
|
@ -505,6 +504,11 @@ void NativeInit(int argc, const char *argv[],
|
|||
if (GetGPUBackend() == GPUBackend::OPENGL) {
|
||||
gl_lost_manager_init();
|
||||
}
|
||||
|
||||
if (cache_dir && strlen(cache_dir)) {
|
||||
DiskCachingFileLoaderCache::SetCacheDir(cache_dir);
|
||||
g_Config.appCacheDirectory = cache_dir;
|
||||
}
|
||||
}
|
||||
|
||||
void NativeInitGraphics(GraphicsContext *graphicsContext) {
|
||||
|
@ -732,10 +736,6 @@ void HandleGlobalMessage(const std::string &msg, const std::string &value) {
|
|||
if (msg == "inputDeviceConnected") {
|
||||
KeyMap::NotifyPadConnected(value);
|
||||
}
|
||||
|
||||
if (msg == "cacheDir") {
|
||||
DiskCachingFileLoaderCache::SetCacheDir(value);
|
||||
}
|
||||
}
|
||||
|
||||
void NativeUpdate(InputState &input) {
|
||||
|
|
|
@ -114,7 +114,7 @@ unsigned int WINAPI TheThread(void *)
|
|||
args.push_back(string.c_str());
|
||||
}
|
||||
|
||||
NativeInit(static_cast<int>(args.size()), &args[0], "1234", "1234");
|
||||
NativeInit(static_cast<int>(args.size()), &args[0], "1234", "1234", nullptr);
|
||||
|
||||
Host *nativeHost = host;
|
||||
host = oldHost;
|
||||
|
|
|
@ -275,7 +275,7 @@ extern "C" jstring Java_org_ppsspp_ppsspp_NativeApp_queryConfig
|
|||
|
||||
extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
||||
(JNIEnv *env, jclass, jstring jmodel, jint jdeviceType, jstring jlangRegion, jstring japkpath,
|
||||
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jshortcutParam,
|
||||
jstring jdataDir, jstring jexternalDir, jstring jlibraryDir, jstring jcacheDir, jstring jshortcutParam,
|
||||
jint jAndroidVersion) {
|
||||
jniEnvUI = env;
|
||||
|
||||
|
@ -309,6 +309,7 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
std::string user_data_path = GetJavaString(env, jdataDir) + "/";
|
||||
library_path = GetJavaString(env, jlibraryDir) + "/";
|
||||
std::string shortcut_param = GetJavaString(env, jshortcutParam);
|
||||
std::string cacheDir = GetJavaString(env, jcacheDir);
|
||||
|
||||
ILOG("NativeApp.init(): External storage path: %s", externalDir.c_str());
|
||||
ILOG("NativeApp.init(): Launch shortcut parameter: %s", shortcut_param.c_str());
|
||||
|
@ -328,11 +329,11 @@ extern "C" void Java_org_ppsspp_ppsspp_NativeApp_init
|
|||
|
||||
if (shortcut_param.empty()) {
|
||||
const char *argv[2] = {app_name.c_str(), 0};
|
||||
NativeInit(1, argv, user_data_path.c_str(), externalDir.c_str());
|
||||
NativeInit(1, argv, user_data_path.c_str(), externalDir.c_str(), cacheDir.c_str());
|
||||
}
|
||||
else {
|
||||
const char *argv[3] = {app_name.c_str(), shortcut_param.c_str(), 0};
|
||||
NativeInit(2, argv, user_data_path.c_str(), externalDir.c_str());
|
||||
NativeInit(2, argv, user_data_path.c_str(), externalDir.c_str(), cacheDir.c_str());
|
||||
}
|
||||
|
||||
ILOG("NativeApp.init() -- end");
|
||||
|
|
|
@ -239,14 +239,13 @@ public class NativeActivity extends Activity implements SurfaceHolder.Callback {
|
|||
String externalStorageDir = sdcard.getAbsolutePath();
|
||||
String dataDir = this.getFilesDir().getAbsolutePath();
|
||||
String apkFilePath = appInfo.sourceDir;
|
||||
String cacheDir = getCacheDir().getAbsolutePath();
|
||||
|
||||
String model = Build.MANUFACTURER + ":" + Build.MODEL;
|
||||
String languageRegion = Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry();
|
||||
|
||||
NativeApp.audioConfig(optimalFramesPerBuffer, optimalSampleRate);
|
||||
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, shortcutParam, Build.VERSION.SDK_INT);
|
||||
|
||||
NativeApp.sendMessage("cacheDir", getCacheDir().getAbsolutePath());
|
||||
NativeApp.init(model, deviceType, languageRegion, apkFilePath, dataDir, externalStorageDir, libraryDir, cacheDir, shortcutParam, Build.VERSION.SDK_INT);
|
||||
|
||||
sendInitialGrants();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ public class NativeApp {
|
|||
public final static int DEVICE_TYPE_TV = 1;
|
||||
public final static int DEVICE_TYPE_DESKTOP = 2;
|
||||
|
||||
public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String shortcutParam, int androidVersion);
|
||||
public static native void init(String model, int deviceType, String languageRegion, String apkPath, String dataDir, String externalDir, String libraryDir, String cacheDir, String shortcutParam, int androidVersion);
|
||||
|
||||
public static native void audioInit();
|
||||
public static native void audioShutdown();
|
||||
|
|
|
@ -266,7 +266,7 @@ void BlackberryMain::startMain(int argc, char *argv[]) {
|
|||
navigator_request_events(0);
|
||||
dialog_request_events(0);
|
||||
vibration_request_events(0);
|
||||
NativeInit(argc, (const char **)argv, "/accounts/1000/shared/misc/", "app/native/assets/");
|
||||
NativeInit(argc, (const char **)argv, "/accounts/1000/shared/misc/", "app/native/assets/", nullptr);
|
||||
graphicsContext = new GLDummyGraphicsContext();
|
||||
NativeInitGraphics(graphicsContext);
|
||||
audio = new BlackberryAudio();
|
||||
|
|
|
@ -46,7 +46,7 @@ bool NativeIsAtTopLevel();
|
|||
// The very first function to be called after NativeGetAppInfo. Even NativeMix is not called
|
||||
// before this, although it may be called at any point in time afterwards (on any thread!)
|
||||
// This functions must NOT call OpenGL. Main thread.
|
||||
void NativeInit(int argc, const char *argv[], const char *savegame_directory, const char *external_directory, bool fs=false);
|
||||
void NativeInit(int argc, const char *argv[], const char *savegame_dir, const char *external_dir, const char *cache_dir, bool fs=false);
|
||||
|
||||
// Runs after NativeInit() at some point. May (and probably should) call OpenGL.
|
||||
// Should not initialize anything screen-size-dependent - do that in NativeResized.
|
||||
|
|
|
@ -616,9 +616,9 @@ int main(int argc, char *argv[]) {
|
|||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
NativeInit(argc, (const char **)argv, path, "D:\\");
|
||||
NativeInit(argc, (const char **)argv, path, "D:\\", nullptr);
|
||||
#else
|
||||
NativeInit(argc, (const char **)argv, path, "/tmp");
|
||||
NativeInit(argc, (const char **)argv, path, "/tmp", nullptr);
|
||||
#endif
|
||||
|
||||
pixel_in_dps = (float)pixel_xres / dp_xres;
|
||||
|
|
|
@ -241,7 +241,7 @@ int main(int argc, char *argv[])
|
|||
if (!strcmp(argv[i],"--fullscreen"))
|
||||
fullscreenCLI=true;
|
||||
}
|
||||
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), assets_dir.c_str(), fullscreenCLI);
|
||||
NativeInit(argc, (const char **)argv, savegame_dir.c_str(), assets_dir.c_str(), nullptr, fullscreenCLI);
|
||||
|
||||
int ret = mainInternal(a);
|
||||
|
||||
|
|
|
@ -120,7 +120,7 @@ static GraphicsContext *graphicsContext;
|
|||
}
|
||||
}
|
||||
|
||||
NativeInit(0, NULL, [self.documentsPath UTF8String], [self.bundlePath UTF8String]);
|
||||
NativeInit(0, NULL, [self.documentsPath UTF8String], [self.bundlePath UTF8String], NULL);
|
||||
|
||||
iCadeToKeyMap[iCadeJoystickUp] = NKCODE_DPAD_UP;
|
||||
iCadeToKeyMap[iCadeJoystickRight] = NKCODE_DPAD_RIGHT;
|
||||
|
|
Loading…
Add table
Reference in a new issue