Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overlays: add ppu compile notification and touch existing compile notifications #13423

Merged
merged 6 commits into from
Mar 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions rpcs3/Crypto/unself.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ bool SCEDecrypter::LoadMetadata(const u8 erk[32], const u8 riv[16])
if ((meta_info.key_pad[0] != 0x00) ||
(meta_info.iv_pad[0] != 0x00))
{
self_log.error("Failed to decrypt metadata info!");
self_log.error("Failed to decrypt SCE metadata info!");
return false;
}

Expand Down Expand Up @@ -1095,7 +1095,7 @@ bool SELFDecrypter::DecryptNPDRM(u8 *metadata, u32 metadata_size)
else if (npd->license == 3) // Free license.
{
// Use klicensee if available.
if (key_v.GetKlicenseeKey() != nullptr)
if (key_v.GetKlicenseeKey())
memcpy(npdrm_key, key_v.GetKlicenseeKey(), 0x10);
else
memcpy(npdrm_key, NP_KLIC_FREE, 0x10);
Expand Down Expand Up @@ -1182,7 +1182,7 @@ bool SELFDecrypter::LoadMetadata(u8* klic_key)
if ((meta_info.key_pad[0] != 0x00) ||
(meta_info.iv_pad[0] != 0x00))
{
self_log.error("Failed to decrypt metadata info!");
self_log.error("Failed to decrypt SELF metadata info!");
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,7 @@ target_sources(rpcs3_emu PRIVATE
RSX/Overlays/overlay_perf_metrics.cpp
RSX/Overlays/overlay_progress_bar.cpp
RSX/Overlays/overlay_save_dialog.cpp
RSX/Overlays/overlay_shader_compile_notification.cpp
RSX/Overlays/overlay_compile_notification.cpp
RSX/Overlays/overlay_user_list_dialog.cpp
RSX/Overlays/overlay_utils.cpp
RSX/Overlays/overlays.cpp
Expand Down
2 changes: 1 addition & 1 deletion rpcs3/Emu/RSX/GL/GLGSRender.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "stdafx.h"
#include "../Overlays/overlay_shader_compile_notification.h"
#include "../Overlays/overlay_compile_notification.h"
#include "../Overlays/Shaders/shader_loading_dialog_native.h"
#include "GLGSRender.h"
#include "GLCompute.h"
Expand Down
36 changes: 35 additions & 1 deletion rpcs3/Emu/RSX/Overlays/overlay_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,17 @@ namespace rsx
void animation_base::begin_animation(u64 frame)
{
frame_start = frame;
frame_end = u64(frame + duration * g_cfg.video.vblank_rate);
frame_end = frame + get_duration_in_frames();
}

u64 animation_base::get_duration_in_frames() const
{
return u64(duration * g_cfg.video.vblank_rate);
}

u64 animation_base::get_remaining_frames(u64 frame) const
{
return frame >= frame_end ? 0 : (frame_end - frame);
}

f32 animation_base::get_progress_ratio(u64 frame) const
Expand Down Expand Up @@ -39,6 +49,18 @@ namespace rsx
return t;
}

void animation_translate::reset(u64 start_frame)
{
active = false;
current = start;
frame_start = start_frame;

if (frame_start > 0)
{
frame_end = frame_start + get_duration_in_frames();
}
}

void animation_translate::apply(compiled_resource& resource)
{
if (!active)
Expand Down Expand Up @@ -94,6 +116,18 @@ namespace rsx
}
}

void animation_color_interpolate::reset(u64 start_frame)
{
active = false;
current = start;
frame_start = start_frame;

if (frame_start > 0)
{
frame_end = frame_start + get_duration_in_frames();
}
}

void animation_color_interpolate::apply(compiled_resource& data)
{
if (!active)
Expand Down
6 changes: 6 additions & 0 deletions rpcs3/Emu/RSX/Overlays/overlay_animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ namespace rsx

std::function<void()> on_finish;

u64 get_duration_in_frames() const;
u64 get_remaining_frames(u64 frame) const;

virtual void apply(compiled_resource&) = 0;
virtual void reset(u64 start_frame) = 0;
virtual void update(u64 frame) = 0;
};

Expand All @@ -57,6 +61,7 @@ namespace rsx
vector3f end{};

void apply(compiled_resource& data) override;
void reset(u64 start_frame = 0) override;
void update(u64 frame) override;
void finish();
};
Expand All @@ -71,6 +76,7 @@ namespace rsx
color4f end{};

void apply(compiled_resource& data) override;
void reset(u64 start_frame = 0) override;
void update(u64 frame) override;
void finish();
};
Expand Down
47 changes: 47 additions & 0 deletions rpcs3/Emu/RSX/Overlays/overlay_compile_notification.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#include "stdafx.h"
#include "overlays.h"
#include "overlay_message.h"
#include "overlay_loading_icon.hpp"

