diff options
Diffstat (limited to '')
| -rw-r--r-- | src/shader_recompiler/main.cpp | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/src/shader_recompiler/main.cpp b/src/shader_recompiler/main.cpp new file mode 100644 index 000000000..39f0bf333 --- /dev/null +++ b/src/shader_recompiler/main.cpp | |||
| @@ -0,0 +1,60 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include <filesystem> | ||
| 6 | |||
| 7 | #include <fmt/format.h> | ||
| 8 | |||
| 9 | #include "shader_recompiler/file_environment.h" | ||
| 10 | #include "shader_recompiler/frontend/ir/basic_block.h" | ||
| 11 | #include "shader_recompiler/frontend/ir/ir_emitter.h" | ||
| 12 | #include "shader_recompiler/frontend/maxwell/control_flow.h" | ||
| 13 | #include "shader_recompiler/frontend/maxwell/decode.h" | ||
| 14 | #include "shader_recompiler/frontend/maxwell/location.h" | ||
| 15 | #include "shader_recompiler/frontend/maxwell/program.h" | ||
| 16 | #include "shader_recompiler/frontend/maxwell/translate/translate.h" | ||
| 17 | |||
| 18 | using namespace Shader; | ||
| 19 | using namespace Shader::Maxwell; | ||
| 20 | |||
| 21 | template <typename Func> | ||
| 22 | static void ForEachFile(const std::filesystem::path& path, Func&& func) { | ||
| 23 | std::filesystem::directory_iterator end; | ||
| 24 | for (std::filesystem::directory_iterator it{path}; it != end; ++it) { | ||
| 25 | if (std::filesystem::is_directory(*it)) { | ||
| 26 | ForEachFile(*it, func); | ||
| 27 | } else { | ||
| 28 | func(*it); | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 33 | void RunDatabase() { | ||
| 34 | std::vector<std::unique_ptr<FileEnvironment>> map; | ||
| 35 | ForEachFile("D:\\Shaders\\Database", [&](const std::filesystem::path& path) { | ||
| 36 | map.emplace_back(std::make_unique<FileEnvironment>(path.string().c_str())); | ||
| 37 | }); | ||
| 38 | for (int i = 0; i < 1; ++i) { | ||
| 39 | for (auto& env : map) { | ||
| 40 | // fmt::print(stdout, "Decoding {}\n", path.string()); | ||
| 41 | const Location start_address{0}; | ||
| 42 | auto cfg{std::make_unique<Flow::CFG>(*env, start_address)}; | ||
| 43 | // fmt::print(stdout, "{}\n", cfg.Dot()); | ||
| 44 | // IR::Program program{env, cfg}; | ||
| 45 | // Optimize(program); | ||
| 46 | // const std::string code{EmitGLASM(program)}; | ||
| 47 | } | ||
| 48 | } | ||
| 49 | } | ||
| 50 | |||
| 51 | int main() { | ||
| 52 | // RunDatabase(); | ||
| 53 | |||
| 54 | FileEnvironment env{"D:\\Shaders\\Database\\test.bin"}; | ||
| 55 | auto cfg{std::make_unique<Flow::CFG>(env, 0)}; | ||
| 56 | // fmt::print(stdout, "{}\n", cfg->Dot()); | ||
| 57 | |||
| 58 | Program program{env, *cfg}; | ||
| 59 | fmt::print(stdout, "{}\n", DumpProgram(program)); | ||
| 60 | } | ||