Native UI refactored (#4623)

Refactor and improve native overlays
This commit is contained in:
kd-11 2018-05-20 23:05:00 +03:00 committed by GitHub
parent 68fff54a8b
commit f6f45b8699
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 310 additions and 219 deletions

View File

@ -2,7 +2,7 @@
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/Cell/PPUModule.h"
#include "Emu/RSX/GSRender.h"
#include "Emu/RSX/Overlays/overlays.h"
#include "cellSysutil.h"
#include "cellMsgDialog.h"
@ -75,24 +75,21 @@ s32 cellMsgDialogOpen2(u32 type, vm::cptr<char> msgString, vm::ptr<CellMsgDialog
cellSysutil.error(msgString.get_ptr());
}
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg = rsxthr->shell_open_message_dialog())
manager->create<rsx::overlays::message_dialog>()->show(msgString.get_ptr(), _type, [callback, userData](s32 status)
{
dlg->show(msgString.get_ptr(), _type, [callback, userData](s32 status)
if (callback)
{
if (callback)
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
sysutil_register_cb([=](ppu_thread& ppu) -> s32
{
callback(ppu, status, userData);
return CELL_OK;
});
}
});
callback(ppu, status, userData);
return CELL_OK;
});
}
});
return CELL_OK;
}
return CELL_OK;
}
const auto dlg = fxm::import<MsgDialogBase>(Emu.GetCallbacks().get_msg_dialog);
@ -237,9 +234,9 @@ s32 cellMsgDialogClose(f32 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 manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg = rsxthr->shell_get_current_dialog())
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
thread_ctrl::spawn("cellMsgDialogClose() Thread", [=]
{
@ -248,7 +245,7 @@ s32 cellMsgDialogClose(f32 delay)
if (Emu.IsStopped())
return;
if (rsxthr->shell_get_current_dialog() != dlg)
if (manager->get<rsx::overlays::message_dialog>() != dlg)
return;
std::this_thread::sleep_for(1ms);
@ -287,10 +284,11 @@ s32 cellMsgDialogAbort()
{
cellSysutil.warning("cellMsgDialogAbort()");
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (rsxthr->shell_close_dialog())
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
dlg->close();
return CELL_OK;
}
}
@ -320,12 +318,11 @@ s32 cellMsgDialogProgressBarSetMsg(u32 progressBarIndex, vm::cptr<char> msgStrin
return CELL_MSGDIALOG_ERROR_PARAM;
}
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_set_message(progressBarIndex, msgString.get_ptr());
return dlg->progress_bar_set_message(progressBarIndex, msgString.get_ptr());
}
}
@ -353,12 +350,11 @@ s32 cellMsgDialogProgressBarReset(u32 progressBarIndex)
{
cellSysutil.warning("cellMsgDialogProgressBarReset(progressBarIndex=%d)", progressBarIndex);
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_reset(progressBarIndex);
return dlg->progress_bar_reset(progressBarIndex);
}
}
@ -386,12 +382,11 @@ s32 cellMsgDialogProgressBarInc(u32 progressBarIndex, u32 delta)
{
cellSysutil.warning("cellMsgDialogProgressBarInc(progressBarIndex=%d, delta=%d)", progressBarIndex, delta);
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg2 = rsxthr->shell_get_current_dialog())
if (auto dlg = manager->get<rsx::overlays::message_dialog>())
{
if (auto casted = dynamic_cast<rsx::overlays::message_dialog*>(dlg2))
return casted->progress_bar_increment(progressBarIndex, (f32)delta);
return dlg->progress_bar_increment(progressBarIndex, (f32)delta);
}
}

View File

@ -847,7 +847,7 @@ void GLGSRender::on_init_thread()
type.disable_cancel = true;
type.progress_bar_count = 1;
dlg = owner->shell_open_message_dialog();
dlg = fxm::get<rsx::overlays::display_manager>()->create<rsx::overlays::message_dialog>();
dlg->show("Loading precompiled shaders from disk...", type, [](s32 status)
{
if (status != CELL_OK)
@ -1113,15 +1113,18 @@ void GLGSRender::load_program(const gl::vertex_upload_info& upload_info)
//Notify the user with HUD notification
if (g_cfg.misc.show_shader_compilation_hint)
{
if (!m_custom_ui)
if (m_overlay_manager)
{
//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();
if (auto dlg = m_overlay_manager->get<rsx::overlays::shader_compile_notification>())
{
//Extend duration
dlg->touch();
}
else
{
//Create dialog but do not show immediately
m_overlay_manager->create<rsx::overlays::shader_compile_notification>();
}
}
}
}
@ -1461,11 +1464,28 @@ void GLGSRender::flip(int buffer)
}
}
if (m_custom_ui)
if (m_overlay_manager)
{
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 (m_overlay_manager->has_dirty())
{
for (const auto& uid : m_overlay_manager->get_dirty())
{
m_ui_renderer.remove_temp_resources(uid);
}
m_overlay_manager->clear_dirty();
}
if (m_overlay_manager->has_visible())
{
gl::screen.bind();
glViewport(0, 0, m_frame->client_width(), m_frame->client_height());
for (const auto& view : m_overlay_manager->get_views())
{
m_ui_renderer.run(m_frame->client_width(), m_frame->client_height(), 0, *view.get());
}
}
}
if (g_cfg.video.overlay)
@ -1582,12 +1602,7 @@ void GLGSRender::do_local_task(bool /*idle*/)
m_gl_texture_cache.do_update();
}
if (m_overlay_cleanup_requests.size())
{
m_ui_renderer.remove_temp_resources();
m_overlay_cleanup_requests.clear();
}
else if (m_custom_ui)
if (m_overlay_manager)
{
if (!in_begin_end && native_ui_flip_request.load())
{
@ -1673,9 +1688,3 @@ void GLGSRender::discard_occlusion_query(rsx::reports::occlusion_query_info* que
glEndQuery(GL_ANY_SAMPLES_PASSED);
}
}
void GLGSRender::shell_do_cleanup()
{
//TODO: Key cleanup requests with UID to identify resources to remove
m_overlay_cleanup_requests.push_back(0);
}

View File

@ -313,8 +313,6 @@ private:
gl::ui_overlay_renderer m_ui_renderer;
gl::video_out_calibration_pass m_video_output_pass;
std::vector<u64> m_overlay_cleanup_requests;
shared_mutex queue_guard;
std::list<work_item> work_queue;
@ -391,6 +389,4 @@ protected:
std::array<std::vector<gsl::byte>, 4> copy_render_targets_to_memory() override;
std::array<std::vector<gsl::byte>, 2> copy_depth_stencil_buffer_to_memory() override;
void shell_do_cleanup() override;
};

View File

@ -2,7 +2,7 @@
#include "stdafx.h"
#include "GLHelpers.h"
#include "../overlays.h"
#include "../Overlays/overlays.h"
extern u64 get_system_time();
@ -327,7 +327,7 @@ namespace gl
{
u32 num_elements = 0;
std::vector<std::unique_ptr<gl::texture>> resources;
std::unordered_map<u64, std::unique_ptr<gl::texture>> temp_image_cache;
std::unordered_map<u64, std::pair<u32, std::unique_ptr<gl::texture>>> temp_image_cache;
std::unordered_map<u64, std::unique_ptr<gl::texture_view>> temp_view_cache;
std::unordered_map<u64, std::unique_ptr<gl::texture>> font_cache;
std::unordered_map<u64, std::unique_ptr<gl::texture_view>> view_cache;
@ -392,7 +392,7 @@ namespace gl
};
}
gl::texture_view* load_simple_image(rsx::overlays::image_info* desc, bool temp_resource)
gl::texture_view* load_simple_image(rsx::overlays::image_info* desc, bool temp_resource, u32 owner_uid)
{
auto tex = std::make_unique<gl::texture>(GL_TEXTURE_2D, desc->w, desc->h, 1, 1, GL_RGBA8);
tex->copy_from(desc->data, gl::texture::format::rgba, gl::texture::type::uint_8_8_8_8);
@ -409,7 +409,7 @@ namespace gl
else
{
u64 key = (u64)desc;
temp_image_cache[key] = std::move(tex);
temp_image_cache[key] = std::move(std::make_pair(owner_uid, std::move(tex)));
temp_view_cache[key] = std::move(view);
}
@ -425,7 +425,7 @@ namespace gl
for (const auto &res : configuration.texture_raw_data)
{
load_simple_image(res.get(), false);
load_simple_image(res.get(), false, UINT32_MAX);
}
configuration.free_resources();
@ -439,9 +439,22 @@ namespace gl
overlay_pass::destroy();
}
void remove_temp_resources()
void remove_temp_resources(u64 key)
{
temp_image_cache.clear();
std::vector<u64> keys_to_remove;
for (auto It = temp_image_cache.begin(); It != temp_image_cache.end(); ++It)
{
if (It->second.first == key)
{
keys_to_remove.push_back(It->first);
}
}
for (const auto& _key : keys_to_remove)
{
temp_image_cache.erase(_key);
temp_view_cache.erase(_key);
}
}
gl::texture_view* find_font(rsx::overlays::font *font)
@ -465,7 +478,7 @@ namespace gl
return result;
}
gl::texture_view* find_temp_image(rsx::overlays::image_info *desc)
gl::texture_view* find_temp_image(rsx::overlays::image_info *desc, u32 owner_uid)
{
auto key = (u64)desc;
auto cached = temp_view_cache.find(key);
@ -475,7 +488,7 @@ namespace gl
}
else
{
return load_simple_image(desc, true);
return load_simple_image(desc, true, owner_uid);
}
}
@ -535,7 +548,7 @@ namespace gl
}
case rsx::overlays::image_resource_id::raw_image:
{
glBindTexture(GL_TEXTURE_2D, find_temp_image((rsx::overlays::image_info*)cmd.first.external_data_ref)->id());
glBindTexture(GL_TEXTURE_2D, find_temp_image((rsx::overlays::image_info*)cmd.first.external_data_ref, ui.uid)->id());
break;
}
case rsx::overlays::image_resource_id::font_file:

