2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2015 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-01-31 11:38:23 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <condition_variable>
|
|
|
|
#include <mutex>
|
|
|
|
#include <queue>
|
2016-01-17 22:54:31 +01:00
|
|
|
#include <vector>
|
2015-01-31 11:38:23 +01:00
|
|
|
|
|
|
|
#include "Common/CommonTypes.h"
|
2016-08-05 16:04:39 +02:00
|
|
|
#include "Common/Flag.h"
|
2015-01-31 11:38:23 +01:00
|
|
|
|
2015-05-01 18:58:11 +02:00
|
|
|
struct EfbPokeData;
|
2019-06-29 10:35:12 +02:00
|
|
|
class PointerWrap;
|
2015-05-01 18:58:11 +02:00
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
class AsyncRequests
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
struct Event
|
|
|
|
{
|
|
|
|
enum Type
|
|
|
|
{
|
|
|
|
EFB_POKE_COLOR,
|
|
|
|
EFB_POKE_Z,
|
|
|
|
EFB_PEEK_COLOR,
|
|
|
|
EFB_PEEK_Z,
|
2015-01-31 12:01:01 +01:00
|
|
|
SWAP_EVENT,
|
2015-01-31 12:43:58 +01:00
|
|
|
BBOX_READ,
|
2022-08-18 22:38:37 +02:00
|
|
|
FIFO_RESET,
|
2015-01-31 13:09:25 +01:00
|
|
|
PERF_QUERY,
|
2019-06-29 10:35:12 +02:00
|
|
|
DO_SAVE_STATE,
|
2015-01-31 11:38:23 +01:00
|
|
|
} type;
|
|
|
|
u64 time;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2017-01-04 12:45:40 +01:00
|
|
|
union
|
|
|
|
{
|
2015-01-31 11:38:23 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 x;
|
|
|
|
u16 y;
|
|
|
|
u32 data;
|
|
|
|
} efb_poke;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u16 x;
|
|
|
|
u16 y;
|
|
|
|
u32* data;
|
|
|
|
} efb_peek;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-31 12:01:01 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
u32 xfbAddr;
|
|
|
|
u32 fbWidth;
|
|
|
|
u32 fbStride;
|
|
|
|
u32 fbHeight;
|
|
|
|
} swap_event;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-31 12:43:58 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
int index;
|
|
|
|
u16* data;
|
|
|
|
} bbox;
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2022-08-18 22:38:37 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
} fifo_reset;
|
|
|
|
|
2015-01-31 13:09:25 +01:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
} perf_query;
|
2019-06-29 10:35:12 +02:00
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
PointerWrap* p;
|
|
|
|
} do_save_state;
|
2015-01-31 11:38:23 +01:00
|
|
|
};
|
2016-06-24 10:43:46 +02:00
|
|
|
};
|
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
AsyncRequests();
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
void PullEvents()
|
|
|
|
{
|
2016-08-05 16:04:39 +02:00
|
|
|
if (!m_empty.IsSet())
|
2015-01-31 11:38:23 +01:00
|
|
|
PullEventsInternal();
|
|
|
|
}
|
|
|
|
void PushEvent(const Event& event, bool blocking = false);
|
2020-04-07 19:37:32 +02:00
|
|
|
void WaitForEmptyQueue();
|
2015-01-31 11:38:23 +01:00
|
|
|
void SetEnable(bool enable);
|
2015-01-31 12:01:01 +01:00
|
|
|
void SetPassthrough(bool enable);
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
static AsyncRequests* GetInstance() { return &s_singleton; }
|
2018-04-12 14:18:04 +02:00
|
|
|
|
2015-01-31 11:38:23 +01:00
|
|
|
private:
|
|
|
|
void PullEventsInternal();
|
|
|
|
void HandleEvent(const Event& e);
|
|
|
|
|
|
|
|
static AsyncRequests s_singleton;
|
|
|
|
|
2016-08-05 16:04:39 +02:00
|
|
|
Common::Flag m_empty;
|
2015-01-31 11:38:23 +01:00
|
|
|
std::queue<Event> m_queue;
|
|
|
|
std::mutex m_mutex;
|
|
|
|
std::condition_variable m_cond;
|
|
|
|
|
2018-04-02 01:01:55 +02:00
|
|
|
bool m_wake_me_up_again = false;
|
|
|
|
bool m_enable = false;
|
|
|
|
bool m_passthrough = true;
|
2015-05-01 18:58:11 +02:00
|
|
|
|
|
|
|
std::vector<EfbPokeData> m_merged_efb_pokes;
|
2015-01-31 11:38:23 +01:00
|
|
|
};
|