spirv: Initial bindings support
This commit is contained in:
parent
d5d468cf2c
commit
b5d7279d87
23 changed files with 679 additions and 300 deletions
|
@ -11,6 +11,7 @@
|
|||
|
||||
#include <boost/intrusive/list.hpp>
|
||||
|
||||
#include "common/bit_cast.h"
|
||||
#include "shader_recompiler/frontend/ir/condition.h"
|
||||
#include "shader_recompiler/frontend/ir/microinstruction.h"
|
||||
#include "shader_recompiler/frontend/ir/value.h"
|
||||
|
@ -68,6 +69,18 @@ public:
|
|||
/// Gets an immutable span to the immediate predecessors.
|
||||
[[nodiscard]] std::span<Block* const> ImmediatePredecessors() const noexcept;
|
||||
|
||||
/// Intrusively store the host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
void SetDefinition(DefinitionType def) {
|
||||
definition = Common::BitCast<u32>(def);
|
||||
}
|
||||
|
||||
/// Return the intrusively stored host definition of this instruction.
|
||||
template <typename DefinitionType>
|
||||
[[nodiscard]] DefinitionType Definition() const noexcept {
|
||||
return Common::BitCast<DefinitionType>(definition);
|
||||
}
|
||||
|
||||
[[nodiscard]] Condition BranchCondition() const noexcept {
|
||||
return branch_cond;
|
||||
}
|
||||
|
@ -161,6 +174,9 @@ private:
|
|||
Block* branch_false{nullptr};
|
||||
/// Block immediate predecessors
|
||||
std::vector<Block*> imm_predecessors;
|
||||
|
||||
/// Intrusively stored host definition of this block.
|
||||
u32 definition{};
|
||||
};
|
||||
|
||||
using BlockList = std::vector<Block*>;
|
||||
|
|
|
@ -9,11 +9,13 @@
|
|||
#include <boost/container/small_vector.hpp>
|
||||
|
||||
#include "shader_recompiler/frontend/ir/function.h"
|
||||
#include "shader_recompiler/shader_info.h"
|
||||
|
||||
namespace Shader::IR {
|
||||
|
||||
struct Program {
|
||||
boost::container::small_vector<Function, 1> functions;
|
||||
Info info;
|
||||
};
|
||||
|
||||
[[nodiscard]] std::string DumpProgram(const Program& program);
|
||||
|
|
|
@ -53,21 +53,22 @@ IR::Program TranslateProgram(ObjectPool<IR::Inst>& inst_pool, ObjectPool<IR::Blo
|
|||
for (Flow::Function& cfg_function : cfg.Functions()) {
|
||||
functions.push_back(IR::Function{
|
||||
.blocks{TranslateCode(inst_pool, block_pool, env, cfg_function)},
|
||||
.post_order_blocks{},
|
||||
});
|
||||
}
|
||||
|
||||
fmt::print(stdout, "No optimizations: {}", IR::DumpProgram(program));
|
||||
for (IR::Function& function : functions) {
|
||||
function.post_order_blocks = PostOrder(function.blocks);
|
||||
Optimization::SsaRewritePass(function.post_order_blocks);
|
||||
}
|
||||
fmt::print(stdout, "{}\n", IR::DumpProgram(program));
|
||||
Optimization::GlobalMemoryToStorageBufferPass(program);
|
||||
for (IR::Function& function : functions) {
|
||||
Optimization::PostOrderInvoke(Optimization::GlobalMemoryToStorageBufferPass, function);
|
||||
Optimization::PostOrderInvoke(Optimization::ConstantPropagationPass, function);
|
||||
Optimization::PostOrderInvoke(Optimization::DeadCodeEliminationPass, function);
|
||||
Optimization::IdentityRemovalPass(function);
|
||||
Optimization::VerificationPass(function);
|
||||
}
|
||||
Optimization::CollectShaderInfoPass(program);
|
||||
//*/
|
||||
return program;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue