Skip to content

Commit

Permalink
rsx/overlays: Introduce 'native' HUD UI and implement some common dia…
Browse files Browse the repository at this point in the history
…logs (RPCS3#4011)
  • Loading branch information
kd-11 authored Jan 17, 2018
1 parent 34c49c7 commit 71f69d1
Show file tree
Hide file tree
Showing 56 changed files with 3,681 additions and 212 deletions.
Binary file added bin/Icons/ui/L1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/L2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/R1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/R2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/circle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/dpad.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/dpad_down.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/dpad_left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/dpad_right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/dpad_up.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/fade_bottom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/fade_top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/left_stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/new.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/right_stick.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/save.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/select.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/square.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/start.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added bin/Icons/ui/triangle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 90 additions & 11 deletions rpcs3/Emu/Cell/Modules/cellMsgDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/RSX/GSRender.h"

#include "cellSysutil.h"
#include "cellMsgDialog.h"
Expand Down Expand Up @@ -60,13 +61,6 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
default: return CELL_MSGDIALOG_ERROR_PARAM;
}

const auto dlg = fxm::import<MsgDialogBase>(Emu.GetCallbacks().get_msg_dialog);

if (!dlg)
{
return CELL_SYSUTIL_ERROR_BUSY;
}

if (_type.se_mute_on)
{
// TODO
Expand All @@ -81,6 +75,33 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
cellSysutil.error(msgString.get_ptr());
}

if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg = rsxthr->shell_open_message_dialog())
{
dlg->show(msgString.get_ptr(), _type, [callback, userData](s32 status)
{
if (callback)
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
callback(ppu, status, userData);
return CELL_OK;
});
}
});

return CELL_OK;
}
}

const auto dlg = fxm::import<MsgDialogBase>(Emu.GetCallbacks().get_msg_dialog);

if (!dlg)
{
return CELL_SYSUTIL_ERROR_BUSY;
}

dlg->type = _type;

dlg->on_close = [callback, userData, wptr = std::weak_ptr<MsgDialogBase>(dlg)](s32 status)
Expand Down Expand Up @@ -213,17 +234,40 @@ s32 cellMsgDialogClose(f32 delay)
{
cellSysutil.warning("cellMsgDialogClose(delay=%f)", delay);

extern u64 get_system_time();
const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000);

if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg = rsxthr->shell_get_current_dialog())
{
thread_ctrl::spawn("cellMsgDialogClose() Thread", [=]
{
while (get_system_time() < wait_until)
{
if (Emu.IsStopped())
return;

if (rsxthr->shell_get_current_dialog() != dlg)
return;

std::this_thread::sleep_for(1ms);
}

dlg->close();
});

return CELL_OK;
}
}

const auto dlg = fxm::get<MsgDialogBase>();

if (!dlg)
{
return CELL_MSGDIALOG_ERROR_DIALOG_NOT_OPENED;
}

extern u64 get_system_time();

const u64 wait_until = get_system_time() + static_cast<s64>(std::max<float>(delay, 0.0f) * 1000);

