CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/GLES/FramebufferManagerGLES.cpp
Views: 1401
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/Common/TextureDecoder.h"
25
#include "GPU/GLES/FramebufferManagerGLES.h"
26
27
FramebufferManagerGLES::FramebufferManagerGLES(Draw::DrawContext *draw) :
28
FramebufferManagerCommon(draw)
29
{
30
needBackBufferYSwap_ = true;
31
presentation_->SetLanguage(draw_->GetShaderLanguageDesc().shaderLanguage);
32
}
33
34
void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) {
35
_assert_msg_(nvfb->fbo, "Expecting a valid nvfb in UpdateDownloadTempBuffer");
36
37
// Discard the previous contents of this buffer where possible.
38
if (gl_extensions.GLES3) {
39
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer");
40
} else if (gl_extensions.IsGLES) {
41
draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer");
42
gstate_c.Dirty(DIRTY_BLEND_STATE);
43
}
44
}
45
46
void FramebufferManagerGLES::NotifyDisplayResized() {
47
FramebufferManagerCommon::NotifyDisplayResized();
48
49
GLRenderManager *render = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
50
render->Resize(PSP_CoreParameter().pixelWidth, PSP_CoreParameter().pixelHeight);
51
}
52
53
bool FramebufferManagerGLES::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
54
int w, h;
55
draw_->GetFramebufferDimensions(nullptr, &w, &h);
56
buffer.Allocate(w, h, GPU_DBG_FORMAT_888_RGB, true);
57
draw_->CopyFramebufferToMemory(nullptr, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8_UNORM, buffer.GetData(), w, Draw::ReadbackMode::BLOCK, "GetOutputFramebuffer");
58
return true;
59
}
60
61