View File

@ -1,6 +1,6 @@
#include "stdafx.h"
#include "overlays.h"
#include "GSRender.h"
#include "../GSRender.h"
namespace rsx
{
@ -13,8 +13,8 @@ namespace rsx
{
//Force unload
exit = true;
if (auto rsxthr = fxm::get<GSRender>())
rsxthr->shell_close_dialog();
if (auto manager = fxm::get<display_manager>())
manager->remove(uid);
if (on_close)
on_close(return_code);

View File

@ -1,8 +1,8 @@
#pragma once
#include "overlay_controls.h"
#include "../../Utilities/Thread.h"
#include "../Io/PadHandler.h"
#include "../../../Utilities/Thread.h"
#include "../../Io/PadHandler.h"
#include "Emu/Memory/vm.h"
#include "Emu/IdManager.h"
#include "pad_thread.h"
@ -43,6 +43,9 @@ namespace rsx
cross
};
u32 uid = UINT32_MAX;
u32 type_index = UINT32_MAX;
u16 virtual_width = 1280;
u16 virtual_height = 720;
@ -161,6 +164,137 @@ namespace rsx
}
};
class display_manager
{
private:
atomic_t<u32> m_uid_ctr { 0u };
std::vector<std::unique_ptr<user_interface>> m_iface_list;
std::vector<u32> m_uids_to_clean;
public:
display_manager() {}
~display_manager() {}
template <typename T>
T* add(std::unique_ptr<T>& entry, bool remove_existing = true)
{
T* e = entry.get();
e->uid = m_uid_ctr.fetch_add(1);
e->type_index = id_manager::typeinfo::get_index<T>();
if (remove_existing)
{
for (auto It = m_iface_list.begin(); It != m_iface_list.end(); It++)
{
if (It->get()->type_index == e->type_index)
{
// Replace
m_uids_to_clean.push_back(It->get()->uid);
It->reset(e);
entry.reset();
return e;
}
}
}
m_iface_list.push_back(std::move(entry));
return e;
}
template <typename T, typename ...Args>
T* create(Args&&... args)
{
std::unique_ptr<T> object = std::make_unique<T>(std::forward<Args>(args)...);
return add(object);
}
bool remove(u32 uid)
{
for (auto It = m_iface_list.begin(); It != m_iface_list.end(); It++)
{
const auto e = It->get();
if (e->uid == uid)
{
m_iface_list.erase(It);
m_uids_to_clean.push_back(uid);
return true;
}
}
return false;
}
template <typename T>
bool remove()
{
const auto type_id = id_manager::typeinfo::get_index<T>();
for (auto It = m_iface_list.begin(); It != m_iface_list.end();)
{
if (It->get()->type_index == type_id)
{
It = m_iface_list.erase(It);
}
else
{
++It;
}
}
}
// True if any visible elements to draw exist
bool has_visible() const
{
return !m_iface_list.empty();
}
// True if any elements have been deleted but their resources may not have been cleaned up
bool has_dirty() const
{
return !m_uids_to_clean.empty();
}
const std::vector<std::unique_ptr<user_interface>>& get_views() const
{
return m_iface_list;
}
const std::vector<u32>& get_dirty() const
{
return m_uids_to_clean;
}
void clear_dirty()
{
m_uids_to_clean.clear();
}
user_interface* get(u32 uid) const
{
for (const auto& iface : m_iface_list)
{
if (iface->uid == uid)
return iface.get();
}
return nullptr;
}
template <typename T>
T* get() const
{
const auto type_id = id_manager::typeinfo::get_index<T>();
for (const auto& iface : m_iface_list)
{
if (iface->type_index == type_id)
{
return static_cast<T*>(iface.get());
}
}
return nullptr;
}
};
struct fps_display : user_interface
{
label m_display;

View File

@ -344,6 +344,11 @@ namespace rsx
void thread::on_task()
{
if (supports_native_ui)
{
m_overlay_manager = fxm::make_always<rsx::overlays::display_manager>();
}
on_init_thread();
reset();
@ -2344,69 +2349,6 @@ namespace rsx
return performance_counters.approximate_load;
}
//TODO: Move these helpers into a better class dedicated to shell interface handling (use idm?)
//They are not dependent on rsx at all
rsx::overlays::save_dialog* thread::shell_open_save_dialog()
{
if (supports_native_ui)
{
auto ptr = new rsx::overlays::save_dialog();
m_custom_ui.reset(ptr);
return ptr;
}
else
{
return nullptr;
}
}
rsx::overlays::message_dialog* thread::shell_open_message_dialog()
{
if (supports_native_ui)
{
auto ptr = new rsx::overlays::message_dialog();
m_custom_ui.reset(ptr);
return ptr;
}
else
{
return nullptr;
}
}
rsx::overlays::trophy_notification* thread::shell_open_trophy_notification()
{
if (supports_native_ui)
{
auto ptr = new rsx::overlays::trophy_notification();
m_custom_ui.reset(ptr);
return ptr;
}
else
{
return nullptr;
}
}
rsx::overlays::user_interface* thread::shell_get_current_dialog()
{
//TODO: Only get dialog type interfaces
return m_custom_ui.get();
}
bool thread::shell_close_dialog()
{
//TODO: Only get dialog type interfaces
if (m_custom_ui)
{
m_invalidated_ui = std::move(m_custom_ui);
shell_do_cleanup();
return true;
}
return false;
}
namespace reports
{
void ZCULL_control::set_enabled(class ::rsx::thread* ptimer, bool state)

View File

@ -12,7 +12,7 @@
#include "RSXFragmentProgram.h"
#include "rsx_methods.h"
#include "rsx_utils.h"
#include "overlays.h"
#include "Overlays/overlays.h"
#include <Utilities/GSL.h>
#include "Utilities/Thread.h"
@ -294,7 +294,7 @@ namespace rsx
rsx::gcm_framebuffer_info m_depth_surface_info;
bool framebuffer_status_valid = false;
std::unique_ptr<rsx::overlays::user_interface> m_custom_ui;
std::shared_ptr<rsx::overlays::display_manager> m_overlay_manager;
std::unique_ptr<rsx::overlays::user_interface> m_invalidated_ui;
public:
@ -571,14 +571,5 @@ namespace rsx
//Get RSX approximate load in %
u32 get_load();
//HLE vsh stuff
//TODO: Move into a separate helper
virtual rsx::overlays::save_dialog* shell_open_save_dialog();
virtual rsx::overlays::message_dialog* shell_open_message_dialog();
virtual rsx::overlays::trophy_notification* shell_open_trophy_notification();
virtual rsx::overlays::user_interface* shell_get_current_dialog();
virtual bool shell_close_dialog();
virtual void shell_do_cleanup(){}
};
}

