Use built-in cpuid.

This commit is contained in:
Jean-Philip Desjardins 2017-06-21 00:01:29 -04:00
parent 75ba141504
commit 65d68e1cf5
3 changed files with 10 additions and 61 deletions

View File

@ -1,17 +1,12 @@
#include <windows.h>
#include <tlhelp32.h>
#include <intrin.h>
#include "Types.h"
#include "string_cast.h"
#include "string_format.h"
#include "SysInfoWnd.h"
#include "win32/LayoutWindow.h"
#ifdef _M_X64
extern "C" void _SysInfo_CPUID(uint32, void*);
#endif
#pragma intrinsic(__rdtsc)
#define CLSNAME _T("SysInfoWnd")
@ -159,24 +154,9 @@ void CSysInfoWnd::UpdateSchedulerInfo()
void CSysInfoWnd::UpdateProcessorFeatures()
{
uint32 nFeatures = 0;
#ifdef _M_X64
uint32 cpuIdResult[3];
_SysInfo_CPUID(1, cpuIdResult);
nFeatures = cpuIdResult[1];
#else
__asm
{
mov eax, 0x00000001;
cpuid;
mov dword ptr[nFeatures], edx
}
#endif
std::array<int, 4> cpuInfo;
__cpuid(cpuInfo.data(), 1);
uint32 nFeatures = cpuInfo[2];
m_pFeatures->ResetContent();
@ -206,7 +186,6 @@ void CSysInfoWnd::UpdateProcessor()
unsigned long WINAPI CSysInfoWnd::ThreadRDTSC(void* pParam)
{
LARGE_INTEGER nTime;
char sCpu[13];
HANDLE hThread = GetCurrentThread();
SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL);
@ -230,23 +209,13 @@ unsigned long WINAPI CSysInfoWnd::ThreadRDTSC(void* pParam)
SetThreadPriority(hThread, THREAD_PRIORITY_NORMAL);
#ifdef _M_X64
_SysInfo_CPUID(0, sCpu);
#else
__asm
{
mov eax, 0x00000000;
cpuid;
mov dword ptr[sCpu + 0], ebx;
mov dword ptr[sCpu + 4], edx;
mov dword ptr[sCpu + 8], ecx;
}
#endif
std::array<int, 4> cpuInfo;
__cpuid(cpuInfo.data(), 0);
char sCpu[13];
memcpy(sCpu + 0, cpuInfo.data() + 1, 4);
memcpy(sCpu + 4, cpuInfo.data() + 3, 4);
memcpy(sCpu + 8, cpuInfo.data() + 2, 4);
sCpu[12] = '\0';
CSysInfoWnd* pWnd = reinterpret_cast<CSysInfoWnd*>(pParam);

View File

@ -1,17 +0,0 @@
PUBLIC _SysInfo_CPUID
.CODE
_SysInfo_CPUID PROC
push r12
mov r12, rdx
mov rax, rcx
cpuid
mov dword ptr[r12 + 0], ebx;
mov dword ptr[r12 + 4], edx;
mov dword ptr[r12 + 8], ecx;
pop r12
ret
_SysInfo_CPUID ENDP
END

View File

@ -863,8 +863,6 @@ if(TARGET_PLATFORM_ANDROID)
endif(TARGET_PLATFORM_ANDROID)
if(TARGET_PLATFORM_WIN32)
ENABLE_LANGUAGE(ASM_MASM)
add_library(gsh_opengl_win32 STATIC
../Source/ui_win32/GSH_OpenGL_SettingsWnd.cpp
../Source/ui_win32/GSH_OpenGLWin32.cpp
@ -956,7 +954,6 @@ if(TARGET_PLATFORM_WIN32)
../Source/ui_win32/SaveView.cpp
../Source/ui_win32/StatsOverlayWindow.cpp
../Source/ui_win32/StdAfx.cpp
../Source/ui_win32/SysInfo_x64.asm
../Source/ui_win32/SysInfoWnd.cpp
../Source/ui_win32/ThreadCallStackViewWnd.cpp
../Source/ui_win32/VFSManagerWnd.cpp