CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/GPU/Common/TextureShaderCommon.h
Views: 1401
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
31
class ClutTexture {
32
public:
33
enum { MAX_RAMPS = 3 };
34
Draw::Texture *texture;
35
int lastFrame;
36
int rampLengths[MAX_RAMPS];
37
int rampStarts[MAX_RAMPS];
38
};
39
40
// For CLUT depal shaders, and other pre-bind texture shaders.
41
// Caches both shaders and palette textures.
42
class TextureShaderCache {
43
public:
44
TextureShaderCache(Draw::DrawContext *draw, Draw2D *draw2D);
45
~TextureShaderCache();
46
47
Draw2DPipeline *GetDepalettizeShader(uint32_t clutMode, GETextureFormat texFormat, GEBufferFormat pixelFormat, bool smoothedDepal, u32 depthUpperBits);
48
ClutTexture GetClutTexture(GEPaletteFormat clutFormat, const u32 clutHash, const u32 *rawClut);
49
50
Draw::SamplerState *GetSampler(bool linearFilter);
51
52
void Clear();
53
void Decimate();
54
std::vector<std::string> DebugGetShaderIDs(DebugShaderType type);
55
std::string DebugGetShaderString(const std::string &id, DebugShaderType type, DebugShaderStringType stringType);
56
57
void DeviceLost();
58
void DeviceRestore(Draw::DrawContext *draw);
59
60
private:
61
Draw::DrawContext *draw_;
62
Draw::SamplerState *nearestSampler_ = nullptr;
63
Draw::SamplerState *linearSampler_ = nullptr;
64
Draw2D *draw2D_;
65
66
std::map<u64, Draw2DPipeline *> depalCache_;
67
std::map<u32, ClutTexture *> texCache_;
68
};
69
70