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/PostShader.h
Views: 1401
1
// Copyright (c) 2013- 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
19
// Postprocessing shader manager
20
// For FXAA, "Natural", bloom, B&W, cross processing and whatnot.
21
22
#pragma once
23
24
#include <string>
25
#include <vector>
26
27
struct ShaderInfo {
28
Path iniFile; // which ini file was this definition in? So we can write settings back later
29
std::string section; // ini file section. This is saved.
30
std::string name; // Fancy display name.
31
std::string parent; // Parent shader ini section name.
32
33
Path fragmentShaderFile;
34
Path vertexShaderFile;
35
36
// Show this shader in lists (i.e. not just for chaining.)
37
bool visible;
38
// Run at output instead of input resolution
39
bool outputResolution;
40
// Use x1 rendering res + nearest screen scaling filter
41
bool isUpscalingFilter;
42
// Is used to post-process stereo-rendering to mono, like red/blue.
43
bool isStereo;
44
// Use 2x display resolution for supersampling with blurry shaders.
45
int SSAAFilterLevel;
46
// Force constant/max refresh for animated filters
47
bool requires60fps;
48
// Takes previous frame as input (for blending effects.)
49
bool usePreviousFrame;
50
51
struct Setting {
52
std::string name;
53
float value;
54
float maxValue;
55
float minValue;
56
float step;
57
};
58
Setting settings[4];
59
60
// TODO: Add support for all kinds of fun options like mapping the depth buffer,
61
// SRGB texture reads, etc. prev shader?
62
63
bool operator == (const std::string &other) const {
64
return name == other;
65
}
66
bool operator == (const ShaderInfo &other) const {
67
return name == other.name;
68
}
69
70
bool operator < (const ShaderInfo &other) const {
71
if (name < other.name) return true;
72
if (name > other.name) return false;
73
// Tie breaker
74
if (iniFile < other.iniFile) return true;
75
if (iniFile > other.iniFile) return false;
76
return false;
77
}
78
};
79
80
struct TextureShaderInfo {
81
Path iniFile;
82
std::string section;
83
std::string name;
84
85
Path computeShaderFile;
86
87
// Upscaling shaders have a fixed scale factor.
88
int scaleFactor;
89
90
bool operator == (const std::string &other) const {
91
return name == other;
92
}
93
bool operator == (const TextureShaderInfo &other) const {
94
return name == other.name;
95
}
96
97
bool operator < (const TextureShaderInfo &other) const {
98
if (name < other.name) return true;
99
if (name > other.name) return false;
100
// Tie breaker
101
if (iniFile < other.iniFile) return true;
102
if (iniFile > other.iniFile) return false;
103
return false;
104
}
105
};
106
107
void ReloadAllPostShaderInfo(Draw::DrawContext *draw);
108
109
const ShaderInfo *GetPostShaderInfo(std::string_view name);
110
std::vector<const ShaderInfo *> GetPostShaderChain(const std::string &name);
111
std::vector<const ShaderInfo *> GetFullPostShadersChain(const std::vector<std::string> &names);
112
bool PostShaderChainRequires60FPS(const std::vector<const ShaderInfo *> &chain);
113
const std::vector<ShaderInfo> &GetAllPostShaderInfo();
114
115
const TextureShaderInfo *GetTextureShaderInfo(std::string_view name);
116
const std::vector<TextureShaderInfo> &GetAllTextureShaderInfo();
117
void RemoveUnknownPostShaders(std::vector<std::string> *names);
118
119
// Call this any time you alter the postshader list. It makes sure
120
// that "usePrevFrame" shaders are at the end, and that there's only one.
121
// It'll also enforce any similar future rules.
122
void FixPostShaderOrder(std::vector<std::string> *names);
123
124