diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_decompiler.cpp | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp index 82228b55d..20dc7d3db 100644 --- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp +++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp | |||
| @@ -2281,7 +2281,7 @@ class ExprDecompiler { | |||
| 2281 | public: | 2281 | public: |
| 2282 | explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {} | 2282 | explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {} |
| 2283 | 2283 | ||
| 2284 | void operator()(VideoCommon::Shader::ExprAnd& expr) { | 2284 | void operator()(const ExprAnd& expr) { |
| 2285 | inner += "( "; | 2285 | inner += "( "; |
| 2286 | std::visit(*this, *expr.operand1); | 2286 | std::visit(*this, *expr.operand1); |
| 2287 | inner += " && "; | 2287 | inner += " && "; |
| @@ -2289,7 +2289,7 @@ public: | |||
| 2289 | inner += ')'; | 2289 | inner += ')'; |
| 2290 | } | 2290 | } |
| 2291 | 2291 | ||
| 2292 | void operator()(VideoCommon::Shader::ExprOr& expr) { | 2292 | void operator()(const ExprOr& expr) { |
| 2293 | inner += "( "; | 2293 | inner += "( "; |
| 2294 | std::visit(*this, *expr.operand1); | 2294 | std::visit(*this, *expr.operand1); |
| 2295 | inner += " || "; | 2295 | inner += " || "; |
| @@ -2297,17 +2297,17 @@ public: | |||
| 2297 | inner += ')'; | 2297 | inner += ')'; |
| 2298 | } | 2298 | } |
| 2299 | 2299 | ||
| 2300 | void operator()(VideoCommon::Shader::ExprNot& expr) { | 2300 | void operator()(const ExprNot& expr) { |
| 2301 | inner += '!'; | 2301 | inner += '!'; |
| 2302 | std::visit(*this, *expr.operand1); | 2302 | std::visit(*this, *expr.operand1); |
| 2303 | } | 2303 | } |
| 2304 | 2304 | ||
| 2305 | void operator()(VideoCommon::Shader::ExprPredicate& expr) { | 2305 | void operator()(const ExprPredicate& expr) { |
| 2306 | const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate); | 2306 | const auto pred = static_cast<Tegra::Shader::Pred>(expr.predicate); |
| 2307 | inner += decomp.GetPredicate(pred); | 2307 | inner += decomp.GetPredicate(pred); |
| 2308 | } | 2308 | } |
| 2309 | 2309 | ||
| 2310 | void operator()(VideoCommon::Shader::ExprCondCode& expr) { | 2310 | void operator()(const ExprCondCode& expr) { |
| 2311 | const Node cc = decomp.ir.GetConditionCode(expr.cc); | 2311 | const Node cc = decomp.ir.GetConditionCode(expr.cc); |
| 2312 | std::string target; | 2312 | std::string target; |
| 2313 | 2313 | ||
| @@ -2329,11 +2329,11 @@ public: | |||
| 2329 | inner += target; | 2329 | inner += target; |
| 2330 | } | 2330 | } |
| 2331 | 2331 | ||
| 2332 | void operator()(VideoCommon::Shader::ExprVar& expr) { | 2332 | void operator()(const ExprVar& expr) { |
| 2333 | inner += GetFlowVariable(expr.var_index); | 2333 | inner += GetFlowVariable(expr.var_index); |
| 2334 | } | 2334 | } |
| 2335 | 2335 | ||
| 2336 | void operator()(VideoCommon::Shader::ExprBoolean& expr) { | 2336 | void operator()(const ExprBoolean& expr) { |
| 2337 | inner += expr.value ? "true" : "false"; | 2337 | inner += expr.value ? "true" : "false"; |
| 2338 | } | 2338 | } |
| 2339 | 2339 | ||
| @@ -2350,7 +2350,7 @@ class ASTDecompiler { | |||
| 2350 | public: | 2350 | public: |
| 2351 | explicit ASTDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {} | 2351 | explicit ASTDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {} |
| 2352 | 2352 | ||
| 2353 | void operator()(VideoCommon::Shader::ASTProgram& ast) { | 2353 | void operator()(const ASTProgram& ast) { |
| 2354 | ASTNode current = ast.nodes.GetFirst(); | 2354 | ASTNode current = ast.nodes.GetFirst(); |
| 2355 | while (current) { | 2355 | while (current) { |
| 2356 | Visit(current); | 2356 | Visit(current); |
| @@ -2358,7 +2358,7 @@ public: | |||
| 2358 | } | 2358 | } |
| 2359 | } | 2359 | } |
| 2360 | 2360 | ||
| 2361 | void operator()(VideoCommon::Shader::ASTIfThen& ast) { | 2361 | void operator()(const ASTIfThen& ast) { |
| 2362 | ExprDecompiler expr_parser{decomp}; | 2362 | ExprDecompiler expr_parser{decomp}; |
| 2363 | std::visit(expr_parser, *ast.condition); | 2363 | std::visit(expr_parser, *ast.condition); |
| 2364 | decomp.code.AddLine("if ({}) {{", expr_parser.GetResult()); | 2364 | decomp.code.AddLine("if ({}) {{", expr_parser.GetResult()); |
| @@ -2372,7 +2372,7 @@ public: | |||
| 2372 | decomp.code.AddLine("}}"); | 2372 | decomp.code.AddLine("}}"); |
| 2373 | } | 2373 | } |
| 2374 | 2374 | ||
| 2375 | void operator()(VideoCommon::Shader::ASTIfElse& ast) { | 2375 | void operator()(const ASTIfElse& ast) { |
| 2376 | decomp.code.AddLine("else {{"); | 2376 | decomp.code.AddLine("else {{"); |
| 2377 | decomp.code.scope++; | 2377 | decomp.code.scope++; |
| 2378 | ASTNode current = ast.nodes.GetFirst(); | 2378 | ASTNode current = ast.nodes.GetFirst(); |
| @@ -2384,29 +2384,29 @@ public: | |||
| 2384 | decomp.code.AddLine("}}"); | 2384 | decomp.code.AddLine("}}"); |
| 2385 | } | 2385 | } |
| 2386 | 2386 | ||
| 2387 | void operator()(VideoCommon::Shader::ASTBlockEncoded& ast) { | 2387 | void operator()([[maybe_unused]] const ASTBlockEncoded& ast) { |
| 2388 | UNREACHABLE(); | 2388 | UNREACHABLE(); |
| 2389 | } | 2389 | } |
| 2390 | 2390 | ||
| 2391 | void operator()(VideoCommon::Shader::ASTBlockDecoded& ast) { | 2391 | void operator()(const ASTBlockDecoded& ast) { |
| 2392 | decomp.VisitBlock(ast.nodes); | 2392 | decomp.VisitBlock(ast.nodes); |
| 2393 | } | 2393 | } |
| 2394 | 2394 | ||
| 2395 | void operator()(VideoCommon::Shader::ASTVarSet& ast) { | 2395 | void operator()(const ASTVarSet& ast) { |
| 2396 | ExprDecompiler expr_parser{decomp}; | 2396 | ExprDecompiler expr_parser{decomp}; |
| 2397 | std::visit(expr_parser, *ast.condition); | 2397 | std::visit(expr_parser, *ast.condition); |
| 2398 | decomp.code.AddLine("{} = {};", GetFlowVariable(ast.index), expr_parser.GetResult()); | 2398 | decomp.code.AddLine("{} = {};", GetFlowVariable(ast.index), expr_parser.GetResult()); |
| 2399 | } | 2399 | } |
| 2400 | 2400 | ||
| 2401 | void operator()(VideoCommon::Shader::ASTLabel& ast) { | 2401 | void operator()(const ASTLabel& ast) { |
| 2402 | decomp.code.AddLine("// Label_{}:", ast.index); | 2402 | decomp.code.AddLine("// Label_{}:", ast.index); |
| 2403 | } | 2403 | } |
| 2404 | 2404 | ||
| 2405 | void operator()(VideoCommon::Shader::ASTGoto& ast) { | 2405 | void operator()([[maybe_unused]] const ASTGoto& ast) { |
| 2406 | UNREACHABLE(); | 2406 | UNREACHABLE(); |
| 2407 | } | 2407 | } |
| 2408 | 2408 | ||
| 2409 | void operator()(VideoCommon::Shader::ASTDoWhile& ast) { | 2409 | void operator()(const ASTDoWhile& ast) { |
| 2410 | ExprDecompiler expr_parser{decomp}; | 2410 | ExprDecompiler expr_parser{decomp}; |
| 2411 | std::visit(expr_parser, *ast.condition); | 2411 | std::visit(expr_parser, *ast.condition); |
| 2412 | decomp.code.AddLine("do {{"); | 2412 | decomp.code.AddLine("do {{"); |
| @@ -2420,7 +2420,7 @@ public: | |||
| 2420 | decomp.code.AddLine("}} while({});", expr_parser.GetResult()); | 2420 | decomp.code.AddLine("}} while({});", expr_parser.GetResult()); |
| 2421 | } | 2421 | } |
| 2422 | 2422 | ||
| 2423 | void operator()(VideoCommon::Shader::ASTReturn& ast) { | 2423 | void operator()(const ASTReturn& ast) { |
| 2424 | const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); | 2424 | const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); |
| 2425 | if (!is_true) { | 2425 | if (!is_true) { |
| 2426 | ExprDecompiler expr_parser{decomp}; | 2426 | ExprDecompiler expr_parser{decomp}; |
| @@ -2440,7 +2440,7 @@ public: | |||
| 2440 | } | 2440 | } |
| 2441 | } | 2441 | } |
| 2442 | 2442 | ||
| 2443 | void operator()(VideoCommon::Shader::ASTBreak& ast) { | 2443 | void operator()(const ASTBreak& ast) { |
| 2444 | const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); | 2444 | const bool is_true = VideoCommon::Shader::ExprIsTrue(ast.condition); |
| 2445 | if (!is_true) { | 2445 | if (!is_true) { |
| 2446 | ExprDecompiler expr_parser{decomp}; | 2446 | ExprDecompiler expr_parser{decomp}; |
| @@ -2455,7 +2455,7 @@ public: | |||
| 2455 | } | 2455 | } |
| 2456 | } | 2456 | } |
| 2457 | 2457 | ||
| 2458 | void Visit(VideoCommon::Shader::ASTNode& node) { | 2458 | void Visit(const ASTNode& node) { |
| 2459 | std::visit(*this, *node->GetInnerData()); | 2459 | std::visit(*this, *node->GetInnerData()); |
| 2460 | } | 2460 | } |
| 2461 | 2461 | ||
| @@ -2468,9 +2468,9 @@ void GLSLDecompiler::DecompileAST() { | |||
| 2468 | for (u32 i = 0; i < num_flow_variables; i++) { | 2468 | for (u32 i = 0; i < num_flow_variables; i++) { |
| 2469 | code.AddLine("bool {} = false;", GetFlowVariable(i)); | 2469 | code.AddLine("bool {} = false;", GetFlowVariable(i)); |
| 2470 | } | 2470 | } |
| 2471 | |||
| 2471 | ASTDecompiler decompiler{*this}; | 2472 | ASTDecompiler decompiler{*this}; |
| 2472 | VideoCommon::Shader::ASTNode program = ir.GetASTProgram(); | 2473 | decompiler.Visit(ir.GetASTProgram()); |
| 2473 | decompiler.Visit(program); | ||
| 2474 | } | 2474 | } |
| 2475 | 2475 | ||
| 2476 | } // Anonymous namespace | 2476 | } // Anonymous namespace |