summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Lioncash2019-10-17 19:36:55 -0400
committerGravatar Lioncash2019-10-17 19:44:00 -0400
commitc6bec9aa103c70eb8c64382e6a4297d5ab141b83 (patch)
tree1a1edba3bf8fac4d103b25adc250e302ca6a4d10 /src
parentMerge pull request #2980 from lioncash/warn (diff)
downloadyuzu-c6bec9aa103c70eb8c64382e6a4297d5ab141b83.tar.gz
yuzu-c6bec9aa103c70eb8c64382e6a4297d5ab141b83.tar.xz
yuzu-c6bec9aa103c70eb8c64382e6a4297d5ab141b83.zip
vk_shader_decompiler: Mark operator() function parameters as const references
These parameters aren't actually modified in any way, so they can be made const references.
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp44
1 files changed, 23 insertions, 21 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 8bcd04221..3fb016b96 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1648,32 +1648,32 @@ class ExprDecompiler {
1648public: 1648public:
1649 explicit ExprDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {} 1649 explicit ExprDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
1650 1650
1651 Id operator()(VideoCommon::Shader::ExprAnd& expr) { 1651 Id operator()(const ExprAnd& expr) {
1652 const Id type_def = decomp.GetTypeDefinition(Type::Bool); 1652 const Id type_def = decomp.GetTypeDefinition(Type::Bool);
1653 const Id op1 = Visit(expr.operand1); 1653 const Id op1 = Visit(expr.operand1);
1654 const Id op2 = Visit(expr.operand2); 1654 const Id op2 = Visit(expr.operand2);
1655 return decomp.Emit(decomp.OpLogicalAnd(type_def, op1, op2)); 1655 return decomp.Emit(decomp.OpLogicalAnd(type_def, op1, op2));
1656 } 1656 }
1657 1657
1658 Id operator()(VideoCommon::Shader::ExprOr& expr) { 1658 Id operator()(const ExprOr& expr) {
1659 const Id type_def = decomp.GetTypeDefinition(Type::Bool); 1659 const Id type_def = decomp.GetTypeDefinition(Type::Bool);
1660 const Id op1 = Visit(expr.operand1); 1660 const Id op1 = Visit(expr.operand1);
1661 const Id op2 = Visit(expr.operand2); 1661 const Id op2 = Visit(expr.operand2);
1662 return decomp.Emit(decomp.OpLogicalOr(type_def, op1, op2)); 1662 return decomp.Emit(decomp.OpLogicalOr(type_def, op1, op2));
1663 } 1663 }
1664 1664
1665 Id operator()(VideoCommon::Shader::ExprNot& expr) { 1665 Id operator()(const ExprNot& expr) {
1666 const Id type_def = decomp.GetTypeDefinition(Type::Bool); 1666 const Id type_def = decomp.GetTypeDefinition(Type::Bool);
1667 const Id op1 = Visit(expr.operand1); 1667 const Id op1 = Visit(expr.operand1);
1668 return decomp.Emit(decomp.OpLogicalNot(type_def, op1)); 1668 return decomp.Emit(decomp.OpLogicalNot(type_def, op1));
1669 } 1669 }
1670 1670
1671 Id operator()(VideoCommon::Shader::ExprPredicate& expr) { 1671 Id operator()(const ExprPredicate& expr) {
1672 const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate); 1672 const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate);
1673 return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred))); 1673 return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred)));
1674 } 1674 }
1675 1675
1676 Id operator()(VideoCommon::Shader::ExprCondCode& expr) { 1676 Id operator()(const ExprCondCode& expr) {
1677 const Node cc = decomp.ir.GetConditionCode(expr.cc); 1677 const Node cc = decomp.ir.GetConditionCode(expr.cc);
1678 Id target; 1678 Id target;
1679 1679
@@ -1693,15 +1693,15 @@ public:
1693 return decomp.Emit(decomp.OpLoad(decomp.t_bool, target)); 1693 return decomp.Emit(decomp.OpLoad(decomp.t_bool, target));
1694 } 1694 }
1695 1695
1696 Id operator()(VideoCommon::Shader::ExprVar& expr) { 1696 Id operator()(const ExprVar& expr) {
1697 return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.flow_variables.at(expr.var_index))); 1697 return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.flow_variables.at(expr.var_index)));
1698 } 1698 }
1699 1699
1700 Id operator()(VideoCommon::Shader::ExprBoolean& expr) { 1700 Id operator()(const ExprBoolean& expr) {
1701 return expr.value ? decomp.v_true : decomp.v_false; 1701 return expr.value ? decomp.v_true : decomp.v_false;
1702 } 1702 }
1703 1703
1704 Id Visit(VideoCommon::Shader::Expr& node) { 1704 Id Visit(const Expr& node) {
1705 return std::visit(*this, *node); 1705 return std::visit(*this, *node);
1706 } 1706 }
1707 1707
@@ -1713,7 +1713,7 @@ class ASTDecompiler {
1713public: 1713public:
1714 explicit ASTDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {} 1714 explicit ASTDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
1715 1715
1716 void operator()(VideoCommon::Shader::ASTProgram& ast) { 1716 void operator()(const ASTProgram& ast) {
1717 ASTNode current = ast.nodes.GetFirst(); 1717 ASTNode current = ast.nodes.GetFirst();
1718 while (current) { 1718 while (current) {
1719 Visit(current); 1719 Visit(current);
@@ -1721,7 +1721,7 @@ public:
1721 } 1721 }
1722 } 1722 }
1723 1723
1724 void operator()(VideoCommon::Shader::ASTIfThen& ast) { 1724 void operator()(const ASTIfThen& ast) {
1725 ExprDecompiler expr_parser{decomp}; 1725 ExprDecompiler expr_parser{decomp};
1726 const Id condition = expr_parser.Visit(ast.condition); 1726 const Id condition = expr_parser.Visit(ast.condition);
1727 const Id then_label = decomp.OpLabel(); 1727 const Id then_label = decomp.OpLabel();
@@ -1738,33 +1738,33 @@ public:
1738 decomp.Emit(endif_label); 1738 decomp.Emit(endif_label);
1739 } 1739 }
1740 1740
1741 void operator()(VideoCommon::Shader::ASTIfElse& ast) { 1741 void operator()([[maybe_unused]] const ASTIfElse& ast) {
1742 UNREACHABLE(); 1742 UNREACHABLE();
1743 } 1743 }
1744 1744
1745 void operator()(VideoCommon::Shader::ASTBlockEncoded& ast) { 1745 void operator()([[maybe_unused]] const ASTBlockEncoded& ast) {
1746 UNREACHABLE(); 1746 UNREACHABLE();
1747 } 1747 }
1748 1748
1749 void operator()(VideoCommon::Shader::ASTBlockDecoded& ast) { 1749 void operator()(const ASTBlockDecoded& ast) {
1750 decomp.VisitBasicBlock(ast.nodes); 1750 decomp.VisitBasicBlock(ast.nodes);
1751 } 1751 }
1752 1752
1753 void operator()(VideoCommon::Shader::ASTVarSet& ast) { 1753 void operator()(const ASTVarSet& ast) {
1754 ExprDecompiler expr_parser{decomp}; 1754 ExprDecompiler expr_parser{decomp};
1755 const Id condition = expr_parser.Visit(ast.condition); 1755 const Id condition = expr_parser.Visit(ast.condition);
1756 decomp.Emit(decomp.OpStore(decomp.flow_variables.at(ast.index), condition)); 1756 decomp.Emit(decomp.OpStore(decomp.flow_variables.at(ast.index), condition));
1757 } 1757 }
1758 1758
1759 void operator()(VideoCommon::Shader::ASTLabel& ast) { 1759 void operator()([[maybe_unused]] const ASTLabel& ast) {
1760 // Do nothing 1760 // Do nothing
1761 } 1761 }
1762 1762
1763 void operator()(VideoCommon::Shader::ASTGoto& ast) { 1763 void operator()([[maybe_unused]] const ASTGoto& ast) {
1764 UNREACHABLE(); 1764 UNREACHABLE();
1765 } 1765 }
1766 1766
1767 void operator()(VideoCommon::Shader::ASTDoWhile& ast) { 1767 void operator()(const ASTDoWhile& ast) {
1768 const Id loop_label = decomp.OpLabel(); 1768 const Id loop_label = decomp.OpLabel();
1769 const Id endloop_label = decomp.OpLabel(); 1769 const Id endloop_label = decomp.OpLabel();
1770 const Id loop_start_block = decomp.OpLabel(); 1770 const Id loop_start_block = decomp.OpLabel();
@@ -1787,7 +1787,7 @@ public:
1787 decomp.Emit(endloop_label); 1787 decomp.Emit(endloop_label);
1788 } 1788 }
1789 1789
1790 void operator()(VideoCommon::Shader::ASTReturn& ast) { 1790 void operator()(const ASTReturn& ast) {
1791 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) { 1791 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) {
1792 ExprDecompiler expr_parser{decomp}; 1792 ExprDecompiler expr_parser{decomp};
1793 const Id condition = expr_parser.Visit(ast.condition); 1793 const Id condition = expr_parser.Visit(ast.condition);
@@ -1817,7 +1817,7 @@ public:
1817 } 1817 }
1818 } 1818 }
1819 1819
1820 void operator()(VideoCommon::Shader::ASTBreak& ast) { 1820 void operator()(const ASTBreak& ast) {
1821 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) { 1821 if (!VideoCommon::Shader::ExprIsTrue(ast.condition)) {
1822 ExprDecompiler expr_parser{decomp}; 1822 ExprDecompiler expr_parser{decomp};
1823 const Id condition = expr_parser.Visit(ast.condition); 1823 const Id condition = expr_parser.Visit(ast.condition);
@@ -1837,7 +1837,7 @@ public:
1837 } 1837 }
1838 } 1838 }
1839 1839
1840 void Visit(VideoCommon::Shader::ASTNode& node) { 1840 void Visit(const ASTNode& node) {
1841 std::visit(*this, *node->GetInnerData()); 1841 std::visit(*this, *node->GetInnerData());
1842 } 1842 }
1843 1843
@@ -1853,9 +1853,11 @@ void SPIRVDecompiler::DecompileAST() {
1853 Name(id, fmt::format("flow_var_{}", i)); 1853 Name(id, fmt::format("flow_var_{}", i));
1854 flow_variables.emplace(i, AddGlobalVariable(id)); 1854 flow_variables.emplace(i, AddGlobalVariable(id));
1855 } 1855 }
1856
1857 const ASTNode program = ir.GetASTProgram();
1856 ASTDecompiler decompiler{*this}; 1858 ASTDecompiler decompiler{*this};
1857 VideoCommon::Shader::ASTNode program = ir.GetASTProgram();
1858 decompiler.Visit(program); 1859 decompiler.Visit(program);
1860
1859 const Id next_block = OpLabel(); 1861 const Id next_block = OpLabel();
1860 Emit(OpBranch(next_block)); 1862 Emit(OpBranch(next_block));
1861 Emit(next_block); 1863 Emit(next_block);