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