From b3371ed09e6866e235141119f9eecc2bb962dc8d Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 30 Dec 2019 13:54:53 -0400 Subject: Shader_IR: add the ability to amend code in the shader ir. This commit introduces a mechanism by which shader IR code can be amended and extended. This useful for track algorithms where certain information can derived from before the track such as indexes to array samplers. --- .../renderer_vulkan/vk_shader_decompiler.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (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 a8baf91de..50feeb003 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -954,6 +954,12 @@ private: Expression Visit(const Node& node) { if (const auto operation = std::get_if(&*node)) { + auto amend_index = operation->GetAmendIndex(); + if (amend_index) { + const Node& amend_node = ir.GetAmendNode(*amend_index); + [[maybe_unused]] const Type type = Visit(amend_node).type; + ASSERT(type == Type::Void); + } const auto operation_index = static_cast(operation->GetCode()); const auto decompiler = operation_decompilers[operation_index]; if (decompiler == nullptr) { @@ -1142,6 +1148,12 @@ private: } if (const auto conditional = std::get_if(&*node)) { + auto amend_index = conditional->GetAmendIndex(); + if (amend_index) { + const Node& amend_node = ir.GetAmendNode(*amend_index); + [[maybe_unused]] const Type type = Visit(amend_node).type; + ASSERT(type == Type::Void); + } // It's invalid to call conditional on nested nodes, use an operation instead const Id true_label = OpLabel(); const Id skip_label = OpLabel(); @@ -1164,6 +1176,12 @@ private: } if (const auto comment = std::get_if(&*node)) { + auto amend_index = comment->GetAmendIndex(); + if (amend_index) { + const Node& amend_node = ir.GetAmendNode(*amend_index); + [[maybe_unused]] const Type type = Visit(amend_node).type; + ASSERT(type == Type::Void); + } Name(OpUndef(t_void), comment->GetText()); return {}; } -- cgit v1.2.3 From 3dd6b55851978440f39487a6ad06b30b792b3b36 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 4 Jan 2020 14:40:57 -0400 Subject: Shader_IR: Address Feedback --- .../renderer_vulkan/vk_shader_decompiler.cpp | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (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 50feeb003..8fe852ce8 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -954,10 +954,8 @@ private: Expression Visit(const Node& node) { if (const auto operation = std::get_if(&*node)) { - auto amend_index = operation->GetAmendIndex(); - if (amend_index) { - const Node& amend_node = ir.GetAmendNode(*amend_index); - [[maybe_unused]] const Type type = Visit(amend_node).type; + if (const auto amend_index = operation->GetAmendIndex()) { + [[maybe_unused]] const Type type = Visit(ir.GetAmendNode(*amend_index)).type; ASSERT(type == Type::Void); } const auto operation_index = static_cast(operation->GetCode()); @@ -1148,10 +1146,8 @@ private: } if (const auto conditional = std::get_if(&*node)) { - auto amend_index = conditional->GetAmendIndex(); - if (amend_index) { - const Node& amend_node = ir.GetAmendNode(*amend_index); - [[maybe_unused]] const Type type = Visit(amend_node).type; + if (const auto amend_index = conditional->GetAmendIndex()) { + [[maybe_unused]] const Type type = Visit(ir.GetAmendNode(*amend_index)).type; ASSERT(type == Type::Void); } // It's invalid to call conditional on nested nodes, use an operation instead @@ -1176,12 +1172,6 @@ private: } if (const auto comment = std::get_if(&*node)) { - auto amend_index = comment->GetAmendIndex(); - if (amend_index) { - const Node& amend_node = ir.GetAmendNode(*amend_index); - [[maybe_unused]] const Type type = Visit(amend_node).type; - ASSERT(type == Type::Void); - } Name(OpUndef(t_void), comment->GetText()); return {}; } -- cgit v1.2.3