You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
[Windows] Additionally use cpuid instruction to detect SSE4.2 support.
This commit is contained in:
@@ -29,6 +29,23 @@
|
|||||||
/**************************************************************************/
|
/**************************************************************************/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <intrin.h> // For builtin __cpuid.
|
||||||
|
#else
|
||||||
|
void __cpuid(int *r_cpuinfo, int p_info) {
|
||||||
|
// Note: Some compilers have a buggy `__cpuid` intrinsic, using inline assembly (based on LLVM-20 implementation) instead.
|
||||||
|
__asm__ __volatile__(
|
||||||
|
"xchgq %%rbx, %q1;"
|
||||||
|
"cpuid;"
|
||||||
|
"xchgq %%rbx, %q1;"
|
||||||
|
: "=a"(r_cpuinfo[0]), "=r"(r_cpuinfo[1]), "=c"(r_cpuinfo[2]), "=d"(r_cpuinfo[3])
|
||||||
|
: "0"(p_info));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef PF_SSE4_2_INSTRUCTIONS_AVAILABLE
|
||||||
|
#define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS_SUBSYSTEM_CONSOLE
|
#ifdef WINDOWS_SUBSYSTEM_CONSOLE
|
||||||
extern int WINAPI mainCRTStartup();
|
extern int WINAPI mainCRTStartup();
|
||||||
@@ -41,7 +58,16 @@ extern int WINAPI ShimMainCRTStartup() __attribute__((used));
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern int WINAPI ShimMainCRTStartup() {
|
extern int WINAPI ShimMainCRTStartup() {
|
||||||
if (IsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE)) {
|
BOOL win_sse42_supported = FALSE;
|
||||||
|
BOOL cpuid_sse42_supported = FALSE;
|
||||||
|
|
||||||
|
int cpuinfo[4];
|
||||||
|
__cpuid(cpuinfo, 0x01);
|
||||||
|
|
||||||
|
win_sse42_supported = IsProcessorFeaturePresent(PF_SSE4_2_INSTRUCTIONS_AVAILABLE);
|
||||||
|
cpuid_sse42_supported = cpuinfo[2] & (1 << 20);
|
||||||
|
|
||||||
|
if (win_sse42_supported || cpuid_sse42_supported) {
|
||||||
#ifdef WINDOWS_SUBSYSTEM_CONSOLE
|
#ifdef WINDOWS_SUBSYSTEM_CONSOLE
|
||||||
return mainCRTStartup();
|
return mainCRTStartup();
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user