Skip to content

Commit

Permalink
rsx: Clean up window management code
Browse files Browse the repository at this point in the history
- Removes a lot of wm_event code that was used to perform window management and is no longer needed.
- Significantly simplifies the vulkan code.
- Implements resource management when vulkan window is minimized to allow resources to be freed.
  • Loading branch information
kd-11 committed Jun 10, 2019
1 parent 57196f0 commit d361eed
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 446 deletions.
8 changes: 1 addition & 7 deletions rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp
@@ -1,4 +1,4 @@
#ifdef _MSC_VER
#ifdef _MSC_VER
#include "stdafx.h"
#include "stdafx_d3d12.h"
#include "D3D12GSRender.h"
Expand Down Expand Up @@ -308,12 +308,6 @@ void D3D12GSRender::on_exit()

void D3D12GSRender::do_local_task(rsx::FIFO_state state)
{
if (state != rsx::FIFO_state::lock_wait)
{
//TODO
m_frame->clear_wm_events();
}

rsx::thread::do_local_task(state);
}

Expand Down
7 changes: 0 additions & 7 deletions rpcs3/Emu/RSX/GL/GLGSRender.cpp
Expand Up @@ -939,12 +939,8 @@ void GLGSRender::on_init_thread()

if (!supports_native_ui)
{
m_frame->disable_wm_event_queue();
m_frame->hide();

m_shaders_cache->load(nullptr);

m_frame->enable_wm_event_queue();
m_frame->show();
}
else
Expand Down Expand Up @@ -1004,7 +1000,6 @@ void GLGSRender::on_init_thread()
}
helper(this);

m_frame->enable_wm_event_queue();
m_shaders_cache->load(&helper);
}
}
Expand Down Expand Up @@ -1918,8 +1913,6 @@ void GLGSRender::do_local_task(rsx::FIFO_state state)
return;
}

m_frame->clear_wm_events();

if (m_overlay_manager)
{
if (!in_begin_end && async_flip_requested & flip_request::native_ui)
Expand Down
4 changes: 1 addition & 3 deletions rpcs3/Emu/RSX/GSRender.cpp
@@ -1,4 +1,4 @@
#include "stdafx.h"
#include "stdafx.h"
#include "Emu/Memory/vm.h"
#include "Emu/System.h"

Expand Down Expand Up @@ -41,8 +41,6 @@ void GSRender::on_exit()
{
if (m_frame)
{
m_frame->disable_wm_event_queue();
m_frame->clear_wm_events();
m_frame->delete_context(m_context);
m_context = nullptr;
}
Expand Down
72 changes: 0 additions & 72 deletions rpcs3/Emu/RSX/GSRender.h
Expand Up @@ -84,78 +84,6 @@ using draw_context_t = void*;
virtual int client_height() = 0;

virtual display_handle_t handle() const = 0;

protected:

// window manager event management
std::deque<wm_event> m_raised_events;
std::atomic_bool wm_event_queue_enabled = {};
std::atomic_bool wm_allow_fullscreen = { true };

public:
// synchronize native window access
shared_mutex wm_event_lock;

void wm_wait() const
{
while (!m_raised_events.empty() && !Emu.IsStopped()) _mm_pause();
}

bool has_wm_events() const
{
return !m_raised_events.empty();
}

void clear_wm_events()
{
if (!m_raised_events.empty())
{
std::lock_guard lock(wm_event_lock);
m_raised_events.clear();
}
}

void push_wm_event(wm_event&& _event)
{
std::lock_guard lock(wm_event_lock);
m_raised_events.push_back(_event);
}

wm_event get_wm_event()
{
if (m_raised_events.empty())
{
return wm_event::none;
}
else
{
std::lock_guard lock(wm_event_lock);

const auto _event = m_raised_events.front();
m_raised_events.pop_front();
return _event;
}
}

void disable_wm_event_queue()
{
wm_event_queue_enabled.store(false);
}

void enable_wm_event_queue()
{
wm_event_queue_enabled.store(true);
}

void disable_wm_fullscreen()
{
wm_allow_fullscreen.store(false);
}

void enable_wm_fullscreen()
{
wm_allow_fullscreen.store(true);
}
};

class GSRender : public rsx::thread
Expand Down

0 comments on commit d361eed

Please sign in to comment.