2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2015-01-31 03:38:23 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <condition_variable>
|
|
|
|
#include <mutex>
|
|
|
|
#include <queue>
|
2016-01-17 14:54:31 -07:00
|
|
|
#include <vector>
|
2015-01-31 03:38:23 -07:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-05 08:04:39 -06:00
|
|
|
#include "Common/Flag.h"
|
2015-01-31 03:38:23 -07:00
|
|
|
|
2015-05-01 10:58:11 -06:00
|
|
|
struct EfbPokeData;
|
|
|
|
|
2015-01-31 03:38:23 -07:00
|
|
|
class AsyncRequests
|
|
|
|
{
|
|
|
|
public:
|
2016-06-24 02:43:46 -06:00
|
|
|
struct Event
|
|
|
|
{
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
EFB_POKE_COLOR,
|
|
|
|
EFB_POKE_Z,
|
|
|
|
EFB_PEEK_COLOR,
|
|
|
|
EFB_PEEK_Z,
|
|
|
|
SWAP_EVENT,
|
|
|
|
BBOX_READ,
|
|
|
|
PERF_QUERY,
|
|
|
|
} type;
|
|
|
|
u64 time;
|
|
|
|
|
2017-01-04 04:45:40 -07:00
|
|
|
union
|
|
|
|
{
|
2016-06-24 02:43:46 -06:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 x;
|
|
|
|
u16 y;
|
|
|
|
u32 data;
|
|
|
|
} efb_poke;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 x;
|
|
|
|
u16 y;
|
|
|
|
u32* data;
|
|
|
|
} efb_peek;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 xfbAddr;
|
|
|
|
u32 fbWidth;
|
|
|
|
u32 fbStride;
|
|
|
|
u32 fbHeight;
|
|
|
|
} swap_event;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
u16* data;
|
|
|
|
} bbox;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
} perf_query;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
AsyncRequests();
|
|
|
|
|
|
|
|
void PullEvents()
|
|
|
|
{
|
2016-08-05 08:04:39 -06:00
|
|
|
if (!m_empty.IsSet())
|
2016-06-24 02:43:46 -06:00
|
|
|
PullEventsInternal();
|
|
|
|
}
|
|
|
|
void PushEvent(const Event& event, bool blocking = false);
|
|
|
|
void SetEnable(bool enable);
|
|
|
|
void SetPassthrough(bool enable);
|
|
|
|
|
|
|
|
static AsyncRequests* GetInstance() { return &s_singleton; }
|
2015-01-31 03:38:23 -07:00
|
|
|
private:
|
2016-06-24 02:43:46 -06:00
|
|
|
void PullEventsInternal();
|
|
|
|
void HandleEvent(const Event& e);
|
2015-01-31 03:38:23 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
static AsyncRequests s_singleton;
|
2015-01-31 03:38:23 -07:00
|
|
|
|
2016-08-05 08:04:39 -06:00
|
|
|
Common::Flag m_empty;
|
2016-06-24 02:43:46 -06:00
|
|
|
std::queue<Event> m_queue;
|
|
|
|
std::mutex m_mutex;
|
|
|
|
std::condition_variable m_cond;
|
2015-01-31 03:38:23 -07:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
bool m_wake_me_up_again;
|
|
|
|
bool m_enable;
|
|
|
|
bool m_passthrough;
|
2015-05-01 10:58:11 -06:00
|
|
|
|
2016-06-24 02:43:46 -06:00
|
|
|
std::vector<EfbPokeData> m_merged_efb_pokes;
|
2015-01-31 03:38:23 -07:00
|
|
|
};
|