summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/citra_qt/debugger/graphics/graphics_cmdlists.cpp2
-rw-r--r--src/video_core/regs.cpp21
-rw-r--r--src/video_core/regs.h4
3 files changed, 11 insertions, 16 deletions
diff --git a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp b/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp
index 536548f36..c68fe753b 100644
--- a/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp
+++ b/src/citra_qt/debugger/graphics/graphics_cmdlists.cpp
@@ -72,7 +72,7 @@ QVariant GPUCommandListModel::data(const QModelIndex& index, int role) const {
72 if (role == Qt::DisplayRole) { 72 if (role == Qt::DisplayRole) {
73 switch (index.column()) { 73 switch (index.column()) {
74 case 0: 74 case 0:
75 return QString::fromLatin1(Pica::Regs::GetCommandName(write.cmd_id).c_str()); 75 return QString::fromLatin1(Pica::Regs::GetRegisterName(write.cmd_id));
76 case 1: 76 case 1:
77 return QString("%1").arg(write.cmd_id, 3, 16, QLatin1Char('0')); 77 return QString("%1").arg(write.cmd_id, 3, 16, QLatin1Char('0'));
78 case 2: 78 case 2:
diff --git a/src/video_core/regs.cpp b/src/video_core/regs.cpp
index f47e9e763..2699e710a 100644
--- a/src/video_core/regs.cpp
+++ b/src/video_core/regs.cpp
@@ -2,8 +2,8 @@
2// Licensed under GPLv2 or any later version 2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <algorithm>
5#include <iterator> 6#include <iterator>
6#include <unordered_map>
7#include <utility> 7#include <utility>
8 8
9#include "common/common_types.h" 9#include "common/common_types.h"
@@ -474,19 +474,14 @@ static const std::pair<u16, const char*> register_names[] = {
474 {0x2DD, "GPUREG_VSH_OPDESCS_DATA7"}, 474 {0x2DD, "GPUREG_VSH_OPDESCS_DATA7"},
475}; 475};
476 476
477std::string Regs::GetCommandName(int index) { 477const char* Regs::GetRegisterName(u16 index) {
478 static std::unordered_map<u32, const char*> map; 478 auto found = std::lower_bound(std::begin(register_names), std::end(register_names), index,
479 479 [](auto p, auto i) { return p.first < i; });
480 if (map.empty()) { 480 if (found->first == index) {
481 map.insert(std::begin(register_names), std::end(register_names)); 481 return found->second;
482 }
483
484 // Return empty string if no match is found
485 auto it = map.find(index);
486 if (it != map.end()) {
487 return it->second;
488 } else { 482 } else {
489 return std::string(); 483 // Return empty string if no match is found
484 return "";
490 } 485 }
491} 486}
492 487
diff --git a/src/video_core/regs.h b/src/video_core/regs.h
index e38ab4333..86826088b 100644
--- a/src/video_core/regs.h
+++ b/src/video_core/regs.h
@@ -64,8 +64,8 @@ struct Regs {
64 std::array<u32, NUM_REGS> reg_array; 64 std::array<u32, NUM_REGS> reg_array;
65 }; 65 };
66 66
67 // Map register indices to names readable by humans 67 /// Map register indices to names readable by humans
68 static std::string GetCommandName(int index); 68 static const char* GetRegisterName(u16 index);
69}; 69};
70 70
71static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Regs struct has wrong size"); 71static_assert(sizeof(Regs) == Regs::NUM_REGS * sizeof(u32), "Regs struct has wrong size");