diff --git a/GPU/Common/FramebufferCommon.cpp b/GPU/Common/FramebufferCommon.cpp index 057c71755a..1df364ff2e 100644 --- a/GPU/Common/FramebufferCommon.cpp +++ b/GPU/Common/FramebufferCommon.cpp @@ -26,11 +26,11 @@ #include "GPU/GPUInterface.h" #include "GPU/GPUState.h" -void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH) { +void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation) { float outW; float outH; - bool rotated = g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL || g_Config.iInternalScreenRotation == ROTATION_LOCKED_VERTICAL180; + bool rotated = rotation == ROTATION_LOCKED_VERTICAL || rotation == ROTATION_LOCKED_VERTICAL180; if (g_Config.bStretchToDisplay) { outW = frameW; diff --git a/GPU/Common/FramebufferCommon.h b/GPU/Common/FramebufferCommon.h index c5e5810055..c42d11fc09 100644 --- a/GPU/Common/FramebufferCommon.h +++ b/GPU/Common/FramebufferCommon.h @@ -237,4 +237,4 @@ protected: }; }; -void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH); +void CenterRect(float *x, float *y, float *w, float *h, float origW, float origH, float frameW, float frameH, int rotation); diff --git a/GPU/Directx9/FramebufferDX9.cpp b/GPU/Directx9/FramebufferDX9.cpp index fce45ec938..2ba9e138cb 100644 --- a/GPU/Directx9/FramebufferDX9.cpp +++ b/GPU/Directx9/FramebufferDX9.cpp @@ -200,8 +200,9 @@ namespace DX9 { // Should try to unify this path with the regular path somehow, but this simple solution works for most of the post shaders // (it always runs at output resolution so FXAA may look odd). float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); - DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.0f, g_Config.iInternalScreenRotation); + int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation); + DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.0f, uvRotation); } void FramebufferManagerDX9::DrawActiveTexture(LPDIRECT3DTEXTURE9 tex, float x, float y, float w, float h, float destW, float destH, bool flip, float u0, float v0, float u1, float v1, int uvRotation) { @@ -741,7 +742,8 @@ namespace DX9 { // Output coordinates float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); + int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation); const float u0 = offsetX / (float)vfb->bufferWidth; const float v0 = offsetY / (float)vfb->bufferHeight; @@ -767,7 +769,7 @@ namespace DX9 { } dxstate.texMipFilter.set(D3DTEXF_NONE); dxstate.texMipLodBias.set(0); - DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, u0, v0, u1, v1, g_Config.iInternalScreenRotation); + DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, u0, v0, u1, v1, uvRotation); } } /* diff --git a/GPU/Directx9/StateMappingDX9.cpp b/GPU/Directx9/StateMappingDX9.cpp index 6ef5c990d1..cc1bbb8a39 100644 --- a/GPU/Directx9/StateMappingDX9.cpp +++ b/GPU/Directx9/StateMappingDX9.cpp @@ -664,10 +664,9 @@ void TransformDrawEngineDX9::ApplyDrawState(int prim) { renderWidthFactor = (float)renderWidth / framebufferManager_->GetTargetBufferWidth(); renderHeightFactor = (float)renderHeight / framebufferManager_->GetTargetBufferHeight(); } else { - // TODO: Aspect-ratio aware and centered float pixelW = PSP_CoreParameter().pixelWidth; float pixelH = PSP_CoreParameter().pixelHeight; - CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH); + CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH, ROTATION_LOCKED_HORIZONTAL); renderWidthFactor = renderWidth / 480.0f; renderHeightFactor = renderHeight / 272.0f; } diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 47cfa1c052..9a70d73425 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -227,7 +227,7 @@ void FramebufferManager::CompileDraw2DProgram() { float v_pixel_delta = v_delta; if (postShaderAtOutputResolution_) { float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, ROTATION_LOCKED_HORIZONTAL); u_pixel_delta = 1.0f / w; v_pixel_delta = 1.0f / h; } @@ -419,8 +419,8 @@ void FramebufferManager::DrawFramebuffer(const u8 *srcPixels, GEBufferFormat src // Should try to unify this path with the regular path somehow, but this simple solution works for most of the post shaders // (it always runs at output resolution so FXAA may look odd). float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); - int uvRotation = g_Config.iInternalScreenRotation; + int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation); if (cardboardSettings.enabled) { // Left Eye Image glstate.viewport.set(cardboardSettings.leftEyeXPosition, cardboardSettings.screenYPosition, cardboardSettings.screenWidth, cardboardSettings.screenHeight); @@ -1049,9 +1049,11 @@ void FramebufferManager::CopyDisplayToOutput() { GLuint colorTexture = fbo_get_color_texture(vfb->fbo); + int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL; + // Output coordinates float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation); // TODO ES3: Use glInvalidateFramebuffer to discard depth/stencil data at the end of frame. @@ -1072,7 +1074,7 @@ void FramebufferManager::CopyDisplayToOutput() { } else { // Fullscreen Image glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); - DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, g_Config.iInternalScreenRotation); + DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, uvRotation); } } else if (usePostShader_ && extraFBOs_.size() == 1 && !postShaderAtOutputResolution_) { // An additional pass, post-processing shader to the extra FBO. @@ -1103,7 +1105,7 @@ void FramebufferManager::CopyDisplayToOutput() { } else { // Fullscreen Image glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); - DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1); + DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, NULL, uvRotation); } if (gl_extensions.GLES3 && glInvalidateFramebuffer != nullptr) { @@ -1123,7 +1125,7 @@ void FramebufferManager::CopyDisplayToOutput() { } else { // Fullscreen Image glstate.viewport.set(0, 0, PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight); - DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_, g_Config.iInternalScreenRotation); + DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, u0, v0, u1, v1, postShaderProgram_, uvRotation); } } diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index 52d1fb7ff1..97e41ab3fd 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -38,9 +38,6 @@ class TextureCache; class TransformDrawEngine; class ShaderManager; -void CenterRect(float *x, float *y, float *w, float *h, - float origW, float origH, float frameW, float frameH); - #ifndef USING_GLES2 // Simple struct for asynchronous PBO readbacks struct AsyncPBO { diff --git a/GPU/GLES/StateMapping.cpp b/GPU/GLES/StateMapping.cpp index 96564919cf..12b354e19a 100644 --- a/GPU/GLES/StateMapping.cpp +++ b/GPU/GLES/StateMapping.cpp @@ -725,10 +725,9 @@ void TransformDrawEngine::ApplyDrawState(int prim) { renderWidthFactor = (float)renderWidth / framebufferManager_->GetTargetBufferWidth(); renderHeightFactor = (float)renderHeight / framebufferManager_->GetTargetBufferHeight(); } else { - // TODO: Aspect-ratio aware and centered float pixelW = PSP_CoreParameter().pixelWidth; float pixelH = PSP_CoreParameter().pixelHeight; - CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH); + CenterRect(&renderX, &renderY, &renderWidth, &renderHeight, 480, 272, pixelW, pixelH, ROTATION_LOCKED_HORIZONTAL); renderWidthFactor = renderWidth / 480.0f; renderHeightFactor = renderHeight / 272.0f; } diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 58fa06dcae..acb2717156 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -50,7 +50,7 @@ u32 clut[4096]; // TODO: This one lives in GPU/GLES/Framebuffer.cpp, move it to somewhere common. void CenterRect(float *x, float *y, float *w, float *h, - float origW, float origH, float frameW, float frameH); + float origW, float origH, float frameW, float frameH, int rotation); GLuint OpenGL_CompileProgram(const char* vertexShader, const char* fragmentShader) { @@ -247,7 +247,7 @@ void SoftGPU::CopyToCurrentFboFromDisplayRam(int srcwidth, int srcheight) glUseProgram(program); float x, y, w, h; - CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, dstwidth, dstheight); + CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, dstwidth, dstheight, ROTATION_LOCKED_HORIZONTAL); x /= 0.5f * dstwidth; y /= 0.5f * dstheight; diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index c9ca6c1554..efe8de98f4 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -184,9 +184,9 @@ void GameSettingsScreen::CreateViews() { // Not sure if we should call this one something different? For now we call it the same as the Android screen rotation option and just put it on the graphics tab. static const char *screenRotation[] = {"Landscape", "Portrait", "Landscape Reversed", "Portrait Reversed"}; - PopupMultiChoice *rot = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalScreenRotation, c->T("Screen Rotation"), screenRotation, 1, ARRAY_SIZE(screenRotation), c, screenManager())); - rot->OnChoice.Handle(this, &GameSettingsScreen::OnScreenRotation); - + PopupMultiChoice *scrRotChoice = graphicsSettings->Add(new PopupMultiChoice(&g_Config.iInternalScreenRotation, c->T("Screen Rotation"), screenRotation, 1, ARRAY_SIZE(screenRotation), c, screenManager())); + scrRotChoice->SetEnabledPtr(&screenRotEnable_); + screenRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); #ifdef ANDROID static const char *deviceResolutions[] = { "Native device resolution", "Auto (same as Rendering)", "1x PSP", "2x PSP", "3x PSP", "4x PSP", "5x PSP" }; @@ -656,6 +656,7 @@ UI::EventReturn GameSettingsScreen::OnRenderingMode(UI::EventParams &e) { postProcEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); resolutionEnable_ = !g_Config.bSoftwareRendering && (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); + screenRotEnable_ = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE); if (g_Config.iRenderingMode == FB_NON_BUFFERED_MODE) { g_Config.bAutoFrameSkip = false; diff --git a/UI/GameSettingsScreen.h b/UI/GameSettingsScreen.h index 209afb4977..a50651a6ec 100644 --- a/UI/GameSettingsScreen.h +++ b/UI/GameSettingsScreen.h @@ -109,6 +109,7 @@ private: bool postProcEnable_; bool resolutionEnable_; bool bloomHackEnable_; + bool screenRotEnable_; }; class DeveloperToolsScreen : public UIDialogScreenWithBackground {