From 6599ebcf31d5d496372aaf63a8ebabfa2d8c4aaa Mon Sep 17 00:00:00 2001 From: Till Rathmann Date: Wed, 1 Aug 2018 14:03:21 +0200 Subject: [PATCH 1/6] Changed from AVX2 to AVX. --- capture/build/win32/capture.vcxproj | 4 ++-- standalone/build/win32/Tracy.vcxproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/capture/build/win32/capture.vcxproj b/capture/build/win32/capture.vcxproj index 23b6d78d..e184935f 100644 --- a/capture/build/win32/capture.vcxproj +++ b/capture/build/win32/capture.vcxproj @@ -86,7 +86,7 @@ true true TRACY_NO_STATISTICS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) - AdvancedVectorExtensions2 + AdvancedVectorExtensions stdcpplatest @@ -118,7 +118,7 @@ true true TRACY_NO_STATISTICS;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) - AdvancedVectorExtensions2 + AdvancedVectorExtensions stdcpplatest diff --git a/standalone/build/win32/Tracy.vcxproj b/standalone/build/win32/Tracy.vcxproj index fd2651ad..5f5420e2 100644 --- a/standalone/build/win32/Tracy.vcxproj +++ b/standalone/build/win32/Tracy.vcxproj @@ -53,7 +53,7 @@ true false true - AdvancedVectorExtensions2 + AdvancedVectorExtensions Caret stdcpplatest Fast @@ -77,7 +77,7 @@ ..\..\libs\glfw\include;..\..\libs\gl3w;..\..\..\imgui;%(AdditionalIncludeDirectories) true true - AdvancedVectorExtensions2 + AdvancedVectorExtensions Caret stdcpplatest Fast From d1dd1d664fb388f04f0eb1051f8ab4ecb0cbab79 Mon Sep 17 00:00:00 2001 From: Till Rathmann Date: Wed, 1 Aug 2018 14:06:00 +0200 Subject: [PATCH 2/6] Removed MSVC /permissive- compiler flag for nfd_win.cpp because it causes problems in combaseapi.h with Windows SDK 8.1. --- standalone/build/win32/Tracy.vcxproj | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/standalone/build/win32/Tracy.vcxproj b/standalone/build/win32/Tracy.vcxproj index 5f5420e2..fe0c85cb 100644 --- a/standalone/build/win32/Tracy.vcxproj +++ b/standalone/build/win32/Tracy.vcxproj @@ -100,7 +100,10 @@ - + + false + false + From 37d5736bf51592a6d803576dc34b7062edc2a1d6 Mon Sep 17 00:00:00 2001 From: Till Rathmann Date: Wed, 1 Aug 2018 14:07:30 +0200 Subject: [PATCH 3/6] Fixed compiler warnings. --- TracyClient.cpp | 4 ---- client/TracyCallstack.cpp | 3 +++ client/TracyProfiler.cpp | 7 ++++--- client/TracyProfiler.hpp | 2 +- client/concurrentqueue.h | 29 ++++++++++++++++++++++------- client/tracy_rpmalloc.cpp | 18 ++++++++++++------ common/TracySocket.cpp | 8 ++++---- common/TracySystem.cpp | 8 ++++++++ common/tracy_lz4.cpp | 2 +- common/tracy_lz4.hpp | 2 +- 10 files changed, 56 insertions(+), 27 deletions(-) diff --git a/TracyClient.cpp b/TracyClient.cpp index 273ccae0..8f465650 100644 --- a/TracyClient.cpp +++ b/TracyClient.cpp @@ -11,10 +11,6 @@ // Define TRACY_ENABLE to enable profiler. -#if ( defined _MSC_VER || defined __CYGWIN__ ) && !defined WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - #include "common/TracySystem.cpp" #ifdef TRACY_ENABLE diff --git a/client/TracyCallstack.cpp b/client/TracyCallstack.cpp index 8e549b65..e76d24a2 100644 --- a/client/TracyCallstack.cpp +++ b/client/TracyCallstack.cpp @@ -5,7 +5,10 @@ #if TRACY_HAS_CALLSTACK == 1 # include +# pragma warning( push ) +# pragma warning( disable : 4091 ) # include +# pragma warning( pop ) #elif TRACY_HAS_CALLSTACK >= 2 # include # include diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 33e9c41a..1f41d35a 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -85,7 +85,7 @@ static int SetupHwTimerFailed() return sigsetjmp( SigIllEnv, 1 ); } -static void SetupHwTimerSigIllHandler( int signum ) +static void SetupHwTimerSigIllHandler( int /*signum*/ ) { siglongjmp( SigIllEnv, 1 ); } @@ -139,8 +139,9 @@ static const char* GetProcessName() # endif #elif defined _GNU_SOURCE || defined __CYGWIN__ return program_invocation_short_name; -#endif +#else return "unknown"; +#endif } enum { QueuePrealloc = 256 * 1024 }; @@ -728,7 +729,7 @@ void Profiler::SendCallstackPayload( uint64_t _ptr ) AppendDataUnsafe( &item, QueueDataSize[(int)QueueType::CallstackPayload] ); AppendDataUnsafe( &l16, sizeof( l16 ) ); - if( sizeof( uintptr_t ) == sizeof( uint64_t ) ) + if( compile_time_condition::value ) { AppendDataUnsafe( ptr, sizeof( uint64_t ) * sz ); } diff --git a/client/TracyProfiler.hpp b/client/TracyProfiler.hpp index bb11fb4e..58e882c1 100644 --- a/client/TracyProfiler.hpp +++ b/client/TracyProfiler.hpp @@ -373,7 +373,7 @@ private: MemWrite( &item->memAlloc.time, GetTime() ); MemWrite( &item->memAlloc.thread, thread ); MemWrite( &item->memAlloc.ptr, (uint64_t)ptr ); - if( sizeof( size ) == 4 ) + if( compile_time_condition::value ) { memcpy( &item->memAlloc.size, &size, 4 ); memset( &item->memAlloc.size + 4, 0, 2 ); diff --git a/client/concurrentqueue.h b/client/concurrentqueue.h index 7a57e547..a3d0237f 100644 --- a/client/concurrentqueue.h +++ b/client/concurrentqueue.h @@ -231,6 +231,21 @@ namespace moodycamel { namespace details { #endif } } +namespace +{ + // to avoid MSVC warning 4127: conditional expression is constant + template + struct compile_time_condition + { + static const bool value = false; + }; + template <> + struct compile_time_condition + { + static const bool value = true; + }; +} + #ifdef MOODYCAMEL_QUEUE_INTERNAL_DEBUG #include "internal/concurrentqueue_internal_debug.h" #endif @@ -797,7 +812,7 @@ public: } // Destroy implicit producer hash tables - if (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE != 0) { + if (compile_time_condition::value) { auto hash = implicitProducerHash.load(std::memory_order_relaxed); while (hash != nullptr) { auto prev = hash->prev; @@ -1504,7 +1519,7 @@ private: template inline bool is_empty() const { - if (context == explicit_context && BLOCK_SIZE <= EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD) { + if (compile_time_condition::value) { // Check flags for (size_t i = 0; i < BLOCK_SIZE; ++i) { if (!emptyFlags[i].load(std::memory_order_relaxed)) { @@ -1550,7 +1565,7 @@ private: template inline bool set_many_empty(index_t i, size_t count) { - if (context == explicit_context && BLOCK_SIZE <= EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD) { + if (compile_time_condition::value) { // Set flags std::atomic_thread_fence(std::memory_order_release); i = BLOCK_SIZE - 1 - static_cast(i & static_cast(BLOCK_SIZE - 1)) - count + 1; @@ -1586,7 +1601,7 @@ private: template inline void reset_empty() { - if (context == explicit_context && BLOCK_SIZE <= EXPLICIT_BLOCK_EMPTY_COUNTER_THRESHOLD) { + if (compile_time_condition::value) { // Reset flags for (size_t i = 0; i != BLOCK_SIZE; ++i) { emptyFlags[i].store(false, std::memory_order_relaxed); @@ -3298,7 +3313,7 @@ private: inline void populate_initial_implicit_producer_hash() { - if (INITIAL_IMPLICIT_PRODUCER_HASH_SIZE == 0) return; + if (compile_time_condition::value) return; implicitProducerHashCount.store(0, std::memory_order_relaxed); auto hash = &initialImplicitProducerHash; @@ -3640,7 +3655,7 @@ ConsumerToken::ConsumerToken(ConcurrentQueue& queue) : itemsConsumedFromCurrent(0), currentProducer(nullptr), desiredProducer(nullptr) { initialOffset = queue.nextExplicitConsumerId.fetch_add(1, std::memory_order_release); - lastKnownGlobalOffset = -1; + lastKnownGlobalOffset = static_cast(-1); } template @@ -3648,7 +3663,7 @@ ConsumerToken::ConsumerToken(BlockingConcurrentQueue& queue) : itemsConsumedFromCurrent(0), currentProducer(nullptr), desiredProducer(nullptr) { initialOffset = reinterpret_cast*>(&queue)->nextExplicitConsumerId.fetch_add(1, std::memory_order_release); - lastKnownGlobalOffset = -1; + lastKnownGlobalOffset = static_cast(-1); } template diff --git a/client/tracy_rpmalloc.cpp b/client/tracy_rpmalloc.cpp index 08e075f9..10957fd3 100644 --- a/client/tracy_rpmalloc.cpp +++ b/client/tracy_rpmalloc.cpp @@ -85,6 +85,8 @@ /// Platform and arch specifics #ifdef _MSC_VER +# pragma warning( push ) +# pragma warning( disable : 4324 ) # define ALIGNED_STRUCT(name, alignment) __declspec(align(alignment)) struct name # define FORCEINLINE __forceinline # define atomic_thread_fence_acquire() //_ReadWriteBarrier() @@ -1769,13 +1771,13 @@ _memory_map_os(size_t size, size_t* offset) { //Ok to MEM_COMMIT - according to MSDN, "actual physical pages are not allocated unless/until the virtual addresses are actually accessed" void* ptr = VirtualAlloc(0, size + padding, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (!ptr) { - assert("Failed to map virtual memory block" == 0); + assert("Failed to map virtual memory block" && 0); return 0; } #else void* ptr = mmap(0, size + padding, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_UNINITIALIZED, -1, 0); if ((ptr == MAP_FAILED) || !ptr) { - assert("Failed to map virtual memory block" == 0); + assert("Failed to map virtual memory block" && 0); return 0; } #endif @@ -1813,12 +1815,12 @@ _memory_unmap_os(void* address, size_t size, size_t offset, int release) { #if PLATFORM_WINDOWS if (!VirtualFree(address, release ? 0 : size, release ? MEM_RELEASE : MEM_DECOMMIT)) { DWORD err = GetLastError(); - assert("Failed to unmap virtual memory block" == 0); + assert("Failed to unmap virtual memory block" && err && 0); } #else MEMORY_UNUSED(release); if (munmap(address, size)) { - assert("Failed to unmap virtual memory block" == 0); + assert("Failed to unmap virtual memory block" && 0); } #endif } @@ -1854,7 +1856,7 @@ _memory_guard_validate(void* p) { if (_memory_config.memory_overwrite) _memory_config.memory_overwrite(p); else - assert("Memory overwrite before block start" == 0); + assert("Memory overwrite before block start" && 0); return; } deadzone[i] = 0; @@ -1866,7 +1868,7 @@ _memory_guard_validate(void* p) { if (_memory_config.memory_overwrite) _memory_config.memory_overwrite(p); else - assert("Memory overwrite after block end" == 0); + assert("Memory overwrite after block end" && 0); return; } deadzone[i] = 0; @@ -2086,4 +2088,8 @@ rpmalloc_global_statistics(rpmalloc_global_statistics_t* stats) { } +#ifdef _MSC_VER +# pragma warning( pop ) +#endif + #endif diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index 8eb54241..bb958358 100644 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -86,7 +86,7 @@ bool Socket::Connect( const char* addr, const char* port ) hints.ai_socktype = SOCK_STREAM; if( getaddrinfo( addr, port, &hints, &res ) != 0 ) return false; - int sock; + int sock = 0; for( ptr = res; ptr; ptr = ptr->ai_next ) { if( ( sock = socket( ptr->ai_family, ptr->ai_socktype, ptr->ai_protocol ) ) == -1 ) continue; @@ -174,7 +174,7 @@ int Socket::Recv( void* _buf, int len, const timeval* tv ) fd_set fds; FD_ZERO( &fds ); - FD_SET( m_sock, &fds ); + FD_SET( static_cast(m_sock), &fds ); #ifndef _WIN32 timeval _tv = *tv; @@ -231,7 +231,7 @@ bool Socket::HasData() fd_set fds; FD_ZERO( &fds ); - FD_SET( m_sock, &fds ); + FD_SET( static_cast(m_sock), &fds ); return select( m_sock+1, &fds, nullptr, nullptr, &tv ) > 0; } @@ -287,7 +287,7 @@ Socket* ListenSocket::Accept() fd_set fds; FD_ZERO( &fds ); - FD_SET( m_sock, &fds ); + FD_SET( static_cast(m_sock), &fds ); select( m_sock+1, &fds, nullptr, nullptr, &tv ); if( FD_ISSET( m_sock, &fds ) ) diff --git a/common/TracySystem.cpp b/common/TracySystem.cpp index 619c631d..b93353f5 100644 --- a/common/TracySystem.cpp +++ b/common/TracySystem.cpp @@ -1,3 +1,11 @@ +#if defined _MSC_VER || defined __CYGWIN__ || defined _WIN32 +# ifndef WIN32_LEAN_AND_MEAN +# define WIN32_LEAN_AND_MEAN +# endif +# ifndef NOMINMAX +# define NOMINMAX +# endif +#endif #ifdef _WIN32 # include #else diff --git a/common/tracy_lz4.cpp b/common/tracy_lz4.cpp index c6d40ad5..fb2ac3c9 100644 --- a/common/tracy_lz4.cpp +++ b/common/tracy_lz4.cpp @@ -701,7 +701,7 @@ LZ4_FORCE_INLINE int LZ4_compress_generic( cctx->dictSize += (U32)inputSize; } cctx->currentOffset += (U32)inputSize; - cctx->tableType = tableType; + cctx->tableType = (U16)tableType; if (inputSize Date: Wed, 1 Aug 2018 14:36:31 +0200 Subject: [PATCH 4/6] Revert "Changed from AVX2 to AVX." This reverts commit 6599ebcf31d5d496372aaf63a8ebabfa2d8c4aaa. --- capture/build/win32/capture.vcxproj | 4 ++-- standalone/build/win32/Tracy.vcxproj | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/capture/build/win32/capture.vcxproj b/capture/build/win32/capture.vcxproj index e184935f..23b6d78d 100644 --- a/capture/build/win32/capture.vcxproj +++ b/capture/build/win32/capture.vcxproj @@ -86,7 +86,7 @@ true true TRACY_NO_STATISTICS;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) - AdvancedVectorExtensions + AdvancedVectorExtensions2 stdcpplatest @@ -118,7 +118,7 @@ true true TRACY_NO_STATISTICS;NDEBUG;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;WIN32_LEAN_AND_MEAN;NOMINMAX;_USE_MATH_DEFINES;%(PreprocessorDefinitions) - AdvancedVectorExtensions + AdvancedVectorExtensions2 stdcpplatest diff --git a/standalone/build/win32/Tracy.vcxproj b/standalone/build/win32/Tracy.vcxproj index fe0c85cb..db9c9a3e 100644 --- a/standalone/build/win32/Tracy.vcxproj +++ b/standalone/build/win32/Tracy.vcxproj @@ -53,7 +53,7 @@ true false true - AdvancedVectorExtensions + AdvancedVectorExtensions2 Caret stdcpplatest Fast @@ -77,7 +77,7 @@ ..\..\libs\glfw\include;..\..\libs\gl3w;..\..\..\imgui;%(AdditionalIncludeDirectories) true true - AdvancedVectorExtensions + AdvancedVectorExtensions2 Caret stdcpplatest Fast From df09fe48cf5e398f4d369256aa76029a88757656 Mon Sep 17 00:00:00 2001 From: Till Rathmann Date: Wed, 1 Aug 2018 14:44:39 +0200 Subject: [PATCH 5/6] Workaround in nfd_win.cpp for MSVC problem in combaseapi.h. --- nfd/nfd_win.cpp | 3 +++ standalone/build/win32/Tracy.vcxproj | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/nfd/nfd_win.cpp b/nfd/nfd_win.cpp index a73fd8a4..37d9b774 100644 --- a/nfd/nfd_win.cpp +++ b/nfd/nfd_win.cpp @@ -19,7 +19,10 @@ #include #include #include + +struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive- #include + #include "nfd_common.h" diff --git a/standalone/build/win32/Tracy.vcxproj b/standalone/build/win32/Tracy.vcxproj index db9c9a3e..fd2651ad 100644 --- a/standalone/build/win32/Tracy.vcxproj +++ b/standalone/build/win32/Tracy.vcxproj @@ -100,10 +100,7 @@ - - false - false - + From 3b302315f901ba9bcd23dac85a4aed679638c175 Mon Sep 17 00:00:00 2001 From: Till Rathmann Date: Wed, 1 Aug 2018 19:18:40 +0200 Subject: [PATCH 6/6] Fixed __ANDROID_API__ < 21 build and FD_SET usage. --- client/TracyProfiler.cpp | 10 +++++----- common/TracySocket.cpp | 12 +++++++++--- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/client/TracyProfiler.cpp b/client/TracyProfiler.cpp index 1f41d35a..bf26292f 100644 --- a/client/TracyProfiler.cpp +++ b/client/TracyProfiler.cpp @@ -124,6 +124,7 @@ static int64_t SetupHwTimer() static const char* GetProcessName() { + const char* processName = "unknown"; #if defined _MSC_VER static char buf[_MAX_PATH]; GetModuleFileNameA( nullptr, buf, _MAX_PATH ); @@ -131,17 +132,16 @@ static const char* GetProcessName() while( *ptr != '\0' ) ptr++; while( ptr > buf && *ptr != '\\' && *ptr != '/' ) ptr--; if( ptr > buf ) ptr++; - return ptr; + processName = ptr; #elif defined __ANDROID__ # if __ANDROID_API__ >= 21 auto buf = getprogname(); - if( buf ) return buf; + if( buf ) processName = buf; # endif #elif defined _GNU_SOURCE || defined __CYGWIN__ - return program_invocation_short_name; -#else - return "unknown"; + processName = program_invocation_short_name; #endif + return processName; } enum { QueuePrealloc = 256 * 1024 }; diff --git a/common/TracySocket.cpp b/common/TracySocket.cpp index bb958358..ed14ac08 100644 --- a/common/TracySocket.cpp +++ b/common/TracySocket.cpp @@ -25,6 +25,12 @@ namespace tracy { +#ifdef _MSC_VER +typedef SOCKET socket_t; +#else +typedef int socket_t; +#endif + #ifdef _MSC_VER struct __wsinit { @@ -174,7 +180,7 @@ int Socket::Recv( void* _buf, int len, const timeval* tv ) fd_set fds; FD_ZERO( &fds ); - FD_SET( static_cast(m_sock), &fds ); + FD_SET( static_cast(m_sock), &fds ); #ifndef _WIN32 timeval _tv = *tv; @@ -231,7 +237,7 @@ bool Socket::HasData() fd_set fds; FD_ZERO( &fds ); - FD_SET( static_cast(m_sock), &fds ); + FD_SET( static_cast(m_sock), &fds ); return select( m_sock+1, &fds, nullptr, nullptr, &tv ) > 0; } @@ -287,7 +293,7 @@ Socket* ListenSocket::Accept() fd_set fds; FD_ZERO( &fds ); - FD_SET( static_cast(m_sock), &fds ); + FD_SET( static_cast(m_sock), &fds ); select( m_sock+1, &fds, nullptr, nullptr, &tv ); if( FD_ISSET( m_sock, &fds ) )