diff --git a/Common/MemArena.cpp b/Common/MemArena.cpp index b8191b0808..c88f764989 100644 --- a/Common/MemArena.cpp +++ b/Common/MemArena.cpp @@ -351,7 +351,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena if (!Memory_TryBase(base, views, num_views, flags, arena)) { PanicAlert("MemoryMap_Setup: Failed finding a memory base."); - exit(0); return 0; } #else @@ -377,7 +376,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena if (!Memory_TryBase(arena->memmap->Base(), views, num_views, flags, arena)) { PanicAlert("MemoryMap_Setup: Failed finding a memory base."); - exit(0); return 0; } u8* base = arena->memmap->Base(); @@ -387,7 +385,6 @@ u8 *MemoryMap_Setup(const MemoryView *views, int num_views, u32 flags, MemArena if (!Memory_TryBase(base, views, num_views, flags, arena)) { PanicAlert("MemoryMap_Setup: Failed finding a memory base."); - exit(0); return 0; } #endif diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 6cb25ff24a..ed5a4a945b 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -133,6 +133,16 @@ void CenterRect(float *x, float *y, float *w, float *h, } } +void FramebufferManager::CompileDraw2DProgram() { + if (!draw2dprogram) { + draw2dprogram = glsl_create_source(basic_vs, tex_fs); + + glsl_bind(draw2dprogram); + glUniform1i(draw2dprogram->sampler0, 0); + glsl_unbind(); + } +} + FramebufferManager::FramebufferManager() : ramDisplayFramebufPtr_(0), displayFramebufPtr_(0), @@ -145,18 +155,15 @@ FramebufferManager::FramebufferManager() : currentRenderVfb_(0), drawPixelsTex_(0), drawPixelsTexFormat_(-1), - convBuf(0) + convBuf(0), + draw2dprogram(0) #ifndef USING_GLES2 , pixelBufObj_(0), currentPBO_(0) #endif { - draw2dprogram = glsl_create_source(basic_vs, tex_fs); - - glsl_bind(draw2dprogram); - glUniform1i(draw2dprogram->sampler0, 0); - glsl_unbind(); + CompileDraw2DProgram(); // And an initial clear. We don't clear per frame as the games are supposed to handle that // by themselves. @@ -197,7 +204,9 @@ FramebufferManager::FramebufferManager() : FramebufferManager::~FramebufferManager() { if (drawPixelsTex_) glDeleteTextures(1, &drawPixelsTex_); - glsl_destroy(draw2dprogram); + if (draw2dprogram) { + glsl_destroy(draw2dprogram); + } #ifndef USING_GLES2 delete [] pixelBufObj_; @@ -316,8 +325,9 @@ void FramebufferManager::DrawActiveTexture(float x, float y, float w, float h, b const float pos[12] = {x,y,0, x+w,y,0, x+w,y+h,0, x,y+h,0}; const float texCoords[8] = {0,v1, u2,v1, u2,v2, 0,v2}; const GLubyte indices[4] = {0,1,3,2}; - + if(!program) { + CompileDraw2DProgram(); program = draw2dprogram; } @@ -824,6 +834,8 @@ void FramebufferManager::BlitFramebuffer_(VirtualFramebuffer *src, VirtualFrameb float x, y, w, h; CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); + CompileDraw2DProgram(); + DrawActiveTexture(x, y, w, h, flip, upscale, vscale, draw2dprogram); glBindTexture(GL_TEXTURE_2D, 0); @@ -1081,6 +1093,8 @@ void FramebufferManager::EndFrame() { void FramebufferManager::DeviceLost() { DestroyAllFBOs(); + glsl_destroy(draw2dprogram); + draw2dprogram = 0; resized_ = false; } diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index e40dce4373..87203c761a 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -152,6 +152,8 @@ public: void DestroyFramebuf(VirtualFramebuffer *vfb); private: + void CompileDraw2DProgram(); + u32 ramDisplayFramebufPtr_; // workaround for MotoGP insanity u32 displayFramebufPtr_; u32 displayStride_; diff --git a/GPU/GLES/ShaderManager.cpp b/GPU/GLES/ShaderManager.cpp index 32540a2d98..4c5c625947 100644 --- a/GPU/GLES/ShaderManager.cpp +++ b/GPU/GLES/ShaderManager.cpp @@ -460,6 +460,8 @@ void ShaderManager::Clear() { fsCache.clear(); vsCache.clear(); globalDirty = 0xFFFFFFFF; + lastFSID.clear(); + lastVSID.clear(); DirtyShader(); } @@ -473,6 +475,8 @@ void ShaderManager::DirtyShader() { lastFSID.clear(); lastVSID.clear(); lastShader = 0; + globalDirty = 0xFFFFFFFF; + shaderSwitchDirty = 0; } void ShaderManager::EndFrame() { // disables vertex arrays diff --git a/UI/EmuScreen.cpp b/UI/EmuScreen.cpp index 02f4a498de..60266feef1 100644 --- a/UI/EmuScreen.cpp +++ b/UI/EmuScreen.cpp @@ -348,6 +348,12 @@ static const struct { int from, to; } legacy_touch_mapping[12] = { }; void EmuScreen::update(InputState &input) { + // Simply forcibily update to the current screen size every frame. Doesn't cost much. + PSP_CoreParameter().outputWidth = dp_xres; + PSP_CoreParameter().outputHeight = dp_yres; + PSP_CoreParameter().pixelWidth = pixel_xres; + PSP_CoreParameter().pixelHeight = pixel_yres; + globalUIState = UISTATE_INGAME; if (errorMessage_.size()) { screenManager()->push(new PromptScreen( diff --git a/UI/GamepadEmu.cpp b/UI/GamepadEmu.cpp index a8037c8450..c898950efe 100644 --- a/UI/GamepadEmu.cpp +++ b/UI/GamepadEmu.cpp @@ -90,8 +90,7 @@ void LayoutGamepad(int w, int h) leftStick.setPos(stickX, stickY, controlScale); } -void UpdateGamepad(InputState &input_state) -{ +void UpdateGamepad(InputState &input_state) { LayoutGamepad(dp_xres, dp_yres); buttonO.update(input_state); @@ -119,8 +118,7 @@ void UpdateGamepad(InputState &input_state) leftStick.update(input_state); } -void DrawGamepad(DrawBuffer &db, float opacity) -{ +void DrawGamepad(DrawBuffer &db, float opacity) { uint32_t color = colorAlpha(0xc0b080, opacity); uint32_t colorOverlay = colorAlpha(0xFFFFFF, opacity); diff --git a/UI/NativeApp.cpp b/UI/NativeApp.cpp index d6d1db815e..ff915e36e9 100644 --- a/UI/NativeApp.cpp +++ b/UI/NativeApp.cpp @@ -367,11 +367,7 @@ void NativeInit(int argc, const char *argv[], SaveState::Load(stateToLoad); g_gameInfoCache.Init(); -} -void NativeInitGraphics() { - gl_lost_manager_init(); - ui_draw2d.SetAtlas(&ui_atlas); screenManager = new ScreenManager(); @@ -388,6 +384,12 @@ void NativeInitGraphics() { // Go directly into the game. screenManager->switchScreen(new EmuScreen(boot_filename)); } +} + +void NativeInitGraphics() { + gl_lost_manager_init(); + ui_draw2d.SetAtlas(&ui_atlas); + UIShader_Init(); @@ -450,6 +452,25 @@ void NativeInitGraphics() { glstate.viewport.set(0, 0, pixel_xres, pixel_yres); } +void NativeShutdownGraphics() { + screenManager->deviceLost(); + + g_gameInfoCache.Clear(); + + delete uiTexture; + uiTexture = NULL; + + delete uiContext; + uiContext = NULL; + + ui_draw2d.Shutdown(); + ui_draw2d_front.Shutdown(); + + UIShader_Shutdown(); + + gl_lost_manager_shutdown(); +} + void TakeScreenshot() { #ifdef _WIN32 g_TakeScreenshot = false; @@ -573,25 +594,12 @@ void NativeMessageReceived(const char *message, const char *value) { } } -void NativeShutdownGraphics() { - g_gameInfoCache.Clear(); - - delete uiTexture; - uiTexture = NULL; +void NativeShutdown() { screenManager->shutdown(); delete screenManager; screenManager = 0; - ui_draw2d.Shutdown(); - ui_draw2d_front.Shutdown(); - - UIShader_Shutdown(); - - gl_lost_manager_shutdown(); -} - -void NativeShutdown() { g_gameInfoCache.Shutdown(); delete host; @@ -604,6 +612,7 @@ void NativeShutdown() { // boot up correctly with "dirty" global variables currently, so we hack around that // by simply exiting. #ifdef ANDROID + ELOG("NativeShutdown called"); exit(0); #endif } diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index e7c0e67285..5bbd391093 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -29,8 +29,7 @@ android:name=".PpssppActivity" android:label="@string/app_name" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" - android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode" - android:screenOrientation="landscape" > + android:configChanges="orientation|locale|keyboard|keyboardHidden|navigation|fontScale|uiMode"> diff --git a/android/jni/Android.mk b/android/jni/Android.mk index 1e47bb3832..f40d2d0572 100644 --- a/android/jni/Android.mk +++ b/android/jni/Android.mk @@ -26,7 +26,7 @@ LOCAL_MODULE := ppsspp_jni NATIVE := ../../native SRC := ../.. -LOCAL_CFLAGS := -DUSE_FFMPEG -DUSE_PROFILER -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O3 -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math +LOCAL_CFLAGS := -DUSE_FFMPEG -DUSE_PROFILER -DGL_GLEXT_PROTOTYPES -DUSING_GLES2 -O0 -g -fsigned-char -Wall -Wno-multichar -Wno-psabi -Wno-unused-variable -fno-strict-aliasing -ffast-math # yes, it's really CPPFLAGS for C++ LOCAL_CPPFLAGS := -std=gnu++11 -fno-rtti LOCAL_C_INCLUDES := \ diff --git a/native b/native index a7b92d63d6..8559d298f8 160000 --- a/native +++ b/native @@ -1 +1 @@ -Subproject commit a7b92d63d6a51f41b3fe8c89fee0bd5f85b8f4a6 +Subproject commit 8559d298f86338c779dee368249edc7087d8dd46