// Copyright (c) 2013- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.161718// Postprocessing shader manager19// For FXAA, "Natural", bloom, B&W, cross processing and whatnot.2021#pragma once2223#include <string>24#include <vector>2526#include "Common/GPU/thin3d.h"2728struct ShaderInfo {29Path iniFile; // which ini file was this definition in? So we can write settings back later30std::string section; // ini file section. This is saved.31std::string name; // Fancy display name.32std::string parent; // Parent shader ini section name.3334Path fragmentShaderFile;35Path vertexShaderFile;3637// Show this shader in lists (i.e. not just for chaining.)38bool visible;39// Run at output instead of input resolution40bool outputResolution;41// Use x1 rendering res + nearest screen scaling filter42bool isUpscalingFilter;43// Is used to post-process stereo-rendering to mono, like red/blue.44bool isStereo;45// Use 2x display resolution for supersampling with blurry shaders.46int SSAAFilterLevel;47// Force constant/max refresh for animated filters48bool requires60fps;49// Takes previous frame as input (for blending effects.)50bool usePreviousFrame;5152struct Setting {53std::string name;54float value;55float maxValue;56float minValue;57float step;58};59Setting settings[4];6061// TODO: Add support for all kinds of fun options like mapping the depth buffer,62// SRGB texture reads, etc. prev shader?6364bool operator == (const std::string &other) const {65return name == other;66}67bool operator == (const ShaderInfo &other) const {68return name == other.name;69}7071bool operator < (const ShaderInfo &other) const {72if (name < other.name) return true;73if (name > other.name) return false;74// Tie breaker75if (iniFile < other.iniFile) return true;76if (iniFile > other.iniFile) return false;77return false;78}79};8081struct TextureShaderInfo {82Path iniFile;83std::string section;84std::string name;8586Path computeShaderFile;8788// Upscaling shaders have a fixed scale factor.89int scaleFactor;9091bool operator == (const std::string &other) const {92return name == other;93}94bool operator == (const TextureShaderInfo &other) const {95return name == other.name;96}9798bool operator < (const TextureShaderInfo &other) const {99if (name < other.name) return true;100if (name > other.name) return false;101// Tie breaker102if (iniFile < other.iniFile) return true;103if (iniFile > other.iniFile) return false;104return false;105}106};107108void ReloadAllPostShaderInfo(Draw::DrawContext *draw);109110const ShaderInfo *GetPostShaderInfo(std::string_view name);111std::vector<const ShaderInfo *> GetPostShaderChain(const std::string &name);112std::vector<const ShaderInfo *> GetFullPostShadersChain(const std::vector<std::string> &names);113bool PostShaderChainRequires60FPS(const std::vector<const ShaderInfo *> &chain);114const std::vector<ShaderInfo> &GetAllPostShaderInfo();115116const TextureShaderInfo *GetTextureShaderInfo(std::string_view name);117const std::vector<TextureShaderInfo> &GetAllTextureShaderInfo();118void RemoveUnknownPostShaders(std::vector<std::string> *names);119120// Call this any time you alter the postshader list. It makes sure121// that "usePrevFrame" shaders are at the end, and that there's only one.122// It'll also enforce any similar future rules.123void FixPostShaderOrder(std::vector<std::string> *names);124125126