summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/common/logging/backend.cpp19
-rw-r--r--src/common/logging/backend.h1
-rw-r--r--src/common/threadsafe_queue.h18
-rw-r--r--src/core/hle/kernel/address_arbiter.cpp6
-rw-r--r--src/core/hle/kernel/address_arbiter.h6
-rw-r--r--src/video_core/renderer_opengl/renderer_opengl.cpp3
6 files changed, 32 insertions, 21 deletions
diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp
index a5e031189..b369f199f 100644
--- a/src/common/logging/backend.cpp
+++ b/src/common/logging/backend.cpp
@@ -40,9 +40,7 @@ public:
const Impl& operator=(Impl const&) = delete;
void PushEntry(Entry e) {
- std::lock_guard<std::mutex> lock(message_mutex);
message_queue.Push(std::move(e));
- message_cv.notify_one();
}
void AddBackend(std::unique_ptr<Backend> backend) {
@@ -86,15 +84,13 @@ private:
}
};
while (true) {
- {
- std::unique_lock<std::mutex> lock(message_mutex);
- message_cv.wait(lock, [&] { return !running || message_queue.Pop(entry); });
- }
- if (!running) {
+ entry = message_queue.PopWait();
+ if (entry.final_entry) {
break;
}
write_logs(entry);
}
+
// Drain the logging queue. Only writes out up to MAX_LOGS_TO_WRITE to prevent a case
// where a system is repeatedly spamming logs even on close.
const int MAX_LOGS_TO_WRITE = filter.IsDebug() ? INT_MAX : 100;
@@ -106,14 +102,13 @@ private:
}
~Impl() {
- running = false;
- message_cv.notify_one();
+ Entry entry;
+ entry.final_entry = true;
+ message_queue.Push(entry);
backend_thread.join();
}
- std::atomic_bool running{true};
- std::mutex message_mutex, writing_mutex;
- std::condition_variable message_cv;
+ std::mutex writing_mutex;
std::thread backend_thread;
std::vector<std::unique_ptr<Backend>> backends;
Common::MPSCQueue<Log::Entry> message_queue;
diff --git a/src/common/logging/backend.h b/src/common/logging/backend.h
index 91bb0c309..a31ee6968 100644
--- a/src/common/logging/backend.h
+++ b/src/common/logging/backend.h
@@ -27,6 +27,7 @@ struct Entry {
unsigned int line_num;
std::string function;
std::string message;
+ bool final_entry = false;
Entry() = default;
Entry(Entry&& o) = default;
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h
index f553efdc9..821e8536a 100644
--- a/src/common/threadsafe_queue.h
+++ b/src/common/threadsafe_queue.h
@@ -8,6 +8,7 @@
// single reader, single writer queue
#include <atomic>
+#include <condition_variable>
#include <cstddef>
#include <mutex>
#include <utility>
@@ -45,6 +46,7 @@ public:
ElementPtr* new_ptr = new ElementPtr();
write_ptr->next.store(new_ptr, std::memory_order_release);
write_ptr = new_ptr;
+ cv.notify_one();
++size;
}
@@ -74,6 +76,16 @@ public:
return true;
}
+ T PopWait() {
+ if (Empty()) {
+ std::unique_lock<std::mutex> lock(cv_mutex);
+ cv.wait(lock, [this]() { return !Empty(); });
+ }
+ T t;
+ Pop(t);
+ return t;
+ }
+
// not thread-safe
void Clear() {
size.store(0);
@@ -101,6 +113,8 @@ private:
ElementPtr* write_ptr;
ElementPtr* read_ptr;
std::atomic_size_t size{0};
+ std::mutex cv_mutex;
+ std::condition_variable cv;
};
// a simple thread-safe,
@@ -135,6 +149,10 @@ public:
return spsc_queue.Pop(t);
}
+ T PopWait() {
+ return spsc_queue.PopWait();
+ }
+
// not thread-safe
void Clear() {
spsc_queue.Clear();
diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp
index 57157beb4..a250d088d 100644
--- a/src/core/hle/kernel/address_arbiter.cpp
+++ b/src/core/hle/kernel/address_arbiter.cpp
@@ -17,8 +17,7 @@
#include "core/hle/result.h"
#include "core/memory.h"
-namespace Kernel {
-namespace AddressArbiter {
+namespace Kernel::AddressArbiter {
// Performs actual address waiting logic.
static ResultCode WaitForAddress(VAddr address, s64 timeout) {
@@ -176,5 +175,4 @@ ResultCode WaitForAddressIfEqual(VAddr address, s32 value, s64 timeout) {
return WaitForAddress(address, timeout);
}
-} // namespace AddressArbiter
-} // namespace Kernel
+} // namespace Kernel::AddressArbiter
diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h
index e3657b8e9..b58f21bec 100644
--- a/src/core/hle/kernel/address_arbiter.h
+++ b/src/core/hle/kernel/address_arbiter.h
@@ -8,9 +8,8 @@
union ResultCode;
-namespace Kernel {
+namespace Kernel::AddressArbiter {
-namespace AddressArbiter {
enum class ArbitrationType {
WaitIfLessThan = 0,
DecrementAndWaitIfLessThan = 1,
@@ -29,6 +28,5 @@ ResultCode ModifyByWaitingCountAndSignalToAddressIfEqual(VAddr address, s32 valu
ResultCode WaitForAddressIfLessThan(VAddr address, s32 value, s64 timeout, bool should_decrement);
ResultCode WaitForAddressIfEqual(VAddr address, s32 value, s64 timeout);
-} // namespace AddressArbiter
-} // namespace Kernel
+} // namespace Kernel::AddressArbiter
diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp
index d40666ac6..272fc2e8e 100644
--- a/src/video_core/renderer_opengl/renderer_opengl.cpp
+++ b/src/video_core/renderer_opengl/renderer_opengl.cpp
@@ -380,7 +380,8 @@ void RendererOpenGL::CaptureScreenshot() {
GLuint renderbuffer;
glGenRenderbuffers(1, &renderbuffer);
glBindRenderbuffer(GL_RENDERBUFFER, renderbuffer);
- glRenderbufferStorage(GL_RENDERBUFFER, GL_RGB8, layout.width, layout.height);
+ glRenderbufferStorage(GL_RENDERBUFFER, state.GetsRGBUsed() ? GL_SRGB8 : GL_RGB8, layout.width,
+ layout.height);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, renderbuffer);
DrawScreen(layout);