mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-06 18:40:36 +00:00
rsx: implemented internal tasks queue (WIP)
This commit is contained in:
parent
7523d01e0f
commit
2e58f312d5
@ -366,7 +366,7 @@ namespace rsx
|
||||
|
||||
if (put == get || !Emu.IsRunning())
|
||||
{
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
||||
do_internal_task();
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -519,6 +519,52 @@ namespace rsx
|
||||
return get_system_time() * 1000;
|
||||
}
|
||||
|
||||
void thread::do_internal_task()
|
||||
{
|
||||
if (m_internal_tasks.empty())
|
||||
{
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ m_mtx_task };
|
||||
|
||||
internal_task_entry &front = m_internal_tasks.front();
|
||||
|
||||
if (front.callback())
|
||||
{
|
||||
front.promise.set_value();
|
||||
m_internal_tasks.pop_front();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::future<void> thread::add_internal_task(std::function<bool()> callback)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock{ m_mtx_task };
|
||||
m_internal_tasks.emplace_back(callback);
|
||||
|
||||
return m_internal_tasks.back().promise.get_future();
|
||||
}
|
||||
|
||||
void thread::invoke(std::function<bool()> callback)
|
||||
{
|
||||
if (get_thread_ctrl() == thread_ctrl::get_current())
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (callback())
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
add_internal_task(callback).wait();
|
||||
}
|
||||
}
|
||||
|
||||
std::array<u32, 4> thread::get_color_surface_addresses() const
|
||||
{
|
||||
u32 offset_color[] =
|
||||
|
@ -329,6 +329,26 @@ namespace rsx
|
||||
virtual u64 timestamp() const;
|
||||
virtual bool on_access_violation(u32 address, bool is_writing) { return false; }
|
||||
|
||||
private:
|
||||
std::mutex m_mtx_task;
|
||||
|
||||
struct internal_task_entry
|
||||
{
|
||||
std::function<bool()> callback;
|
||||
std::promise<void> promise;
|
||||
|
||||
internal_task_entry(std::function<bool()> callback) : callback(callback)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
std::deque<internal_task_entry> m_internal_tasks;
|
||||
void do_internal_task();
|
||||
|
||||
public:
|
||||
std::future<void> add_internal_task(std::function<bool()> callback);
|
||||
void invoke(std::function<bool()> callback);
|
||||
|
||||
/**
|
||||
* Fill buffer with 4x4 scale offset matrix.
|
||||
* Vertex shader's position is to be multiplied by this matrix.
|
||||
|
Loading…
x
Reference in New Issue
Block a user