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/GLES/FragmentTestCacheGLES.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 "Common/CommonTypes.h"
22
#include "GPU/GLES/TextureCacheGLES.h"
23
24
#include "GPU/ge_constants.h"
25
26
struct FragmentTestID {
27
union {
28
struct {
29
u32 alpha;
30
u32 colorRefFunc;
31
u32 colorMask;
32
};
33
u32 d[3];
34
};
35
36
bool operator < (const FragmentTestID &other) const {
37
for (size_t i = 0; i < sizeof(d) / sizeof(u32); i++) {
38
if (d[i] < other.d[i])
39
return true;
40
if (d[i] > other.d[i])
41
return false;
42
}
43
return false;
44
}
45
bool operator == (const FragmentTestID &other) const {
46
for (size_t i = 0; i < sizeof(d) / sizeof(u32); i++) {
47
if (d[i] != other.d[i])
48
return false;
49
}
50
return true;
51
}
52
};
53
54
struct FragmentTestTexture {
55
GLRTexture *texture;
56
int lastFrame;
57
};
58
59
class FragmentTestCacheGLES {
60
public:
61
FragmentTestCacheGLES(Draw::DrawContext *draw);
62
~FragmentTestCacheGLES();
63
64
void SetTextureCache(TextureCacheGLES *tc) {
65
textureCache_ = tc;
66
}
67
68
void BindTestTexture(int slot);
69
70
void DeviceLost() {
71
Clear(false);
72
render_ = nullptr;
73
}
74
void DeviceRestore(Draw::DrawContext *draw);
75
void Clear(bool deleteThem = true);
76
void Decimate();
77
78
private:
79
80
GLRTexture *CreateTestTexture(const GEComparison funcs[4], const u8 refs[4], const u8 masks[4], const bool valid[4]);
81
static FragmentTestID GenerateTestID() ;
82
83
GLRenderManager *render_;
84
TextureCacheGLES *textureCache_;
85
86
std::map<FragmentTestID, FragmentTestTexture> cache_;
87
GLRTexture *lastTexture_ = nullptr;
88
int decimationCounter_ = 0;
89
};
90
91