thread_ctrl::spawn("cellMsgDialogClose() Thread", [=]()
{
while (dlg->state == MsgDialogState::Open && get_system_time() < wait_until)
Expand All @@ -243,6 +287,14 @@ s32 cellMsgDialogAbort()
{
cellSysutil.warning("cellMsgDialogAbort()");

if (auto rsxthr = fxm::get<GSRender>())
{
if (rsxthr->shell_close_dialog())
{
return CELL_OK;
}
}

const auto dlg = fxm::get<MsgDialogBase>();

if (!dlg)
Expand All @@ -263,6 +315,15 @@ s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr<char> msgStrin
{
cellSysutil.warning("cellMsgDialogProgressBarSetMsg(progressBarIndex=%d, msgString=%s)", progressBarIndex, msgString);

if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_set_message(progressBarIndex, msgString.get_ptr());
}
}

const auto dlg = fxm::get<MsgDialogBase>();

if (!dlg)
Expand All @@ -287,6 +348,15 @@ s32 cellMsgDialogProgressBarReset(u32 progressBarIndex)
{
cellSysutil.warning("cellMsgDialogProgressBarReset(progressBarIndex=%d)", progressBarIndex);

if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_reset(progressBarIndex);
}
}

const auto dlg = fxm::get<MsgDialogBase>();

if (!dlg)
Expand All @@ -311,6 +381,15 @@ s32 cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
{
cellSysutil.warning("cellMsgDialogProgressBarInc(progressBarIndex=%d, delta=%d)", progressBarIndex, delta);

if (auto rsxthr = fxm::get<GSRender>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_increment(progressBarIndex, (f32)delta);
}
}

const auto dlg = fxm::get<MsgDialogBase>();

if (!dlg)
Expand Down
13 changes: 1 addition & 12 deletions rpcs3/Emu/Cell/Modules/cellSaveData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,18 +355,7 @@ static NEVER_INLINE s32 savedata_op(ppu_thread& ppu, u32 operation, u32 version,
while (funcList)
{
// Display Save Data List asynchronously in the GUI thread.
atomic_t<bool> dlg_result(false);

Emu.CallAfter([&]()
{
selected = Emu.GetCallbacks().get_save_dialog()->ShowSaveDataList(save_entries, focused, operation, listSet);
dlg_result = true;
});

while (!dlg_result)
{
thread_ctrl::wait_for(1000);
}
selected = Emu.GetCallbacks().get_save_dialog()->ShowSaveDataList(save_entries, focused, operation, listSet);

// UI returns -1 for new save games
if (selected == -1)
Expand Down
5 changes: 2 additions & 3 deletions rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,9 +534,8 @@ error_code sceNpTrophyUnlockTrophy(u32 context, u32 handle, s32 trophyId, vm::pt
sceNpTrophy.error("Failed to get info for trophy dialog. Error code %x", ret);
*details = SceNpTrophyDetails();
}
Emu.CallAfter([det = *details, trophyIconData]() {
Emu.GetCallbacks().get_trophy_notification_dialog()->ShowTrophyNotification(det, trophyIconData);
});

Emu.GetCallbacks().get_trophy_notification_dialog()->ShowTrophyNotification(*details, trophyIconData);
}

return CELL_OK;
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/D3D12/D3D12GSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void D3D12GSRender::on_exit()
return GSRender::on_exit();
}

void D3D12GSRender::do_local_task()
void D3D12GSRender::do_local_task(bool)
{
//TODO
m_frame->clear_wm_events();
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/D3D12/D3D12GSRender.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class D3D12GSRender : public GSRender
protected:
virtual void on_init_thread() override;
virtual void on_exit() override;
virtual void do_local_task() override;
virtual void do_local_task(bool idle) override;
virtual bool do_method(u32 cmd, u32 arg) override;
virtual void end() override;
virtual void flip(int buffer) override;
Expand Down
103 changes: 96 additions & 7 deletions rpcs3/Emu/RSX/GL/GLGSRender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ GLGSRender::GLGSRender() : GSRender()
m_vertex_cache.reset(new gl::weak_vertex_cache());

supports_multidraw = !g_cfg.video.strict_rendering_mode;
supports_native_ui = (bool)g_cfg.misc.use_native_interface;
}

extern CellGcmContextData current_context;
Expand Down Expand Up @@ -614,9 +615,6 @@ void GLGSRender::on_init_thread()
{
GSRender::on_init_thread();

m_frame->disable_wm_event_queue();
m_frame->hide();

gl::init();

//Enable adaptive vsync if vsync is requested
Expand Down Expand Up @@ -756,16 +754,71 @@ void GLGSRender::on_init_thread()
glEnable(GL_CLIP_DISTANCE0 + 5);

m_depth_converter.create();
m_ui_renderer.create();

m_gl_texture_cache.initialize();
m_thread_id = std::this_thread::get_id();

m_shaders_cache->load();
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
{
struct native_helper : gl::shader_cache::progress_dialog_helper
{
rsx::thread *owner = nullptr;
rsx::overlays::message_dialog *dlg = nullptr;

native_helper(GLGSRender *ptr) :
owner(ptr) {}

void create() override
{
MsgDialogType type = {};
type.disable_cancel = true;
type.progress_bar_count = 1;

dlg = owner->shell_open_message_dialog();
dlg->show("Loading precompiled shaders from disk...", type, [](s32 status)
{
if (status != CELL_OK)
Emu.Stop();
});
}

void update_msg(u32 processed, u32 entry_count) override
{
dlg->progress_bar_set_message(0, fmt::format("Loading pipeline object %u of %u", processed, entry_count));
owner->flip(0);
}

void inc_value(u32 value) override
{
dlg->progress_bar_increment(0, (f32)value);
owner->flip(0);
}

void close() override
{
dlg->return_code = CELL_OK;
dlg->close();
}
}
helper(this);

m_frame->enable_wm_event_queue();
m_frame->show();
m_frame->enable_wm_event_queue();
m_shaders_cache->load(&helper);
}
}


void GLGSRender::on_exit()
{
m_prog_buffer.clear();
Expand Down Expand Up @@ -826,6 +879,7 @@ void GLGSRender::on_exit()
m_text_printer.close();
m_gl_texture_cache.destroy();
m_depth_converter.destroy();
m_ui_renderer.destroy();

for (u32 i = 0; i < occlusion_query_count; ++i)
{
Expand Down Expand Up @@ -963,8 +1017,22 @@ void GLGSRender::load_program(u32 vertex_base, u32 vertex_count)
m_program->use();

if (m_prog_buffer.check_cache_missed())
{
m_shaders_cache->store(pipeline_properties, vertex_program, fragment_program);

//Notify the user with HUD notification
if (!m_custom_ui)
{
//Create notification but do not draw it at this time. No need to spam flip requests
m_custom_ui = std::make_unique<rsx::overlays::shader_compile_notification>();
}
else if (auto casted = dynamic_cast<rsx::overlays::shader_compile_notification*>(m_custom_ui.get()))
{
//Probe the notification
casted->touch();
}
}

u8 *buf;
u32 vertex_state_offset;
u32 vertex_constants_offset;
Expand Down Expand Up @@ -1244,6 +1312,13 @@ void GLGSRender::flip(int buffer)
gl::screen.clear(gl::buffers::color);
m_flip_fbo.blit(gl::screen, screen_area, areai(aspect_ratio).flipped_vertical(), gl::buffers::color, gl::filter::linear);

if (m_custom_ui)
{
gl::screen.bind();
glViewport(0, 0, m_frame->client_width(), m_frame->client_height());
m_ui_renderer.run(m_frame->client_width(), m_frame->client_height(), 0, *m_custom_ui.get());
}

if (g_cfg.video.overlay)
{
gl::screen.bind();
Expand Down Expand Up @@ -1334,7 +1409,7 @@ void GLGSRender::on_notify_memory_unmapped(u32 address_base, u32 size)
}
}

void GLGSRender::do_local_task()
void GLGSRender::do_local_task(bool idle)
{
m_frame->clear_wm_events();

Expand All @@ -1354,6 +1429,15 @@ void GLGSRender::do_local_task()
lock.unlock();
q.cv.notify_one();
}

if (m_custom_ui)
{
if (!in_begin_end && idle && native_ui_flip_request.load())
{
native_ui_flip_request.store(false);
flip((s32)current_display_buffer);
}
}
}

work_item& GLGSRender::post_flush_request(u32 address, gl::texture_cache::thrashed_set& flush_data)
Expand Down Expand Up @@ -1415,4 +1499,9 @@ void GLGSRender::get_occlusion_query_result(rsx::occlusion_query_info* query)
glGetQueryObjectiv((GLuint)query->driver_handle, GL_QUERY_RESULT, &result);

query->result += result;
}

void GLGSRender::shell_do_cleanup()
{
m_ui_renderer.remove_temp_resources();
}
Loading

0 comments on commit 71f69d1

Please sign in to comment.