mirror of
https://github.com/hedge-dev/UnleashedRecomp.git
synced 2026-04-28 05:11:37 +00:00
Add more stuff to the profiler window.
This commit is contained in:
parent
755b48d3f0
commit
42f808c926
1 changed files with 61 additions and 10 deletions
|
|
@ -1887,11 +1887,37 @@ static uint32_t HashVertexDeclaration(uint32_t vertexDeclaration)
|
||||||
return vertexDeclaration;
|
return vertexDeclaration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static constexpr size_t PROFILER_VALUE_COUNT = 1024;
|
||||||
|
static size_t g_profilerValueIndex;
|
||||||
|
|
||||||
|
struct Profiler
|
||||||
|
{
|
||||||
|
std::atomic<double> value;
|
||||||
|
double values[PROFILER_VALUE_COUNT];
|
||||||
|
std::chrono::steady_clock::time_point start;
|
||||||
|
|
||||||
|
void begin()
|
||||||
|
{
|
||||||
|
start = std::chrono::steady_clock::now();
|
||||||
|
}
|
||||||
|
|
||||||
|
void end()
|
||||||
|
{
|
||||||
|
value = std::chrono::duration<double, std::milli>(std::chrono::steady_clock::now() - start).count();
|
||||||
|
}
|
||||||
|
|
||||||
|
double updateAndReturnAverage()
|
||||||
|
{
|
||||||
|
values[g_profilerValueIndex] = value;
|
||||||
|
return std::accumulate(values, values + PROFILER_VALUE_COUNT, 0.0) / PROFILER_VALUE_COUNT;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
static double g_applicationValues[PROFILER_VALUE_COUNT];
|
||||||
|
static Profiler g_renderDirectorProfiler;
|
||||||
|
|
||||||
static bool g_profilerVisible;
|
static bool g_profilerVisible;
|
||||||
static bool g_profilerWasToggled;
|
static bool g_profilerWasToggled;
|
||||||
static constexpr size_t PROFILER_VALUE_COUNT = 256;
|
|
||||||
static double g_profilerDeltaTimes[PROFILER_VALUE_COUNT];
|
|
||||||
static size_t g_profilerValueIndex;
|
|
||||||
|
|
||||||
static void DrawProfiler()
|
static void DrawProfiler()
|
||||||
{
|
{
|
||||||
|
|
@ -1907,27 +1933,47 @@ static void DrawProfiler()
|
||||||
|
|
||||||
ImFont* font = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf");
|
ImFont* font = ImFontAtlasSnapshot::GetFont("FOT-SeuratPro-M.otf");
|
||||||
float defaultScale = font->Scale;
|
float defaultScale = font->Scale;
|
||||||
font->Scale = 16.0f / font->FontSize;
|
font->Scale = ImGui::GetDefaultFont()->FontSize / font->FontSize;
|
||||||
ImGui::PushFont(font);
|
ImGui::PushFont(font);
|
||||||
|
|
||||||
if (ImGui::Begin("Profiler", &g_profilerVisible))
|
if (ImGui::Begin("Profiler", &g_profilerVisible))
|
||||||
{
|
{
|
||||||
g_profilerDeltaTimes[g_profilerValueIndex] = App::s_deltaTime * 1000.0;
|
g_applicationValues[g_profilerValueIndex] = App::s_deltaTime * 1000.0;
|
||||||
|
double renderDirectorAvg = g_renderDirectorProfiler.updateAndReturnAverage();
|
||||||
|
|
||||||
if (ImPlot::BeginPlot("Frametimes"))
|
if (ImPlot::BeginPlot("Frame Time"))
|
||||||
{
|
{
|
||||||
ImPlot::SetupAxisLimits(ImAxis_Y1, 8.0, 32.0);
|
ImPlot::SetupAxisLimits(ImAxis_Y1, 0.0, 20.0);
|
||||||
ImPlot::SetupAxis(ImAxis_Y1, "ms", ImPlotAxisFlags_None);
|
ImPlot::SetupAxis(ImAxis_Y1, "ms", ImPlotAxisFlags_None);
|
||||||
ImPlot::PlotLine<double>("Application", g_profilerDeltaTimes, PROFILER_VALUE_COUNT, 1.0, 0.0, ImPlotLineFlags_None, g_profilerValueIndex);
|
ImPlot::PlotLine<double>("Application", g_applicationValues, PROFILER_VALUE_COUNT, 1.0, 0.0, ImPlotLineFlags_None, g_profilerValueIndex);
|
||||||
|
ImPlot::PlotLine<double>("Render Director", g_renderDirectorProfiler.values, PROFILER_VALUE_COUNT, 1.0, 0.0, ImPlotLineFlags_None, g_profilerValueIndex);
|
||||||
|
|
||||||
ImPlot::EndPlot();
|
ImPlot::EndPlot();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_profilerValueIndex = (g_profilerValueIndex + 1) % PROFILER_VALUE_COUNT;
|
g_profilerValueIndex = (g_profilerValueIndex + 1) % PROFILER_VALUE_COUNT;
|
||||||
|
|
||||||
const double deltaTimeAvg = std::accumulate(g_profilerDeltaTimes, g_profilerDeltaTimes + PROFILER_VALUE_COUNT, 0.0) / PROFILER_VALUE_COUNT;
|
const double applicationAvg = std::accumulate(g_applicationValues, g_applicationValues + PROFILER_VALUE_COUNT, 0.0) / PROFILER_VALUE_COUNT;
|
||||||
|
|
||||||
ImGui::Text("Average Application: %g ms (%g FPS)", deltaTimeAvg, 1000.0 / deltaTimeAvg);
|
ImGui::Text("Average Application: %g ms (%g FPS)", applicationAvg, 1000.0 / applicationAvg);
|
||||||
|
ImGui::Text("Average Render Director: %g ms (%g FPS)", renderDirectorAvg, 1000.0 / renderDirectorAvg);
|
||||||
|
|
||||||
|
O1HeapDiagnostics diagnostics, physicalDiagnostics;
|
||||||
|
{
|
||||||
|
std::lock_guard lock(g_userHeap.mutex);
|
||||||
|
diagnostics = o1heapGetDiagnostics(g_userHeap.heap);
|
||||||
|
}
|
||||||
|
{
|
||||||
|
std::lock_guard lock(g_userHeap.physicalMutex);
|
||||||
|
physicalDiagnostics = o1heapGetDiagnostics(g_userHeap.physicalHeap);
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Text("Heap Allocated: %d MB", int32_t(diagnostics.allocated / (1024 * 1024)));
|
||||||
|
ImGui::Text("Physical Heap Allocated: %d MB", int32_t(physicalDiagnostics.allocated / (1024 * 1024)));
|
||||||
|
|
||||||
|
auto capabilities = g_device->getCapabilities();
|
||||||
|
ImGui::Text("Present Wait: %s", capabilities.presentWait ? "Supported" : "Unsupported");
|
||||||
|
ImGui::Text("Triangle Fan: %s", capabilities.triangleFan ? "Supported" : "Unsupported");
|
||||||
}
|
}
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
|
|
@ -4129,6 +4175,7 @@ static std::thread g_renderThread([]
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
size_t count = g_renderQueue.wait_dequeue_bulk(commands, std::size(commands));
|
size_t count = g_renderQueue.wait_dequeue_bulk(commands, std::size(commands));
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
auto& cmd = commands[i];
|
auto& cmd = commands[i];
|
||||||
|
|
@ -4802,6 +4849,8 @@ PPC_FUNC(sub_8258C8A0)
|
||||||
PPC_FUNC_IMPL(__imp__sub_8258CAE0);
|
PPC_FUNC_IMPL(__imp__sub_8258CAE0);
|
||||||
PPC_FUNC(sub_8258CAE0)
|
PPC_FUNC(sub_8258CAE0)
|
||||||
{
|
{
|
||||||
|
g_renderDirectorProfiler.begin();
|
||||||
|
|
||||||
if (g_needsResize)
|
if (g_needsResize)
|
||||||
{
|
{
|
||||||
auto r3 = ctx.r3;
|
auto r3 = ctx.r3;
|
||||||
|
|
@ -4814,6 +4863,8 @@ PPC_FUNC(sub_8258CAE0)
|
||||||
}
|
}
|
||||||
|
|
||||||
__imp__sub_8258CAE0(ctx, base);
|
__imp__sub_8258CAE0(ctx, base);
|
||||||
|
|
||||||
|
g_renderDirectorProfiler.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessResolutionFix(PPCRegister& r4, PPCRegister& f1, PPCRegister& f2)
|
void PostProcessResolutionFix(PPCRegister& r4, PPCRegister& f1, PPCRegister& f2)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue