2012-11-01 16:19:01 +01: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 23:01:49 +01:00
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
2012-11-01 16:19:01 +01: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 20:58:33 +02:00
|
|
|
#include "Common/Data/Collections/Hashmaps.h"
|
|
|
|
|
#include "Common/GPU/OpenGL/GLCommon.h"
|
|
|
|
|
#include "Common/GPU/OpenGL/GLRenderManager.h"
|
2015-07-26 22:38:40 +02:00
|
|
|
|
|
|
|
|
#include "GPU/GPUState.h"
|
2013-10-13 20:47:52 -07:00
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
2013-09-15 12:46:14 +02:00
|
|
|
#include "GPU/Common/IndexGenerator.h"
|
2014-09-10 10:44:22 +02:00
|
|
|
#include "GPU/Common/VertexDecoderCommon.h"
|
2014-09-13 15:13:34 +02:00
|
|
|
#include "GPU/Common/DrawEngineCommon.h"
|
2015-10-24 23:49:05 +02:00
|
|
|
#include "GPU/Common/GPUStateUtils.h"
|
2020-10-31 18:56:44 +01:00
|
|
|
#include "GPU/Common/FragmentShaderGenerator.h"
|
2012-12-25 13:47:59 +01:00
|
|
|
|
2012-12-21 16:49:42 +01:00
|
|
|
class LinkedShader;
|
2017-01-21 22:16:30 +01:00
|
|
|
class ShaderManagerGLES;
|
|
|
|
|
class TextureCacheGLES;
|
|
|
|
|
class FramebufferManagerGLES;
|
2014-09-13 13:03:37 +02:00
|
|
|
class FramebufferManagerCommon;
|
2014-09-13 13:15:18 +02:00
|
|
|
class TextureCacheCommon;
|
2017-01-21 22:16:30 +01:00
|
|
|
class FragmentTestCacheGLES;
|
2014-03-29 16:51:38 -07:00
|
|
|
struct TransformedVertex;
|
2013-02-01 00:18:23 +01:00
|
|
|
|
2012-12-21 16:49:42 +01:00
|
|
|
struct DecVtxFormat;
|
|
|
|
|
|
2018-07-13 18:35:44 +09:00
|
|
|
class TessellationDataTransferGLES : public TessellationDataTransfer {
|
|
|
|
|
private:
|
|
|
|
|
GLRTexture *data_tex[3]{};
|
2018-09-22 22:06:40 +09:00
|
|
|
int prevSizeU = 0, prevSizeV = 0;
|
|
|
|
|
int prevSizeWU = 0, prevSizeWV = 0;
|
2018-07-13 18:35:44 +09: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 13:39:02 +09:00
|
|
|
void SendDataToShader(const SimpleVertex *const *points, int size_u, int size_v, u32 vertType, const Spline::Weight2D &weights) override;
|
2018-07-13 18:35:44 +09:00
|
|
|
void EndFrame(); // Queues textures for deletion.
|
|
|
|
|
};
|
|
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
// Handles transform, lighting and drawing.
|
2017-12-07 14:56:19 +01:00
|
|
|
class DrawEngineGLES : public DrawEngineCommon {
|
2012-12-25 13:47:59 +01:00
|
|
|
public:
|
2017-11-19 00:43:58 +01:00
|
|
|
DrawEngineGLES(Draw::DrawContext *draw);
|
2022-12-10 20:32:12 -08:00
|
|
|
~DrawEngineGLES();
|
2013-08-30 10:25:01 +02:00
|
|
|
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetShaderManager(ShaderManagerGLES *shaderManager) {
|
2012-12-25 15:28:34 +01:00
|
|
|
shaderManager_ = shaderManager;
|
|
|
|
|
}
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetTextureCache(TextureCacheGLES *textureCache) {
|
2013-01-30 20:40:26 +01:00
|
|
|
textureCache_ = textureCache;
|
|
|
|
|
}
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetFramebufferManager(FramebufferManagerGLES *fbManager) {
|
2013-02-01 00:18:23 +01:00
|
|
|
framebufferManager_ = fbManager;
|
|
|
|
|
}
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetFragmentTestCache(FragmentTestCacheGLES *testCache) {
|
2014-08-24 15:26:38 -07:00
|
|
|
fragmentTestCache_ = testCache;
|
|
|
|
|
}
|
2017-12-09 23:58:08 +01:00
|
|
|
|
2023-02-26 11:05:52 +01:00
|
|
|
void DeviceLost() override;
|
|
|
|
|
void DeviceRestore(Draw::DrawContext *draw) override;
|
2013-01-10 12:51:18 +01:00
|
|
|
|
2021-11-06 00:45:43 +01:00
|
|
|
void ClearTrackedVertexArrays() override {}
|
2013-01-19 17:05:08 +01:00
|
|
|
|
2017-11-19 12:25:57 +01:00
|
|
|
void BeginFrame();
|
|
|
|
|
void EndFrame();
|
|
|
|
|
|
2013-08-11 01:25:14 +02:00
|
|
|
// So that this can be inlined
|
|
|
|
|
void Flush() {
|
2023-05-23 18:00:50 +02:00
|
|
|
if (!numDrawCalls_)
|
2013-08-11 01:25:14 +02:00
|
|
|
return;
|
|
|
|
|
DoFlush();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-14 18:11:00 -07:00
|
|
|
void FinishDeferred() {
|
2023-05-23 18:00:50 +02:00
|
|
|
if (!numDrawCalls_)
|
2015-03-14 18:11:00 -07:00
|
|
|
return;
|
2017-11-19 17:37:56 +01:00
|
|
|
DoFlush();
|
2015-03-14 18:11:00 -07:00
|
|
|
}
|
|
|
|
|
|
2023-05-03 22:49:59 +02:00
|
|
|
void DispatchFlush() override {
|
2023-05-23 18:00:50 +02:00
|
|
|
if (!numDrawCalls_)
|
2023-05-03 22:49:59 +02:00
|
|
|
return;
|
|
|
|
|
Flush();
|
|
|
|
|
}
|
2014-09-14 14:04:09 -07:00
|
|
|
|
2017-11-19 12:25:57 +01:00
|
|
|
void ClearInputLayoutMap();
|
|
|
|
|
|
2020-04-04 11:52:32 -07:00
|
|
|
bool SupportsHWTessellation() const;
|
|
|
|
|
|
|
|
|
|
protected:
|
2023-06-12 20:20:06 +02:00
|
|
|
bool UpdateUseHWTessellation(bool enable) const override;
|
2020-04-04 11:52:32 -07:00
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
private:
|
2022-12-01 19:15:38 +01:00
|
|
|
void Invalidate(InvalidationCallbackFlags flags);
|
2022-11-24 10:38:49 +01:00
|
|
|
|
2017-12-09 23:58:08 +01:00
|
|
|
void InitDeviceObjects();
|
|
|
|
|
void DestroyDeviceObjects();
|
|
|
|
|
|
2013-08-11 01:25:14 +02:00
|
|
|
void DoFlush();
|
2013-01-30 20:40:26 +01:00
|
|
|
void ApplyDrawState(int prim);
|
2017-12-12 15:04:46 +01:00
|
|
|
void ApplyDrawStateLate(bool setStencil, int stencilValue);
|
2015-11-08 21:47:08 +01:00
|
|
|
|
2023-06-12 20:20:06 +02:00
|
|
|
GLRInputLayout *SetupDecFmtForDraw(const DecVtxFormat &decFmt);
|
2017-11-19 12:25:57 +01:00
|
|
|
|
|
|
|
|
struct FrameData {
|
|
|
|
|
GLPushBuffer *pushVertex;
|
|
|
|
|
GLPushBuffer *pushIndex;
|
|
|
|
|
};
|
|
|
|
|
FrameData frameData_[GLRenderManager::MAX_INFLIGHT_FRAMES];
|
|
|
|
|
|
2023-09-11 12:02:56 +02:00
|
|
|
DenseHashMap<uint32_t, GLRInputLayout *> inputLayoutMap_;
|
2017-11-19 12:25:57 +01:00
|
|
|
|
|
|
|
|
GLRInputLayout *softwareInputLayout_ = nullptr;
|
|
|
|
|
GLRenderManager *render_;
|
2013-01-10 12:51:18 +01:00
|
|
|
|
2012-12-25 13:47:59 +01:00
|
|
|
// Other
|
2017-06-02 12:03:46 +02:00
|
|
|
ShaderManagerGLES *shaderManager_ = nullptr;
|
|
|
|
|
TextureCacheGLES *textureCache_ = nullptr;
|
|
|
|
|
FramebufferManagerGLES *framebufferManager_ = nullptr;
|
|
|
|
|
FragmentTestCacheGLES *fragmentTestCache_ = nullptr;
|
2017-11-19 00:43:58 +01:00
|
|
|
Draw::DrawContext *draw_;
|
2013-01-19 19:22:15 +01:00
|
|
|
|
2018-01-31 19:36:32 +01:00
|
|
|
// Need to preserve the scissor for use when clearing.
|
2023-06-12 11:49:44 +02:00
|
|
|
ViewportAndScissor vpAndScissor_{};
|
|
|
|
|
// Need to preserve writemask, easiest way.
|
|
|
|
|
GenericStencilFuncState stencilState_{};
|
2018-01-31 19:36:32 +01:00
|
|
|
|
2017-06-02 12:03:46 +02:00
|
|
|
int bufferDecimationCounter_ = 0;
|
2020-05-24 20:27:58 +02:00
|
|
|
int lastRenderStepId_ = -1;
|
|
|
|
|
|
2017-01-09 03:37:21 +09:00
|
|
|
// Hardware tessellation
|
2018-07-11 01:09:20 +09:00
|
|
|
TessellationDataTransferGLES *tessDataTransferGLES;
|
2012-12-25 13:47:59 +01:00
|
|
|
};
|