diff --git a/src/xenia/app/premake5.lua b/src/xenia/app/premake5.lua index 442d6585b..35361d011 100644 --- a/src/xenia/app/premake5.lua +++ b/src/xenia/app/premake5.lua @@ -50,18 +50,20 @@ project("xenia-app") files({ "xenia_main.cc", "../base/main_"..platform_suffix..".cc", + "../base/main_init_"..platform_suffix..".cc", }) - filter("files:xenia_main.cc or ../base/main_"..platform_suffix..".cc") - vectorextensions("IA32") -- Disable AVX for main_win.cc so our AVX check/error can happen. + resincludedirs({ + project_root, + }) filter("platforms:Windows") files({ "main_resources.rc", }) - resincludedirs({ - project_root, - }) + + filter("files:../base/main_init_"..platform_suffix..".cc") + vectorextensions("IA32") -- Disable AVX for main_init_win.cc so our AVX check doesn't use AVX instructions. filter("platforms:Linux") links({ diff --git a/src/xenia/base/main_init_win.cc b/src/xenia/base/main_init_win.cc new file mode 100644 index 000000000..e6b0c9c59 --- /dev/null +++ b/src/xenia/base/main_init_win.cc @@ -0,0 +1,40 @@ +/** + ****************************************************************************** + * Xenia : Xbox 360 Emulator Research Project * + ****************************************************************************** + * Copyright 2014 Ben Vanik. All rights reserved. * + * Released under the BSD license - see LICENSE in the root for more details. * + ****************************************************************************** + */ + +#include "xenia/base/main.h" + +#include + +#include "third_party/xbyak/xbyak/xbyak_util.h" + +class StartupAvxCheck { + public: + StartupAvxCheck() { + Xbyak::util::Cpu cpu; + if (cpu.has(Xbyak::util::Cpu::tAVX)) { + return; + } + // TODO(gibbed): detect app type and printf instead, if needed? + MessageBoxA( + nullptr, + "Your CPU does not support AVX, which is required by Xenia. See the " + "FAQ for system requirements at https://xenia.jp", + "Xenia Error", MB_OK | MB_ICONERROR | MB_SETFOREGROUND); + ExitProcess(static_cast(-1)); + } +}; + +// This is a hack to get an instance of StartupAvxCheck +// constructed before any initialization code, +// where the AVX check then happens in the constructor. +// +// https://docs.microsoft.com/en-us/cpp/preprocessor/init-seg +#pragma warning(suppress : 4073) +#pragma init_seg(lib) +static StartupAvxCheck gStartupAvxCheck;