diff options
-rw-r--r-- | src/common/threadsafe_queue.h | 35 | ||||
-rw-r--r-- | src/core/core_timing.cpp | 4 | ||||
-rw-r--r-- | src/video_core/gpu.cpp | 1 | ||||
-rw-r--r-- | src/video_core/gpu.h | 1 | ||||
-rw-r--r-- | src/video_core/surface.cpp | 2 |
5 files changed, 22 insertions, 21 deletions
diff --git a/src/common/threadsafe_queue.h b/src/common/threadsafe_queue.h index edf13bc49..f553efdc9 100644 --- a/src/common/threadsafe_queue.h +++ b/src/common/threadsafe_queue.h @@ -7,17 +7,16 @@ // a simple lockless thread-safe, // single reader, single writer queue -#include <algorithm> #include <atomic> #include <cstddef> #include <mutex> -#include "common/common_types.h" +#include <utility> namespace Common { -template <typename T, bool NeedSize = true> +template <typename T> class SPSCQueue { public: - SPSCQueue() : size(0) { + SPSCQueue() { write_ptr = read_ptr = new ElementPtr(); } ~SPSCQueue() { @@ -25,13 +24,12 @@ public: delete read_ptr; } - u32 Size() const { - static_assert(NeedSize, "using Size() on FifoQueue without NeedSize"); + std::size_t Size() const { return size.load(); } bool Empty() const { - return !read_ptr->next.load(); + return Size() == 0; } T& Front() const { @@ -47,13 +45,13 @@ public: ElementPtr* new_ptr = new ElementPtr(); write_ptr->next.store(new_ptr, std::memory_order_release); write_ptr = new_ptr; - if (NeedSize) - size++; + + ++size; } void Pop() { - if (NeedSize) - size--; + --size; + ElementPtr* tmpptr = read_ptr; // advance the read pointer read_ptr = tmpptr->next.load(); @@ -66,8 +64,7 @@ public: if (Empty()) return false; - if (NeedSize) - size--; + --size; ElementPtr* tmpptr = read_ptr; read_ptr = tmpptr->next.load(std::memory_order_acquire); @@ -89,7 +86,7 @@ private: // and a pointer to the next ElementPtr class ElementPtr { public: - ElementPtr() : next(nullptr) {} + ElementPtr() {} ~ElementPtr() { ElementPtr* next_ptr = next.load(); @@ -98,21 +95,21 @@ private: } T current; - std::atomic<ElementPtr*> next; + std::atomic<ElementPtr*> next{nullptr}; }; ElementPtr* write_ptr; ElementPtr* read_ptr; - std::atomic<u32> size; + std::atomic_size_t size{0}; }; // a simple thread-safe, // single reader, multiple writer queue -template <typename T, bool NeedSize = true> +template <typename T> class MPSCQueue { public: - u32 Size() const { + std::size_t Size() const { return spsc_queue.Size(); } @@ -144,7 +141,7 @@ public: } private: - SPSCQueue<T, NeedSize> spsc_queue; + SPSCQueue<T> spsc_queue; std::mutex write_lock; }; } // namespace Common diff --git a/src/core/core_timing.cpp b/src/core/core_timing.cpp index 2c44651f2..4ea00c277 100644 --- a/src/core/core_timing.cpp +++ b/src/core/core_timing.cpp @@ -54,10 +54,10 @@ static std::vector<Event> event_queue; static u64 event_fifo_id; // the queue for storing the events from other threads threadsafe until they will be added // to the event_queue by the emu thread -static Common::MPSCQueue<Event, false> ts_queue; +static Common::MPSCQueue<Event> ts_queue; // the queue for unscheduling the events from other threads threadsafe -static Common::MPSCQueue<std::pair<const EventType*, u64>, false> unschedule_queue; +static Common::MPSCQueue<std::pair<const EventType*, u64>> unschedule_queue; constexpr int MAX_SLICE_LENGTH = 20000; diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 018363f95..3d00c308b 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp @@ -18,6 +18,7 @@ namespace Tegra { u32 FramebufferConfig::BytesPerPixel(PixelFormat format) { switch (format) { case PixelFormat::ABGR8: + case PixelFormat::BGRA8: return 4; default: return 4; diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index 21d82e426..a482196ea 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h @@ -80,6 +80,7 @@ class DebugContext; struct FramebufferConfig { enum class PixelFormat : u32 { ABGR8 = 1, + BGRA8 = 5, }; /** diff --git a/src/video_core/surface.cpp b/src/video_core/surface.cpp index 2f6612a35..044ba116a 100644 --- a/src/video_core/surface.cpp +++ b/src/video_core/surface.cpp @@ -426,6 +426,8 @@ PixelFormat PixelFormatFromGPUPixelFormat(Tegra::FramebufferConfig::PixelFormat switch (format) { case Tegra::FramebufferConfig::PixelFormat::ABGR8: return PixelFormat::ABGR8U; + case Tegra::FramebufferConfig::PixelFormat::BGRA8: + return PixelFormat::BGRA8; default: LOG_CRITICAL(HW_GPU, "Unimplemented format={}", static_cast<u32>(format)); UNREACHABLE(); |