summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-09-24 10:57:45 -0400
committerGravatar FernandoS272019-10-04 18:52:55 -0400
commit000ad558dd21a0f1f0be57ddbb59540956314896 (patch)
treea4ea12c3500f86e139a6da600133ba8c4dcb66bc /src
parentShader_IR: clean up AST handling and add documentation. (diff)
downloadyuzu-000ad558dd21a0f1f0be57ddbb59540956314896.tar.gz
yuzu-000ad558dd21a0f1f0be57ddbb59540956314896.tar.xz
yuzu-000ad558dd21a0f1f0be57ddbb59540956314896.zip
vk_shader_decompiler: Clean code and be const correct.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp2
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp12
2 files changed, 6 insertions, 8 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 572fae353..bff1067a4 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -19,8 +19,8 @@
19#include "video_core/renderer_opengl/gl_device.h" 19#include "video_core/renderer_opengl/gl_device.h"
20#include "video_core/renderer_opengl/gl_rasterizer.h" 20#include "video_core/renderer_opengl/gl_rasterizer.h"
21#include "video_core/renderer_opengl/gl_shader_decompiler.h" 21#include "video_core/renderer_opengl/gl_shader_decompiler.h"
22#include "video_core/shader/node.h"
23#include "video_core/shader/ast.h" 22#include "video_core/shader/ast.h"
23#include "video_core/shader/node.h"
24#include "video_core/shader/shader_ir.h" 24#include "video_core/shader/shader_ir.h"
25 25
26namespace OpenGL::GLShader { 26namespace OpenGL::GLShader {
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 11effe4a1..4bc7da198 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1659,12 +1659,12 @@ public:
1659 } 1659 }
1660 1660
1661 void operator()(VideoCommon::Shader::ExprPredicate& expr) { 1661 void operator()(VideoCommon::Shader::ExprPredicate& expr) {
1662 auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate); 1662 const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate);
1663 current_id = decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred))); 1663 current_id = decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred)));
1664 } 1664 }
1665 1665
1666 void operator()(VideoCommon::Shader::ExprCondCode& expr) { 1666 void operator()(VideoCommon::Shader::ExprCondCode& expr) {
1667 Node cc = decomp.ir.GetConditionCode(expr.cc); 1667 const Node cc = decomp.ir.GetConditionCode(expr.cc);
1668 Id target; 1668 Id target;
1669 1669
1670 if (const auto pred = std::get_if<PredicateNode>(&*cc)) { 1670 if (const auto pred = std::get_if<PredicateNode>(&*cc)) {
@@ -1785,8 +1785,7 @@ public:
1785 } 1785 }
1786 1786
1787 void operator()(VideoCommon::Shader::ASTReturn& ast) { 1787 void operator()(VideoCommon::Shader::ASTReturn& ast) {
1788 bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); 1788 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) {
1789 if (!is_true) {
1790 ExprDecompiler expr_parser{decomp}; 1789 ExprDecompiler expr_parser{decomp};
1791 const Id condition = expr_parser.Visit(ast.condition); 1790 const Id condition = expr_parser.Visit(ast.condition);
1792 const Id then_label = decomp.OpLabel(); 1791 const Id then_label = decomp.OpLabel();
@@ -1816,8 +1815,7 @@ public:
1816 } 1815 }
1817 1816
1818 void operator()(VideoCommon::Shader::ASTBreak& ast) { 1817 void operator()(VideoCommon::Shader::ASTBreak& ast) {
1819 bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); 1818 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) {
1820 if (!is_true) {
1821 ExprDecompiler expr_parser{decomp}; 1819 ExprDecompiler expr_parser{decomp};
1822 const Id condition = expr_parser.Visit(ast.condition); 1820 const Id condition = expr_parser.Visit(ast.condition);
1823 const Id then_label = decomp.OpLabel(); 1821 const Id then_label = decomp.OpLabel();
@@ -1846,7 +1844,7 @@ private:
1846}; 1844};
1847 1845
1848void SPIRVDecompiler::DecompileAST() { 1846void SPIRVDecompiler::DecompileAST() {
1849 u32 num_flow_variables = ir.GetASTNumVariables(); 1847 const u32 num_flow_variables = ir.GetASTNumVariables();
1850 for (u32 i = 0; i < num_flow_variables; i++) { 1848 for (u32 i = 0; i < num_flow_variables; i++) {
1851 const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false); 1849 const Id id = OpVariable(t_prv_bool, spv::StorageClass::Private, v_false);
1852 Name(id, fmt::format("flow_var_{}", i)); 1850 Name(id, fmt::format("flow_var_{}", i));