View File

@ -1587,7 +1587,7 @@ void VKGSRender::on_init_thread()
type.disable_cancel = true;
type.progress_bar_count = 1;
dlg = owner->shell_open_message_dialog();
dlg = fxm::get<rsx::overlays::display_manager>()->create<rsx::overlays::message_dialog>();
dlg->show("Loading precompiled shaders from disk...", type, [](s32 status)
{
if (status != CELL_OK)
@ -2026,6 +2026,16 @@ void VKGSRender::process_swap_request(frame_context_t *ctx, bool free_resources)
m_text_writer->reset_descriptors();
}
if (m_overlay_manager && m_overlay_manager->has_dirty())
{
for (const auto& uid : m_overlay_manager->get_dirty())
{
m_ui_renderer->remove_temp_resources(uid);
}
m_overlay_manager->clear_dirty();
}
m_attachment_clear_pass->free_resources();
m_depth_converter->free_resources();
m_depth_scaler->free_resources();
@ -2166,14 +2176,7 @@ void VKGSRender::do_local_task(bool /*idle*/)
#endif
//TODO: Guard this
if (m_overlay_cleanup_requests.size())
{
flush_command_queue(true);
m_ui_renderer->remove_temp_resources();
m_overlay_cleanup_requests.clear();
}
else if (m_custom_ui)
if (m_overlay_manager)
{
if (!in_begin_end && native_ui_flip_request.load())
{
@ -2356,15 +2359,18 @@ void VKGSRender::load_program(const vk::vertex_upload_info& vertex_info)
//Notify the user with HUD notification
if (g_cfg.misc.show_shader_compilation_hint)
{
if (!m_custom_ui)
if (m_overlay_manager)
{
//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();
if (auto dlg = m_overlay_manager->get<rsx::overlays::shader_compile_notification>())
{
//Extend duration
dlg->touch();
}
else
{
//Create dialog but do not show immediately
m_overlay_manager->create<rsx::overlays::shader_compile_notification>();
}
}
}
}
@ -3174,7 +3180,8 @@ void VKGSRender::flip(int buffer)
std::unique_ptr<vk::framebuffer_holder> direct_fbo;
std::vector<std::unique_ptr<vk::image_view>> swap_image_view;
if (g_cfg.video.overlay || m_custom_ui)
const bool has_overlay = (m_overlay_manager && m_overlay_manager->has_visible());
if (g_cfg.video.overlay || has_overlay)
{
//Change the image layout whilst setting up a dependency on waiting for the blit op to finish before we start writing
VkImageSubresourceRange subres = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
@ -3212,9 +3219,12 @@ void VKGSRender::flip(int buffer)
direct_fbo.reset(new vk::framebuffer_holder(*m_device, single_target_pass, m_client_width, m_client_height, std::move(swap_image_view)));
}
if (m_custom_ui)
if (has_overlay)
{
m_ui_renderer->run(*m_current_command_buffer, direct_fbo->width(), direct_fbo->height(), direct_fbo.get(), single_target_pass, m_texture_upload_buffer_ring_info, *m_custom_ui);
for (const auto& view : m_overlay_manager->get_views())
{
m_ui_renderer->run(*m_current_command_buffer, direct_fbo->width(), direct_fbo->height(), direct_fbo.get(), single_target_pass, m_texture_upload_buffer_ring_info, *view.get());
}
}
if (g_cfg.video.overlay)
@ -3434,9 +3444,3 @@ void VKGSRender::discard_occlusion_query(rsx::reports::occlusion_query_info* que
m_occlusion_query_pool.reset_queries(*m_current_command_buffer, data.indices);
m_occlusion_map.erase(query->driver_handle);
}
void VKGSRender::shell_do_cleanup()
{
//TODO: Guard this
m_overlay_cleanup_requests.push_back(0);
}

View File

@ -365,8 +365,6 @@ private:
//Vertex layout
rsx::vertex_input_layout m_vertex_layout;
std::vector<u64> m_overlay_cleanup_requests;
#if !defined(_WIN32) && defined(HAVE_VULKAN)
Display *m_display_handle = nullptr;
#endif
@ -428,6 +426,4 @@ protected:
bool on_access_violation(u32 address, bool is_writing) override;
void on_notify_memory_unmapped(u32 address_base, u32 size) override;
void shell_do_cleanup() override;
};

View File

@ -4,7 +4,7 @@
#include "VKFragmentProgram.h"
#include "VKRenderTargets.h"
#include "../overlays.h"
#include "../Overlays/overlays.h"
namespace vk
{
@ -417,7 +417,7 @@ namespace vk
std::vector<std::unique_ptr<vk::image>> resources;
std::unordered_map<u64, std::unique_ptr<vk::image>> font_cache;
std::unordered_map<u64, std::unique_ptr<vk::image_view>> view_cache;
std::vector<std::unique_ptr<vk::image>> temp_image_cache;
std::unordered_map<u64, std::pair<u32, std::unique_ptr<vk::image>>> temp_image_cache;
std::unordered_map<u64, std::unique_ptr<vk::image_view>> temp_view_cache;
ui_overlay_renderer()
@ -491,7 +491,7 @@ namespace vk
}
vk::image_view* upload_simple_texture(vk::render_device &dev, vk::command_buffer &cmd,
vk::vk_data_heap& upload_heap, u64 key, int w, int h, bool font, bool temp, void *pixel_src)
vk::vk_data_heap& upload_heap, u64 key, int w, int h, bool font, bool temp, void *pixel_src, u32 owner_uid)
{
const VkFormat format = (font) ? VK_FORMAT_R8_UNORM : VK_FORMAT_B8G8R8A8_UNORM;
const u32 pitch = (font) ? w : w * 4;
@ -543,7 +543,7 @@ namespace vk
else if (!temp)
resources.push_back(std::move(tex));
else
temp_image_cache.push_back(std::move(tex));
temp_image_cache[key] = std::move(std::make_pair(owner_uid, std::move(tex)));
return result;
}
@ -559,7 +559,7 @@ namespace vk
u64 storage_key = 1;
for (const auto &res : configuration.texture_raw_data)
{
upload_simple_texture(dev, cmd, upload_heap, storage_key++, res->w, res->h, false, false, res->data);
upload_simple_texture(dev, cmd, upload_heap, storage_key++, res->w, res->h, false, false, res->data, UINT32_MAX);
}
configuration.free_resources();
@ -577,10 +577,22 @@ namespace vk
overlay_pass::destroy();
}
void remove_temp_resources()
void remove_temp_resources(u32 key)
{
temp_image_cache.clear();
temp_view_cache.clear();
std::vector<u64> keys_to_remove;
for (auto It = temp_image_cache.begin(); It != temp_image_cache.end(); ++It)
{
if (It->second.first == key)
{
keys_to_remove.push_back(It->first);
}
}
for (const auto& _key : keys_to_remove)
{
temp_image_cache.erase(_key);
temp_view_cache.erase(_key);
}
}
vk::image_view* find_font(rsx::overlays::font *font, vk::command_buffer &cmd, vk::vk_data_heap &upload_heap)
@ -591,17 +603,19 @@ namespace vk
return found->second.get();
//Create font file
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, font->width, font->height, true, false, font->glyph_data.data());
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, font->width, font->height,
true, false, font->glyph_data.data(), UINT32_MAX);
}
vk::image_view* find_temp_image(rsx::overlays::image_info *desc, vk::command_buffer &cmd, vk::vk_data_heap &upload_heap)
vk::image_view* find_temp_image(rsx::overlays::image_info *desc, vk::command_buffer &cmd, vk::vk_data_heap &upload_heap, u32 owner_uid)
{
u64 key = (u64)desc;
auto found = temp_view_cache.find(key);
if (found != temp_view_cache.end())
return found->second.get();
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, desc->w, desc->h, false, true, desc->data);
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, desc->w, desc->h,
false, true, desc->data, owner_uid);
}
void update_uniforms(vk::glsl::program* /*program*/) override
@ -674,7 +688,7 @@ namespace vk
src = find_font(command.first.font_ref, cmd, upload_heap)->value;
break;
case rsx::overlays::image_resource_id::raw_image:
src = find_temp_image((rsx::overlays::image_info*)command.first.external_data_ref, cmd, upload_heap)->value;
src = find_temp_image((rsx::overlays::image_info*)command.first.external_data_ref, cmd, upload_heap, ui.uid)->value;
break;
default:
src = view_cache[command.first.texture_ref]->value;

