From 01b21ee1e8e7455dd84ee7f22d33426caaaafdb3 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Tue, 25 Jun 2019 20:15:40 -0400 Subject: shader_ir: Corrections, documenting and asserting control_flow --- src/video_core/shader/control_flow.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/video_core/shader/control_flow.h') diff --git a/src/video_core/shader/control_flow.h b/src/video_core/shader/control_flow.h index 4a2cd622c..4689b0c10 100644 --- a/src/video_core/shader/control_flow.h +++ b/src/video_core/shader/control_flow.h @@ -1,3 +1,7 @@ +// Copyright 2019 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + #pragma once #include @@ -20,12 +24,15 @@ struct Condition { ConditionCode cc{ConditionCode::T}; bool IsUnconditional() const { - return (predicate == Pred::UnusedIndex) && (cc == ConditionCode::T); + return predicate == Pred::UnusedIndex && cc == ConditionCode::T; + } + bool operator==(const Condition& other) const { + return std::tie(predicate, cc) == std::tie(other.predicate, other.cc); } }; struct ShaderBlock { - ShaderBlock() {} + ShaderBlock() = default; ShaderBlock(const ShaderBlock& sb) = default; u32 start{}; u32 end{}; @@ -35,11 +42,12 @@ struct ShaderBlock { bool kills{}; s32 address{}; bool operator==(const Branch& b) const { - return std::memcmp(this, &b, sizeof(Branch)) == 0; + return std::tie(cond, kills, address) == std::tie(b.cond, b.kills, b.address); } } branch; bool operator==(const ShaderBlock& sb) const { - return std::memcmp(this, &sb, sizeof(ShaderBlock)) == 0; + return std::tie(start, end, ignore_branch, branch) == + std::tie(sb.start, sb.end, sb.ignore_branch, sb.branch); } }; -- cgit v1.2.3