Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Common/TextureShaderCommon.h
5671 views
1
// Copyright (c) 2014- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include <map>
21
#include <vector>
22
#include <string>
23
24
#include "Common/CommonTypes.h"
25
#include "Common/GPU/thin3d.h"
26
#include "GPU/ge_constants.h"
27
#include "GPU/Common/Draw2D.h"
28
#include "GPU/Common/ShaderCommon.h"
29
30
class ClutTexture {
31
public:
32
enum { MAX_RAMPS = 3 };
33
Draw::Texture *texture;
34
int lastFrame;
35
int rampLengths[MAX_RAMPS];
36
int rampStarts[MAX_RAMPS];
37
};
38
39
// For CLUT depal shaders, and other pre-bind texture shaders.
40
// Caches both shaders and palette textures.
41
class TextureShaderCache {
42
public:
43
TextureShaderCache(Draw::DrawContext *draw, Draw2D *draw2D);
44
~TextureShaderCache();
45
46
Draw2DPipeline *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat, bool smoothedDepal, u32 depthUpperBits);
47
ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, const u32 *rawClut);
48
49
Draw::SamplerState *GetSampler(bool linearFilter);
50
51
void Clear();
52
void Decimate();
53
std::vector<std::string> DebugGetShaderIDs(DebugShaderType type);
54
std::string DebugGetShaderString(const std::string &id, DebugShaderType type, DebugShaderStringType stringType);
55
56
void DeviceLost();
57
void DeviceRestore(Draw::DrawContext *draw);
58
59
private:
60
Draw::DrawContext *draw_;
61
Draw::SamplerState *nearestSampler_ = nullptr;
62
Draw::SamplerState *linearSampler_ = nullptr;
63
Draw2D *draw2D_;
64
65
std::map<u64, Draw2DPipeline *> depalCache_;
66
std::map<u32, ClutTexture *> texCache_;
67
};
68
69