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
|
|
|
|
|
2020-10-05 18:58:33 +00:00
|
|
|
#include "Common/Data/Collections/Hashmaps.h"
|
|
|
|
#include "Common/GPU/OpenGL/GLCommon.h"
|
|
|
|
#include "Common/GPU/OpenGL/GLRenderManager.h"
|
2015-07-26 20:38:40 +00:00
|
|
|
|
|
|
|
#include "GPU/GPUState.h"
|
2013-10-14 03:47:52 +00:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2013-09-15 10:46:14 +00:00
|
|
|
#include "GPU/Common/IndexGenerator.h"
|
2014-09-10 08:44:22 +00:00
|
|
|
#include "GPU/Common/VertexDecoderCommon.h"
|
2014-09-13 13:13:34 +00:00
|
|
|
#include "GPU/Common/DrawEngineCommon.h"
|
2015-10-24 21:49:05 +00:00
|
|
|
#include "GPU/Common/GPUStateUtils.h"
|
2020-10-31 17:56:44 +00:00
|
|
|
#include "GPU/Common/FragmentShaderGenerator.h"
|
2012-12-25 12:47:59 +00:00
|
|
|
|
2012-12-21 15:49:42 +00:00
|
|
|
class LinkedShader;
|
2017-01-21 21:16:30 +00:00
|
|
|
class ShaderManagerGLES;
|
|
|
|
class TextureCacheGLES;
|
|
|
|
class FramebufferManagerGLES;
|
2014-09-13 11:03:37 +00:00
|
|
|
class FramebufferManagerCommon;
|
2014-09-13 11:15:18 +00:00
|
|
|
class TextureCacheCommon;
|
2017-01-21 21:16:30 +00:00
|
|
|
class FragmentTestCacheGLES;
|
2014-03-29 23:51:38 +00:00
|
|
|
struct TransformedVertex;
|
2013-01-31 23:18:23 +00:00
|
|
|
|
2012-12-21 15:49:42 +00:00
|
|
|
struct DecVtxFormat;
|
|
|
|
|
2018-04-13 07:11:08 +00:00
|
|
|
enum {
|
|
|
|
TEX_SLOT_PSP_TEXTURE = 0,
|
|
|
|
TEX_SLOT_SHADERBLEND_SRC = 1,
|
|
|
|
TEX_SLOT_ALPHATEST = 2,
|
|
|
|
TEX_SLOT_CLUT = 3,
|
2018-06-29 15:21:30 +00:00
|
|
|
TEX_SLOT_SPLINE_POINTS = 4,
|
|
|
|
TEX_SLOT_SPLINE_WEIGHTS_U = 5,
|
|
|
|
TEX_SLOT_SPLINE_WEIGHTS_V = 6,
|
2018-04-13 07:11:08 +00:00
|
|
|
};
|
|
|
|
|
2018-07-13 09:35:44 +00:00
|
|
|
class TessellationDataTransferGLES : public TessellationDataTransfer {
|
|
|
|
private:
|
|
|
|
GLRTexture *data_tex[3]{};
|
2018-09-22 13:06:40 +00:00
|
|
|
int prevSizeU = 0, prevSizeV = 0;
|
|
|
|
int prevSizeWU = 0, prevSizeWV = 0;
|
2018-07-13 09:35:44 +00:00
|
|
|
GLRenderManager *renderManager_;
|
|
|
|
public:
|
|
|
|
TessellationDataTransferGLES(GLRenderManager *renderManager)
|
|
|
|
: renderManager_(renderManager) { }
|
|
|
|
~TessellationDataTransferGLES() {
|
|
|
|
EndFrame();
|
|
|
|
}
|
|
|
|
// Send spline/bezier's control points and weights to vertex shader through floating point texture.
|
2018-09-29 04:39:02 +00:00
|
|
|
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
|
2018-07-13 09:35:44 +00:00
|
|
|
void EndFrame(); // Queues textures for deletion.
|
|
|
|
};
|
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
// Handles transform, lighting and drawing.
|
2017-12-07 13:56:19 +00:00
|
|
|
class DrawEngineGLES : public DrawEngineCommon {
|
2012-12-25 12:47:59 +00:00
|
|
|
public:
|
2017-11-18 23:43:58 +00:00
|
|
|
DrawEngineGLES(Draw::DrawContext *draw);
|
2016-04-10 08:21:48 +00:00
|
|
|
virtual ~DrawEngineGLES();
|
2013-08-30 08:25:01 +00:00
|
|
|
|
2017-01-21 21:16:30 +00:00
|
|
|
void SetShaderManager(ShaderManagerGLES *shaderManager) {
|
2012-12-25 14:28:34 +00:00
|
|
|
shaderManager_ = shaderManager;
|
|
|
|
}
|
2017-01-21 21:16:30 +00:00
|
|
|
void SetTextureCache(TextureCacheGLES *textureCache) {
|
2013-01-30 19:40:26 +00:00
|
|
|
textureCache_ = textureCache;
|
|
|
|
}
|
2017-01-21 21:16:30 +00:00
|
|
|
void SetFramebufferManager(FramebufferManagerGLES *fbManager) {
|
2013-01-31 23:18:23 +00:00
|
|
|
framebufferManager_ = fbManager;
|
|
|
|
}
|
2017-01-21 21:16:30 +00:00
|
|
|
void SetFragmentTestCache(FragmentTestCacheGLES *testCache) {
|
2014-08-24 22:26:38 +00:00
|
|
|
fragmentTestCache_ = testCache;
|
|
|
|
}
|
2017-12-09 22:58:08 +00:00
|
|
|
|
|
|
|
void DeviceLost();
|
2018-05-27 20:19:03 +00:00
|
|
|
void DeviceRestore(Draw::DrawContext *draw);
|
2013-01-10 11:51:18 +00:00
|
|
|
|
2021-11-05 23:45:43 +00:00
|
|
|
void ClearTrackedVertexArrays() override {}
|
2013-01-19 16:05:08 +00:00
|
|
|
|
2017-11-19 11:25:57 +00:00
|
|
|
void BeginFrame();
|
|
|
|
void EndFrame();
|
|
|
|
|
|
|
|
|
2013-08-10 23:25:14 +00:00
|
|
|
// So that this can be inlined
|
|
|
|
void Flush() {
|
|
|
|
if (!numDrawCalls)
|
|
|
|
return;
|
|
|
|
DoFlush();
|
|
|
|
}
|
|
|
|
|
2015-03-15 01:11:00 +00:00
|
|
|
void FinishDeferred() {
|
|
|
|
if (!numDrawCalls)
|
|
|
|
return;
|
2017-11-19 16:37:56 +00:00
|
|
|
DoFlush();
|
2015-03-15 01:11:00 +00:00
|
|
|
}
|
|
|
|
|
2014-03-29 23:51:38 +00:00
|
|
|
bool IsCodePtrVertexDecoder(const u8 *ptr) const;
|
2013-12-01 02:39:16 +00:00
|
|
|
|
2015-04-08 19:37:54 +00:00
|
|
|
void DispatchFlush() override { Flush(); }
|
2014-09-14 21:04:09 +00:00
|
|
|
|
2017-12-12 13:07:52 +00:00
|
|
|
GLPushBuffer *GetPushVertexBuffer() {
|
|
|
|
return frameData_[render_->GetCurFrame()].pushVertex;
|
|
|
|
}
|
|
|
|
GLPushBuffer *GetPushIndexBuffer() {
|
|
|
|
return frameData_[render_->GetCurFrame()].pushIndex;
|
|
|
|
}
|
2015-12-14 06:48:21 +00:00
|
|
|
|
2017-11-19 11:25:57 +00:00
|
|
|
void ClearInputLayoutMap();
|
|
|
|
|
2020-04-04 18:52:32 +00:00
|
|
|
bool SupportsHWTessellation() const;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool UpdateUseHWTessellation(bool enable) override;
|
2021-11-05 23:45:43 +00:00
|
|
|
void DecimateTrackedVertexArrays() {}
|
2020-04-04 18:52:32 +00:00
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
private:
|
2017-12-09 22:58:08 +00:00
|
|
|
void InitDeviceObjects();
|
|
|
|
void DestroyDeviceObjects();
|
|
|
|
|
2013-08-10 23:25:14 +00:00
|
|
|
void DoFlush();
|
2013-01-30 19:40:26 +00:00
|
|
|
void ApplyDrawState(int prim);
|
2017-12-12 14:04:46 +00:00
|
|
|
void ApplyDrawStateLate(bool setStencil, int stencilValue);
|
2020-11-08 12:14:23 +00:00
|
|
|
void ResetFramebufferRead();
|
2015-11-08 20:47:08 +00:00
|
|
|
|
2017-11-19 11:25:57 +00:00
|
|
|
GLRInputLayout *SetupDecFmtForDraw(LinkedShader *program, const DecVtxFormat &decFmt);
|
|
|
|
|
2020-05-24 21:45:06 +00:00
|
|
|
void *DecodeVertsToPushBuffer(GLPushBuffer *push, uint32_t *bindOffset, GLRBuffer **buf);
|
2017-11-19 11:25:57 +00:00
|
|
|
|
|
|
|
struct FrameData {
|
|
|
|
GLPushBuffer *pushVertex;
|
|
|
|
GLPushBuffer *pushIndex;
|
|
|
|
};
|
|
|
|
FrameData frameData_[GLRenderManager::MAX_INFLIGHT_FRAMES];
|
|
|
|
|
|
|
|
DenseHashMap<uint32_t, GLRInputLayout *, nullptr> inputLayoutMap_;
|
|
|
|
|
|
|
|
GLRInputLayout *softwareInputLayout_ = nullptr;
|
|
|
|
GLRenderManager *render_;
|
2013-01-10 11:51:18 +00:00
|
|
|
|
2012-12-25 12:47:59 +00:00
|
|
|
// Other
|
2017-06-02 10:03:46 +00:00
|
|
|
ShaderManagerGLES *shaderManager_ = nullptr;
|
|
|
|
TextureCacheGLES *textureCache_ = nullptr;
|
|
|
|
FramebufferManagerGLES *framebufferManager_ = nullptr;
|
|
|
|
FragmentTestCacheGLES *fragmentTestCache_ = nullptr;
|
2017-11-18 23:43:58 +00:00
|
|
|
Draw::DrawContext *draw_;
|
2017-06-02 10:03:46 +00:00
|
|
|
|
2018-01-31 18:36:32 +00:00
|
|
|
// Need to preserve the scissor for use when clearing.
|
|
|
|
ViewportAndScissor vpAndScissor;
|
|
|
|
|
2017-06-02 10:03:46 +00:00
|
|
|
int bufferDecimationCounter_ = 0;
|
2014-05-13 04:47:55 +00:00
|
|
|
|
2020-05-24 18:27:58 +00:00
|
|
|
int lastRenderStepId_ = -1;
|
|
|
|
|
2017-01-08 18:37:21 +00:00
|
|
|
// Hardware tessellation
|
2018-07-10 16:09:20 +00:00
|
|
|
TessellationDataTransferGLES *tessDataTransferGLES;
|
2012-12-25 12:47:59 +00:00
|
|
|
};
|