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 <string>
21 #include <vector>
22 
23 #include "Common/File/Path.h"
24 
25 #include "GPU/GPUCommon.h"
26 #include "GPU/GLES/FramebufferManagerGLES.h"
27 #include "GPU/GLES/DrawEngineGLES.h"
28 #include "GPU/GLES/DepalettizeShaderGLES.h"
29 #include "GPU/GLES/FragmentTestCacheGLES.h"
30 
31 class ShaderManagerGLES;
32 class TextureCacheGLES;
33 class LinkedShader;
34 
35 class GPU_GLES : public GPUCommon {
36 public:
37 	GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
38 	~GPU_GLES();
39 
40 	// This gets called on startup and when we get back from settings.
41 	void CheckGPUFeatures() override;
42 
43 	bool IsReady() override;
44 	void CancelReady() override;
45 
46 	void PreExecuteOp(u32 op, u32 diff) override;
47 	void ExecuteOp(u32 op, u32 diff) override;
48 
49 	void ReapplyGfxState() override;
50 	void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
51 	void GetStats(char *buffer, size_t bufsize) override;
52 
53 	void ClearCacheNextFrame() override;
54 	void DeviceLost() override;  // Only happens on Android. Drop all textures and shaders.
55 	void DeviceRestore() override;
56 
57 	void DoState(PointerWrap &p) override;
58 
59 	void ClearShaderCache() override;
60 	void CleanupBeforeUI() override;
61 
62 	// Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend.
63 	std::vector<std::string> DebugGetShaderIDs(DebugShaderType shader) override;
64 	std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override;
65 
66 	void BeginHostFrame() override;
67 	void EndHostFrame() override;
68 
69 protected:
70 	void FinishDeferred() override;
71 
72 private:
Flush()73 	void Flush() {
74 		drawEngine_.Flush();
75 	}
76 	void CheckFlushOp(int cmd, u32 diff);
77 	void BuildReportingInfo();
78 
79 	void InitClear() override;
80 	void BeginFrame() override;
81 	void CopyDisplayToOutput(bool reallyDirty) override;
82 	void Reinitialize() override;
83 
84 	FramebufferManagerGLES *framebufferManagerGL_;
85 	TextureCacheGLES *textureCacheGL_;
86 	DepalShaderCacheGLES depalShaderCache_;
87 	DrawEngineGLES drawEngine_;
88 	FragmentTestCacheGLES fragmentTestCache_;
89 	ShaderManagerGLES *shaderManagerGL_;
90 
91 	Path shaderCachePath_;
92 };
93