Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/GLES/DrawEngineGLES.h
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
#pragma once
19
20
#include "Common/Data/Collections/Hashmaps.h"
21
#include "Common/GPU/OpenGL/GLCommon.h"
22
#include "Common/GPU/OpenGL/GLRenderManager.h"
23
24
#include "GPU/GPUState.h"
25
#include "GPU/Common/GPUDebugInterface.h"
26
#include "GPU/Common/IndexGenerator.h"
27
#include "GPU/Common/VertexDecoderCommon.h"
28
#include "GPU/Common/DrawEngineCommon.h"
29
#include "GPU/Common/GPUStateUtils.h"
30
#include "GPU/Common/FragmentShaderGenerator.h"
31
32
class LinkedShader;
33
class ShaderManagerGLES;
34
class TextureCacheGLES;
35
class FramebufferManagerGLES;
36
class FramebufferManagerCommon;
37
class TextureCacheCommon;
38
class FragmentTestCacheGLES;
39
struct TransformedVertex;
40
41
struct DecVtxFormat;
42
43
class TessellationDataTransferGLES : public TessellationDataTransfer {
44
private:
45
GLRTexture *data_tex[3]{};
46
int prevSizeU = 0, prevSizeV = 0;
47
int prevSizeWU = 0, prevSizeWV = 0;
48
GLRenderManager *renderManager_;
49
public:
50
TessellationDataTransferGLES(GLRenderManager *renderManager)
51
: renderManager_(renderManager) { }
52
~TessellationDataTransferGLES() {
53
EndFrame();
54
}
55
// Send spline/bezier's control points and weights to vertex shader through floating point texture.
56
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
57
void EndFrame(); // Queues textures for deletion.
58
};
59
60
// Handles transform, lighting and drawing.
61
class DrawEngineGLES : public DrawEngineCommon {
62
public:
63
DrawEngineGLES(Draw::DrawContext *draw);
64
~DrawEngineGLES();
65
66
void SetShaderManager(ShaderManagerGLES *shaderManager) {
67
shaderManager_ = shaderManager;
68
}
69
void SetTextureCache(TextureCacheGLES *textureCache) {
70
textureCache_ = textureCache;
71
}
72
void SetFramebufferManager(FramebufferManagerGLES *fbManager) {
73
framebufferManager_ = fbManager;
74
}
75
void SetFragmentTestCache(FragmentTestCacheGLES *testCache) {
76
fragmentTestCache_ = testCache;
77
}
78
79
void DeviceLost() override;
80
void DeviceRestore(Draw::DrawContext *draw) override;
81
82
void BeginFrame() override;
83
void EndFrame();
84
85
// So that this can be inlined
86
void Flush() override;
87
void FinishDeferred() {
88
Flush();
89
}
90
91
void ClearInputLayoutMap();
92
93
static bool SupportsHWTessellation() ;
94
95
protected:
96
bool UpdateUseHWTessellation(bool enable) const override;
97
98
private:
99
void Invalidate(InvalidationCallbackFlags flags);
100
101
void InitDeviceObjects();
102
void DestroyDeviceObjects();
103
104
void ApplyDrawState(int prim);
105
void ApplyDrawStateLate(bool setStencil, int stencilValue);
106
107
GLRInputLayout *SetupDecFmtForDraw(const DecVtxFormat &decFmt);
108
109
struct FrameData {
110
GLPushBuffer *pushVertex;
111
GLPushBuffer *pushIndex;
112
};
113
FrameData frameData_[GLRenderManager::MAX_INFLIGHT_FRAMES];
114
115
DenseHashMap<uint32_t, GLRInputLayout *> inputLayoutMap_;
116
117
GLRInputLayout *softwareInputLayout_ = nullptr;
118
GLRenderManager *render_;
119
120
// Other
121
ShaderManagerGLES *shaderManager_ = nullptr;
122
TextureCacheGLES *textureCache_ = nullptr;
123
FramebufferManagerGLES *framebufferManager_ = nullptr;
124
FragmentTestCacheGLES *fragmentTestCache_ = nullptr;
125
Draw::DrawContext *draw_;
126
127
// Need to preserve the scissor for use when clearing.
128
ViewportAndScissor vpAndScissor_{};
129
// Need to preserve writemask, easiest way.
130
GenericStencilFuncState stencilState_{};
131
132
int bufferDecimationCounter_ = 0;
133
int lastRenderStepId_ = -1;
134
135
// Hardware tessellation
136
TessellationDataTransferGLES *tessDataTransferGLES;
137
};
138
139