View File

@ -3,7 +3,7 @@
#include "rsx_methods.h"
#include "Emu/RSX/GCM.h"
#include "Common/BufferUtils.h"
#include "overlays.h"
#include "Overlays/overlays.h"
#include "Utilities/sysinfo.h"
extern "C"

View File

@ -294,7 +294,7 @@
<PrecompiledHeader>NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Emu\RSX\Null\NullGSRender.cpp" />
<ClCompile Include="Emu\RSX\overlays.cpp" />
<ClCompile Include="Emu\RSX\Overlays\overlays.cpp" />
<ClCompile Include="Emu\RSX\rsx_methods.cpp" />
<ClCompile Include="Emu\RSX\rsx_utils.cpp" />
<ClCompile Include="Crypto\aes.cpp">
@ -530,8 +530,8 @@
<ClInclude Include="Emu\RSX\Common\texture_cache.h" />
<ClInclude Include="Emu\RSX\gcm_enums.h" />
<ClInclude Include="Emu\RSX\gcm_printing.h" />
<ClInclude Include="Emu\RSX\overlays.h" />
<ClInclude Include="Emu\RSX\overlay_controls.h" />
<ClInclude Include="Emu\RSX\Overlays\overlays.h" />
<ClInclude Include="Emu\RSX\Overlays\overlay_controls.h" />
<ClInclude Include="Emu\RSX\rsx_cache.h" />
<ClInclude Include="Emu\RSX\rsx_decode.h" />
<ClInclude Include="Emu\RSX\rsx_vertex_data.h" />

