mirror of
https://github.com/stenzek/duckstation.git
synced 2024-11-23 13:59:49 +00:00
System: Fix CPU usage not showing for sw-renderer-for-readbacks
This commit is contained in:
parent
8f314c8d49
commit
06ecc50797
@ -20,6 +20,11 @@ class HostDisplayTexture;
|
||||
class TimingEvent;
|
||||
class Timers;
|
||||
|
||||
namespace Threading
|
||||
{
|
||||
class Thread;
|
||||
}
|
||||
|
||||
class GPU
|
||||
{
|
||||
public:
|
||||
@ -74,6 +79,7 @@ public:
|
||||
virtual ~GPU();
|
||||
|
||||
virtual GPURenderer GetRendererType() const = 0;
|
||||
virtual const Threading::Thread* GetSWThread() const = 0;
|
||||
|
||||
virtual bool Initialize();
|
||||
virtual void Reset(bool clear_vram);
|
||||
|
@ -44,6 +44,11 @@ GPU_HW::~GPU_HW()
|
||||
}
|
||||
}
|
||||
|
||||
const Threading::Thread* GPU_HW::GetSWThread() const
|
||||
{
|
||||
return m_sw_renderer ? m_sw_renderer->GetThread() : nullptr;
|
||||
}
|
||||
|
||||
bool GPU_HW::Initialize()
|
||||
{
|
||||
if (!GPU::Initialize())
|
||||
|
@ -33,6 +33,8 @@ public:
|
||||
GPU_HW();
|
||||
virtual ~GPU_HW();
|
||||
|
||||
const Threading::Thread* GetSWThread() const;
|
||||
|
||||
virtual bool Initialize() override;
|
||||
virtual void Reset(bool clear_vram) override;
|
||||
virtual bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display) override;
|
||||
|
@ -45,6 +45,11 @@ GPURenderer GPU_SW::GetRendererType() const
|
||||
return GPURenderer::Software;
|
||||
}
|
||||
|
||||
const Threading::Thread* GPU_SW::GetSWThread() const
|
||||
{
|
||||
return m_backend.GetThread();
|
||||
}
|
||||
|
||||
bool GPU_SW::Initialize()
|
||||
{
|
||||
// we need something to draw in.. but keep the current api if we have one
|
||||
|
@ -23,6 +23,7 @@ public:
|
||||
ALWAYS_INLINE const GPU_SW_Backend& GetBackend() const { return m_backend; }
|
||||
|
||||
GPURenderer GetRendererType() const override;
|
||||
const Threading::Thread* GetSWThread() const;
|
||||
|
||||
bool Initialize() override;
|
||||
bool DoState(StateWrapper& sw, HostDisplayTexture** host_texture, bool update_display) override;
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "fmt/format.h"
|
||||
#include "game_database.h"
|
||||
#include "gpu.h"
|
||||
#include "gpu_sw.h"
|
||||
#include "gte.h"
|
||||
#include "host.h"
|
||||
#include "host_display.h"
|
||||
@ -2149,9 +2148,8 @@ void System::UpdatePerformanceCounters()
|
||||
100.0f;
|
||||
s_last_global_tick_counter = global_tick_counter;
|
||||
|
||||
const Threading::Thread* sw_thread =
|
||||
g_gpu->IsHardwareRenderer() ? nullptr : static_cast<GPU_SW*>(g_gpu.get())->GetBackend().GetThread();
|
||||
const u64 cpu_time = s_cpu_thread_handle.GetCPUTime();
|
||||
const Threading::Thread* sw_thread = g_gpu->GetSWThread();
|
||||
const u64 cpu_time = s_cpu_thread_handle ? s_cpu_thread_handle.GetCPUTime() : 0;
|
||||
const u64 sw_time = sw_thread ? sw_thread->GetCPUTime() : 0;
|
||||
const u64 cpu_delta = cpu_time - s_last_cpu_time;
|
||||
const u64 sw_delta = sw_time - s_last_sw_time;
|
||||
@ -2176,20 +2174,14 @@ void System::ResetPerformanceCounters()
|
||||
s_last_frame_number = s_frame_number;
|
||||
s_last_internal_frame_number = s_internal_frame_number;
|
||||
s_last_global_tick_counter = TimingEvents::GetGlobalTickCounter();
|
||||
s_last_cpu_time = s_cpu_thread_handle.GetCPUTime();
|
||||
s_last_sw_time = 0;
|
||||
if (!g_gpu->IsHardwareRenderer())
|
||||
{
|
||||
const Threading::Thread* sw_thread = static_cast<GPU_SW*>(g_gpu.get())->GetBackend().GetThread();
|
||||
if (sw_thread)
|
||||
s_last_sw_time = sw_thread->GetCPUTime();
|
||||
}
|
||||
s_last_cpu_time = s_cpu_thread_handle ? s_cpu_thread_handle.GetCPUTime() : 0;
|
||||
if (const Threading::Thread* sw_thread = g_gpu->GetSWThread(); sw_thread)
|
||||
s_last_sw_time = sw_thread->GetCPUTime();
|
||||
else
|
||||
s_last_sw_time = 0;
|
||||
|
||||
s_average_frame_time_accumulator = 0.0f;
|
||||
s_worst_frame_time_accumulator = 0.0f;
|
||||
s_cpu_thread_usage = 0.0f;
|
||||
s_cpu_thread_time = 0.0f;
|
||||
s_sw_thread_usage = 0.0f;
|
||||
s_sw_thread_time = 0.0f;
|
||||
s_fps_timer.Reset();
|
||||
ResetThrottler();
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ void ImGuiManager::DrawPerformanceOverlay()
|
||||
FormatProcessorStat(text, System::GetCPUThreadUsage(), System::GetCPUThreadAverageTime());
|
||||
DRAW_LINE(fixed_font, text, IM_COL32(255, 255, 255, 255));
|
||||
|
||||
if (!g_gpu->IsHardwareRenderer() && g_settings.gpu_use_thread)
|
||||
if (g_gpu->GetSWThread())
|
||||
{
|
||||
text.Assign("SW: ");
|
||||
FormatProcessorStat(text, System::GetSWThreadUsage(), System::GetSWThreadAverageTime());
|
||||
|
Loading…
Reference in New Issue
Block a user