diff --git a/Core/Config.cpp b/Core/Config.cpp index d0a0fcba8d..6b8cbfce39 100644 --- a/Core/Config.cpp +++ b/Core/Config.cpp @@ -65,7 +65,7 @@ void CConfig::Load(const char *iniFileName) graphics->Get("BufferedRendering", &bBufferedRendering, true); graphics->Get("HardwareTransform", &bHardwareTransform, true); graphics->Get("LinearFiltering", &bLinearFiltering, false); - graphics->Get("SSAA", &SSAntiAlaising, 0); + graphics->Get("SSAA", &SSAntiAliasing, 0); graphics->Get("VBO", &bUseVBO, false); graphics->Get("DisableG3DLog", &bDisableG3DLog, false); graphics->Get("VertexCache", &bVertexCache, true); @@ -118,7 +118,7 @@ void CConfig::Save() graphics->Set("BufferedRendering", bBufferedRendering); graphics->Set("HardwareTransform", bHardwareTransform); graphics->Set("LinearFiltering", bLinearFiltering); - graphics->Set("SSAA", SSAntiAlaising); + graphics->Set("SSAA", SSAntiAliasing); graphics->Set("VBO", bUseVBO); graphics->Set("DisableG3DLog", bDisableG3DLog); graphics->Set("VertexCache", bVertexCache); diff --git a/Core/Config.h b/Core/Config.h index b9bf04ac5e..7103f0073f 100644 --- a/Core/Config.h +++ b/Core/Config.h @@ -55,7 +55,7 @@ public: bool bLinearFiltering; bool bUseVBO; int iWindowZoom; // for Windows - bool SSAntiAlaising; //for Windows, too + bool SSAntiAliasing; //for Windows, too bool bDisableG3DLog; bool bVertexCache; diff --git a/Core/HLE/sceAudio.h b/Core/HLE/sceAudio.h index 54cc830af1..7bea235cdc 100644 --- a/Core/HLE/sceAudio.h +++ b/Core/HLE/sceAudio.h @@ -61,7 +61,7 @@ struct AudioChannel // We copy samples as they are written into this simple ring buffer. // Might try something more efficient later. - FixedSizeQueue sampleQueue; + FixedSizeQueue sampleQueue; void DoState(PointerWrap &p) { p.Do(reserved); diff --git a/GPU/GLES/DisplayListInterpreter.cpp b/GPU/GLES/DisplayListInterpreter.cpp index 54034325bb..477a7e8e24 100644 --- a/GPU/GLES/DisplayListInterpreter.cpp +++ b/GPU/GLES/DisplayListInterpreter.cpp @@ -169,10 +169,9 @@ GLES_GPU::GLES_GPU(int renderWidth, int renderHeight) prevDisplayFramebuf_(0), prevPrevDisplayFramebuf_(0), renderWidth_(renderWidth), - renderHeight_(renderHeight) + renderHeight_(renderHeight), + resized_(false) { - renderWidthFactor_ = (float)renderWidth / 480.0f; - renderHeightFactor_ = (float)renderHeight / 272.0f; shaderManager_ = new ShaderManager(); transformDraw_.SetShaderManager(shaderManager_); TextureCache_Init(); @@ -306,6 +305,12 @@ void GLES_GPU::CopyDisplayToOutput() { shaderManager_->DirtyUniform(DIRTY_ALL); gstate_c.textureChanged = true; + if (resized_) { + DestroyAllFBOs(); + glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); + resized_ = false; + } + BeginDebugDraw(); } @@ -412,13 +417,15 @@ void GLES_GPU::SetRenderFrameBuffer() { //#ifdef ANDROID // vfb->colorDepth = FBO_8888; //#endif - vfb->fbo = fbo_create(vfb->width * renderWidthFactor_, vfb->height * renderHeightFactor_, 1, true, vfb->colorDepth); + float renderWidthFactor = (float)PSP_CoreParameter().renderWidth / 480.0f; + float renderHeightFactor = (float)PSP_CoreParameter().renderHeight / 272.0f; + vfb->fbo = fbo_create(vfb->width * renderWidthFactor, vfb->height * renderHeightFactor, 1, true, vfb->colorDepth); vfb->last_frame_used = gpuStats.numFrames; vfbs_.push_back(vfb); fbo_bind_as_render_target(vfb->fbo); glEnable(GL_DITHER); - glstate.viewport.set(0, 0, renderWidth_, renderHeight_); + glstate.viewport.set(0, 0, PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); currentRenderVfb_ = vfb; glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); INFO_LOG(HLE, "Creating FBO for %08x : %i x %i x %i", vfb->fb_address, vfb->width, vfb->height, vfb->format); @@ -439,7 +446,7 @@ void GLES_GPU::SetRenderFrameBuffer() { // the first time the buffer is bound on this frame. // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); #endif - glstate.viewport.set(0, 0, renderWidth_, renderHeight_); + glstate.viewport.set(0, 0, PSP_CoreParameter().renderWidth, PSP_CoreParameter().renderHeight); currentRenderVfb_ = vfb; vfb->last_frame_used = gpuStats.numFrames; } @@ -1243,17 +1250,25 @@ void GLES_GPU::Flush() { transformDraw_.Flush(); } -void GLES_GPU::DoState(PointerWrap &p) { - GPUCommon::DoState(p); - - TextureCache_Clear(true); - - gstate_c.textureChanged = true; +void GLES_GPU::DestroyAllFBOs() { for (auto iter = vfbs_.begin(); iter != vfbs_.end(); ++iter) { VirtualFramebuffer *v = *iter; fbo_destroy(v->fbo); delete v; } vfbs_.clear(); +} + +void GLES_GPU::Resized() { + resized_ = true; +} + +void GLES_GPU::DoState(PointerWrap &p) { + GPUCommon::DoState(p); + + TextureCache_Clear(true); + + gstate_c.textureChanged = true; + DestroyAllFBOs(); shaderManager_->ClearCache(true); } diff --git a/GPU/GLES/DisplayListInterpreter.h b/GPU/GLES/DisplayListInterpreter.h index e00c692db1..22d6c90772 100644 --- a/GPU/GLES/DisplayListInterpreter.h +++ b/GPU/GLES/DisplayListInterpreter.h @@ -56,6 +56,9 @@ public: virtual void Flush(); virtual void DoState(PointerWrap &p); + // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. + virtual void Resized(); + private: void DoBlockTransfer(); @@ -65,12 +68,14 @@ private: // Deletes old FBOs. void DecimateFBOs(); + void DestroyAllFBOs(); FramebufferManager framebufferManager; TransformDrawEngine transformDraw_; ShaderManager *shaderManager_; u8 *flushBeforeCommand_; bool interruptsEnabled_; + bool resized_; u32 displayFramebufPtr_; u32 displayStride_; @@ -79,9 +84,6 @@ private: int renderWidth_; int renderHeight_; - float renderWidthFactor_; - float renderHeightFactor_; - struct CmdProcessorState { u32 pc; u32 stallAddr; diff --git a/GPU/GPUInterface.h b/GPU/GPUInterface.h index e5f507326a..ee5f4bdb6d 100644 --- a/GPU/GPUInterface.h +++ b/GPU/GPUInterface.h @@ -80,6 +80,9 @@ public: virtual void Flush() = 0; virtual void DoState(PointerWrap &p) = 0; + // Called by the window system if the window size changed. This will be reflected in PSPCoreParam.pixel*. + virtual void Resized() = 0; + // Debugging virtual void DumpNextFrame() = 0; }; diff --git a/GPU/Null/NullGpu.h b/GPU/Null/NullGpu.h index 3c22cdcb00..0b50aa83a2 100644 --- a/GPU/Null/NullGpu.h +++ b/GPU/Null/NullGpu.h @@ -45,6 +45,8 @@ public: virtual void DeviceLost() {} virtual void DumpNextFrame() {} + virtual void Resized() {} + private: bool interruptsEnabled_; }; diff --git a/Windows/EmuThread.cpp b/Windows/EmuThread.cpp index 9d629d6220..cd38e3ead5 100644 --- a/Windows/EmuThread.cpp +++ b/Windows/EmuThread.cpp @@ -72,8 +72,8 @@ DWORD TheThread(LPVOID x) coreParameter.enableDebugging = true; coreParameter.printfEmuLog = false; coreParameter.headLess = false; - coreParameter.renderWidth = (480 * g_Config.iWindowZoom) * (g_Config.SSAntiAlaising + 1); - coreParameter.renderHeight = (272 * g_Config.iWindowZoom) * (g_Config.SSAntiAlaising + 1); + coreParameter.renderWidth = (480 * g_Config.iWindowZoom) * (g_Config.SSAntiAliasing + 1); + coreParameter.renderHeight = (272 * g_Config.iWindowZoom) * (g_Config.SSAntiAliasing + 1); coreParameter.outputWidth = 480 * g_Config.iWindowZoom; coreParameter.outputHeight = 272 * g_Config.iWindowZoom; coreParameter.pixelWidth = 480 * g_Config.iWindowZoom; diff --git a/Windows/OpenGLBase.cpp b/Windows/OpenGLBase.cpp index d4401716b1..f739dcab1e 100644 --- a/Windows/OpenGLBase.cpp +++ b/Windows/OpenGLBase.cpp @@ -47,11 +47,6 @@ void GL_Resized() // Resize And Initialize The GL Window } glstate.viewport.set(0, 0, xres, yres); glstate.viewport.restore(); - glMatrixMode(GL_PROJECTION); // Select The Projection Matrix - glLoadIdentity(); // Reset The Projection Matrix - glOrtho(0.0f,xres,yres,0.0f,-1.0f,1.0f); // Create Ortho 640x480 View (0,0 At Top Left) - glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix - glLoadIdentity(); // Reset The Modelview Matrix } diff --git a/Windows/WndMainWindow.cpp b/Windows/WndMainWindow.cpp index 57cbde6e43..b5bd9615f1 100644 --- a/Windows/WndMainWindow.cpp +++ b/Windows/WndMainWindow.cpp @@ -124,7 +124,17 @@ namespace MainWindow MoveWindow(hwndDisplay, 0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight, TRUE); PSP_CoreParameter().pixelWidth = rc.right - rc.left; PSP_CoreParameter().pixelHeight = rc.bottom - rc.top; - GL_Resized(); + + // round up to a zoom factor for the render size. + int zoom = (rc.right - rc.left + 479) / 480; + if (g_Config.SSAntiAliasing) zoom *= 2; + PSP_CoreParameter().renderWidth = 480 * zoom; + PSP_CoreParameter().renderHeight = 272 * zoom; + PSP_CoreParameter().outputWidth = 480 * zoom; + PSP_CoreParameter().outputHeight = 272 * zoom; + + if (gpu) + gpu->Resized(); } void SetZoom(float zoom) { @@ -259,6 +269,11 @@ namespace MainWindow break; case WM_MOVE: + ResizeDisplay(); + break; + + case WM_SIZE: + ResizeDisplay(); break; case WM_COMMAND: @@ -511,7 +526,7 @@ namespace MainWindow UpdateMenus(); break; case ID_OPTIONS_SIMPLE2XSSAA: - g_Config.SSAntiAlaising = !g_Config.SSAntiAlaising; + g_Config.SSAntiAliasing = !g_Config.SSAntiAliasing; UpdateMenus(); break; case ID_OPTIONS_DISABLEG3DLOG: @@ -615,11 +630,6 @@ namespace MainWindow case WM_DESTROY: PostQuitMessage(0); break; - case WM_SIZE: - { - ResizeDisplay(); - } - break; case WM_NCHITTEST: if (skinMode) return HTCAPTION; @@ -668,7 +678,7 @@ namespace MainWindow CHECKITEM(ID_OPTIONS_HARDWARETRANSFORM, g_Config.bHardwareTransform); CHECKITEM(ID_OPTIONS_FASTMEMORY, g_Config.bFastMemory); CHECKITEM(ID_OPTIONS_LINEARFILTERING, g_Config.bLinearFiltering); - CHECKITEM(ID_OPTIONS_SIMPLE2XSSAA, g_Config.SSAntiAlaising); + CHECKITEM(ID_OPTIONS_SIMPLE2XSSAA, g_Config.SSAntiAliasing); CHECKITEM(ID_EMULATION_RUNONLOAD, g_Config.bAutoRun); CHECKITEM(ID_OPTIONS_USEVBO, g_Config.bUseVBO); CHECKITEM(ID_OPTIONS_DISABLEG3DLOG, g_Config.bDisableG3DLog);