namespace rsx
{
namespace overlays
{
static std::shared_ptr<loading_icon24> s_shader_loading_icon24;
static std::shared_ptr<loading_icon24> s_ppu_loading_icon24;

void show_shader_compile_notification()
{
if (!s_shader_loading_icon24)
{
// Creating the icon requires FS read, so it is important to cache it
s_shader_loading_icon24 = std::make_shared<loading_icon24>();
}

queue_message(
localized_string_id::RSX_OVERLAYS_COMPILING_SHADERS,
5'000'000,
{},
message_pin_location::bottom,
s_shader_loading_icon24,
true);
}

void show_ppu_compile_notification()
{
if (!s_ppu_loading_icon24)
{
// Creating the icon requires FS read, so it is important to cache it
s_ppu_loading_icon24 = std::make_shared<loading_icon24>();
}

queue_message(
localized_string_id::RSX_OVERLAYS_COMPILING_PPU_MODULES,
5'000'000,
{},
message_pin_location::bottom,
s_ppu_loading_icon24,
true);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ namespace rsx
namespace overlays
{
void show_shader_compile_notification();
void show_ppu_compile_notification();
}
}
90 changes: 73 additions & 17 deletions rpcs3/Emu/RSX/Overlays/overlay_message.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace rsx
m_fade_out_animation.current = color4f(1.f);
m_fade_out_animation.end = color4f(1.f, 1.f, 1.f, 0.f);
m_fade_out_animation.duration = 1.f;
m_fade_out_animation.active = true;
m_fade_out_animation.active = false;

back_color = color4f(0.25f, 0.25f, 0.25f, 0.85f);

Expand All @@ -55,6 +55,11 @@ namespace rsx
template message_item::message_item(std::string msg_id, u64, std::shared_ptr<atomic_t<u32>>, std::shared_ptr<overlay_element>);
template message_item::message_item(localized_string_id msg_id, u64, std::shared_ptr<atomic_t<u32>>, std::shared_ptr<overlay_element>);

void message_item::reset_expiration()
{
m_expiration_time = get_expiration_time(m_visible_duration);
}

u64 message_item::get_expiration() const
{
// If reference counting is enabled and reached 0 consider it expired
Expand All @@ -79,11 +84,7 @@ namespace rsx

compiled_resource& message_item::get_compiled()
{
auto& current_animation = m_fade_in_animation.active
? m_fade_in_animation
: m_fade_out_animation;

if (!m_processed || !current_animation.active)
if (!m_processed)
{
compiled_resources = {};
return compiled_resources;
Expand All @@ -99,6 +100,10 @@ namespace rsx
compiled_resources.add(m_icon->get_compiled());
}

auto& current_animation = m_fade_in_animation.active
? m_fade_in_animation
: m_fade_out_animation;

current_animation.apply(compiled_resources);
return compiled_resources;
}
Expand All @@ -118,12 +123,37 @@ namespace rsx

if (m_fade_in_animation.active)
{
// We are fading in.
m_fade_in_animation.update(rsx::get_current_renderer()->vblank_count);
}
else if (time + u64(m_fade_out_animation.duration * 1'000'000) > m_expiration_time)
else if (time + u64(m_fade_out_animation.duration * 1'000'000) > get_expiration())
{
// We are fading out.

// Only activate the animation if the message hasn't expired yet (prevents glitches afterwards).
if (time <= get_expiration())
{
m_fade_out_animation.active = true;
}

m_fade_out_animation.update(rsx::get_current_renderer()->vblank_count);
}
else if (m_fade_out_animation.active)
{
// We are fading out, but the expiration was extended.

// Reset the fade in animation to the state of the fade out animation to prevent opacity pop.
const usz current_frame = rsx::get_current_renderer()->vblank_count;
const f32 fade_out_progress = static_cast<f32>(m_fade_out_animation.get_remaining_frames(current_frame)) / static_cast<f32>(m_fade_out_animation.get_duration_in_frames());
const u64 fade_in_frames_done = u64(fade_out_progress * m_fade_in_animation.get_duration_in_frames());

m_fade_in_animation.reset(current_frame - fade_in_frames_done);
m_fade_in_animation.active = true;
m_fade_in_animation.update(current_frame);

// Reset the fade out animation.
m_fade_out_animation.reset();
}

m_processed = true;
}
Expand All @@ -132,9 +162,16 @@ namespace rsx
{
const u64 cur_time = rsx::uclock();

while (!vis_set.empty() && vis_set.front().get_expiration() < cur_time)
for (auto it = vis_set.begin(); it != vis_set.end();)
{
vis_set.pop_front();
if (it->get_expiration() < cur_time)
{
it = vis_set.erase(it);
}
else
{
it++;
}
}

while (vis_set.size() < max_visible_items && !ready_set.empty())
Expand Down Expand Up @@ -205,23 +242,31 @@ namespace rsx
return cr;
}

bool message::message_exists(message_pin_location location, localized_string_id id)
bool message::message_exists(message_pin_location location, localized_string_id id, bool allow_refresh)
{
return message_exists(location, get_localized_u32string(id));
return message_exists(location, get_localized_u32string(id), allow_refresh);
}

bool message::message_exists(message_pin_location location, const std::string& msg)
bool message::message_exists(message_pin_location location, const std::string& msg, bool allow_refresh)
{
return message_exists(location, utf8_to_u32string(msg));
return message_exists(location, utf8_to_u32string(msg), allow_refresh);
}

bool message::message_exists(message_pin_location location, const std::u32string& msg)
bool message::message_exists(message_pin_location location, const std::u32string& msg, bool allow_refresh)
{
auto check_list = [&](const std::deque<message_item>& list)
auto check_list = [&](std::deque<message_item>& list)
{
return std::any_of(list.cbegin(), list.cend(), [&](const message_item& item)
return std::any_of(list.begin(), list.end(), [&](message_item& item)
{
return item.text_matches(msg);
if (item.text_matches(msg))
{
if (allow_refresh)
{
item.reset_expiration();
}
return true;
}
return false;
});
};

Expand All @@ -236,5 +281,16 @@ namespace rsx
return false;
}

void refresh_message_queue()
{
if (auto manager = g_fxo->try_get<rsx::overlays::display_manager>())
{
if (auto msg_overlay = manager->get<rsx::overlays::message>())
{
msg_overlay->refresh();
}
}
}

} // namespace overlays
} // namespace rsx
Loading