summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-10-04 23:23:16 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:57 +0200
commite6eae4b815bf4bc480d62677fdf9bdbf5d6cba82 (patch)
tree8d5aefe385e6dd88a8f91092dd1d5b347fc4725c /src/video_core/shader
parentShader_Ir: Address Feedback and clang format. (diff)
downloadyuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar.gz
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar.bz2
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar.lz
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar.xz
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.tar.zst
yuzu-e6eae4b815bf4bc480d62677fdf9bdbf5d6cba82.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/ast.cpp48
-rw-r--r--src/video_core/shader/ast.h12
-rw-r--r--src/video_core/shader/control_flow.cpp2
-rw-r--r--src/video_core/shader/decode.cpp2
4 files changed, 14 insertions, 50 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() {
false_condition = MakeExpr<ExprBoolean>(false);
}
-ASTManager::ASTManager(ASTManager&& other)
+ASTManager::ASTManager(ASTManager&& other) noexcept
: labels_map(std::move(other.labels_map)), labels_count{other.labels_count},
gotos(std::move(other.gotos)), labels(std::move(other.labels)), variables{other.variables},
program{other.program}, main_node{other.main_node}, false_condition{other.false_condition},
@@ -384,7 +384,7 @@ ASTManager::ASTManager(ASTManager&& other)
other.main_node.reset();
}
-ASTManager& ASTManager::operator=(ASTManager&& other) {
+ASTManager& ASTManager::operator=(ASTManager&& other) noexcept {
full_decompile = other.full_decompile;
labels_map = std::move(other.labels_map);
labels_count = other.labels_count;
@@ -490,7 +490,7 @@ void ASTManager::Decompile() {
it++;
}
if (full_decompile) {
- for (const ASTNode label : labels) {
+ for (const ASTNode& label : labels) {
auto& manager = label->GetManager();
manager.Remove(label);
}
@@ -500,12 +500,12 @@ void ASTManager::Decompile() {
while (it != labels.end()) {
bool can_remove = true;
ASTNode label = *it;
- for (const ASTNode goto_node : gotos) {
+ for (const ASTNode& goto_node : gotos) {
const auto label_index = goto_node->GetGotoLabel();
if (!label_index) {
return;
}
- ASTNode glabel = labels[*label_index];
+ ASTNode& glabel = labels[*label_index];
if (glabel == label) {
can_remove = false;
break;
@@ -543,40 +543,6 @@ bool ASTManager::IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const {
return false;
}
-ASTNode CommonParent(ASTNode first, ASTNode second) {
- if (first->GetParent() == second->GetParent()) {
- return first->GetParent();
- }
- const u32 first_level = first->GetLevel();
- const u32 second_level = second->GetLevel();
- u32 min_level;
- u32 max_level;
- ASTNode max;
- ASTNode min;
- if (first_level > second_level) {
- min_level = second_level;
- min = second;
- max_level = first_level;
- max = first;
- } else {
- min_level = first_level;
- min = first;
- max_level = second_level;
- max = second;
- }
-
- while (max_level > min_level) {
- max_level--;
- max = max->GetParent();
- }
-
- while (min->GetParent() != max->GetParent()) {
- min = min->GetParent();
- max = max->GetParent();
- }
- return min->GetParent();
-}
-
bool ASTManager::IndirectlyRelated(ASTNode first, ASTNode second) {
return !(first->GetParent() == second->GetParent() || DirectlyRelated(first, second));
}
@@ -608,7 +574,7 @@ bool ASTManager::DirectlyRelated(ASTNode first, ASTNode second) {
max = max->GetParent();
}
- return (min->GetParent() == max->GetParent());
+ return min->GetParent() == max->GetParent();
}
void ASTManager::ShowCurrentState(std::string state) {
@@ -617,7 +583,7 @@ void ASTManager::ShowCurrentState(std::string state) {
}
void ASTManager::SanityCheck() {
- for (auto label : labels) {
+ for (auto& label : labels) {
if (!label->GetParent()) {
LOG_CRITICAL(HW_GPU, "Sanity Check Failed");
}
diff --git a/src/video_core/shader/ast.h b/src/video_core/shader/ast.h
index 8efd4c147..ba234138e 100644
--- a/src/video_core/shader/ast.h
+++ b/src/video_core/shader/ast.h
@@ -97,7 +97,7 @@ public:
class ASTBlockDecoded {
public:
- explicit ASTBlockDecoded(NodeBlock& new_nodes) : nodes(std::move(new_nodes)) {}
+ explicit ASTBlockDecoded(NodeBlock&& new_nodes) : nodes(std::move(new_nodes)) {}
NodeBlock nodes;
};
@@ -255,8 +255,8 @@ public:
return std::holds_alternative<ASTBlockEncoded>(data);
}
- void TransformBlockEncoded(NodeBlock& nodes) {
- data = ASTBlockDecoded(nodes);
+ void TransformBlockEncoded(NodeBlock&& nodes) {
+ data = ASTBlockDecoded(std::move(nodes));
}
bool IsLoop() const {
@@ -304,8 +304,8 @@ public:
ASTManager(const ASTManager& o) = delete;
ASTManager& operator=(const ASTManager& other) = delete;
- ASTManager(ASTManager&& other);
- ASTManager& operator=(ASTManager&& other);
+ ASTManager(ASTManager&& other) noexcept;
+ ASTManager& operator=(ASTManager&& other) noexcept;
void Init();
@@ -362,8 +362,6 @@ public:
private:
bool IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const;
- ASTNode CommonParent(ASTNode first, ASTNode second);
-
bool IndirectlyRelated(ASTNode first, ASTNode second);
bool DirectlyRelated(ASTNode first, ASTNode second);
diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp
index c2fa734e7..3c3a41ba6 100644
--- a/src/video_core/shader/control_flow.cpp
+++ b/src/video_core/shader/control_flow.cpp
@@ -58,7 +58,7 @@ struct BlockInfo {
struct CFGRebuildState {
explicit CFGRebuildState(const ProgramCode& program_code, const std::size_t program_size,
const u32 start)
- : program_code{program_code}, program_size{program_size}, start{start} {}
+ : start{start}, program_code{program_code}, program_size{program_size} {}
u32 start{};
std::vector<BlockInfo> block_info{};
diff --git a/src/video_core/shader/decode.cpp b/src/video_core/shader/decode.cpp
index 6d4359295..2626b1616 100644
--- a/src/video_core/shader/decode.cpp
+++ b/src/video_core/shader/decode.cpp
@@ -90,7 +90,7 @@ public:
if (node->IsBlockEncoded()) {
auto block = std::get_if<ASTBlockEncoded>(node->GetInnerData());
NodeBlock bb = ir.DecodeRange(block->start, block->end);
- node->TransformBlockEncoded(bb);
+ node->TransformBlockEncoded(std::move(bb));
}
}