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
|
2012-11-26 13:25:14 +10:00
|
|
|
|
2014-10-19 21:11:09 +02:00
|
|
|
#include <map>
|
|
|
|
|
2014-05-27 22:22:56 +02:00
|
|
|
#include "gfx_es2/gpu_features.h"
|
2017-02-04 18:46:12 +01:00
|
|
|
#include "gfx/gl_common.h"
|
2017-11-19 17:37:56 +01:00
|
|
|
#include "thin3d/GLRenderManager.h"
|
2013-05-05 22:52:01 -07:00
|
|
|
#include "GPU/GPUInterface.h"
|
2013-02-17 01:06:06 +01:00
|
|
|
#include "GPU/GPUState.h"
|
2017-01-21 22:16:30 +01:00
|
|
|
#include "GPU/GLES/TextureScalerGLES.h"
|
2014-09-13 13:15:18 +02:00
|
|
|
#include "GPU/Common/TextureCacheCommon.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2013-02-21 21:37:19 +01:00
|
|
|
struct VirtualFramebuffer;
|
2017-01-21 22:16:30 +01:00
|
|
|
class FramebufferManagerGLES;
|
|
|
|
class DepalShaderCacheGLES;
|
|
|
|
class ShaderManagerGLES;
|
2016-04-10 10:21:48 +02:00
|
|
|
class DrawEngineGLES;
|
2017-11-19 17:37:56 +01:00
|
|
|
class GLRTexture;
|
2013-02-21 21:37:19 +01:00
|
|
|
|
2017-01-21 22:16:30 +01:00
|
|
|
class TextureCacheGLES : public TextureCacheCommon {
|
2013-01-30 20:40:26 +01:00
|
|
|
public:
|
2017-02-05 19:51:50 +01:00
|
|
|
TextureCacheGLES(Draw::DrawContext *draw);
|
2017-01-21 22:16:30 +01:00
|
|
|
~TextureCacheGLES();
|
2013-01-30 20:40:26 +01:00
|
|
|
|
2017-02-27 23:09:12 +01:00
|
|
|
void Clear(bool delete_them) override;
|
2013-01-30 20:40:26 +01:00
|
|
|
void StartFrame();
|
2013-02-01 00:18:23 +01:00
|
|
|
|
2017-02-08 15:58:46 +01:00
|
|
|
void SetFramebufferManager(FramebufferManagerGLES *fbManager);
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetDepalShaderCache(DepalShaderCacheGLES *dpCache) {
|
2014-03-29 21:58:38 +01:00
|
|
|
depalShaderCache_ = dpCache;
|
|
|
|
}
|
2017-01-21 22:16:30 +01:00
|
|
|
void SetShaderManager(ShaderManagerGLES *sm) {
|
2014-05-31 18:55:00 -07:00
|
|
|
shaderManager_ = sm;
|
|
|
|
}
|
2017-02-04 11:47:19 +01:00
|
|
|
void SetDrawEngine(DrawEngineGLES *td) {
|
|
|
|
drawEngine_ = td;
|
2015-12-13 22:48:21 -08:00
|
|
|
}
|
2014-01-19 17:28:11 -08:00
|
|
|
|
2017-02-07 00:24:38 +01:00
|
|
|
void ForgetLastTexture() override {
|
2017-11-19 17:37:56 +01:00
|
|
|
lastBoundTexture = nullptr;
|
2017-01-24 09:41:38 +01:00
|
|
|
gstate_c.Dirty(DIRTY_TEXTURE_PARAMS);
|
2014-05-27 02:00:49 -07:00
|
|
|
}
|
2017-02-20 00:13:09 +01:00
|
|
|
void InvalidateLastTexture(TexCacheEntry *entry = nullptr) override {
|
|
|
|
if (!entry || entry->textureName == lastBoundTexture) {
|
2017-11-19 17:37:56 +01:00
|
|
|
lastBoundTexture = nullptr;
|
2017-02-20 00:13:09 +01:00
|
|
|
}
|
2017-02-19 23:50:04 +01:00
|
|
|
}
|
2014-05-27 02:00:49 -07:00
|
|
|
|
2018-04-13 20:00:14 +02:00
|
|
|
void SetFramebufferSamplingParams(u16 bufferWidth, u16 bufferHeight, bool forcePoint);
|
2017-10-18 13:03:49 +02:00
|
|
|
bool GetCurrentTextureDebug(GPUDebugBuffer &buffer, int level) override;
|
2014-06-15 13:34:58 -07:00
|
|
|
|
2018-04-05 11:25:49 +02:00
|
|
|
void DeviceLost();
|
2017-12-07 14:56:19 +01:00
|
|
|
void DeviceRestore(Draw::DrawContext *draw);
|
|
|
|
|
2016-01-04 21:29:03 -08:00
|
|
|
protected:
|
2017-02-19 23:07:00 +01:00
|
|
|
void BindTexture(TexCacheEntry *entry) override;
|
2017-02-08 15:43:53 +01:00
|
|
|
void Unbind() override;
|
2017-02-23 17:31:24 +01:00
|
|
|
void ReleaseTexture(TexCacheEntry *entry, bool delete_them) override;
|
2016-01-04 21:29:03 -08:00
|
|
|
|
2014-04-01 14:14:56 +02:00
|
|
|
private:
|
2013-01-30 20:40:26 +01:00
|
|
|
void UpdateSamplingParams(TexCacheEntry &entry, bool force);
|
2019-10-24 22:40:26 +02:00
|
|
|
void LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &replaced, int level, int scaleFactor, Draw::DataFormat dstFmt);
|
|
|
|
Draw::DataFormat GetDestFormat(GETextureFormat format, GEPaletteFormat clutFormat) const;
|
2017-11-19 18:22:46 +01:00
|
|
|
|
2019-10-24 22:40:26 +02:00
|
|
|
TexCacheEntry::TexStatus CheckAlpha(const uint8_t *pixelData, Draw::DataFormat dstFmt, int stride, int w, int h);
|
2017-02-20 00:05:23 +01:00
|
|
|
void UpdateCurrentClut(GEPaletteFormat clutFormat, u32 clutBase, bool clutIndexIsSimple) override;
|
2017-02-19 23:25:09 +01:00
|
|
|
void ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFramebuffer *framebuffer) override;
|
2013-01-30 20:40:26 +01:00
|
|
|
|
2018-03-25 10:49:28 +02:00
|
|
|
void BuildTexture(TexCacheEntry *const entry) override;
|
2016-05-01 11:17:55 -07:00
|
|
|
|
2017-11-19 17:37:56 +01:00
|
|
|
GLRenderManager *render_;
|
2015-04-08 20:52:35 +02:00
|
|
|
|
2017-01-21 22:16:30 +01:00
|
|
|
TextureScalerGLES scaler;
|
2013-04-09 01:52:19 -07:00
|
|
|
|
2017-11-19 17:37:56 +01:00
|
|
|
GLRTexture *lastBoundTexture;
|
2013-08-01 00:13:58 +02:00
|
|
|
|
2017-02-08 15:58:46 +01:00
|
|
|
FramebufferManagerGLES *framebufferManagerGL_;
|
2017-01-21 22:16:30 +01:00
|
|
|
DepalShaderCacheGLES *depalShaderCache_;
|
|
|
|
ShaderManagerGLES *shaderManager_;
|
2017-02-04 11:47:19 +01:00
|
|
|
DrawEngineGLES *drawEngine_;
|
2017-02-19 23:50:04 +01:00
|
|
|
|
2018-04-05 11:25:49 +02:00
|
|
|
GLRInputLayout *shadeInputLayout_ = nullptr;
|
2017-12-14 17:50:40 +01:00
|
|
|
|
2017-02-19 23:50:04 +01:00
|
|
|
enum { INVALID_TEX = -1 };
|
2013-01-30 20:40:26 +01:00
|
|
|
};
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2019-10-24 22:40:26 +02:00
|
|
|
Draw::DataFormat getClutDestFormat(GEPaletteFormat format);
|