2012-11-01 15:19:01 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
2012-11-04 22:01:49 +00:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 15:19:01 +00:00
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2012-11-19 22:29:14 +00:00
|
|
|
#include <list>
|
2012-12-28 20:58:00 +00:00
|
|
|
#include <deque>
|
2012-11-19 20:23:29 +00:00
|
|
|
|
2013-08-20 20:34:47 +00:00
|
|
|
#include "GPU/GPUCommon.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/FramebufferManagerGLES.h"
|
2016-04-10 08:27:28 +00:00
|
|
|
#include "GPU/GLES/DrawEngineGLES.h"
|
2017-01-21 21:16:30 +00:00
|
|
|
#include "GPU/GLES/TextureCacheGLES.h"
|
|
|
|
#include "GPU/GLES/DepalettizeShaderGLES.h"
|
|
|
|
#include "GPU/GLES/FragmentTestCacheGLES.h"
|
2013-08-20 20:34:47 +00:00
|
|
|
|
2017-01-21 21:16:30 +00:00
|
|
|
class ShaderManagerGLES;
|
2012-12-21 15:49:42 +00:00
|
|
|
class LinkedShader;
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
class GPU_GLES : public GPUCommon {
|
2012-11-01 15:19:01 +00:00
|
|
|
public:
|
2017-01-30 15:50:35 +00:00
|
|
|
GPU_GLES(GraphicsContext *gfxCtx, Draw::DrawContext *draw);
|
2016-04-10 08:21:48 +00:00
|
|
|
~GPU_GLES();
|
2015-09-05 17:58:47 +00:00
|
|
|
|
2015-09-05 19:23:58 +00:00
|
|
|
// This gets called on startup and when we get back from settings.
|
2015-09-05 17:58:47 +00:00
|
|
|
void CheckGPUFeatures();
|
|
|
|
|
2017-12-03 19:30:00 +00:00
|
|
|
bool IsReady() override;
|
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
void PreExecuteOp(u32 op, u32 diff) override;
|
|
|
|
void ExecuteOp(u32 op, u32 diff) override;
|
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void ReapplyGfxState() override;
|
2015-07-25 12:22:43 +00:00
|
|
|
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
|
2016-03-31 08:17:02 +00:00
|
|
|
void GetStats(char *buffer, size_t bufsize) override;
|
2016-12-21 17:33:08 +00:00
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
void ClearCacheNextFrame() override;
|
|
|
|
void DeviceLost() override; // Only happens on Android. Drop all textures and shaders.
|
2016-09-11 03:29:58 +00:00
|
|
|
void DeviceRestore() override;
|
2015-07-25 12:22:43 +00:00
|
|
|
|
|
|
|
void DoState(PointerWrap &p) override;
|
2013-10-09 14:08:36 +00:00
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
void ClearShaderCache() override;
|
|
|
|
void CleanupBeforeUI() override;
|
|
|
|
bool DecodeTexture(u8 *dest, const GPUgstate &state) override {
|
2016-12-21 17:07:17 +00:00
|
|
|
return textureCacheGL_->DecodeTexture(dest, state);
|
2013-02-17 00:06:06 +00:00
|
|
|
}
|
2015-07-25 12:22:43 +00:00
|
|
|
bool FramebufferDirty() override;
|
|
|
|
bool FramebufferReallyDirty() override;
|
2013-02-17 00:06:06 +00:00
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) override {
|
2013-04-29 07:30:54 +00:00
|
|
|
primaryInfo = reportingPrimaryInfo_;
|
|
|
|
fullInfo = reportingFullInfo_;
|
|
|
|
}
|
2013-01-26 23:15:39 +00:00
|
|
|
|
2016-04-10 08:21:48 +00:00
|
|
|
typedef void (GPU_GLES::*CmdFunc)(u32 op, u32 diff);
|
2014-04-17 08:36:24 +00:00
|
|
|
struct CommandInfo {
|
2017-01-24 09:44:02 +00:00
|
|
|
uint64_t flags;
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES::CmdFunc func;
|
2014-04-17 08:36:24 +00:00
|
|
|
};
|
2014-04-16 14:54:19 +00:00
|
|
|
|
2014-04-16 15:01:56 +00:00
|
|
|
void Execute_Prim(u32 op, u32 diff);
|
2017-01-24 09:44:02 +00:00
|
|
|
void Execute_LoadClut(u32 op, u32 diff);
|
2014-04-16 15:01:56 +00:00
|
|
|
|
2015-10-14 15:45:21 +00:00
|
|
|
// Using string because it's generic - makes no assumptions on the size of the shader IDs of this backend.
|
|
|
|
std::vector<std::string> DebugGetShaderIDs(DebugShaderType shader) override;
|
|
|
|
std::string DebugGetShaderString(std::string id, DebugShaderType shader, DebugShaderStringType stringType) override;
|
|
|
|
|
2017-03-17 09:48:43 +00:00
|
|
|
void BeginHostFrame() override;
|
|
|
|
|
2013-04-28 21:23:30 +00:00
|
|
|
protected:
|
2015-03-15 01:11:00 +00:00
|
|
|
void FastRunLoop(DisplayList &list) override;
|
|
|
|
void FinishDeferred() override;
|
2013-04-28 21:23:30 +00:00
|
|
|
|
2012-11-06 16:05:27 +00:00
|
|
|
private:
|
2013-08-10 23:25:14 +00:00
|
|
|
void Flush() {
|
2016-04-10 08:21:48 +00:00
|
|
|
drawEngine_.Flush();
|
2013-08-10 23:25:14 +00:00
|
|
|
}
|
2013-08-06 17:08:38 +00:00
|
|
|
void CheckFlushOp(int cmd, u32 diff);
|
2013-04-29 00:49:17 +00:00
|
|
|
void BuildReportingInfo();
|
2016-12-21 18:58:10 +00:00
|
|
|
|
2017-11-05 19:33:28 +00:00
|
|
|
void InitClear() override;
|
|
|
|
void BeginFrame() override;
|
|
|
|
void CopyDisplayToOutput() override;
|
|
|
|
void Reinitialize() override;
|
2016-12-21 18:58:10 +00:00
|
|
|
|
2014-06-15 22:19:49 +00:00
|
|
|
inline void UpdateVsyncInterval(bool force);
|
2014-06-29 04:51:25 +00:00
|
|
|
void UpdateCmdInfo();
|
2012-11-26 19:38:26 +00:00
|
|
|
|
2014-04-17 08:36:24 +00:00
|
|
|
static CommandInfo cmdInfo_[256];
|
2014-04-16 14:54:19 +00:00
|
|
|
|
2017-01-21 21:16:30 +00:00
|
|
|
FramebufferManagerGLES *framebufferManagerGL_;
|
|
|
|
TextureCacheGLES *textureCacheGL_;
|
|
|
|
DepalShaderCacheGLES depalShaderCache_;
|
2016-04-10 08:21:48 +00:00
|
|
|
DrawEngineGLES drawEngine_;
|
2017-01-21 21:16:30 +00:00
|
|
|
FragmentTestCacheGLES fragmentTestCache_;
|
2017-01-23 19:48:23 +00:00
|
|
|
ShaderManagerGLES *shaderManagerGL_;
|
2013-01-30 19:40:26 +00:00
|
|
|
|
2017-12-04 02:38:22 +00:00
|
|
|
#ifdef _WIN32
|
2013-06-16 21:45:06 +00:00
|
|
|
int lastVsync_;
|
2017-12-04 02:38:22 +00:00
|
|
|
#endif
|
2017-08-20 17:03:16 +00:00
|
|
|
int vertexCost_ = 0;
|
2013-04-29 00:49:17 +00:00
|
|
|
|
2013-04-29 07:30:54 +00:00
|
|
|
std::string reportingPrimaryInfo_;
|
|
|
|
std::string reportingFullInfo_;
|
2016-01-17 16:11:51 +00:00
|
|
|
std::string shaderCachePath_;
|
2012-11-01 15:19:01 +00:00
|
|
|
};
|