mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-25 23:44:35 +00:00
Display dialog when CPU doesn't support AVX/AVX2.
This commit is contained in:
parent
7fc1729f3b
commit
aefa2a9573
@ -114,6 +114,7 @@
|
|||||||
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotSet</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotSet</EnableEnhancedInstructionSet>
|
||||||
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotSet</EnableEnhancedInstructionSet>
|
<EnableEnhancedInstructionSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotSet</EnableEnhancedInstructionSet>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\winmainArchDiscovery.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\TracyAlign.hpp" />
|
<ClInclude Include="..\..\..\common\TracyAlign.hpp" />
|
||||||
|
@ -78,6 +78,9 @@
|
|||||||
<ClCompile Include="..\..\src\winmain.cpp">
|
<ClCompile Include="..\..\src\winmain.cpp">
|
||||||
<Filter>src</Filter>
|
<Filter>src</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="..\..\src\winmainArchDiscovery.cpp">
|
||||||
|
<Filter>src</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
<ClInclude Include="..\..\..\common\tracy_lz4.hpp">
|
||||||
|
@ -1,11 +1,48 @@
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
# include <windows.h>
|
# include <windows.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
# include <intrin.h>
|
||||||
|
# include <stdint.h>
|
||||||
|
|
||||||
|
namespace tracy
|
||||||
|
{
|
||||||
|
bool DiscoveryAVX();
|
||||||
|
bool DiscoveryAVX2();
|
||||||
|
}
|
||||||
|
|
||||||
int main( int argc, char** argv );
|
int main( int argc, char** argv );
|
||||||
|
|
||||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd, int nCmd )
|
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmd, int nCmd )
|
||||||
{
|
{
|
||||||
|
{
|
||||||
|
uint32_t regs[4];
|
||||||
|
__cpuidex( (int*)regs, 0, 0 );
|
||||||
|
const uint32_t maxLeaf = regs[0];
|
||||||
|
bool cpuHasAVX = false;
|
||||||
|
bool cpuHasAVX2 = false;
|
||||||
|
if( maxLeaf >= 1 )
|
||||||
|
{
|
||||||
|
__cpuidex( (int*)regs, 1, 0 );
|
||||||
|
cpuHasAVX = ( regs[2] & 0x10000000 ) != 0;
|
||||||
|
}
|
||||||
|
if( maxLeaf >= 7 )
|
||||||
|
{
|
||||||
|
__cpuidex( (int*)regs, 7, 0 );
|
||||||
|
cpuHasAVX2 = ( regs[1] & 0x00000020 ) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( tracy::DiscoveryAVX2() && !cpuHasAVX2 )
|
||||||
|
{
|
||||||
|
MessageBoxA( nullptr, "This program is compiled with AVX2 instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if( tracy::DiscoveryAVX() && !cpuHasAVX )
|
||||||
|
{
|
||||||
|
MessageBoxA( nullptr, "This program is compiled with AVX instruction set, but your CPU doesn't support it. You must recompile with lower instruction set.\n\nIn Visual Studio go to Project properties -> C/C++ -> Code Generation -> Enable Enhanced Instruction Set and select appropriate value for your CPU.", "Wrong CPU architecture", MB_ICONERROR );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return main( __argc, __argv );
|
return main( __argc, __argv );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
22
profiler/src/winmainArchDiscovery.cpp
Normal file
22
profiler/src/winmainArchDiscovery.cpp
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
#ifdef _WIN32
|
||||||
|
namespace tracy
|
||||||
|
{
|
||||||
|
bool DiscoveryAVX()
|
||||||
|
{
|
||||||
|
#ifdef __AVX__
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DiscoveryAVX2()
|
||||||
|
{
|
||||||
|
#ifdef __AVX2__
|
||||||
|
return true;
|
||||||
|
#else
|
||||||
|
return false;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
Reference in New Issue
Block a user