123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741 |
- #ifndef _AK_PLATFORM_FUNCS_H_
- #define _AK_PLATFORM_FUNCS_H_
- #include "malloc.h"
- #include <AK/Tools/Common/AkAssert.h>
- #include <AK/SoundEngine/Common/AkAtomic.h>
- #include <windows.h>
- #include <stdio.h>
- #if defined(_WIN64)
- #include <math.h>
- #endif
- #include <intrin.h>
- #if defined(AK_XBOXSERIESX)
- #include <ammintrin.h>
- #endif
- struct AkThreadProperties
- {
- int nPriority;
- #ifdef AK_WIN_UNIVERSAL_APP
- PROCESSOR_NUMBER processorNumber;
- #else
- AkUInt32 dwAffinityMask;
- #endif
- AkUInt32 uStackSize;
- };
- namespace AK
- {
- extern AkReal32 g_fFreqRatio;
- }
- #define AK_DECLARE_THREAD_ROUTINE( FuncName ) DWORD WINAPI FuncName(LPVOID lpParameter)
- #define AK_THREAD_RETURN( _param_ ) return (_param_);
- #define AK_THREAD_ROUTINE_PARAMETER lpParameter
- #define AK_GET_THREAD_ROUTINE_PARAMETER_PTR(type) reinterpret_cast<type*>( AK_THREAD_ROUTINE_PARAMETER )
- #define AK_RETURN_THREAD_OK 0x00000000
- #define AK_RETURN_THREAD_ERROR 0x00000001
- #define AK_DEFAULT_STACK_SIZE (128*1024)
- #define AK_THREAD_PRIORITY_NORMAL THREAD_PRIORITY_NORMAL
- #define AK_THREAD_PRIORITY_ABOVE_NORMAL THREAD_PRIORITY_ABOVE_NORMAL
- #define AK_THREAD_PRIORITY_BELOW_NORMAL THREAD_PRIORITY_BELOW_NORMAL
- #define AK_THREAD_PRIORITY_TIME_CRITICAL THREAD_PRIORITY_TIME_CRITICAL
- #define AK_THREAD_MODE_BACKGROUND_BEGIN THREAD_MODE_BACKGROUND_BEGIN
- #define AK_NULL_THREAD NULL
- #define AK_INFINITE INFINITE
- #define AkMax(x1, x2) (((x1) > (x2))? (x1): (x2))
- #define AkMin(x1, x2) (((x1) < (x2))? (x1): (x2))
- #define AkClamp(x, min, max) ((x) < (min)) ? (min) : (((x) > (max) ? (max) : (x)))
- namespace AKPLATFORM
- {
-
-
-
-
- inline void AkClearEvent( AkEvent & out_event )
- {
- out_event = NULL;
- }
-
- inline AKRESULT AkCreateEvent( AkEvent & out_event )
- {
- out_event = ::CreateEvent( NULL,
- false,
- false,
- NULL
- );
- return ( out_event ) ? AK_Success : AK_Fail;
- }
-
- inline void AkDestroyEvent( AkEvent & io_event )
- {
- if ( io_event )
- ::CloseHandle( io_event );
- io_event = NULL;
- }
-
- inline void AkWaitForEvent( AkEvent & in_event )
- {
- AKVERIFY( ::WaitForSingleObject( in_event, INFINITE ) == WAIT_OBJECT_0 );
- }
-
- inline void AkSignalEvent( const AkEvent & in_event )
- {
- AKVERIFY( ::SetEvent( in_event ) );
- }
-
- AkForceInline void AkClearSemaphore(AkSemaphore& io_semaphore)
- {
- io_semaphore = NULL;
- }
-
- inline AKRESULT AkCreateSemaphore(AkSemaphore& out_semaphore, AkUInt32 in_initialCount)
- {
- out_semaphore = ::CreateSemaphore(
- NULL,
- in_initialCount,
- INT_MAX,
- NULL);
- return (out_semaphore) ? AK_Success : AK_Fail;
- }
-
- inline void AkDestroySemaphore(AkSemaphore& io_semaphore)
- {
- ::CloseHandle(io_semaphore);
- }
-
- inline void AkWaitForSemaphore(AkSemaphore& in_semaphore)
- {
- AKVERIFY(::WaitForSingleObject(in_semaphore, INFINITE) == WAIT_OBJECT_0);
- }
-
- inline void AkReleaseSemaphore(AkSemaphore& in_semaphore, AkUInt32 in_count)
- {
- AKVERIFY(ReleaseSemaphore(in_semaphore, in_count, NULL) >= 0);
- }
-
-
-
- inline bool AkIsValidThread( AkThread * in_pThread )
- {
- return (*in_pThread != AK_NULL_THREAD);
- }
-
- inline void AkClearThread( AkThread * in_pThread )
- {
- *in_pThread = AK_NULL_THREAD;
- }
-
- inline void AkCloseThread( AkThread * in_pThread )
- {
- AKASSERT( in_pThread );
- AKASSERT( *in_pThread );
- AKVERIFY( ::CloseHandle( *in_pThread ) );
- AkClearThread( in_pThread );
- }
- #define AkExitThread( _result ) return _result;
-
- inline void AkGetDefaultThreadProperties( AkThreadProperties & out_threadProperties )
- {
- out_threadProperties.nPriority = AK_THREAD_PRIORITY_NORMAL;
- out_threadProperties.uStackSize= AK_DEFAULT_STACK_SIZE;
- #ifdef AK_WIN_UNIVERSAL_APP
- out_threadProperties.processorNumber.Group = 0;
- out_threadProperties.processorNumber.Number = MAXIMUM_PROCESSORS;
- out_threadProperties.processorNumber.Reserved = 0;
- #else
- out_threadProperties.dwAffinityMask = 0;
- #endif
- }
-
- inline void AkSetThreadName( AkThread in_threadHnd, DWORD in_dwThreadID, LPCSTR in_szThreadName )
- {
- const DWORD MS_VC_EXCEPTION=0x406D1388;
- #pragma pack(push,8)
- typedef struct tagTHREADNAME_INFO
- {
- DWORD dwType;
- LPCSTR szName;
- DWORD dwThreadID;
- DWORD dwFlags;
- } THREADNAME_INFO;
- #pragma pack(pop)
- THREADNAME_INFO info;
- info.dwType = 0x1000;
- info.szName = in_szThreadName;
- info.dwThreadID = in_dwThreadID;
- info.dwFlags = 0;
- __try
- {
- RaiseException( MS_VC_EXCEPTION, 0, sizeof(info)/sizeof(ULONG_PTR), (ULONG_PTR*)&info );
- }
- #pragma warning(suppress: 6312 6322)
- __except(EXCEPTION_CONTINUE_EXECUTION)
- {
- }
- #if defined(AK_XBOX) || defined(_GAMING_DESKTOP)
- wchar_t wszThreadName[32];
- AkUInt32 maxStrLen = (sizeof(wszThreadName) / sizeof(wchar_t)) - 1;
- AkUInt32 nameStrLen = AkMin((int)strlen(in_szThreadName), maxStrLen);
- MultiByteToWideChar(CP_UTF8, 0, in_szThreadName, nameStrLen, wszThreadName, maxStrLen);
- wszThreadName[nameStrLen] = '\0';
- SetThreadDescription(in_threadHnd, wszThreadName);
- #endif
- }
-
- inline void AkCreateThread(
- AkThreadRoutine pStartRoutine,
- void * pParams,
- const AkThreadProperties & in_threadProperties,
- AkThread * out_pThread,
- const char * in_szThreadName )
- {
- AKASSERT( out_pThread != NULL );
- AKASSERT( (in_threadProperties.nPriority >= THREAD_PRIORITY_LOWEST && in_threadProperties.nPriority <= THREAD_PRIORITY_HIGHEST)
- || ( in_threadProperties.nPriority == THREAD_PRIORITY_TIME_CRITICAL )
- || ( in_threadProperties.nPriority == THREAD_MODE_BACKGROUND_BEGIN ) );
- DWORD dwThreadID;
- *out_pThread = ::CreateThread( NULL,
- in_threadProperties.uStackSize,
- pStartRoutine,
- pParams,
- CREATE_SUSPENDED,
- &dwThreadID );
-
- if ( !*out_pThread )
- {
- AkClearThread( out_pThread );
- return;
- }
-
- if (in_szThreadName)
- {
- AkSetThreadName(*out_pThread, dwThreadID, in_szThreadName);
- }
-
- if ( !::SetThreadPriority( *out_pThread, in_threadProperties.nPriority ) &&
- in_threadProperties.nPriority != THREAD_MODE_BACKGROUND_BEGIN )
- {
- AKASSERT( !"Failed setting thread priority" );
- AkCloseThread( out_pThread );
- AkClearThread(out_pThread);
- return;
- }
- #ifdef AK_WIN_UNIVERSAL_APP
- if ( in_threadProperties.processorNumber.Number != MAXIMUM_PROCESSORS)
- {
- if ( !SetThreadIdealProcessorEx( *out_pThread, const_cast<PPROCESSOR_NUMBER>(&in_threadProperties.processorNumber), NULL) )
- {
- AKASSERT( !"Failed setting thread ideal processor" );
- AkCloseThread( out_pThread );
- AkClearThread(out_pThread);
- return;
- }
- }
- #else
- if (in_threadProperties.dwAffinityMask)
- {
- AkUInt32 dwAffinityMask = in_threadProperties.dwAffinityMask;
- DWORD_PTR procAffinity, sysAffinity;
- if (::GetProcessAffinityMask(::GetCurrentProcess(), &procAffinity, &sysAffinity))
- {
-
- dwAffinityMask &= procAffinity;
- }
- if (!::SetThreadAffinityMask(*out_pThread, dwAffinityMask))
- {
- AKASSERT(!"Failed setting thread affinity mask");
- AkCloseThread(out_pThread);
- AkClearThread(out_pThread);
- return;
- }
- }
- #endif
-
- if (!::ResumeThread(*out_pThread))
- {
- AKASSERT(!"Failed to start the thread");
- AkCloseThread(out_pThread);
- AkClearThread(out_pThread);
- return;
- }
- }
-
- inline void AkWaitForSingleThread( AkThread * in_pThread )
- {
- AKASSERT( in_pThread );
- AKASSERT( *in_pThread );
- ::WaitForSingleObject( *in_pThread, INFINITE );
- }
-
- inline AkThreadID CurrentThread()
- {
- return ::GetCurrentThreadId();
- }
-
- inline void AkSleep( AkUInt32 in_ulMilliseconds )
- {
- ::Sleep( in_ulMilliseconds );
- }
-
-
-
- inline void AkMemCpy( void * pDest, const void * pSrc, AkUInt32 uSize )
- {
- memcpy( pDest, pSrc, uSize );
- }
-
- inline void AkMemMove( void* pDest, const void* pSrc, AkUInt32 uSize )
- {
- memmove( pDest, pSrc, uSize );
- }
-
- inline void AkMemSet( void * pDest, AkInt32 iVal, AkUInt32 uSize )
- {
- memset( pDest, iVal, uSize );
- }
-
-
-
- inline void PerformanceCounter( AkInt64 * out_piLastTime )
- {
- ::QueryPerformanceCounter( (LARGE_INTEGER*)out_piLastTime );
- }
-
- inline void PerformanceFrequency( AkInt64 * out_piFreq )
- {
- ::QueryPerformanceFrequency( (LARGE_INTEGER*)out_piFreq );
- }
-
- inline void UpdatePerformanceFrequency()
- {
- AkInt64 iFreq;
- PerformanceFrequency( &iFreq );
- AK::g_fFreqRatio = (AkReal32)((AkReal64)iFreq / 1000);
- }
-
- inline AkReal32 Elapsed( const AkInt64 & in_iNow, const AkInt64 & in_iStart )
- {
- return ( in_iNow - in_iStart ) / AK::g_fFreqRatio;
- }
-
- inline AkInt32 AkWideCharToChar( const wchar_t* in_pszUnicodeString,
- AkUInt32 in_uiOutBufferSize,
- char* io_pszAnsiString )
- {
- if(!io_pszAnsiString)
- return WideCharToMultiByte(CP_UTF8, 0, in_pszUnicodeString, -1, NULL, 0, NULL, NULL);
- int iWritten = ::WideCharToMultiByte(CP_UTF8,
- 0,
- in_pszUnicodeString,
- (int)AkMin( ( (AkUInt32)wcslen( in_pszUnicodeString )), in_uiOutBufferSize-1 ),
- io_pszAnsiString,
- in_uiOutBufferSize,
- NULL,
- NULL);
- io_pszAnsiString[iWritten] = 0;
- return iWritten;
- }
-
- inline AkInt32 AkCharToWideChar( const char* in_pszAnsiString,
- AkUInt32 in_uiOutBufferSize,
- void* io_pvUnicodeStringBuffer )
- {
- return ::MultiByteToWideChar( CP_UTF8,
- 0,
- in_pszAnsiString,
- -1,
- (wchar_t*)io_pvUnicodeStringBuffer,
- in_uiOutBufferSize);
- }
-
- inline AkInt32 AkUtf8ToWideChar( const char* in_pszUtf8String,
- AkUInt32 in_uiOutBufferSize,
- void* io_pvUnicodeStringBuffer )
- {
- return ::MultiByteToWideChar( CP_UTF8,
- 0,
- in_pszUtf8String,
- -1,
- (wchar_t*)io_pvUnicodeStringBuffer,
- in_uiOutBufferSize);
- }
-
- inline void SafeStrCpy( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
- {
- size_t iSizeCopy = AkMin( in_uDestMaxNumChars - 1, wcslen( in_pSrc ) + 1 );
- wcsncpy_s( in_pDest, in_uDestMaxNumChars, in_pSrc, iSizeCopy );
- in_pDest[iSizeCopy] = '\0';
- }
-
- inline void SafeStrCpy( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
- {
- size_t iSizeCopy = AkMin( in_uDestMaxNumChars - 1, strlen( in_pSrc ) + 1 );
- strncpy_s( in_pDest, in_uDestMaxNumChars, in_pSrc, iSizeCopy );
- in_pDest[iSizeCopy] = '\0';
- }
-
- inline void SafeStrCat( wchar_t * in_pDest, const wchar_t* in_pSrc, size_t in_uDestMaxNumChars )
- {
- int iAvailableSize = (int)( in_uDestMaxNumChars - wcslen( in_pDest ) - 1 );
- wcsncat_s( in_pDest, in_uDestMaxNumChars, in_pSrc, AkMin( iAvailableSize, (int)wcslen( in_pSrc ) ) );
- }
-
- inline void SafeStrCat( char * in_pDest, const char* in_pSrc, size_t in_uDestMaxNumChars )
- {
- int iAvailableSize = (int)( in_uDestMaxNumChars - strlen( in_pDest ) - 1 );
- strncat_s( in_pDest, in_uDestMaxNumChars, in_pSrc, AkMin( iAvailableSize, (int)strlen( in_pSrc ) ) );
- }
- inline int SafeStrFormat(wchar_t * in_pDest, size_t in_uDestMaxNumChars, const wchar_t* in_pszFmt, ...)
- {
- va_list args;
- va_start(args, in_pszFmt);
- int r = vswprintf(in_pDest, in_uDestMaxNumChars, in_pszFmt, args);
- va_end(args);
- return r;
- }
- inline int SafeStrFormat(char * in_pDest, size_t in_uDestMaxNumChars, const char* in_pszFmt, ...)
- {
- va_list args;
- va_start(args, in_pszFmt);
- int r = vsnprintf(in_pDest, in_uDestMaxNumChars, in_pszFmt, args);
- va_end(args);
- return r;
- }
-
- #define AkAlloca( _size_ ) _alloca( _size_ )
-
- #if ! defined(AK_OPTIMIZED)
- inline void OutputDebugMsg( const wchar_t* in_pszMsg )
- {
- OutputDebugStringW( in_pszMsg );
- }
-
- inline void OutputDebugMsg( const char* in_pszMsg )
- {
- OutputDebugStringA( in_pszMsg );
- }
-
-
-
-
- template <int MaxSize = 256>
- inline void OutputDebugMsgV(const wchar_t* in_pszFmt, ...)
- {
-
-
-
- wchar_t* msg = (wchar_t*)AkAlloca(MaxSize * sizeof(wchar_t));
- msg[MaxSize - 1] = '\0';
- va_list args;
- va_start(args, in_pszFmt);
- vswprintf(msg, MaxSize, in_pszFmt, args);
- va_end(args);
- OutputDebugMsg(msg);
- }
-
-
-
-
- template <int MaxSize = 256>
- inline void OutputDebugMsgV(const char* in_pszFmt, ...)
- {
- int size = 0;
- {
-
- char msg[MaxSize];
- msg[MaxSize - 1] = '\0';
- va_list args;
- va_start(args, in_pszFmt);
- size = vsnprintf(msg, MaxSize, in_pszFmt, args);
- va_end(args);
-
- if (0 <= size && size <= MaxSize)
- {
- OutputDebugMsg(msg);
- return;
- }
- }
-
- {
-
- size++;
- char* msg = (char*)AkAlloca((size) * sizeof(char));
- msg[size - 1] = '\0';
- va_list args;
- va_start(args, in_pszFmt);
- vsnprintf(msg, size, in_pszFmt, args);
- va_end(args);
- OutputDebugMsg(msg);
- }
- }
- #else
- inline void OutputDebugMsg(const wchar_t*){}
- inline void OutputDebugMsg(const char*){}
- template <int MaxSize = 0>
- inline void OutputDebugMsgV(const wchar_t*, ...) {}
- template <int MaxSize = 0>
- inline void OutputDebugMsgV(const char*, ...) {}
- #endif
-
-
-
-
-
-
-
-
- #define CONVERT_WIDE_TO_OSCHAR( _wstring_, _oscharstring_ ) ( _oscharstring_ ) = (AkOSChar*)( _wstring_ )
-
-
-
-
-
-
-
-
- #define CONVERT_CHAR_TO_OSCHAR( _astring_, _oscharstring_ ) \
- _oscharstring_ = (AkOSChar*)AkAlloca( (1 + strlen( _astring_ )) * sizeof(AkOSChar)); \
- AKPLATFORM::AkCharToWideChar( _astring_, (AkUInt32)(1 + strlen(_astring_ )), (AkOSChar*)( _oscharstring_ ) )
-
-
-
-
-
-
-
-
- #define CONVERT_OSCHAR_TO_WIDE( _osstring_, _wstring_ ) _wstring_ = _osstring_
-
-
-
-
-
-
-
-
- #define CONVERT_OSCHAR_TO_CHAR( _osstring_, _astring_ ) \
- _astring_ = (char*)AkAlloca( 1 + AKPLATFORM::AkWideCharToChar( _osstring_, 0, NULL )); \
- AKPLATFORM::AkWideCharToChar( _osstring_, AkUInt32(1 + AKPLATFORM::AkWideCharToChar( _osstring_, 0, NULL )), _astring_ );
-
-
- inline size_t AkUtf16StrLen( const AkUtf16* in_pStr )
- {
- return ( wcslen( in_pStr ) );
- }
-
-
- inline size_t OsStrLen( const AkOSChar* in_pszString )
- {
- return ( wcslen( in_pszString ) );
- }
-
- #define AK_OSPRINTF swprintf_s
-
-
-
-
-
-
- inline int OsStrCmp( const AkOSChar* in_pszString1, const AkOSChar* in_pszString2 )
- {
- return ( wcscmp( in_pszString1, in_pszString2 ) );
- }
-
-
-
-
-
-
- inline int OsStrNCmp( const AkOSChar* in_pszString1, const AkOSChar* in_pszString2, size_t in_MaxCountSize)
- {
- return wcsncmp(in_pszString1, in_pszString2, in_MaxCountSize);
- }
-
- #define AK_UTF16_TO_WCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
- #define AK_WCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
- #define AK_UTF8_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
- #define AK_UTF16_TO_OSCHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
- #define AK_UTF16_TO_CHAR( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkWideCharToChar( in_pSrc, in_MaxSize, in_pdDest )
- #define AK_CHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::AkCharToWideChar( in_pSrc, in_MaxSize, in_pdDest )
- #define AK_OSCHAR_TO_UTF16( in_pdDest, in_pSrc, in_MaxSize ) AKPLATFORM::SafeStrCpy( in_pdDest, in_pSrc, in_MaxSize )
-
- inline bool IsAbsolutePath(const AkOSChar* in_pszPath, size_t in_pathLen)
- {
- return
- (in_pathLen >= 3 && in_pszPath[1] == ':' && in_pszPath[2] == '\\') ||
- (in_pathLen >= 2 && in_pszPath[0] == '\\');
- }
-
- #define AK_PATH_SEPARATOR L"\\"
- #define AK_LIBRARY_PREFIX L""
- #define AK_DYNAMIC_LIBRARY_EXTENSION L".dll"
- #define AK_FILEHANDLE_TO_UINTPTR(_h) ((AkUIntPtr)_h)
- #define AK_SET_FILEHANDLE_TO_UINTPTR(_h,_u) _h = (AkFileHandle)_u
- #if defined(AK_ENABLE_PERF_RECORDING)
-
- static AkUInt32 g_uAkPerfRecExecCount = 0;
- static AkReal32 g_fAkPerfRecExecTime = 0.f;
- #define AK_PERF_RECORDING_RESET() \
- AKPLATFORM::g_uAkPerfRecExecCount = 0;\
- AKPLATFORM::g_fAkPerfRecExecTime = 0.f;
- #define AK_PERF_RECORDING_START( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ ) \
- AkInt64 iAkPerfRecTimeBefore; \
- if ( (AKPLATFORM::g_uAkPerfRecExecCount >= (__uExecutionCountStart__)) && (AKPLATFORM::g_uAkPerfRecExecCount <= (__uExecutionCountStop__)) ) \
- AKPLATFORM::PerformanceCounter( &iAkPerfRecTimeBefore );
- #define AK_PERF_RECORDING_STOP( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ ) \
- if ( (AKPLATFORM::g_uAkPerfRecExecCount >= (__uExecutionCountStart__)) && (AKPLATFORM::g_uAkPerfRecExecCount <= (__uExecutionCountStop__)) ) \
- { \
- AkInt64 iAkPerfRecTimeAfter; \
- AKPLATFORM::PerformanceCounter( &iAkPerfRecTimeAfter ); \
- AKPLATFORM::g_fAkPerfRecExecTime += AKPLATFORM::Elapsed( iAkPerfRecTimeAfter, iAkPerfRecTimeBefore ); \
- if ( AKPLATFORM::g_uAkPerfRecExecCount == (__uExecutionCountStop__) ) \
- { \
- AkReal32 fAverageExecutionTime = AKPLATFORM::g_fAkPerfRecExecTime/((__uExecutionCountStop__)-(__uExecutionCountStart__)); \
- AkOSChar str[256]; \
- swprintf_s(str, 256, AKTEXT("%s average execution time: %f\n"), AKTEXT(__StorageName__), fAverageExecutionTime);\
- AKPLATFORM::OutputDebugMsg( str ); \
- } \
- } \
- AKPLATFORM::g_uAkPerfRecExecCount++;
- #endif
- #if (defined(AK_CPU_X86_64) || defined(AK_CPU_X86))
-
-
-
- inline void CPUID(AkUInt32 in_uLeafOpcode, AkUInt32 in_uSubLeafOpcode, unsigned int out_uCPUFeatures[4])
- {
- __cpuidex((int*)out_uCPUFeatures, in_uLeafOpcode, in_uSubLeafOpcode);
- }
- #endif
- }
- #endif
|