ppsspp/GPU/GLES/TextureCacheGLES.h

110 lines
3.5 KiB
C
Raw Normal View History

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