diff options
| author | 2021-02-16 04:10:22 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | b5d7279d878211654b4abb165d94af763a365f47 (patch) | |
| tree | 9b3a7b6e9d7d2b8945fe87d27ff75f1712ef06aa /src/shader_recompiler/frontend | |
| parent | shader: Improve object pool (diff) | |
| download | yuzu-b5d7279d878211654b4abb165d94af763a365f47.tar.gz yuzu-b5d7279d878211654b4abb165d94af763a365f47.tar.xz yuzu-b5d7279d878211654b4abb165d94af763a365f47.zip | |
spirv: Initial bindings support
Diffstat (limited to 'src/shader_recompiler/frontend')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/basic_block.h | 16 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/program.h | 2 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/program.cpp | 7 |
3 files changed, 22 insertions, 3 deletions
diff --git a/src/shader_recompiler/frontend/ir/basic_block.h b/src/shader_recompiler/frontend/ir/basic_block.h index 778b32e43..b14a35ec5 100644 --- a/src/shader_recompiler/frontend/ir/basic_block.h +++ b/src/shader_recompiler/frontend/ir/basic_block.h | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | 11 | ||
| 12 | #include <boost/intrusive/list.hpp> | 12 | #include <boost/intrusive/list.hpp> |
| 13 | 13 | ||
| 14 | #include "common/bit_cast.h" | ||
| 14 | #include "shader_recompiler/frontend/ir/condition.h" | 15 | #include "shader_recompiler/frontend/ir/condition.h" |
| 15 | #include "shader_recompiler/frontend/ir/microinstruction.h" | 16 | #include "shader_recompiler/frontend/ir/microinstruction.h" |
| 16 | #include "shader_recompiler/frontend/ir/value.h" | 17 | #include "shader_recompiler/frontend/ir/value.h" |
| @@ -68,6 +69,18 @@ public: | |||
| 68 | /// Gets an immutable span to the immediate predecessors. | 69 | /// Gets an immutable span to the immediate predecessors. |
| 69 | [[nodiscard]] std::span<Block* const> ImmediatePredecessors() const noexcept; | 70 | [[nodiscard]] std::span<Block* const> ImmediatePredecessors() const noexcept; |
| 70 | 71 | ||
| 72 | /// Intrusively store the host definition of this instruction. | ||
| 73 | template <typename DefinitionType> | ||
| 74 | void SetDefinition(DefinitionType def) { | ||
| 75 | definition = Common::BitCast<u32>(def); | ||
| 76 | } | ||
| 77 | |||
| 78 | /// Return the intrusively stored host definition of this instruction. | ||
| 79 | template <typename DefinitionType> | ||
| 80 | [[nodiscard]] DefinitionType Definition() const noexcept { | ||
| 81 | return Common::BitCast<DefinitionType>(definition); | ||
| 82 | } | ||
| 83 | |||
| 71 | [[nodiscard]] Condition BranchCondition() const noexcept { | 84 | [[nodiscard]] Condition BranchCondition() const noexcept { |
| 72 | return branch_cond; | 85 | return branch_cond; |
| 73 | } | 86 | } |
| @@ -161,6 +174,9 @@ private: | |||
| 161 | Block* branch_false{nullptr}; | 174 | Block* branch_false{nullptr}; |
| 162 | /// Block immediate predecessors | 175 | /// Block immediate predecessors |
| 163 | std::vector<Block*> imm_predecessors; | 176 | std::vector<Block*> imm_predecessors; |
| 177 | |||
| 178 | /// Intrusively stored host definition of this block. | ||
| 179 | u32 definition{}; | ||
| 164 | }; | 180 | }; |
| 165 | 181 | ||
| 166 | using BlockList = std::vector<Block*>; | 182 | using BlockList = std::vector<Block*>; |
diff --git a/src/shader_recompiler/frontend/ir/program.h b/src/shader_recompiler/frontend/ir/program.h index efaf1aa1e..98aab2dc6 100644 --- a/src/shader_recompiler/frontend/ir/program.h +++ b/src/shader_recompiler/frontend/ir/program.h | |||
| @@ -9,11 +9,13 @@ | |||
| 9 | #include <boost/container/small_vector.hpp> | 9 | #include <boost/container/small_vector.hpp> |
| 10 | 10 | ||
| 11 | #include "shader_recompiler/frontend/ir/function.h" | 11 | #include "shader_recompiler/frontend/ir/function.h" |
| 12 | #include "shader_recompiler/shader_info.h" | ||
| 12 | 13 | ||
| 13 | namespace Shader::IR { | 14 | namespace Shader::IR { |
| 14 | 15 | ||
| 15 | struct Program { | 16 | struct Program { |
| 16 | boost::container::small_vector<Function, 1> functions; | 17 | boost::container::small_vector<Function, 1> functions; |
| 18 | Info info; | ||
| 17 | }; | 19 | }; |
| 18 | 20 | ||
| 19 | [[nodiscard]] std::string DumpProgram(const Program& program); | 21 | [[nodiscard]] std::string DumpProgram(const Program& program); |
diff --git a/src/shader_recompiler/frontend/maxwell/program.cpp b/src/shader_recompiler/frontend/maxwell/program.cpp index dab6d68c0..8331d576c 100644 --- a/src/shader_recompiler/frontend/maxwell/program.cpp +++ b/src/shader_recompiler/frontend/maxwell/program.cpp | |||
| @@ -53,21 +53,22 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo | |||
| 53 | for (Flow::Function& cfg_function : cfg.Functions()) { | 53 | for (Flow::Function& cfg_function : cfg.Functions()) { |
| 54 | functions.push_back(IR::Function{ | 54 | functions.push_back(IR::Function{ |
| 55 | .blocks{TranslateCode(inst_pool, block_pool, env, cfg_function)}, | 55 | .blocks{TranslateCode(inst_pool, block_pool, env, cfg_function)}, |
| 56 | .post_order_blocks{}, | ||
| 56 | }); | 57 | }); |
| 57 | } | 58 | } |
| 58 | |||
| 59 | fmt::print(stdout, "No optimizations: {}", IR::DumpProgram(program)); | ||
| 60 | for (IR::Function& function : functions) { | 59 | for (IR::Function& function : functions) { |
| 61 | function.post_order_blocks = PostOrder(function.blocks); | 60 | function.post_order_blocks = PostOrder(function.blocks); |
| 62 | Optimization::SsaRewritePass(function.post_order_blocks); | 61 | Optimization::SsaRewritePass(function.post_order_blocks); |
| 63 | } | 62 | } |
| 63 | fmt::print(stdout, "{}\n", IR::DumpProgram(program)); | ||
| 64 | Optimization::GlobalMemoryToStorageBufferPass(program); | ||
| 64 | for (IR::Function& function : functions) { | 65 | for (IR::Function& function : functions) { |
| 65 | Optimization::PostOrderInvoke(Optimization::GlobalMemoryToStorageBufferPass, function); | ||
| 66 | Optimization::PostOrderInvoke(Optimization::ConstantPropagationPass, function); | 66 | Optimization::PostOrderInvoke(Optimization::ConstantPropagationPass, function); |
| 67 | Optimization::PostOrderInvoke(Optimization::DeadCodeEliminationPass, function); | 67 | Optimization::PostOrderInvoke(Optimization::DeadCodeEliminationPass, function); |
| 68 | Optimization::IdentityRemovalPass(function); | 68 | Optimization::IdentityRemovalPass(function); |
| 69 | Optimization::VerificationPass(function); | 69 | Optimization::VerificationPass(function); |
| 70 | } | 70 | } |
| 71 | Optimization::CollectShaderInfoPass(program); | ||
| 71 | //*/ | 72 | //*/ |
| 72 | return program; | 73 | return program; |
| 73 | } | 74 | } |