From fec4eb9776bc063d109e5fd5f23906df45e715a1 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 14 Mar 2019 02:30:19 -0300 Subject: vk_shader_decompiler: Implement Visit --- .../renderer_vulkan/vk_shader_decompiler.cpp | 51 +++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) (limited to 'src/video_core/renderer_vulkan') diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 7af8e79df..5f174bb7f 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -149,7 +149,16 @@ public: Emit(default_branch); Emit(OpReturn()); - UNIMPLEMENTED(); + for (const auto& pair : ir.GetBasicBlocks()) { + const auto& [address, bb] = pair; + Emit(labels.at(address)); + + VisitBasicBlock(bb); + + const auto next_it = labels.lower_bound(address + 1); + const Id next_label = next_it != labels.end() ? next_it->second : default_branch; + Emit(OpBranch(next_label)); + } Emit(jump_label); Emit(OpBranch(continue_label)); @@ -451,6 +460,46 @@ private: interfaces.push_back(per_vertex); } + void VisitBasicBlock(const NodeBlock& bb) { + for (const Node node : bb) { + static_cast(Visit(node)); + } + } + + Id Visit(Node node) { + if (const auto operation = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto gpr = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto immediate = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto predicate = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto abuf = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto cbuf = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto gmem = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto conditional = std::get_if(node)) { + UNIMPLEMENTED(); + + } else if (const auto comment = std::get_if(node)) { + Name(Emit(OpUndef(t_void)), comment->GetText()); + return {}; + } + + UNREACHABLE(); + return {}; + } + Id DeclareBuiltIn(spv::BuiltIn builtin, spv::StorageClass storage, Id type, const std::string& name) { const Id id = OpVariable(type, storage); -- cgit v1.2.3