From 127864b679d3f22df5abfae3e4a667de600c6aae Mon Sep 17 00:00:00 2001 From: Henrik Rydgard Date: Wed, 4 Dec 2013 11:46:42 +0100 Subject: [PATCH] Prevent post shaders from getting applied twice in some circumstances when playing video. --- GPU/GLES/Framebuffer.cpp | 21 +++++++++------------ GPU/GLES/Framebuffer.h | 2 +- UI/GameSettingsScreen.cpp | 3 ++- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 73f446998d..854d9a38e1 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -323,7 +323,7 @@ FramebufferManager::~FramebufferManager() { delete [] convBuf; } -void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize) { +void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize, bool applyPostShader) { if (drawPixelsTex_ && drawPixelsTexFormat_ != pixelFormat) { glDeleteTextures(1, &drawPixelsTex_); drawPixelsTex_ = 0; @@ -417,15 +417,14 @@ void FramebufferManager::DrawPixels(const u8 *framebuf, GEBufferFormat pixelForm float x, y, w, h; CenterRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight); - glBindTexture(GL_TEXTURE_2D,drawPixelsTex_); - if (g_Config.iTexFiltering == LINEAR || (g_Config.iTexFiltering == LINEARFMV && g_iNumVideos)) { - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - } + glBindTexture(GL_TEXTURE_2D, drawPixelsTex_); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 512, 272, GL_RGBA, GL_UNSIGNED_BYTE, useConvBuf ? convBuf : framebuf); - // This draws directly at the backbuffer so if there's a post shader, we need to apply it here. 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). - if (usePostShader_) { + // This might draw directly at the backbuffer (if so, applyPostShader is set) so if there's a post shader, we need to apply it here. + // 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). + if (applyPostShader && usePostShader_ && g_Config.iRenderingMode != 0) { DrawActiveTexture(0, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 480.0f / 512.0f, 1.0f, postShaderProgram_); } else { DrawActiveTexture(0, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 480.0f / 512.0f); @@ -735,8 +734,6 @@ void FramebufferManager::SetRenderFrameBuffer() { vfb->colorDepth = FBO_565; break; case GE_FORMAT_8888: - vfb->colorDepth = FBO_8888; - break; default: vfb->colorDepth = FBO_8888; break; @@ -881,8 +878,8 @@ void FramebufferManager::CopyDisplayToOutput() { } if (!vfb) { - // Just a pointer to plain memory to draw. Draw it. - DrawPixels(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_); + // Just a pointer to plain memory to draw. We should create a framebuffer, then draw to it. + DrawPixels(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_, true); return; } } else { diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index f61750ecad..b118d272e0 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -114,7 +114,7 @@ public: shaderManager_ = sm; } - void DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize); + void DrawPixels(const u8 *framebuf, GEBufferFormat pixelFormat, int linesize, bool applyPostShader = false); // If texture != 0, will bind it. void DrawActiveTexture(GLuint texture, float x, float y, float w, float h, float destW, float destH, bool flip = false, float uscale = 1.0f, float vscale = 1.0f, GLSLProgram *program = 0); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 1e709021a6..f22cc001c2 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -269,7 +269,6 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new ItemHeader(s->T("Networking"))); systemSettings->Add(new CheckBox(&g_Config.bEnableWlan, s->T("Networking", "Enable networking/wlan (beta)"))); - enableReports_ = Reporting::IsEnabled(); //#ifndef ANDROID systemSettings->Add(new ItemHeader(s->T("Cheats", "Cheats (experimental, see forums)"))); systemSettings->Add(new CheckBox(&g_Config.bEnableCheats, s->T("Enable Cheats"))); @@ -282,6 +281,8 @@ void GameSettingsScreen::CreateViews() { systemSettings->Add(new Choice(s->T("Clear Recent Games List")))->OnClick.Handle(this, &GameSettingsScreen::OnClearRecents); systemSettings->Add(new Choice(s->T("Restore Default Settings")))->OnClick.Handle(this, &GameSettingsScreen::OnRestoreDefaultSettings); systemSettings->Add(new CheckBox(&g_Config.bEnableAutoLoad, s->T("Auto Load Newest Savestate"))); + + enableReports_ = Reporting::IsEnabled(); enableReportsCheckbox_ = new CheckBox(&enableReports_, s->T("Enable Compatibility Server Reports")); enableReportsCheckbox_->SetEnabled(Reporting::IsSupported()); systemSettings->Add(enableReportsCheckbox_);