Skip to content

Commit 833a366

Browse files
kernel: Use std::list for semaphore
1 parent 5c1de38 commit 833a366

File tree

3 files changed

+20
-22
lines changed

3 files changed

+20
-22
lines changed

src/core/libraries/kernel/threads/semaphore.cpp

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// SPDX-License-Identifier: GPL-2.0-or-later
33

44
#include <condition_variable>
5+
#include <list>
56
#include <mutex>
6-
#include <utility>
7-
#include <boost/intrusive/list.hpp>
87
#include <pthread.h>
98
#include "common/assert.h"
109
#include "common/logging/log.h"
@@ -13,9 +12,6 @@
1312

1413
namespace Libraries::Kernel {
1514

16-
using ListBaseHook =
17-
boost::intrusive::list_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>;
18-
1915
class Semaphore {
2016
public:
2117
Semaphore(s32 init_count, s32 max_count, std::string_view name, bool is_fifo)
@@ -37,7 +33,7 @@ class Semaphore {
3733

3834
// Create waiting thread object and add it into the list of waiters.
3935
WaitingThread waiter{need_count, is_fifo};
40-
AddWaiter(waiter);
36+
AddWaiter(&waiter);
4137

4238
// Perform the wait.
4339
return waiter.Wait(lk, timeout);
@@ -52,14 +48,14 @@ class Semaphore {
5248

5349
// Wake up threads in order of priority.
5450
for (auto it = wait_list.begin(); it != wait_list.end();) {
55-
auto& waiter = *it;
56-
if (waiter.need_count > token_count) {
51+
auto* waiter = *it;
52+
if (waiter->need_count > token_count) {
5753
it++;
5854
continue;
5955
}
6056
it = wait_list.erase(it);
61-
token_count -= waiter.need_count;
62-
waiter.cv.notify_one();
57+
token_count -= waiter->need_count;
58+
waiter->cv.notify_one();
6359
}
6460

6561
return true;
@@ -70,17 +66,17 @@ class Semaphore {
7066
if (num_waiters) {
7167
*num_waiters = wait_list.size();
7268
}
73-
for (auto& waiter : wait_list) {
74-
waiter.was_cancled = true;
75-
waiter.cv.notify_one();
69+
for (auto* waiter : wait_list) {
70+
waiter->was_cancled = true;
71+
waiter->cv.notify_one();
7672
}
7773
wait_list.clear();
7874
token_count = set_count < 0 ? init_count : set_count;
7975
return ORBIS_OK;
8076
}
8177

8278
public:
83-
struct WaitingThread : public ListBaseHook {
79+
struct WaitingThread {
8480
std::condition_variable cv;
8581
u32 priority;
8682
s32 need_count;
@@ -132,24 +128,21 @@ class Semaphore {
132128
}
133129
};
134130

135-
void AddWaiter(WaitingThread& waiter) {
131+
void AddWaiter(WaitingThread* waiter) {
136132
// Insert at the end of the list for FIFO order.
137133
if (is_fifo) {
138134
wait_list.push_back(waiter);
139135
return;
140136
}
141137
// Find the first with priority less then us and insert right before it.
142138
auto it = wait_list.begin();
143-
while (it != wait_list.end() && it->priority > waiter.priority) {
139+
while (it != wait_list.end() && (*it)->priority > waiter->priority) {
144140
it++;
145141
}
146142
wait_list.insert(it, waiter);
147143
}
148144

149-
using WaitingThreads =
150-
boost::intrusive::list<WaitingThread, boost::intrusive::base_hook<ListBaseHook>,
151-
boost::intrusive::constant_time_size<false>>;
152-
WaitingThreads wait_list;
145+
std::list<WaitingThread*> wait_list;
153146
std::string name;
154147
std::atomic<s32> token_count;
155148
std::mutex mutex;

src/video_core/amdgpu/liverpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ struct Liverpool {
167167
static constexpr auto* GetBinaryInfo(const Shader& sh) {
168168
const auto* code = sh.template Address<u32*>();
169169
const auto* bininfo = std::bit_cast<const BinaryInfo*>(code + (code[1] + 1) * 2);
170-
ASSERT_MSG(bininfo->Valid(), "Invalid shader binary header");
170+
// ASSERT_MSG(bininfo->Valid(), "Invalid shader binary header");
171171
return bininfo;
172172
}
173173

src/video_core/renderer_vulkan/vk_pipeline_cache.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,12 @@ void PipelineCache::RefreshGraphicsKey() {
250250
infos[i] = nullptr;
251251
continue;
252252
}
253-
253+
const auto* bininfo = Liverpool::GetBinaryInfo(*pgm);
254+
if (!bininfo->Valid()) {
255+
key.stage_hashes[i] = 0;
256+
infos[i] = nullptr;
257+
continue;
258+
}
254259
const auto stage = Shader::Stage{i};
255260
std::tie(infos[i], modules[i], key.stage_hashes[i]) = GetProgram(pgm, stage, binding);
256261
}

0 commit comments

Comments
 (0)