From 434856c6368bd4c6930075bbf95b7e834215eb17 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Fri, 15 May 2020 01:56:58 -0300 Subject: [PATCH 1/2] vk_shader_decompiler: Don't assert for void returns Atomic instructions can be used without returning anything and this is valid code. Remove the assert. --- src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 167e20e91..808a265e5 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -1071,8 +1071,7 @@ private: void VisitBasicBlock(const NodeBlock& bb) { for (const auto& node : bb) { - [[maybe_unused]] const Type type = Visit(node).type; - ASSERT(type == Type::Void); + Visit(node); } } From ed4e3249917c5991fd515ff846ae4b52b99153fb Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Thu, 14 May 2020 21:26:37 -0300 Subject: [PATCH 2/2] shader_decompiler: Visit source nodes even when they assign to RZ Some operations like atomicMin were ignored because they returned were being stored to RZ. This operations have a side effect and it was being ignored. --- src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 4 +++- src/video_core/renderer_vulkan/vk_shader_decompiler.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 960ebf1a1..f695ee1db 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp @@ -1538,7 +1538,9 @@ private: Expression target; if (const auto gpr = std::get_if(&*dest)) { if (gpr->GetIndex() == Register::ZeroIndex) { - // Writing to Register::ZeroIndex is a no op + // Writing to Register::ZeroIndex is a no op but we still have to visit the source + // as it might have side effects. + code.AddLine("{};", Visit(src).GetCode()); return {}; } target = {GetRegister(gpr->GetIndex()), Type::Float}; diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp index 808a265e5..1749e068e 100644 --- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp +++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp @@ -1361,7 +1361,9 @@ private: Expression target{}; if (const auto gpr = std::get_if(&*dest)) { if (gpr->GetIndex() == Register::ZeroIndex) { - // Writing to Register::ZeroIndex is a no op + // Writing to Register::ZeroIndex is a no op but we still have to visit its source + // because it might have side effects. + Visit(src); return {}; } target = {registers.at(gpr->GetIndex()), Type::Float};