summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Lioncash2022-01-25 13:50:10 -0500
committerGravatar Lioncash2022-01-25 13:50:14 -0500
commitcfd9f7d25b4c1aea49b4dc017990f12142b8302b (patch)
tree7ab83e57f2340b5447738cdc195489312e530a54
parentvideo_core/macro: Remove unused parameter from Execute() (diff)
downloadyuzu-cfd9f7d25b4c1aea49b4dc017990f12142b8302b.tar.gz
yuzu-cfd9f7d25b4c1aea49b4dc017990f12142b8302b.tar.xz
yuzu-cfd9f7d25b4c1aea49b4dc017990f12142b8302b.zip
video_core/macro_hle: Return unique_ptr directly from GetHLEProgram()
Same behavior, but less code and header dependencies.
-rw-r--r--src/video_core/macro/macro.cpp5
-rw-r--r--src/video_core/macro/macro_hle.cpp4
-rw-r--r--src/video_core/macro/macro_hle.h5
3 files changed, 7 insertions, 7 deletions
diff --git a/src/video_core/macro/macro.cpp b/src/video_core/macro/macro.cpp
index 0870a7687..0ae78a9e5 100644
--- a/src/video_core/macro/macro.cpp
+++ b/src/video_core/macro/macro.cpp
@@ -65,10 +65,9 @@ void MacroEngine::Execute(u32 method, const std::vector<u32>& parameters) {
65 cache_info.lle_program = Compile(code); 65 cache_info.lle_program = Compile(code);
66 } 66 }
67 67
68 auto hle_program = hle_macros->GetHLEProgram(cache_info.hash); 68 if (auto hle_program = hle_macros->GetHLEProgram(cache_info.hash)) {
69 if (hle_program.has_value()) {
70 cache_info.has_hle_program = true; 69 cache_info.has_hle_program = true;
71 cache_info.hle_program = std::move(hle_program.value()); 70 cache_info.hle_program = std::move(hle_program);
72 cache_info.hle_program->Execute(parameters, method); 71 cache_info.hle_program->Execute(parameters, method);
73 } else { 72 } else {
74 cache_info.lle_program->Execute(parameters, method); 73 cache_info.lle_program->Execute(parameters, method);
diff --git a/src/video_core/macro/macro_hle.cpp b/src/video_core/macro/macro_hle.cpp
index 3f743ce55..900ad23c9 100644
--- a/src/video_core/macro/macro_hle.cpp
+++ b/src/video_core/macro/macro_hle.cpp
@@ -105,11 +105,11 @@ private:
105HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} {} 105HLEMacro::HLEMacro(Engines::Maxwell3D& maxwell3d_) : maxwell3d{maxwell3d_} {}
106HLEMacro::~HLEMacro() = default; 106HLEMacro::~HLEMacro() = default;
107 107
108std::optional<std::unique_ptr<CachedMacro>> HLEMacro::GetHLEProgram(u64 hash) const { 108std::unique_ptr<CachedMacro> HLEMacro::GetHLEProgram(u64 hash) const {
109 const auto it = std::find_if(hle_funcs.cbegin(), hle_funcs.cend(), 109 const auto it = std::find_if(hle_funcs.cbegin(), hle_funcs.cend(),
110 [hash](const auto& pair) { return pair.first == hash; }); 110 [hash](const auto& pair) { return pair.first == hash; });
111 if (it == hle_funcs.end()) { 111 if (it == hle_funcs.end()) {
112 return std::nullopt; 112 return nullptr;
113 } 113 }
114 return std::make_unique<HLEMacroImpl>(maxwell3d, it->second); 114 return std::make_unique<HLEMacroImpl>(maxwell3d, it->second);
115} 115}
diff --git a/src/video_core/macro/macro_hle.h b/src/video_core/macro/macro_hle.h
index c0a12e793..b86ba84a1 100644
--- a/src/video_core/macro/macro_hle.h
+++ b/src/video_core/macro/macro_hle.h
@@ -5,7 +5,6 @@
5#pragma once 5#pragma once
6 6
7#include <memory> 7#include <memory>
8#include <optional>
9#include "common/common_types.h" 8#include "common/common_types.h"
10 9
11namespace Tegra { 10namespace Tegra {
@@ -19,7 +18,9 @@ public:
19 explicit HLEMacro(Engines::Maxwell3D& maxwell3d_); 18 explicit HLEMacro(Engines::Maxwell3D& maxwell3d_);
20 ~HLEMacro(); 19 ~HLEMacro();
21 20
22 std::optional<std::unique_ptr<CachedMacro>> GetHLEProgram(u64 hash) const; 21 // Allocates and returns a cached macro if the hash matches a known function.
22 // Returns nullptr otherwise.
23 [[nodiscard]] std::unique_ptr<CachedMacro> GetHLEProgram(u64 hash) const;
23 24
24private: 25private:
25 Engines::Maxwell3D& maxwell3d; 26 Engines::Maxwell3D& maxwell3d;