summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_vulkan
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-09-28 21:16:19 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:57 +0200
commit3c09d9abe6d268ada063fd67c08d09fc0fcad613 (patch)
tree27f1442ec1ee8390850dd5099ed3642f1d3f59db /src/video_core/renderer_vulkan
parentvk_shader_decompiler: Correct Branches inside conditionals. (diff)
downloadyuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar.gz
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar.bz2
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar.lz
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar.xz
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.tar.zst
yuzu-3c09d9abe6d268ada063fd67c08d09fc0fcad613.zip
Diffstat (limited to 'src/video_core/renderer_vulkan')
-rw-r--r--src/video_core/renderer_vulkan/vk_shader_decompiler.cpp43
1 files changed, 18 insertions, 25 deletions
diff --git a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
index 2b55a3727..8bcd04221 100644
--- a/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
+++ b/src/video_core/renderer_vulkan/vk_shader_decompiler.cpp
@@ -1646,34 +1646,34 @@ private:
class ExprDecompiler {
public:
- ExprDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
+ explicit ExprDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
- void operator()(VideoCommon::Shader::ExprAnd& expr) {
+ Id operator()(VideoCommon::Shader::ExprAnd& expr) {
const Id type_def = decomp.GetTypeDefinition(Type::Bool);
const Id op1 = Visit(expr.operand1);
const Id op2 = Visit(expr.operand2);
- current_id = decomp.Emit(decomp.OpLogicalAnd(type_def, op1, op2));
+ return decomp.Emit(decomp.OpLogicalAnd(type_def, op1, op2));
}
- void operator()(VideoCommon::Shader::ExprOr& expr) {
+ Id operator()(VideoCommon::Shader::ExprOr& expr) {
const Id type_def = decomp.GetTypeDefinition(Type::Bool);
const Id op1 = Visit(expr.operand1);
const Id op2 = Visit(expr.operand2);
- current_id = decomp.Emit(decomp.OpLogicalOr(type_def, op1, op2));
+ return decomp.Emit(decomp.OpLogicalOr(type_def, op1, op2));
}
- void operator()(VideoCommon::Shader::ExprNot& expr) {
+ Id operator()(VideoCommon::Shader::ExprNot& expr) {
const Id type_def = decomp.GetTypeDefinition(Type::Bool);
const Id op1 = Visit(expr.operand1);
- current_id = decomp.Emit(decomp.OpLogicalNot(type_def, op1));
+ return decomp.Emit(decomp.OpLogicalNot(type_def, op1));
}
- void operator()(VideoCommon::Shader::ExprPredicate& expr) {
+ Id operator()(VideoCommon::Shader::ExprPredicate& expr) {
const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate);
- current_id = decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred)));
+ return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.predicates.at(pred)));
}
- void operator()(VideoCommon::Shader::ExprCondCode& expr) {
+ Id operator()(VideoCommon::Shader::ExprCondCode& expr) {
const Node cc = decomp.ir.GetConditionCode(expr.cc);
Id target;
@@ -1690,35 +1690,28 @@ public:
} else if (const auto flag = std::get_if<InternalFlagNode>(&*cc)) {
target = decomp.internal_flags.at(static_cast<u32>(flag->GetFlag()));
}
- current_id = decomp.Emit(decomp.OpLoad(decomp.t_bool, target));
+ return decomp.Emit(decomp.OpLoad(decomp.t_bool, target));
}
- void operator()(VideoCommon::Shader::ExprVar& expr) {
- current_id =
- decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.flow_variables.at(expr.var_index)));
+ Id operator()(VideoCommon::Shader::ExprVar& expr) {
+ return decomp.Emit(decomp.OpLoad(decomp.t_bool, decomp.flow_variables.at(expr.var_index)));
}
- void operator()(VideoCommon::Shader::ExprBoolean& expr) {
- current_id = expr.value ? decomp.v_true : decomp.v_false;
- }
-
- Id GetResult() {
- return current_id;
+ Id operator()(VideoCommon::Shader::ExprBoolean& expr) {
+ return expr.value ? decomp.v_true : decomp.v_false;
}
Id Visit(VideoCommon::Shader::Expr& node) {
- std::visit(*this, *node);
- return current_id;
+ return std::visit(*this, *node);
}
private:
- Id current_id;
SPIRVDecompiler& decomp;
};
class ASTDecompiler {
public:
- ASTDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
+ explicit ASTDecompiler(SPIRVDecompiler& decomp) : decomp{decomp} {}
void operator()(VideoCommon::Shader::ASTProgram& ast) {
ASTNode current = ast.nodes.GetFirst();
@@ -1850,7 +1843,7 @@ public:
private:
SPIRVDecompiler& decomp;
- Id current_loop_exit;
+ Id current_loop_exit{};
};
void SPIRVDecompiler::DecompileAST() {