mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06:00
VideoCommon: use a new async event system for efb access
This commit is contained in:
71
Source/Core/VideoCommon/AsyncRequests.h
Normal file
71
Source/Core/VideoCommon/AsyncRequests.h
Normal file
@ -0,0 +1,71 @@
|
||||
// Copyright 2013 Dolphin Emulator Project
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
class AsyncRequests
|
||||
{
|
||||
public:
|
||||
struct Event
|
||||
{
|
||||
enum Type
|
||||
{
|
||||
EFB_POKE_COLOR,
|
||||
EFB_POKE_Z,
|
||||
EFB_PEEK_COLOR,
|
||||
EFB_PEEK_Z,
|
||||
} type;
|
||||
u64 time;
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
{
|
||||
u16 x;
|
||||
u16 y;
|
||||
u32 data;
|
||||
} efb_poke;
|
||||
|
||||
struct
|
||||
{
|
||||
u16 x;
|
||||
u16 y;
|
||||
u32* data;
|
||||
} efb_peek;
|
||||
};
|
||||
};
|
||||
|
||||
AsyncRequests();
|
||||
|
||||
void PullEvents()
|
||||
{
|
||||
if (!m_empty.load())
|
||||
PullEventsInternal();
|
||||
}
|
||||
void PushEvent(const Event& event, bool blocking = false);
|
||||
void SetEnable(bool enable);
|
||||
|
||||
static AsyncRequests* GetInstance() { return &s_singleton; }
|
||||
|
||||
private:
|
||||
void PullEventsInternal();
|
||||
void HandleEvent(const Event& e);
|
||||
|
||||
static AsyncRequests s_singleton;
|
||||
|
||||
std::atomic<bool> m_empty;
|
||||
std::queue<Event> m_queue;
|
||||
std::mutex m_mutex;
|
||||
std::condition_variable m_cond;
|
||||
|
||||
bool m_wake_me_up_again;
|
||||
bool m_enable;
|
||||
};
|
Reference in New Issue
Block a user