From: Michel Zou Date: Tue, 1 Sep 2020 07:22:27 +0000 (+0200) Subject: swr: fix build with mingw X-Git-Url: https://git.libre-soc.org/?p=mesa.git;a=commitdiff_plain;h=3d74fbf502a256e64e5d79d099ec1fc82a693505 swr: fix build with mingw Reviewed-by: Jan Zielinski Tested-by: Prodea Alexandru-Liviu Cc: mesa-stable closes #3454 Part-of: --- diff --git a/src/gallium/auxiliary/tessellator/tessellator.cpp b/src/gallium/auxiliary/tessellator/tessellator.cpp index ac16aabd098..7452ec6cb44 100644 --- a/src/gallium/auxiliary/tessellator/tessellator.cpp +++ b/src/gallium/auxiliary/tessellator/tessellator.cpp @@ -18,9 +18,7 @@ */ #include "tessellator.hpp" -#if defined(__MINGW32__) || defined(__MINGW64__) -#include -#elif defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #include // ceil #else #include @@ -195,7 +193,7 @@ INT32 floatToIDotF( const float& input ) if (iShift >= 0) { // assert( iShift < 32 ); -#if defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #pragma warning( suppress : 4293 ) #endif _fxpMaxPosValueFloat -= INT32( 1 ) << iShift; @@ -217,7 +215,7 @@ INT32 floatToIDotF( const float& input ) if (iShift >= 0) { // assert( iShift < 32 ); -#if defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #pragma warning( suppress : 4293 ) #endif _fxpMaxPosValueFloat -= INT32( 1 ) << iShift; diff --git a/src/gallium/drivers/swr/meson.build b/src/gallium/drivers/swr/meson.build index f8c4ba93f55..0e6f9214f3c 100644 --- a/src/gallium/drivers/swr/meson.build +++ b/src/gallium/drivers/swr/meson.build @@ -239,6 +239,7 @@ if with_swr_arches.contains('skx') version : '0.0.0', soversion : host_machine.system() == 'windows' ? '' : '0', install : true, + name_prefix : host_machine.system() == 'windows' ? '' : 'lib', ) else swr_arch_libs += static_library( @@ -280,6 +281,7 @@ if with_swr_arches.contains('knl') version : '0.0.0', soversion : host_machine.system() == 'windows' ? '' : '0', install : true, + name_prefix : host_machine.system() == 'windows' ? '' : 'lib', ) else swr_arch_libs += static_library( @@ -326,6 +328,7 @@ if with_swr_arches.contains('avx2') version : '0.0.0', soversion : host_machine.system() == 'windows' ? '' : '0', install : true, + name_prefix : host_machine.system() == 'windows' ? '' : 'lib', ) else swr_arch_libs += static_library( @@ -360,6 +363,7 @@ if with_swr_arches.contains('avx') version : '0.0.0', soversion : host_machine.system() == 'windows' ? '' : '0', install : true, + name_prefix : host_machine.system() == 'windows' ? '' : 'lib', ) else swr_arch_libs += static_library( diff --git a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp index c1d3f2d6138..bcdc6d01358 100644 --- a/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp +++ b/src/gallium/drivers/swr/rasterizer/archrast/archrast.cpp @@ -25,6 +25,8 @@ * @brief Implementation for archrast. * ******************************************************************************/ +#include + #include #include diff --git a/src/gallium/drivers/swr/rasterizer/common/os.cpp b/src/gallium/drivers/swr/rasterizer/common/os.cpp index aa817d451b4..a40745f30fc 100644 --- a/src/gallium/drivers/swr/rasterizer/common/os.cpp +++ b/src/gallium/drivers/swr/rasterizer/common/os.cpp @@ -34,7 +34,7 @@ #include #endif // Linux -#if defined(_WIN32) +#if defined(_MSC_VER) static const DWORD MS_VC_EXCEPTION = 0x406D1388; #pragma pack(push, 8) @@ -76,7 +76,7 @@ void LegacySetThreadName(const char* pThreadName) void SWR_API SetCurrentThreadName(const char* pThreadName) { -#if defined(_WIN32) +#if defined(_MSC_VER) // The SetThreadDescription API was brought in version 1607 of Windows 10. typedef HRESULT(WINAPI * PFNSetThreadDescription)(HANDLE hThread, PCWSTR lpThreadDescription); // The SetThreadDescription API works even if no debugger is attached. diff --git a/src/gallium/drivers/swr/rasterizer/common/os.h b/src/gallium/drivers/swr/rasterizer/common/os.h index bda114d64e2..f48ed6443c6 100644 --- a/src/gallium/drivers/swr/rasterizer/common/os.h +++ b/src/gallium/drivers/swr/rasterizer/common/os.h @@ -49,7 +49,11 @@ #undef MemoryFence #endif +#if defined(_MSC_VER) #define OSALIGN(RWORD, WIDTH) __declspec(align(WIDTH)) RWORD +#elif defined(__GNUC__) +#define OSALIGN(RWORD, WIDTH) RWORD __attribute__((aligned(WIDTH))) +#endif #if defined(_DEBUG) // We compile Debug builds with inline function expansion enabled. This allows diff --git a/src/gallium/drivers/swr/rasterizer/common/swr_assert.cpp b/src/gallium/drivers/swr/rasterizer/common/swr_assert.cpp index 8e874fbc223..0f5382044c2 100644 --- a/src/gallium/drivers/swr/rasterizer/common/swr_assert.cpp +++ b/src/gallium/drivers/swr/rasterizer/common/swr_assert.cpp @@ -30,7 +30,7 @@ #if SWR_ENABLE_ASSERTS || SWR_ENABLE_REL_ASSERTS -#if defined(_WIN32) +#if defined(_MSC_VER) #pragma comment(lib, "user32.lib") #endif // _WIN32 diff --git a/src/gallium/drivers/swr/rasterizer/common/swr_assert.h b/src/gallium/drivers/swr/rasterizer/common/swr_assert.h index f6bf83ea5a8..cd9854f2549 100644 --- a/src/gallium/drivers/swr/rasterizer/common/swr_assert.h +++ b/src/gallium/drivers/swr/rasterizer/common/swr_assert.h @@ -71,7 +71,7 @@ while (0) \ _SWR_WARN_RESTORE -#if defined(_WIN32) +#if defined(_MSC_VER) #define SWR_ASSUME(e, ...) \ _SWR_MACRO_START __assume(e); \ _SWR_MACRO_END diff --git a/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp b/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp index 05a598b60a9..d9f4ddb3ffb 100644 --- a/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/tessellator.cpp @@ -18,7 +18,7 @@ */ #include "tessellator.hpp" -#if defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #include // ceil #else #include @@ -179,7 +179,7 @@ INT32 floatToIDotF( const float& input ) if (iShift >= 0) { // assert( iShift < 32 ); -#if defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #pragma warning( suppress : 4293 ) #endif _fxpMaxPosValueFloat -= INT32( 1 ) << iShift; @@ -201,7 +201,7 @@ INT32 floatToIDotF( const float& input ) if (iShift >= 0) { // assert( iShift < 32 ); -#if defined(_WIN32) || defined(_WIN64) +#if defined(_MSC_VER) #pragma warning( suppress : 4293 ) #endif _fxpMaxPosValueFloat -= INT32( 1 ) << iShift; diff --git a/src/gallium/drivers/swr/rasterizer/core/threads.cpp b/src/gallium/drivers/swr/rasterizer/core/threads.cpp index 556e02e99ef..1338f929071 100644 --- a/src/gallium/drivers/swr/rasterizer/core/threads.cpp +++ b/src/gallium/drivers/swr/rasterizer/core/threads.cpp @@ -105,8 +105,6 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread Core* pCore = nullptr; - uint32_t numThreads = (uint32_t)_mm_popcount_sizeT(gmask.Mask); - while (BitScanForwardSizeT((unsigned long*)&threadId, gmask.Mask)) { // clear mask @@ -148,8 +146,6 @@ void CalculateProcessorTopology(CPUNumaNodes& out_nodes, uint32_t& out_numThread auto& numaNode = out_nodes[numaId]; numaNode.numaId = numaId; - uint32_t coreId = 0; - if (nullptr == pCore) { numaNode.cores.push_back(Core()); @@ -980,14 +976,14 @@ DWORD workerThreadMain(LPVOID) = delete; template DWORD workerThreadInit(LPVOID pData) { -#if defined(_WIN32) +#if defined(_MSC_VER) __try #endif // _WIN32 { return workerThreadMain(pData); } -#if defined(_WIN32) +#if defined(_MSC_VER) __except (EXCEPTION_CONTINUE_SEARCH) { } diff --git a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp index 96224a73738..7b8689933b5 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/JitManager.cpp @@ -159,7 +159,7 @@ JitManager::JitManager(uint32_t simdWidth, const char* arch, const char* core) : mFetchShaderTy = FunctionType::get(Type::getVoidTy(mContext), fsArgs, false); -#if defined(_WIN32) +#if defined(_MSC_VER) // explicitly instantiate used symbols from potentially staticly linked libs sys::DynamicLibrary::AddSymbol("exp2f", &exp2f); sys::DynamicLibrary::AddSymbol("log2f", &log2f); diff --git a/src/gallium/drivers/swr/rasterizer/jitter/jit_pch.hpp b/src/gallium/drivers/swr/rasterizer/jitter/jit_pch.hpp index a5c5b1f73c9..3e7bc8b5df8 100644 --- a/src/gallium/drivers/swr/rasterizer/jitter/jit_pch.hpp +++ b/src/gallium/drivers/swr/rasterizer/jitter/jit_pch.hpp @@ -30,7 +30,7 @@ #pragma once -#if defined(_WIN32) +#if defined(_MSC_VER) #pragma warning(disable : 4146 4244 4267 4800 4996) #endif diff --git a/src/gallium/drivers/swr/rasterizer/memory/Convert.h b/src/gallium/drivers/swr/rasterizer/memory/Convert.h index de4986c2732..c8c6b30daff 100644 --- a/src/gallium/drivers/swr/rasterizer/memory/Convert.h +++ b/src/gallium/drivers/swr/rasterizer/memory/Convert.h @@ -27,7 +27,7 @@ ******************************************************************************/ #pragma once -#if defined(_WIN32) +#if defined(_MSC_VER) // disable "potential divide by 0" #pragma warning(disable: 4723) #endif