Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VideoCommon: show loaded stats for the asset loader if turned on in c…
…onfiguration
- Loading branch information
Showing
13 changed files
with
200 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomAssetLoaderStats.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2023 Dolphin Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#include "VideoCommon/GraphicsModSystem/Runtime/CustomAssetLoaderStats.h" | ||
|
||
#include <imgui.h> | ||
|
||
namespace VideoCommon | ||
{ | ||
void CustomAssetLoaderStats::Display() const | ||
{ | ||
const float scale = ImGui::GetIO().DisplayFramebufferScale.x; | ||
// TODO: This is the same position as the regular statistics text | ||
ImGui::SetNextWindowPos(ImVec2(10.0f * scale, 10.0f * scale), ImGuiCond_FirstUseEver); | ||
ImGui::SetNextWindowSizeConstraints(ImVec2(200.0f * scale, 100.0f * scale), | ||
ImGui::GetIO().DisplaySize); | ||
if (!ImGui::Begin("Asset Loader", nullptr, ImGuiWindowFlags_NoNavInputs)) | ||
{ | ||
ImGui::End(); | ||
return; | ||
} | ||
|
||
ImGui::Columns(2, "Asset Loader", true); | ||
|
||
const auto draw_statistic = [](const char* name, const char* format, auto&&... args) { | ||
ImGui::TextUnformatted(name); | ||
ImGui::NextColumn(); | ||
ImGui::Text(format, std::forward<decltype(args)>(args)...); | ||
ImGui::NextColumn(); | ||
}; | ||
|
||
{ | ||
std::lock_guard lk(m_lock); | ||
draw_statistic("Textures", "%d", m_textures_loaded); | ||
draw_statistic("Game Textures", "%d", m_game_textures_loaded); | ||
} | ||
|
||
ImGui::End(); | ||
} | ||
|
||
void CustomAssetLoaderStats::AddTexture() | ||
{ | ||
std::lock_guard lk(m_lock); | ||
m_textures_loaded++; | ||
} | ||
|
||
void CustomAssetLoaderStats::RemoveTexture() | ||
{ | ||
std::lock_guard lk(m_lock); | ||
m_textures_loaded--; | ||
} | ||
|
||
void CustomAssetLoaderStats::AddGameTexture() | ||
{ | ||
std::lock_guard lk(m_lock); | ||
m_game_textures_loaded++; | ||
} | ||
void CustomAssetLoaderStats::RemoveGameTexture() | ||
{ | ||
std::lock_guard lk(m_lock); | ||
m_game_textures_loaded--; | ||
} | ||
|
||
void CustomAssetLoaderStats::Reset() | ||
{ | ||
std::lock_guard lk(m_lock); | ||
m_textures_loaded = 0; | ||
m_game_textures_loaded = 0; | ||
} | ||
} // namespace VideoCommon |
30 changes: 30 additions & 0 deletions
30
Source/Core/VideoCommon/GraphicsModSystem/Runtime/CustomAssetLoaderStats.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright 2023 Dolphin Emulator Project | ||
// SPDX-License-Identifier: GPL-2.0-or-later | ||
|
||
#pragma once | ||
|
||
#include <mutex> | ||
|
||
#include "Common/CommonTypes.h" | ||
|
||
namespace VideoCommon | ||
{ | ||
class CustomAssetLoaderStats | ||
{ | ||
public: | ||
void Display() const; | ||
|
||
void AddTexture(); | ||
void RemoveTexture(); | ||
|
||
void AddGameTexture(); | ||
void RemoveGameTexture(); | ||
|
||
void Reset(); | ||
|
||
private: | ||
mutable std::mutex m_lock; | ||
u64 m_textures_loaded = 0; | ||
u64 m_game_textures_loaded = 0; | ||
}; | ||
} // namespace VideoCommon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.