summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-09-22 18:33:13 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:53 +0200
commit189a50bc2addbf43824be396f205e900af7523b3 (patch)
treea90f376dece470233b110c16d12fb58ce03f6385 /src/video_core
parentShader_IR: corrections and clang-format (diff)
downloadyuzu-189a50bc2addbf43824be396f205e900af7523b3.tar
yuzu-189a50bc2addbf43824be396f205e900af7523b3.tar.gz
yuzu-189a50bc2addbf43824be396f205e900af7523b3.tar.bz2
yuzu-189a50bc2addbf43824be396f205e900af7523b3.tar.lz
yuzu-189a50bc2addbf43824be396f205e900af7523b3.tar.xz
yuzu-189a50bc2addbf43824be396f205e900af7523b3.tar.zst
yuzu-189a50bc2addbf43824be396f205e900af7523b3.zip
Diffstat (limited to 'src/video_core')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp35
1 files changed, 18 insertions, 17 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index b8c3442bc..572fae353 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -355,7 +355,7 @@ public:
if (!ir.IsFlowStackDisabled()) {
for (const auto stack : std::array{MetaStackClass::Ssy, MetaStackClass::Pbk}) {
code.AddLine("uint {}[{}];", FlowStackName(stack), FLOW_STACK_SIZE);
- code.AddLine("uint {} = 0u;", FlowStackTopName(stack));
+ code.AddLine("uint {} = 0U;", FlowStackTopName(stack));
}
}
@@ -1837,10 +1837,9 @@ private:
return {};
}
- Expression WriteExit() {
+ void PreExit() {
if (stage != ProgramType::Fragment) {
- code.AddLine("return;");
- return {};
+ return;
}
const auto& used_registers = ir.GetRegisters();
const auto SafeGetRegister = [&](u32 reg) -> Expression {
@@ -1872,13 +1871,12 @@ private:
// already contains one past the last color register.
code.AddLine("gl_FragDepth = {};", SafeGetRegister(current_reg + 1).AsFloat());
}
-
- code.AddLine("return;");
- return {};
}
Expression Exit(Operation operation) {
- return WriteExit();
+ PreExit();
+ code.AddLine("return;");
+ return {};
}
Expression Discard(Operation operation) {
@@ -2277,7 +2275,7 @@ const std::string flow_var = "flow_var_";
class ExprDecompiler {
public:
- ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
+ explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
void operator()(VideoCommon::Shader::ExprAnd& expr) {
inner += "( ";
@@ -2301,12 +2299,12 @@ public:
}
void operator()(VideoCommon::Shader::ExprPredicate& expr) {
- auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate);
+ const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate);
inner += decomp.GetPredicate(pred);
}
void operator()(VideoCommon::Shader::ExprCondCode& expr) {
- Node cc = decomp.ir.GetConditionCode(expr.cc);
+ const Node cc = decomp.ir.GetConditionCode(expr.cc);
std::string target;
if (const auto pred = std::get_if<PredicateNode>(&*cc)) {
@@ -2321,6 +2319,8 @@ public:
}
} else if (const auto flag = std::get_if<InternalFlagNode>(&*cc)) {
target = decomp.GetInternalFlag(flag->GetFlag());
+ } else {
+ UNREACHABLE();
}
inner += target;
}
@@ -2338,13 +2338,13 @@ public:
}
private:
- std::string inner{};
+ std::string inner;
GLSLDecompiler& decomp;
};
class ASTDecompiler {
public:
- ASTDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
+ explicit ASTDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
void operator()(VideoCommon::Shader::ASTProgram& ast) {
ASTNode current = ast.nodes.GetFirst();
@@ -2417,7 +2417,7 @@ public:
}
void operator()(VideoCommon::Shader::ASTReturn& ast) {
- bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition);
+ const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition);
if (!is_true) {
ExprDecompiler expr_parser{decomp};
std::visit(expr_parser, *ast.condition);
@@ -2427,7 +2427,8 @@ public:
if (ast.kills) {
decomp.code.AddLine("discard;");
} else {
- decomp.WriteExit();
+ decomp.PreExit();
+ decomp.code.AddLine("return;");
}
if (!is_true) {
decomp.code.scope--;
@@ -2436,7 +2437,7 @@ public:
}
void operator()(VideoCommon::Shader::ASTBreak& ast) {
- bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition);
+ const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition);
if (!is_true) {
ExprDecompiler expr_parser{decomp};
std::visit(expr_parser, *ast.condition);
@@ -2459,7 +2460,7 @@ private:
};
void GLSLDecompiler::DecompileAST() {
- u32 num_flow_variables = ir.GetASTNumVariables();
+ const u32 num_flow_variables = ir.GetASTNumVariables();
for (u32 i = 0; i < num_flow_variables; i++) {
code.AddLine("bool {}{} = false;", flow_var, i);
}