From eef643cf63317804b4973a1681844533cf366a79 Mon Sep 17 00:00:00 2001 From: ty Date: Thu, 22 Apr 2021 17:17:18 -0400 Subject: [PATCH] Core: Purge OS specific CPU usage providers --- pcsx2/CMakeLists.txt | 4 - pcsx2/gui/CpuUsageProvider.cpp | 18 +- pcsx2/gui/CpuUsageProvider.h | 26 +- pcsx2/gui/CpuUsageProviderLnx.cpp | 31 -- pcsx2/gui/CpuUsageProviderMSW.cpp | 287 ------------------ pcsx2/windows/VCprojects/pcsx2.vcxproj | 4 - .../windows/VCprojects/pcsx2.vcxproj.filters | 6 - 7 files changed, 13 insertions(+), 363 deletions(-) delete mode 100644 pcsx2/gui/CpuUsageProviderLnx.cpp delete mode 100644 pcsx2/gui/CpuUsageProviderMSW.cpp diff --git a/pcsx2/CMakeLists.txt b/pcsx2/CMakeLists.txt index ebf07efcee..50ae01262c 100644 --- a/pcsx2/CMakeLists.txt +++ b/pcsx2/CMakeLists.txt @@ -744,7 +744,6 @@ set(pcsx2IPUHeaders set(pcsx2LinuxSources CDVD/Linux/DriveUtility.cpp CDVD/Linux/IOCtlSrc.cpp - gui/CpuUsageProviderLnx.cpp Linux/LnxConsolePipe.cpp Linux/LnxKeyCodes.cpp Linux/LnxFlatFileReader.cpp @@ -753,7 +752,6 @@ set(pcsx2LinuxSources set(pcsx2OSXSources CDVD/Linux/DriveUtility.cpp CDVD/Linux/IOCtlSrc.cpp - gui/CpuUsageProviderLnx.cpp Linux/LnxConsolePipe.cpp # Linux/LnxKeyCodes.cpp Darwin/DarwinFlatFileReader.cpp @@ -762,7 +760,6 @@ set(pcsx2OSXSources set(pcsx2FreeBSDSources CDVD/Linux/DriveUtility.cpp CDVD/Linux/IOCtlSrc.cpp - gui/CpuUsageProviderLnx.cpp Linux/LnxConsolePipe.cpp Linux/LnxKeyCodes.cpp Darwin/DarwinFlatFileReader.cpp @@ -894,7 +891,6 @@ set(pcsx2ZipToolsHeaders set(pcsx2WindowsSources CDVD/Windows/DriveUtility.cpp CDVD/Windows/IOCtlSrc.cpp - gui/CpuUsageProviderMSW.cpp windows/FlatFileReaderWindows.cpp windows/Optimus.cpp windows/PatchBrowser.cpp diff --git a/pcsx2/gui/CpuUsageProvider.cpp b/pcsx2/gui/CpuUsageProvider.cpp index 1e13623912..85ff3e4f2c 100644 --- a/pcsx2/gui/CpuUsageProvider.cpp +++ b/pcsx2/gui/CpuUsageProvider.cpp @@ -1,5 +1,5 @@ /* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team + * Copyright (C) 2002-2021 PCSX2 Dev Team * * PCSX2 is free software: you can redistribute it and/or modify it under the terms * of the GNU Lesser General Public License as published by the Free Software Found- @@ -47,7 +47,7 @@ AllPCSX2Threads AllPCSX2Threads::operator-( const AllPCSX2Threads& right ) const return retval; } -DefaultCpuUsageProvider::DefaultCpuUsageProvider() +CpuUsageProvider::CpuUsageProvider() { m_pct_ee = 0; m_pct_gs = 0; @@ -58,18 +58,18 @@ DefaultCpuUsageProvider::DefaultCpuUsageProvider() Reset(); } -void DefaultCpuUsageProvider::Reset() +void CpuUsageProvider::Reset() { for( uint i=0; i m_Implementation; - -public: - CpuUsageProvider(); - virtual ~CpuUsageProvider(); - - virtual bool IsImplemented() const { return m_Implementation->IsImplemented(); } - virtual void UpdateStats() { m_Implementation->UpdateStats(); } - virtual int GetEEcorePct() const { return m_Implementation->GetEEcorePct(); } - virtual int GetGsPct() const { return m_Implementation->GetGsPct(); } - virtual int GetVUPct() const { return m_Implementation->GetVUPct(); } - virtual int GetGuiPct() const { return m_Implementation->GetGuiPct(); } -}; - struct AllPCSX2Threads { u64 ee, gs, vu, ui; @@ -59,7 +41,7 @@ struct AllPCSX2Threads AllPCSX2Threads operator-( const AllPCSX2Threads& right ) const; }; -class DefaultCpuUsageProvider : +class CpuUsageProvider : public BaseCpuUsageProvider, public EventListener_CoreThread { @@ -76,8 +58,8 @@ protected: u32 m_pct_ui; public: - DefaultCpuUsageProvider(); - virtual ~DefaultCpuUsageProvider() = default; + CpuUsageProvider(); + virtual ~CpuUsageProvider() = default; bool IsImplemented() const; void Reset(); diff --git a/pcsx2/gui/CpuUsageProviderLnx.cpp b/pcsx2/gui/CpuUsageProviderLnx.cpp deleted file mode 100644 index 0ddea212cf..0000000000 --- a/pcsx2/gui/CpuUsageProviderLnx.cpp +++ /dev/null @@ -1,31 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#include "PrecompiledHeader.h" -#include "CpuUsageProvider.h" - -// CpuUsageProvider under Linux (Doesn't Do Jack, yet!) -// -// Currently this just falls back on the Default, which itself is not implemented under -// linux, as of me writing this. I'm not sure if it'll be easier to implement the -// default provider (see Utilities/LnxThreads.cpp for details) or to use a custom/manual -// implementation here. - -CpuUsageProvider::CpuUsageProvider() : - m_Implementation( new DefaultCpuUsageProvider() ) -{ -} - -CpuUsageProvider::~CpuUsageProvider() = default; diff --git a/pcsx2/gui/CpuUsageProviderMSW.cpp b/pcsx2/gui/CpuUsageProviderMSW.cpp deleted file mode 100644 index 30a6550290..0000000000 --- a/pcsx2/gui/CpuUsageProviderMSW.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/* PCSX2 - PS2 Emulator for PCs - * Copyright (C) 2002-2010 PCSX2 Dev Team - * - * PCSX2 is free software: you can redistribute it and/or modify it under the terms - * of the GNU Lesser General Public License as published by the Free Software Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along with PCSX2. - * If not, see . - */ - -#include "PrecompiledHeader.h" -#include "CpuUsageProvider.h" - -// undef this for compiler errors, code errors, security denies, and total fail. -#define _COM_SUCKS_SHIT_ - -#ifndef _COM_SUCKS_SHIT_ - -#include "MswStuff.h" -#include "System.h" -#include "SysThreads.h" -#include "GS.h" - -#include -#include -#include -#include -#include - -using namespace Threading; - -#pragma comment(lib, "wbemuuid.lib") -#pragma comment(lib, "comsuppw.lib") - -class CpuUsageProviderMSW : public BaseCpuUsageProvider -{ -protected: - bool m_IsImplemented; - - CComPtr m_WbemServices; - - //CComPtr m_Refresher; - //CComPtr m_Enum; - -public: - CpuUsageProviderMSW(); - virtual ~CpuUsageProviderMSW(); - - bool IsImplemented() const; - void UpdateStats(); - int GetEEcorePct() const; - int GetGsPct() const; - int GetVUPct() const; - int GetGuiPct() const; -}; - -CpuUsageProviderMSW::CpuUsageProviderMSW() -{ - m_IsImplemented = false; - - { - // Test if the OS supports cooked thread performance info... - - wxDoNotLogInThisScope please; - wxDynamicLibrary perfinst( L"WmiPerfInst.dll" ); - if( !perfinst.IsLoaded() ) - { - wxDynamicLibrary cooker( L"Wmicookr.dll" ); - if( !cooker.IsLoaded() ) return; - } - } - - m_IsImplemented = true; - - HRESULT hr; - CComPtr m_IWbemLocator; - - // We're pretty well assured COM is Initialized. - CoInitialize(NULL); - - if( FAILED (hr = CoInitializeSecurity( - NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, 0) ) ) - { - switch( hr ) - { - case RPC_E_TOO_LATE: break; // harmless failure, expected with wxWidgets. - - case RPC_E_NO_GOOD_SECURITY_PACKAGES: - throw Exception::RuntimeError().SetDiagMsg( L"(CpuUsageProviderMSW) CoInitializeSecurity failed: No good security packages! .. whatever tht means." ); - - case E_OUTOFMEMORY: - throw Exception::OutOfMemory( L"(CpuUsageProviderMSW) Out of Memory error returned during call to CoInitializeSecurity." ); - - default: - throw Exception::RuntimeError().SetDiagMsg( wxsFormat( L"(CpuUsageProviderMSW) CoInitializeSecurity failed with an unknown error code: %d", hr ) ); - } - } - - //BSTR bstrNamespace = L"\\\\.\\root\\cimv2"; - BSTR bstrNamespace = L"root\\cimv2"; - - if( FAILED (hr = CoCreateInstance ( - CLSID_WbemAdministrativeLocator, - NULL , - CLSCTX_INPROC_SERVER | CLSCTX_LOCAL_SERVER , - IID_IUnknown , - (LPVOID*)&m_IWbemLocator) ) ) - { - return; - } - - if( FAILED (hr = m_IWbemLocator->ConnectServer( - bstrNamespace, NULL, NULL, NULL, 0, NULL, NULL, &m_WbemServices) ) ) - { - return; - } - - /* - HRESULT hr; - CComPtr m_Config; - - if (FAILED (hr = CoCreateInstance( - CLSID_WbemRefresher, - NULL, - CLSCTX_INPROC_SERVER, - IID_IWbemRefresher, - (void**) &m_Refresher))) - { - return; - } - - if (FAILED (hr = m_Refresher->QueryInterface( - IID_IWbemConfigureRefresher, - (void **)&m_Config))) - { - return; - } - - long lID = 0; // why? - - // Add an enumerator to the refresher. - if (FAILED (hr = m_Config->AddEnum( - m_WbemServices, - L"Win32_PerfRawData_PerfProc_Process", - 0, - NULL, - &m_Enum, - &lID))) - { - return; - }*/ -} - -CpuUsageProviderMSW::~CpuUsageProviderMSW() -{ - //CoUninitialize(); -} - -bool CpuUsageProviderMSW::IsImplemented() const -{ - return m_IsImplemented; -} - -void CpuUsageProviderMSW::UpdateStats() -{ - HRESULT hRes; - BSTR strQuery = L"Select * from Win32_PerfFormattedData_PerfProc_Thread where Name='EEcore'"; - BSTR strQL = L"WQL"; - - CComPtr m_EnumObject; - hRes = m_WbemServices->ExecQuery(strQL, strQuery, WBEM_FLAG_RETURN_IMMEDIATELY, NULL, &m_EnumObject); - - if( FAILED(hRes) ) - { - //throw Exception::WinApiError("Could not execute Query"); - return; - } - - hRes = m_EnumObject->Reset(); - if( FAILED(hRes) ) - { - //MessageBox("Could not Enumerate"); - return; - } - - ULONG uCount = 1, uReturned; - IWbemClassObject* pClassObject = NULL; - hRes = m_EnumObject->Next(WBEM_INFINITE,uCount, &pClassObject, &uReturned); - if( FAILED(hRes) ) - { - const wxChar* msg = NULL; - - switch( hRes ) - { - case WBEM_E_INVALID_PARAMETER: - msg = L"One or more invalid parameters were specified in the call."; - break; - - case WBEM_E_UNEXPECTED: - msg = L"An object in the enumeration has been deleted, destroying the validity of the enumeration."; - break; - - case WBEM_E_TRANSPORT_FAILURE: - msg = L"This indicates the failure of the remote procedure call (RPC) link between the current process and Windows Management."; - break; - - case WBEM_S_FALSE: - msg = L"The number of objects returned was less than the number requested. WBEM_S_FALSE is also returned when this method is called with a value of 0 for the uCount parameter."; - break; - - case WBEM_S_TIMEDOUT: - msg = L"A time-out occurred before you obtained all the objects."; - break; - - case WBEM_E_ACCESS_DENIED: - msg = L"Access Denied to WMI Query."; - break; - - case WBEM_E_OUT_OF_MEMORY: - throw Exception::OutOfMemory( L"(CpuUsageProviderMSW) Out of Memory Enumerating WMI Object." ); - - default: - throw Exception::RuntimeError().SetDiagMsg( wxsFormat( L"(CpuUsageProviderMSW) WMI Object Enumeration failed with an unknown error code: %d", hRes ) ); - } - - if( msg != NULL ) - throw Exception::RuntimeError().SetDiagMsg( (wxString)L"(CpuUsageProviderMSW) " + msg ); - - return; - } - - VARIANT v; - BSTR strClassProp = SysAllocString(L"LoadPercentage"); - hRes = pClassObject->Get(strClassProp, 0, &v, 0, 0); - if( FAILED(hRes) ) - { - //MessageBox("Could not Get Value"); - return; - } - - SysFreeString(strClassProp); - _bstr_t bstrPath = &v; //Just to convert BSTR to ANSI - char* strPath=(char*)bstrPath; - - /*if (SUCCEEDED(hRes)) - MessageBox(strPath); - else - MessageBox("Error in getting object");*/ - - VariantClear(&v); -} - -int CpuUsageProviderMSW::GetEEcorePct() const -{ - return 0; -} - -int CpuUsageProviderMSW::GetGsPct() const -{ - return 0; -} - -int CpuUsageProviderMSW::GetVUPct() const -{ - return 0; -} - -int CpuUsageProviderMSW::GetGuiPct() const -{ - return 0; -} - -#endif - -CpuUsageProvider::CpuUsageProvider() : - m_Implementation( new DefaultCpuUsageProvider() ) -{ -} - -CpuUsageProvider::~CpuUsageProvider() -{ -} diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj b/pcsx2/windows/VCprojects/pcsx2.vcxproj index 58f26316da..4338b31dd5 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj @@ -576,10 +576,6 @@ - - true - - diff --git a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters index 177aef4aba..956acd556a 100644 --- a/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters +++ b/pcsx2/windows/VCprojects/pcsx2.vcxproj.filters @@ -659,12 +659,6 @@ AppHost - - AppHost - - - AppHost - AppHost