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"
|
2015-09-06 11:05:18 +00:00
|
|
|
#include "GPU/GLES/FBO.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;
|
2015-12-31 15:59:40 +00:00
|
|
|
class GraphicsContext;
|
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:
|
2016-04-10 08:21:48 +00:00
|
|
|
GPU_GLES(GraphicsContext *gfxCtx);
|
|
|
|
~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();
|
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
void PreExecuteOp(u32 op, u32 diff) override;
|
|
|
|
void ExecuteOp(u32 op, u32 diff) override;
|
|
|
|
|
2015-09-06 10:23:14 +00:00
|
|
|
void ReapplyGfxStateInternal() override;
|
2015-07-25 12:22:43 +00:00
|
|
|
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
|
|
|
|
void BeginFrame() 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 DumpNextFrame() override;
|
|
|
|
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_;
|
|
|
|
}
|
2015-09-17 18:29:37 +00:00
|
|
|
std::vector<FramebufferInfo> GetFramebufferList() override;
|
2013-01-26 23:15:39 +00:00
|
|
|
|
2016-09-25 23:31:38 +00:00
|
|
|
bool GetCurrentFramebuffer(GPUDebugBuffer &buffer, GPUDebugFramebufferType type, int maxRes) override;
|
2015-09-17 18:29:37 +00:00
|
|
|
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override;
|
|
|
|
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
|
|
|
|
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level) override;
|
2016-01-10 17:25:19 +00:00
|
|
|
bool GetCurrentClut(GPUDebugBuffer &buffer) override;
|
2016-09-25 23:35:43 +00:00
|
|
|
static bool GetOutputFramebuffer(GPUDebugBuffer &buffer);
|
2015-09-17 18:29:37 +00:00
|
|
|
bool GetCurrentSimpleVertices(int count, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices) override;
|
2013-09-23 02:03:31 +00:00
|
|
|
|
2015-07-25 12:22:43 +00:00
|
|
|
bool DescribeCodePtr(const u8 *ptr, std::string &name) override;
|
2013-12-01 02:39:16 +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-22 14:44:27 +00:00
|
|
|
void Execute_Bezier(u32 op, u32 diff);
|
|
|
|
void Execute_Spline(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
|
|
|
void Execute_VertexType(u32 op, u32 diff);
|
2014-06-29 04:37:41 +00:00
|
|
|
void Execute_VertexTypeSkinning(u32 op, u32 diff);
|
2014-04-17 07:22:32 +00:00
|
|
|
void Execute_TexSize0(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;
|
|
|
|
|
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
|
|
|
|
|
|
|
void InitClearInternal() override;
|
|
|
|
void BeginFrameInternal() override;
|
|
|
|
void CopyDisplayToOutputInternal() override;
|
|
|
|
void ReinitializeInternal() override;
|
|
|
|
|
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
|
|
|
|
2013-06-16 21:45:06 +00:00
|
|
|
int lastVsync_;
|
2013-04-29 00:49:17 +00:00
|
|
|
|
2013-04-29 07:30:54 +00:00
|
|
|
std::string reportingPrimaryInfo_;
|
|
|
|
std::string reportingFullInfo_;
|
2015-12-31 15:59:40 +00:00
|
|
|
|
|
|
|
GraphicsContext *gfxCtx_;
|
2016-01-17 16:11:51 +00:00
|
|
|
std::string shaderCachePath_;
|
2012-11-01 15:19:01 +00:00
|
|
|
};
|