diff options
Diffstat (limited to 'src/video_core/shader/ast.cpp')
| -rw-r--r-- | src/video_core/shader/ast.cpp | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/src/video_core/shader/ast.cpp b/src/video_core/shader/ast.cpp index c4548f0bc..2eb065c3d 100644 --- a/src/video_core/shader/ast.cpp +++ b/src/video_core/shader/ast.cpp | |||
| @@ -376,7 +376,7 @@ void ASTManager::Init() { | |||
| 376 | false_condition = MakeExpr<ExprBoolean>(false); | 376 | false_condition = MakeExpr<ExprBoolean>(false); |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | ASTManager::ASTManager(ASTManager&& other) | 379 | ASTManager::ASTManager(ASTManager&& other) noexcept |
| 380 | : labels_map(std::move(other.labels_map)), labels_count{other.labels_count}, | 380 | : labels_map(std::move(other.labels_map)), labels_count{other.labels_count}, |
| 381 | gotos(std::move(other.gotos)), labels(std::move(other.labels)), variables{other.variables}, | 381 | gotos(std::move(other.gotos)), labels(std::move(other.labels)), variables{other.variables}, |
| 382 | program{other.program}, main_node{other.main_node}, false_condition{other.false_condition}, | 382 | program{other.program}, main_node{other.main_node}, false_condition{other.false_condition}, |
| @@ -384,7 +384,7 @@ ASTManager::ASTManager(ASTManager&& other) | |||
| 384 | other.main_node.reset(); | 384 | other.main_node.reset(); |
| 385 | } | 385 | } |
| 386 | 386 | ||
| 387 | ASTManager& ASTManager::operator=(ASTManager&& other) { | 387 | ASTManager& ASTManager::operator=(ASTManager&& other) noexcept { |
| 388 | full_decompile = other.full_decompile; | 388 | full_decompile = other.full_decompile; |
| 389 | labels_map = std::move(other.labels_map); | 389 | labels_map = std::move(other.labels_map); |
| 390 | labels_count = other.labels_count; | 390 | labels_count = other.labels_count; |
| @@ -490,7 +490,7 @@ void ASTManager::Decompile() { | |||
| 490 | it++; | 490 | it++; |
| 491 | } | 491 | } |
| 492 | if (full_decompile) { | 492 | if (full_decompile) { |
| 493 | for (const ASTNode label : labels) { | 493 | for (const ASTNode& label : labels) { |
| 494 | auto& manager = label->GetManager(); | 494 | auto& manager = label->GetManager(); |
| 495 | manager.Remove(label); | 495 | manager.Remove(label); |
| 496 | } | 496 | } |
| @@ -500,12 +500,12 @@ void ASTManager::Decompile() { | |||
| 500 | while (it != labels.end()) { | 500 | while (it != labels.end()) { |
| 501 | bool can_remove = true; | 501 | bool can_remove = true; |
| 502 | ASTNode label = *it; | 502 | ASTNode label = *it; |
| 503 | for (const ASTNode goto_node : gotos) { | 503 | for (const ASTNode& goto_node : gotos) { |
| 504 | const auto label_index = goto_node->GetGotoLabel(); | 504 | const auto label_index = goto_node->GetGotoLabel(); |
| 505 | if (!label_index) { | 505 | if (!label_index) { |
| 506 | return; | 506 | return; |
| 507 | } | 507 | } |
| 508 | ASTNode glabel = labels[*label_index]; | 508 | ASTNode& glabel = labels[*label_index]; |
| 509 | if (glabel == label) { | 509 | if (glabel == label) { |
| 510 | can_remove = false; | 510 | can_remove = false; |
| 511 | break; | 511 | break; |
| @@ -543,40 +543,6 @@ bool ASTManager::IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const { | |||
| 543 | return false; | 543 | return false; |
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | ASTNode CommonParent(ASTNode first, ASTNode second) { | ||
| 547 | if (first->GetParent() == second->GetParent()) { | ||
| 548 | return first->GetParent(); | ||
| 549 | } | ||
| 550 | const u32 first_level = first->GetLevel(); | ||
| 551 | const u32 second_level = second->GetLevel(); | ||
| 552 | u32 min_level; | ||
| 553 | u32 max_level; | ||
| 554 | ASTNode max; | ||
| 555 | ASTNode min; | ||
| 556 | if (first_level > second_level) { | ||
| 557 | min_level = second_level; | ||
| 558 | min = second; | ||
| 559 | max_level = first_level; | ||
| 560 | max = first; | ||
| 561 | } else { | ||
| 562 | min_level = first_level; | ||
| 563 | min = first; | ||
| 564 | max_level = second_level; | ||
| 565 | max = second; | ||
| 566 | } | ||
| 567 | |||
| 568 | while (max_level > min_level) { | ||
| 569 | max_level--; | ||
| 570 | max = max->GetParent(); | ||
| 571 | } | ||
| 572 | |||
| 573 | while (min->GetParent() != max->GetParent()) { | ||
| 574 | min = min->GetParent(); | ||
| 575 | max = max->GetParent(); | ||
| 576 | } | ||
| 577 | return min->GetParent(); | ||
| 578 | } | ||
| 579 | |||
| 580 | bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) { | 546 | bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) { |
| 581 | return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second)); | 547 | return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second)); |
| 582 | } | 548 | } |
| @@ -608,7 +574,7 @@ bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) { | |||
| 608 | max = max->GetParent(); | 574 | max = max->GetParent(); |
| 609 | } | 575 | } |
| 610 | 576 | ||
| 611 | return (min->GetParent() == max->GetParent()); | 577 | return min->GetParent() == max->GetParent(); |
| 612 | } | 578 | } |
| 613 | 579 | ||
| 614 | void ASTManager::ShowCurrentState(std::string state) { | 580 | void ASTManager::ShowCurrentState(std::string state) { |
| @@ -617,7 +583,7 @@ void ASTManager::ShowCurrentState(std::string state) { | |||
| 617 | } | 583 | } |
| 618 | 584 | ||
| 619 | void ASTManager::SanityCheck() { | 585 | void ASTManager::SanityCheck() { |
| 620 | for (auto label : labels) { | 586 | for (auto& label : labels) { |
| 621 | if (!label->GetParent()) { | 587 | if (!label->GetParent()) { |
| 622 | LOG_CRITICAL(HW_GPU, "Sanity Check Failed"); | 588 | LOG_CRITICAL(HW_GPU, "Sanity Check Failed"); |
| 623 | } | 589 | } |