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/Common/GPU/OpenGL/GLFrameData.cpp
Views: 1401
1
#include "Common/GPU/OpenGL/GLCommon.h"
2
#include "Common/GPU/OpenGL/GLFrameData.h"
3
#include "Common/GPU/OpenGL/GLRenderManager.h"
4
#include "Common/Log.h"
5
6
void GLDeleter::Take(GLDeleter &other) {
7
_assert_msg_(IsEmpty(), "Deleter already has stuff");
8
shaders = std::move(other.shaders);
9
programs = std::move(other.programs);
10
buffers = std::move(other.buffers);
11
textures = std::move(other.textures);
12
inputLayouts = std::move(other.inputLayouts);
13
framebuffers = std::move(other.framebuffers);
14
pushBuffers = std::move(other.pushBuffers);
15
other.shaders.clear();
16
other.programs.clear();
17
other.buffers.clear();
18
other.textures.clear();
19
other.inputLayouts.clear();
20
other.framebuffers.clear();
21
other.pushBuffers.clear();
22
}
23
24
// Runs on the GPU thread.
25
void GLDeleter::Perform(GLRenderManager *renderManager, bool skipGLCalls) {
26
for (auto pushBuffer : pushBuffers) {
27
renderManager->UnregisterPushBuffer(pushBuffer);
28
if (skipGLCalls) {
29
pushBuffer->Destroy(false);
30
}
31
delete pushBuffer;
32
}
33
pushBuffers.clear();
34
for (auto shader : shaders) {
35
if (skipGLCalls && shader)
36
shader->shader = 0; // prevent the glDeleteShader
37
delete shader;
38
}
39
shaders.clear();
40
for (auto program : programs) {
41
if (skipGLCalls && program)
42
program->program = 0; // prevent the glDeleteProgram
43
delete program;
44
}
45
programs.clear();
46
for (auto buffer : buffers) {
47
if (skipGLCalls && buffer)
48
buffer->buffer_ = 0;
49
delete buffer;
50
}
51
buffers.clear();
52
for (auto texture : textures) {
53
if (skipGLCalls && texture)
54
texture->texture = 0;
55
delete texture;
56
}
57
textures.clear();
58
for (auto inputLayout : inputLayouts) {
59
// No GL objects in an inputLayout yet
60
delete inputLayout;
61
}
62
inputLayouts.clear();
63
for (auto framebuffer : framebuffers) {
64
if (skipGLCalls) {
65
framebuffer->handle = 0;
66
framebuffer->color_texture.texture = 0;
67
framebuffer->z_stencil_buffer = 0;
68
framebuffer->z_stencil_texture.texture = 0;
69
framebuffer->z_buffer = 0;
70
framebuffer->stencil_buffer = 0;
71
}
72
delete framebuffer;
73
}
74
framebuffers.clear();
75
}
76
77