summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/main.cpp
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2021-02-11 16:39:06 -0300
committerGravatar ameerj2021-07-22 21:51:22 -0400
commit9170200a11715d131645d1ffb92e86e6ef0d7e88 (patch)
tree6c6f84c38a9b59d023ecb09c0737ea56da166b64 /src/shader_recompiler/main.cpp
parentspirv: Initial SPIR-V support (diff)
downloadyuzu-9170200a11715d131645d1ffb92e86e6ef0d7e88.tar.gz
yuzu-9170200a11715d131645d1ffb92e86e6ef0d7e88.tar.xz
yuzu-9170200a11715d131645d1ffb92e86e6ef0d7e88.zip
shader: Initial implementation of an AST
Diffstat (limited to 'src/shader_recompiler/main.cpp')
-rw-r--r--src/shader_recompiler/main.cpp29
1 files changed, 21 insertions, 8 deletions
diff --git a/src/shader_recompiler/main.cpp b/src/shader_recompiler/main.cpp
index 9887e066d..3ca1677c4 100644
--- a/src/shader_recompiler/main.cpp
+++ b/src/shader_recompiler/main.cpp
@@ -2,6 +2,7 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono>
5#include <filesystem> 6#include <filesystem>
6 7
7#include <fmt/format.h> 8#include <fmt/format.h>
@@ -36,34 +37,46 @@ void RunDatabase() {
36 ForEachFile("D:\\Shaders\\Database", [&](const std::filesystem::path& path) { 37 ForEachFile("D:\\Shaders\\Database", [&](const std::filesystem::path& path) {
37 map.emplace_back(std::make_unique<FileEnvironment>(path.string().c_str())); 38 map.emplace_back(std::make_unique<FileEnvironment>(path.string().c_str()));
38 }); 39 });
39 for (int i = 0; i < 300; ++i) { 40 auto block_pool{std::make_unique<ObjectPool<Flow::Block>>()};
41 auto t0 = std::chrono::high_resolution_clock::now();
42 int N = 1;
43 int n = 0;
44 for (int i = 0; i < N; ++i) {
40 for (auto& env : map) { 45 for (auto& env : map) {
46 ++n;
41 // fmt::print(stdout, "Decoding {}\n", path.string()); 47 // fmt::print(stdout, "Decoding {}\n", path.string());
48
42 const Location start_address{0}; 49 const Location start_address{0};
43 auto cfg{std::make_unique<Flow::CFG>(*env, start_address)}; 50 block_pool->ReleaseContents();
51 Flow::CFG cfg{*env, *block_pool, start_address};
44 // fmt::print(stdout, "{}\n", cfg->Dot()); 52 // fmt::print(stdout, "{}\n", cfg->Dot());
45 // IR::Program program{env, cfg}; 53 // IR::Program program{env, cfg};
46 // Optimize(program); 54 // Optimize(program);
47 // const std::string code{EmitGLASM(program)}; 55 // const std::string code{EmitGLASM(program)};
48 } 56 }
49 } 57 }
58 auto t = std::chrono::high_resolution_clock::now();
59 fmt::print(stdout, "{} ms",
60 std::chrono::duration_cast<std::chrono::milliseconds>(t - t0).count() / double(N));
50} 61}
51 62
52int main() { 63int main() {
53 // RunDatabase(); 64 // RunDatabase();
54 65
66 auto flow_block_pool{std::make_unique<ObjectPool<Flow::Block>>()};
55 auto inst_pool{std::make_unique<ObjectPool<IR::Inst>>()}; 67 auto inst_pool{std::make_unique<ObjectPool<IR::Inst>>()};
56 auto block_pool{std::make_unique<ObjectPool<IR::Block>>()}; 68 auto block_pool{std::make_unique<ObjectPool<IR::Block>>()};
57 69
58 // FileEnvironment env{"D:\\Shaders\\Database\\test.bin"}; 70 FileEnvironment env{"D:\\Shaders\\Database\\Oninaki\\CS8F146B41DB6BD826.bin"};
59 FileEnvironment env{"D:\\Shaders\\Database\\Oninaki\\CS15C2FB1F0B965767.bin"}; 71 // FileEnvironment env{"D:\\Shaders\\shader.bin"};
60 for (int i = 0; i < 1; ++i) { 72 for (int i = 0; i < 1; ++i) {
61 block_pool->ReleaseContents(); 73 block_pool->ReleaseContents();
62 inst_pool->ReleaseContents(); 74 inst_pool->ReleaseContents();
63 auto cfg{std::make_unique<Flow::CFG>(env, 0)}; 75 flow_block_pool->ReleaseContents();
64 // fmt::print(stdout, "{}\n", cfg->Dot()); 76 Flow::CFG cfg{env, *flow_block_pool, 0};
65 IR::Program program{TranslateProgram(*inst_pool, *block_pool, env, *cfg)}; 77 fmt::print(stdout, "{}\n", cfg.Dot());
66 // fmt::print(stdout, "{}\n", IR::DumpProgram(program)); 78 IR::Program program{TranslateProgram(*inst_pool, *block_pool, env, cfg)};
79 fmt::print(stdout, "{}\n", IR::DumpProgram(program));
67 Backend::SPIRV::EmitSPIRV spirv{program}; 80 Backend::SPIRV::EmitSPIRV spirv{program};
68 } 81 }
69} 82}