View File

@ -66,6 +66,9 @@
<Filter Include="Emu\GPU\RSX\Capture">
<UniqueIdentifier>{3f233c0b-4ee1-4c02-963f-0109d3d9c705}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\GPU\RSX\Overlays">
<UniqueIdentifier>{7536c5ad-d58f-40a7-96db-74d959fa4c02}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Crypto\aes.cpp">
@ -734,9 +737,6 @@
<ClCompile Include="Emu\Io\PadHandler.cpp">
<Filter>Emu\Io</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\overlays.cpp">
<Filter>Emu\GPU\RSX</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\lv2\sys_gpio.cpp">
<Filter>Emu\Cell\lv2</Filter>
</ClCompile>
@ -746,6 +746,9 @@
<ClCompile Include="Emu\RSX\Capture\rsx_capture.cpp">
<Filter>Emu\GPU\RSX\Capture</Filter>
</ClCompile>
<ClCompile Include="Emu\RSX\Overlays\overlays.cpp">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Crypto\aes.h">
@ -1402,12 +1405,6 @@
<ClInclude Include="Emu\Cell\lv2\sys_net.h">
<Filter>Emu\Cell\lv2</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\overlay_controls.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\overlays.h">
<Filter>Emu\GPU\RSX</Filter>
</ClInclude>
<ClInclude Include="Emu\Cell\lv2\sys_gpio.h">
<Filter>Emu\Cell\lv2</Filter>
</ClInclude>
@ -1441,5 +1438,11 @@
<ClInclude Include="Emu\RSX\Capture\rsx_capture.h">
<Filter>Emu\GPU\RSX\Capture</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Overlays\overlay_controls.h">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClInclude>
<ClInclude Include="Emu\RSX\Overlays\overlays.h">
<Filter>Emu\GPU\RSX\Overlays</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -2,19 +2,16 @@
#include "save_data_list_dialog.h"
#include <Emu/IdManager.h>
#include <Emu/RSX/GSRender.h>
#include <Emu/RSX/Overlays/overlays.h>
s32 save_data_dialog::ShowSaveDataList(std::vector<SaveDataEntry>& save_entries, s32 focused, u32 op, vm::ptr<CellSaveDataListSet> listSet)
{
//TODO: Install native shell as an Emu callback
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto native_dlg = rsxthr->shell_open_save_dialog())
{
auto result = native_dlg->show(save_entries, op, listSet);
if (result != rsx::overlays::user_interface::selection_code::error)
return result;
}
auto result = manager->create<rsx::overlays::save_dialog>()->show(save_entries, op, listSet);
if (result != rsx::overlays::user_interface::selection_code::error)
return result;
}
//Fall back to front-end GUI

View File

@ -3,16 +3,13 @@
#include "trophy_notification_frame.h"
#include "../Emu/System.h"
#include "../Emu/RSX/GSRender.h"
#include "../Emu/RSX/Overlays/overlays.h"
s32 trophy_notification_helper::ShowTrophyNotification(const SceNpTrophyDetails& trophy, const std::vector<uchar>& trophy_icon_buffer)
{
if (auto rsxthr = fxm::get<GSRender>())
if (auto manager = fxm::get<rsx::overlays::display_manager>())
{
if (auto dlg = rsxthr->shell_open_trophy_notification())
{
return dlg->show(trophy, trophy_icon_buffer);
}
return manager->create<rsx::overlays::trophy_notification>()->show(trophy, trophy_icon_buffer);
}
Emu.CallAfter([=]