2016-08-07 17:59:35 -07:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 23:01:49 +01:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 16:19:01 +01:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-12-29 23:44:35 +01:00
|
|
|
#include <algorithm>
|
|
|
|
|
2021-05-01 07:15:04 -07:00
|
|
|
#include "Common/Data/Convert/ColorConv.h"
|
2020-10-04 10:04:01 +02:00
|
|
|
#include "Common/Profiler/Profiler.h"
|
2020-10-04 23:24:14 +02:00
|
|
|
#include "Common/GPU/OpenGL/GLCommon.h"
|
|
|
|
#include "Common/GPU/OpenGL/GLDebugLog.h"
|
|
|
|
#include "Common/GPU/OpenGL/GLSLProgram.h"
|
|
|
|
#include "Common/GPU/thin3d.h"
|
2013-01-30 21:09:53 +01:00
|
|
|
#include "Core/MemMap.h"
|
|
|
|
#include "Core/Config.h"
|
2018-06-16 18:42:31 -07:00
|
|
|
#include "Core/ConfigValues.h"
|
2013-01-30 21:09:53 +01:00
|
|
|
#include "Core/System.h"
|
2013-09-11 22:21:15 +02:00
|
|
|
#include "Core/Reporting.h"
|
2013-01-30 21:09:53 +01:00
|
|
|
#include "GPU/ge_constants.h"
|
|
|
|
#include "GPU/GPUState.h"
|
2020-08-03 23:17:22 +02:00
|
|
|
#include "GPU/Common/FramebufferManagerCommon.h"
|
2020-05-09 22:06:22 -07:00
|
|
|
#include "GPU/Common/PresentationCommon.h"
|
2014-05-04 00:18:01 -07:00
|
|
|
#include "GPU/Common/TextureDecoder.h"
|
2014-06-13 08:35:12 -07:00
|
|
|
#include "GPU/Debugger/Stepping.h"
|
2017-01-21 22:16:30 +01:00
|
|
|
#include "GPU/GLES/FramebufferManagerGLES.h"
|
|
|
|
#include "GPU/GLES/TextureCacheGLES.h"
|
|
|
|
#include "GPU/GLES/ShaderManagerGLES.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2022-08-16 21:38:09 +02:00
|
|
|
FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) :
|
|
|
|
FramebufferManagerCommon(draw)
|
2013-01-30 21:09:53 +01:00
|
|
|
{
|
2017-02-15 16:01:59 +01:00
|
|
|
needBackBufferYSwap_ = true;
|
2020-12-14 19:34:41 +01:00
|
|
|
presentation_->SetLanguage(draw_->GetShaderLanguageDesc().shaderLanguage);
|
2022-08-03 22:47:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FramebufferManagerGLES::~FramebufferManagerGLES() {
|
|
|
|
delete[] convBuf_;
|
2014-06-15 15:19:49 -07:00
|
|
|
}
|
2013-01-14 19:26:10 +01:00
|
|
|
|
2020-11-06 09:09:18 +01:00
|
|
|
void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) {
|
|
|
|
_assert_msg_(nvfb->fbo, "Expecting a valid nvfb in UpdateDownloadTempBuffer");
|
|
|
|
|
|
|
|
// Discard the previous contents of this buffer where possible.
|
|
|
|
if (gl_extensions.GLES3) {
|
|
|
|
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer");
|
|
|
|
} else if (gl_extensions.IsGLES) {
|
|
|
|
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer");
|
|
|
|
gstate_c.Dirty(DIRTY_BLEND_STATE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-21 14:54:48 +01:00
|
|
|
void FramebufferManagerGLES::NotifyDisplayResized() {
|
|
|
|
FramebufferManagerCommon::NotifyDisplayResized();
|
|
|
|
|
2022-08-16 21:38:09 +02:00
|
|
|
GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
|
|
|
|
render->Resize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
|
2013-01-31 19:14:57 +08:00
|
|
|
}
|
2013-09-22 19:03:31 -07:00
|
|
|
|
2017-01-21 22:16:30 +01:00
|
|
|
bool FramebufferManagerGLES::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
|
2017-10-16 16:27:16 +02:00
|
|
|
int w, h;
|
|
|
|
draw_->GetFramebufferDimensions(nullptr, &w, &h);
|
|
|
|
buffer.Allocate(w, h, GPU_DBG_FORMAT_888_RGB, true);
|
2020-05-21 11:24:05 +02:00
|
|
|
draw_->CopyFramebufferToMemorySync(nullptr, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8_UNORM, buffer.GetData(), w, "GetOutputFramebuffer");
|
2014-12-20 08:31:56 -08:00
|
|
|
return true;
|
2017-12-21 11:41:53 -08:00
|
|
|
}
|