Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/GLES/FramebufferManagerGLES.cpp
3186 views
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include "Common/GPU/OpenGL/GLFeatures.h"
19
#include "Common/GPU/OpenGL/GLRenderManager.h"
20
#include "Common/GPU/thin3d.h"
21
#include "Core/System.h"
22
#include "GPU/Common/FramebufferManagerCommon.h"
23
#include "GPU/Common/PresentationCommon.h"
24
#include "GPU/GLES/FramebufferManagerGLES.h"
25
26
FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) :
27
FramebufferManagerCommon(draw)
28
{
29
needBackBufferYSwap_ = true;
30
presentation_->SetLanguage(draw_->GetShaderLanguageDesc().shaderLanguage);
31
}
32
33
void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) {
34
_assert_msg_(nvfb->fbo, "Expecting a valid nvfb in UpdateDownloadTempBuffer");
35
36
// Discard the previous contents of this buffer where possible.
37
if (gl_extensions.GLES3) {
38
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer");
39
} else if (gl_extensions.IsGLES) {
40
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer");
41
gstate_c.Dirty(DIRTY_BLEND_STATE);
42
}
43
}
44
45
void FramebufferManagerGLES::NotifyDisplayResized() {
46
FramebufferManagerCommon::NotifyDisplayResized();
47
48
GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
49
render->Resize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
50
}
51
52
bool FramebufferManagerGLES::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
53
int w, h;
54
draw_->GetFramebufferDimensions(nullptr, &w, &h);
55
buffer.Allocate(w, h, GPU_DBG_FORMAT_888_RGB, true);
56
draw_->CopyFramebufferToMemory(nullptr, Draw::Aspect::COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8_UNORM, buffer.GetData(), w, Draw::ReadbackMode::BLOCK, "GetOutputFramebuffer");
57
return true;
58
}
59
60