summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/citra_qt/debugger/profiler.cpp4
-rw-r--r--src/common/thread.h81
-rw-r--r--src/video_core/rasterizer.cpp4
3 files changed, 20 insertions, 69 deletions
diff --git a/src/citra_qt/debugger/profiler.cpp b/src/citra_qt/debugger/profiler.cpp
index ae0568b6a..2ac1748b7 100644
--- a/src/citra_qt/debugger/profiler.cpp
+++ b/src/citra_qt/debugger/profiler.cpp
@@ -26,7 +26,7 @@ static QVariant GetDataForColumn(int col, const AggregatedDuration& duration)
26static const TimingCategoryInfo* GetCategoryInfo(int id) 26static const TimingCategoryInfo* GetCategoryInfo(int id)
27{ 27{
28 const auto& categories = GetProfilingManager().GetTimingCategoriesInfo(); 28 const auto& categories = GetProfilingManager().GetTimingCategoriesInfo();
29 if (id >= categories.size()) { 29 if ((size_t)id >= categories.size()) {
30 return nullptr; 30 return nullptr;
31 } else { 31 } else {
32 return &categories[id]; 32 return &categories[id];
@@ -98,7 +98,7 @@ QVariant ProfilerModel::data(const QModelIndex& index, int role) const
98 const TimingCategoryInfo* info = GetCategoryInfo(index.row() - 2); 98 const TimingCategoryInfo* info = GetCategoryInfo(index.row() - 2);
99 return info != nullptr ? QString(info->name) : QVariant(); 99 return info != nullptr ? QString(info->name) : QVariant();
100 } else { 100 } else {
101 if (index.row() - 2 < results.time_per_category.size()) { 101 if (index.row() - 2 < (int)results.time_per_category.size()) {
102 return GetDataForColumn(index.column(), results.time_per_category[index.row() - 2]); 102 return GetDataForColumn(index.column(), results.time_per_category[index.row() - 2]);
103 } else { 103 } else {
104 return QVariant(); 104 return QVariant();
diff --git a/src/common/thread.h b/src/common/thread.h
index a45728e1e..5fdb6baeb 100644
--- a/src/common/thread.h
+++ b/src/common/thread.h
@@ -51,109 +51,60 @@ int CurrentThreadId();
51void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask); 51void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask);
52void SetCurrentThreadAffinity(u32 mask); 52void SetCurrentThreadAffinity(u32 mask);
53 53
54class Event 54class Event {
55{
56public: 55public:
57 Event() 56 Event() : is_set(false) {}
58 : is_set(false)
59 {}
60 57
61 void Set() 58 void Set() {
62 {
63 std::lock_guard<std::mutex> lk(m_mutex); 59 std::lock_guard<std::mutex> lk(m_mutex);
64 if (!is_set) 60 if (!is_set) {
65 {
66 is_set = true; 61 is_set = true;
67 m_condvar.notify_one(); 62 m_condvar.notify_one();
68 } 63 }
69 } 64 }
70 65
71 void Wait() 66 void Wait() {
72 {
73 std::unique_lock<std::mutex> lk(m_mutex); 67 std::unique_lock<std::mutex> lk(m_mutex);
74 m_condvar.wait(lk, IsSet(this)); 68 m_condvar.wait(lk, [&]{ return is_set; });
75 is_set = false; 69 is_set = false;
76 } 70 }
77 71
78 void Reset() 72 void Reset() {
79 {
80 std::unique_lock<std::mutex> lk(m_mutex); 73 std::unique_lock<std::mutex> lk(m_mutex);
81 // no other action required, since wait loops on the predicate and any lingering signal will get cleared on the first iteration 74 // no other action required, since wait loops on the predicate and any lingering signal will get cleared on the first iteration
82 is_set = false; 75 is_set = false;
83 } 76 }
84 77
85private: 78private:
86 class IsSet 79 bool is_set;
87 {
88 public:
89 IsSet(const Event* ev)
90 : m_event(ev)
91 {}
92
93 bool operator()()
94 {
95 return m_event->is_set;
96 }
97
98 private:
99 const Event* const m_event;
100 };
101
102 volatile bool is_set;
103 std::condition_variable m_condvar; 80 std::condition_variable m_condvar;
104 std::mutex m_mutex; 81 std::mutex m_mutex;
105}; 82};
106 83
107// TODO: doesn't work on windows with (count > 2) 84class Barrier {
108class Barrier
109{
110public: 85public:
111 Barrier(size_t count) 86 Barrier(size_t count) : m_count(count), m_waiting(0) {}
112 : m_count(count), m_waiting(0)
113 {}
114 87
115 // block until "count" threads call Sync() 88 /// Blocks until all "count" threads have called Sync()
116 bool Sync() 89 void Sync() {
117 {
118 std::unique_lock<std::mutex> lk(m_mutex); 90 std::unique_lock<std::mutex> lk(m_mutex);
119 91
120 // TODO: broken when next round of Sync()s 92 // TODO: broken when next round of Sync()s
121 // is entered before all waiting threads return from the notify_all 93 // is entered before all waiting threads return from the notify_all
122 94
123 if (m_count == ++m_waiting) 95 if (++m_waiting == m_count) {
124 {
125 m_waiting = 0; 96 m_waiting = 0;
126 m_condvar.notify_all(); 97 m_condvar.notify_all();
127 return true; 98 } else {
128 } 99 m_condvar.wait(lk, [&]{ return m_waiting == 0; });
129 else
130 {
131 m_condvar.wait(lk, IsDoneWating(this));
132 return false;
133 } 100 }
134 } 101 }
135 102
136private: 103private:
137 class IsDoneWating
138 {
139 public:
140 IsDoneWating(const Barrier* bar)
141 : m_bar(bar)
142 {}
143
144 bool operator()()
145 {
146 return (0 == m_bar->m_waiting);
147 }
148
149 private:
150 const Barrier* const m_bar;
151 };
152
153 std::condition_variable m_condvar; 104 std::condition_variable m_condvar;
154 std::mutex m_mutex; 105 std::mutex m_mutex;
155 const size_t m_count; 106 const size_t m_count;
156 volatile size_t m_waiting; 107 size_t m_waiting;
157}; 108};
158 109
159void SleepCurrentThread(int ms); 110void SleepCurrentThread(int ms);
diff --git a/src/video_core/rasterizer.cpp b/src/video_core/rasterizer.cpp
index dd46f0ec3..6ec253601 100644
--- a/src/video_core/rasterizer.cpp
+++ b/src/video_core/rasterizer.cpp
@@ -342,10 +342,10 @@ static void ProcessTriangleInternal(const VertexShader::OutputVertex& v0,
342 342
343 case Regs::TextureConfig::MirroredRepeat: 343 case Regs::TextureConfig::MirroredRepeat:
344 { 344 {
345 int coord = (int)((unsigned)val % (2 * size)); 345 unsigned int coord = ((unsigned)val % (2 * size));
346 if (coord >= size) 346 if (coord >= size)
347 coord = 2 * size - 1 - coord; 347 coord = 2 * size - 1 - coord;
348 return coord; 348 return (int)coord;
349 } 349 }
350 350
351 default: 351 default: