Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add generic "PostShader" functionality, replacing FXAA (it's one of t…
…hem). Replaces #4018, sorry DanyalZia :)
- Loading branch information
Showing
23 changed files
with
342 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,109 @@ | |||
// Copyright (c) 2013- PPSSPP Project. | |||
|
|||
// This program is free software: you can redistribute it and/or modify | |||
// it under the terms of the GNU General Public License as published by | |||
// the Free Software Foundation, version 2.0 or later versions. | |||
|
|||
// This program is distributed in the hope that it will be useful, | |||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
// GNU General Public License 2.0 for more details. | |||
|
|||
// A copy of the GPL 2.0 should have been included with the program. | |||
// If not, see http://www.gnu.org/licenses/ | |||
|
|||
// Official git repository and contact information can be found at | |||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | |||
|
|||
|
|||
// Postprocessing shader manager | |||
|
|||
#include <string> | |||
#include <vector> | |||
|
|||
#include "base/logging.h" | |||
#include "file/ini_file.h" | |||
#include "file/file_util.h" | |||
#include "file/vfs.h" | |||
|
|||
#include "GPU/Common/PostShader.h" | |||
|
|||
static std::vector<ShaderInfo> shaderInfo; | |||
|
|||
// Scans the directories for shader ini files and collects info about all the shaders found. | |||
// Additionally, scan the VFS assets. (TODO) | |||
|
|||
void LoadPostShaderInfo(std::vector<std::string> directories) { | |||
shaderInfo.clear(); | |||
ShaderInfo off; | |||
off.name = "Off"; | |||
off.section = "Off"; | |||
shaderInfo.push_back(off); | |||
|
|||
for (size_t d = 0; d < directories.size(); d++) { | |||
std::vector<FileInfo> fileInfo; | |||
getFilesInDir(directories[d].c_str(), &fileInfo, "ini:"); | |||
if (fileInfo.size() == 0) { | |||
// TODO: Really gotta fix the filter, now it's gonna open shaders as ini files.. | |||
VFSGetFileListing(directories[d].c_str(), &fileInfo, "ini:"); | |||
} | |||
|
|||
for (size_t f = 0; f < fileInfo.size(); f++) { | |||
IniFile ini; | |||
bool success = false; | |||
std::string name = fileInfo[f].fullName; | |||
std::string path = directories[d]; | |||
// Hack around Android VFS path bug. really need to redesign this. | |||
if (name.substr(0, 7) == "assets/") | |||
name = name.substr(7); | |||
if (path.substr(0, 7) == "assets/") | |||
path = path.substr(7); | |||
if (!ini.LoadFromVFS(name)) { | |||
// vsh load. meh. | |||
} else { | |||
success = true; | |||
} | |||
if (!success) | |||
continue; | |||
|
|||
// Alright, let's loop through the sections and see if any is a shader. | |||
// Ignore the first section (which only consists of the comments before the first real one). | |||
for (size_t i = 1; i < ini.Sections().size(); i++) { | |||
IniFile::Section §ion = ini.Sections()[i]; | |||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
|||
if (section.Exists("Fragment") && section.Exists("Vertex")) { | |||
// Valid shader! | |||
ShaderInfo info; | |||
std::string temp; | |||
info.section = section.name(); | |||
section.Get("Name", &info.name, section.name().c_str()); | |||
section.Get("Fragment", &temp, ""); | |||
info.fragmentShaderFile = path + "/" + temp; | |||
section.Get("Vertex", &temp, ""); | |||
info.vertexShaderFile = path + "/" + temp; | |||
shaderInfo.push_back(info); | |||
} | |||
} | |||
} | |||
} | |||
} | |||
|
|||
// Scans the directories for shader ini files and collects info about all the shaders found. | |||
void LoadAllPostShaderInfo() { | |||
std::vector<std::string> directories; | |||
directories.push_back("assets/shaders"); | |||
LoadPostShaderInfo(directories); | |||
} | |||
|
|||
const ShaderInfo *GetPostShaderInfo(std::string name) { | |||
LoadAllPostShaderInfo(); | |||
for (size_t i = 0; i < shaderInfo.size(); i++) { | |||
if (shaderInfo[i].section == name) | |||
return &shaderInfo[i]; | |||
} | |||
return 0; | |||
} | |||
|
|||
const std::vector<ShaderInfo> &GetAllPostShaderInfo() { | |||
LoadAllPostShaderInfo(); | |||
return shaderInfo; | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,41 @@ | |||
// Copyright (c) 2013- PPSSPP Project. | |||
|
|||
// This program is free software: you can redistribute it and/or modify | |||
// it under the terms of the GNU General Public License as published by | |||
// the Free Software Foundation, version 2.0 or later versions. | |||
|
|||
// This program is distributed in the hope that it will be useful, | |||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
// GNU General Public License 2.0 for more details. | |||
|
|||
// A copy of the GPL 2.0 should have been included with the program. | |||
// If not, see http://www.gnu.org/licenses/ | |||
|
|||
// Official git repository and contact information can be found at | |||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/. | |||
|
|||
|
|||
// Postprocessing shader manager | |||
// For FXAA, "Natural", bloom, B&W, cross processing and whatnot. | |||
|
|||
#include <string> | |||
#include <vector> | |||
|
|||
#include "file/ini_file.h" | |||
|
|||
struct ShaderInfo { | |||
std::string iniFile; // which ini file was this definition in? So we can write settings back later | |||
std::string section; // ini file section. This is saved. | |||
std::string name; // Fancy display name. TODO: Not using yet. | |||
|
|||
std::string fragmentShaderFile; | |||
std::string vertexShaderFile; | |||
|
|||
// TODO: Add support for all kinds of fun options like mapping the depth buffer, | |||
// SRGB texture reads, multiple shaders chained, etc. | |||
}; | |||
|
|||
const ShaderInfo *GetPostShaderInfo(std::string name); | |||
|
|||
const std::vector<ShaderInfo> &GetAllPostShaderInfo(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
This seems to break Windows compilation, at least for me, in 2010 mode:
Edit: 2013 doesn't like it either.