mirror of https://github.com/AxioDL/metaforce.git
aurora: Pipeline info debug overlay
This commit is contained in:
parent
5183809027
commit
0703cf60b3
|
@ -19,6 +19,11 @@ namespace ImGui {
|
||||||
void ClearIniSettings();
|
void ClearIniSettings();
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
||||||
|
namespace aurora::gfx {
|
||||||
|
extern std::atomic_uint32_t queuedPipelines;
|
||||||
|
extern std::atomic_uint32_t createdPipelines;
|
||||||
|
} // namespace aurora::gfx
|
||||||
|
|
||||||
#include "TCastTo.hpp" // Generated file, do not modify include path
|
#include "TCastTo.hpp" // Generated file, do not modify include path
|
||||||
|
|
||||||
namespace metaforce {
|
namespace metaforce {
|
||||||
|
@ -707,7 +712,7 @@ void ImGuiConsole::ShowAboutWindow(bool canClose, std::string_view errorString)
|
||||||
|
|
||||||
void ImGuiConsole::ShowDebugOverlay() {
|
void ImGuiConsole::ShowDebugOverlay() {
|
||||||
if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo &&
|
if (!m_frameCounter && !m_frameRate && !m_inGameTime && !m_roomTimer && !m_playerInfo && !m_areaInfo &&
|
||||||
!m_worldInfo && !m_randomStats && !m_resourceStats) {
|
!m_worldInfo && !m_randomStats && !m_resourceStats && !m_pipelineInfo) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
|
@ -864,16 +869,22 @@ void ImGuiConsole::ShowDebugOverlay() {
|
||||||
|
|
||||||
ImGuiStringViewText(fmt::format(FMT_STRING("Resource Objects: {}\n"), g_SimplePool->GetLiveObjects()));
|
ImGuiStringViewText(fmt::format(FMT_STRING("Resource Objects: {}\n"), g_SimplePool->GetLiveObjects()));
|
||||||
}
|
}
|
||||||
|
if (m_pipelineInfo) {
|
||||||
|
if (hasPrevious) {
|
||||||
|
ImGui::Separator();
|
||||||
|
}
|
||||||
|
hasPrevious = true;
|
||||||
|
|
||||||
|
ImGuiStringViewText(fmt::format(FMT_STRING("Queued pipelines: {}\n"), aurora::gfx::queuedPipelines));
|
||||||
|
ImGuiStringViewText(fmt::format(FMT_STRING("Done pipelines: {}\n"), aurora::gfx::createdPipelines));
|
||||||
|
}
|
||||||
ShowCornerContextMenu(m_debugOverlayCorner, m_inputOverlayCorner);
|
ShowCornerContextMenu(m_debugOverlayCorner, m_inputOverlayCorner);
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
}
|
}
|
||||||
void TextCenter(const std::string& text) {
|
void TextCenter(const std::string& text) {
|
||||||
float font_size = ImGui::GetFontSize() * text.size() / 2;
|
float font_size = ImGui::GetFontSize() * text.size() / 2;
|
||||||
ImGui::SameLine(
|
ImGui::SameLine(ImGui::GetWindowSize().x / 2 - font_size + (font_size / 2));
|
||||||
ImGui::GetWindowSize().x / 2 -
|
|
||||||
font_size + (font_size / 2)
|
|
||||||
);
|
|
||||||
|
|
||||||
ImGui::TextUnformatted(text.c_str());
|
ImGui::TextUnformatted(text.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -86,6 +86,7 @@ private:
|
||||||
bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean();
|
bool m_randomStats = m_cvarCommons.m_debugOverlayShowRandomStats->toBoolean();
|
||||||
bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean();
|
bool m_resourceStats = m_cvarCommons.m_debugOverlayShowResourceStats->toBoolean();
|
||||||
bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean();
|
bool m_showInput = m_cvarCommons.m_debugOverlayShowInput->toBoolean();
|
||||||
|
bool m_pipelineInfo = true; // TODO cvar
|
||||||
bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
|
bool m_developer = m_cvarMgr.findCVar("developer")->toBoolean();
|
||||||
bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();
|
bool m_cheats = m_cvarMgr.findCVar("cheats")->toBoolean();
|
||||||
bool m_isInitialized = false;
|
bool m_isInitialized = false;
|
||||||
|
|
|
@ -61,11 +61,13 @@ metaforce::CFogState g_fogState;
|
||||||
using NewPipelineCallback = std::function<wgpu::RenderPipeline()>;
|
using NewPipelineCallback = std::function<wgpu::RenderPipeline()>;
|
||||||
static std::mutex g_pipelineMutex;
|
static std::mutex g_pipelineMutex;
|
||||||
static std::thread g_pipelineThread;
|
static std::thread g_pipelineThread;
|
||||||
static bool g_pipelineThreadEnd = false;
|
static std::atomic_bool g_pipelineThreadEnd;
|
||||||
static std::condition_variable g_pipelineCv;
|
static std::condition_variable g_pipelineCv;
|
||||||
static std::unordered_map<PipelineRef, wgpu::RenderPipeline> g_pipelines;
|
static std::unordered_map<PipelineRef, wgpu::RenderPipeline> g_pipelines;
|
||||||
static std::deque<std::pair<PipelineRef, NewPipelineCallback>> g_queuedPipelines;
|
static std::deque<std::pair<PipelineRef, NewPipelineCallback>> g_queuedPipelines;
|
||||||
static std::unordered_map<BindGroupRef, wgpu::BindGroup> g_cachedBindGroups;
|
static std::unordered_map<BindGroupRef, wgpu::BindGroup> g_cachedBindGroups;
|
||||||
|
std::atomic_uint32_t queuedPipelines;
|
||||||
|
std::atomic_uint32_t createdPipelines;
|
||||||
|
|
||||||
static ByteBuffer g_verts;
|
static ByteBuffer g_verts;
|
||||||
static ByteBuffer g_uniforms;
|
static ByteBuffer g_uniforms;
|
||||||
|
@ -83,7 +85,7 @@ static PipelineRef find_pipeline(PipelineCreateCommand command, NewPipelineCallb
|
||||||
const auto hash = xxh3_hash(command);
|
const auto hash = xxh3_hash(command);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
{
|
{
|
||||||
std::lock_guard guard{g_pipelineMutex};
|
std::scoped_lock guard{g_pipelineMutex};
|
||||||
found = g_pipelines.find(hash) != g_pipelines.end();
|
found = g_pipelines.find(hash) != g_pipelines.end();
|
||||||
if (!found) {
|
if (!found) {
|
||||||
const auto ref =
|
const auto ref =
|
||||||
|
@ -92,13 +94,13 @@ static PipelineRef find_pipeline(PipelineCreateCommand command, NewPipelineCallb
|
||||||
found = true;
|
found = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!found) {
|
||||||
if (!found) {
|
|
||||||
{
|
|
||||||
std::lock_guard guard{g_pipelineMutex};
|
|
||||||
g_queuedPipelines.emplace_back(std::pair{hash, std::move(cb)});
|
g_queuedPipelines.emplace_back(std::pair{hash, std::move(cb)});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
g_pipelineCv.notify_one();
|
g_pipelineCv.notify_one();
|
||||||
|
queuedPipelines++;
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -183,8 +185,9 @@ static void pipeline_worker() {
|
||||||
cb = std::move(g_queuedPipelines.front());
|
cb = std::move(g_queuedPipelines.front());
|
||||||
}
|
}
|
||||||
auto result = cb.second();
|
auto result = cb.second();
|
||||||
|
// std::this_thread::sleep_for(std::chrono::milliseconds{1500});
|
||||||
{
|
{
|
||||||
std::lock_guard lock{g_pipelineMutex};
|
std::scoped_lock lock{g_pipelineMutex};
|
||||||
if (g_pipelines.contains(cb.first)) {
|
if (g_pipelines.contains(cb.first)) {
|
||||||
Log.report(logvisor::Fatal, FMT_STRING("Duplicate pipeline {}"), cb.first);
|
Log.report(logvisor::Fatal, FMT_STRING("Duplicate pipeline {}"), cb.first);
|
||||||
unreachable();
|
unreachable();
|
||||||
|
@ -193,6 +196,8 @@ static void pipeline_worker() {
|
||||||
g_queuedPipelines.pop_front();
|
g_queuedPipelines.pop_front();
|
||||||
hasMore = !g_queuedPipelines.empty();
|
hasMore = !g_queuedPipelines.empty();
|
||||||
}
|
}
|
||||||
|
createdPipelines++;
|
||||||
|
queuedPipelines--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue