faster texture cache loading in low fps modes

This commit is contained in:
Green Sky 2024-02-05 12:50:36 +01:00
parent 7d0e5c80bd
commit 139db5b03b
No known key found for this signature in database
7 changed files with 26 additions and 12 deletions

@ -1 +1 @@
Subproject commit 2d73c7272c3c254086fa067ccfdfb4072c20f7c9 Subproject commit 9ca6adee4f6f01d83fd1f5ece5c4b84396079ccc

@ -1 +1 @@
Subproject commit 20af7dd705fe1be68f7678292125620d48aa278b Subproject commit a1f5add8d347da2eb8acb812cd6dbcb36a46778d

@ -1 +1 @@
Subproject commit 390b123fb7380e5da30954d1b0a337208407f40d Subproject commit d304d719e9b7c3c40d32fc45993f0ccfd34c556e

View File

@ -136,7 +136,7 @@ ChatGui4::~ChatGui4(void) {
//} //}
} }
void ChatGui4::render(float time_delta) { float ChatGui4::render(float time_delta) {
if (!_cr.storage<Contact::Components::TagAvatarInvalidate>().empty()) { // handle force-reloads for avatars if (!_cr.storage<Contact::Components::TagAvatarInvalidate>().empty()) { // handle force-reloads for avatars
std::vector<Contact3> to_purge; std::vector<Contact3> to_purge;
_cr.view<Contact::Components::TagAvatarInvalidate>().each([&to_purge](const Contact3 c) { _cr.view<Contact::Components::TagAvatarInvalidate>().each([&to_purge](const Contact3 c) {
@ -627,8 +627,14 @@ void ChatGui4::render(float time_delta) {
} }
ImGui::End(); ImGui::End();
_contact_tc.workLoadQueue(); bool unfinished_work_queue = _contact_tc.workLoadQueue();
_msg_tc.workLoadQueue(); unfinished_work_queue = unfinished_work_queue || _msg_tc.workLoadQueue();
if (unfinished_work_queue) {
return 0.1f; // so we can get images loaded faster
} else {
return 1.f; // TODO: higher min fps?
}
} }
void ChatGui4::sendFilePath(const char* file_path) { void ChatGui4::sendFilePath(const char* file_path) {

View File

@ -57,7 +57,7 @@ class ChatGui4 {
~ChatGui4(void); ~ChatGui4(void);
public: public:
void render(float time_delta); float render(float time_delta);
public: public:
bool any_unread {false}; bool any_unread {false};

View File

@ -168,7 +168,7 @@ Screen* MainScreen::render(float time_delta, bool&) {
const float pm_interval = pm.render(time_delta); // render const float pm_interval = pm.render(time_delta); // render
cg.render(time_delta); // render const float cg_interval = cg.render(time_delta); // render
sw.render(); // render sw.render(); // render
tuiu.render(); // render tuiu.render(); // render
tdch.render(); // render tdch.render(); // render
@ -217,6 +217,8 @@ Screen* MainScreen::render(float time_delta, bool&) {
ImGui::ShowDemoWindow(); ImGui::ShowDemoWindow();
} }
_render_interval = std::min<float>(pm_interval, cg_interval);
if ( if (
_fps_perf_mode > 1 // TODO: magic _fps_perf_mode > 1 // TODO: magic
) { ) {
@ -228,9 +230,9 @@ Screen* MainScreen::render(float time_delta, bool&) {
_window_hidden _window_hidden
) )
) { ) {
_render_interval = std::min<float>(1.f/1.f, pm_interval); _render_interval = std::min<float>(1.f/1.f, _render_interval);
} else { } else {
_render_interval = std::min<float>(1.f/60.f, pm_interval); _render_interval = std::min<float>(1.f/60.f, _render_interval);
} }
_time_since_event += time_delta; _time_since_event += time_delta;

View File

@ -162,8 +162,10 @@ struct TextureCache {
} }
} }
void workLoadQueue(void) { // returns true if there is still work queued up
for (auto it = _to_load.begin(); it != _to_load.end(); it++) { bool workLoadQueue(void) {
auto it = _to_load.begin();
for (; it != _to_load.end(); it++) {
auto new_entry_opt = _l.load(_tu, *it); auto new_entry_opt = _l.load(_tu, *it);
if (new_entry_opt.has_value()) { if (new_entry_opt.has_value()) {
_cache.emplace(*it, new_entry_opt.value()); _cache.emplace(*it, new_entry_opt.value());
@ -172,6 +174,10 @@ struct TextureCache {
break; // end load from queue/onlyload 1 per update break; // end load from queue/onlyload 1 per update
} }
} }
it++;
return it != _to_load.end();
} }
}; };