Table of Contents

Wwise SDK 2019.2.2
AkPlatformFuncs.h
1 /*******************************************************************************
2 The content of this file includes portions of the AUDIOKINETIC Wwise Technology
3 released in source code form as part of the SDK installer package.
4 
5 Commercial License Usage
6 
7 Licensees holding valid commercial licenses to the AUDIOKINETIC Wwise Technology
8 may use this file in accordance with the end user license agreement provided
9 with the software or, alternatively, in accordance with the terms contained in a
10 written agreement between you and Audiokinetic Inc.
11 
12 Apache License Usage
13 
14 Alternatively, this file may be used under the Apache License, Version 2.0 (the
15 "Apache License"); you may not use this file except in compliance with the
16 Apache License. You may obtain a copy of the Apache License at
17 http://www.apache.org/licenses/LICENSE-2.0.
18 
19 Unless required by applicable law or agreed to in writing, software distributed
20 under the Apache License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES
21 OR CONDITIONS OF ANY KIND, either express or implied. See the Apache License for
22 the specific language governing permissions and limitations under the License.
23 
24  Version: <VERSION> Build: <BUILDNUMBER>
25  Copyright (c) <COPYRIGHTYEAR> Audiokinetic Inc.
26 *******************************************************************************/
27 
28 // AkPlatformFuncs.h
29 
30 /// \file
31 /// Platform-dependent functions definition.
32 
33 #ifndef _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H
34 #define _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H
35 
36 #include <AK/SoundEngine/Common/AkTypes.h>
37 #include <AK/SoundEngine/Common/AkAtomic.h>
38 
39 // Uncomment the following to enable built-in platform profiler markers in the sound engine
40 //#define AK_ENABLE_INSTRUMENT
41 
42 #if defined(AK_WIN)
43 #include <AK/Tools/Win32/AkPlatformFuncs.h>
44 
45 #elif defined (AK_XBOX)
46 #include <AK/Tools/XboxOne/AkPlatformFuncs.h>
47 
48 #elif defined (AK_APPLE)
49 #include <AK/Tools/Mac/AkPlatformFuncs.h>
50 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
51 
52 #elif defined (AK_ANDROID)
53 #include <AK/Tools/Android/AkPlatformFuncs.h>
54 
55 #elif defined (AK_PS4)
56 #include <AK/Tools/PS4/AkPlatformFuncs.h>
57 
58 #elif defined (AK_PELLEGRINO)
59 #include <AK/Tools/Pellegrino/AkPlatformFuncs.h>
60 
61 #elif defined (AK_EMSCRIPTEN)
62 #include <AK/Tools/Emscripten/AkPlatformFuncs.h>
63 
64 #elif defined (AK_LINUX)
65 
66 #ifdef AK_GGP
67 #include <AK/Tools/GGP/AkPlatformFuncs.h>
68 #endif
69 #include <AK/Tools/Linux/AkPlatformFuncs.h>
70 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
71 
72 #elif defined (AK_QNX)
73 #include <AK/Tools/QNX/AkPlatformFuncs.h>
74 #include <AK/Tools/POSIX/AkPlatformFuncs.h>
75 
76 #elif defined (AK_NX)
77 #include <AK/Tools/NX/AkPlatformFuncs.h>
78 
79 #else
80 #error AkPlatformFuncs.h: Undefined platform
81 #endif
82 
83 #ifndef AkPrefetchZero
84 #define AkPrefetchZero(___Dest, ___Size)
85 #endif
86 
87 #ifndef AkPrefetchZeroAligned
88 #define AkPrefetchZeroAligned(___Dest, ___Size)
89 #endif
90 
91 #ifndef AkZeroMemAligned
92 #define AkZeroMemAligned(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
93 #endif
94 #ifndef AkZeroMemLarge
95 #define AkZeroMemLarge(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
96 #endif
97 #ifndef AkZeroMemSmall
98 #define AkZeroMemSmall(___Dest, ___Size) AKPLATFORM::AkMemSet(___Dest, 0, ___Size);
99 #endif
100 
101 #ifndef AkAllocaSIMD
102 #ifdef __clang__
103 #if __has_builtin( __builtin_alloca_with_align )
104 #define AkAllocaSIMD( _size_ ) __builtin_alloca_with_align( _size_, 128 )
105 #else
106 // work around alloca alignment issues in versions of clang before 4.0
107 #define AkAllocaSIMD( _size_ ) (void*)( ( ( uintptr_t )AkAlloca( _size_ + 16 ) + 0xF ) & ~0xF )
108 #endif
109 #else
110 #define AkAllocaSIMD( _size_ ) AkAlloca( _size_ )
111 #endif
112 #endif
113 
114 #ifndef AK_THREAD_INIT_CODE
115 #define AK_THREAD_INIT_CODE(_threadProperties)
116 #endif
117 
118 /// Utility functions
119 namespace AK
120 {
121  /// Count non-zero bits.
122  /// \return Number of channels.
123  AkForceInline AkUInt32 GetNumNonZeroBits( AkUInt32 in_uWord )
124  {
125  AkUInt32 num = 0;
126  while( in_uWord ){ ++num; in_uWord &= in_uWord-1; }
127  return num;
128  }
129 }
130 
131 namespace AKPLATFORM
132 {
134  {
135  AkGetDefaultThreadProperties(out_threadProperties);
136  out_threadProperties.nPriority = AK_THREAD_PRIORITY_ABOVE_NORMAL;
137  }
138 }
139 
140 #ifndef AK_PERF_RECORDING_RESET
141 #define AK_PERF_RECORDING_RESET()
142 #endif
143 #ifndef AK_PERF_RECORDING_START
144 #define AK_PERF_RECORDING_START( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ )
145 #endif
146 #ifndef AK_PERF_RECORDING_STOP
147 #define AK_PERF_RECORDING_STOP( __StorageName__, __uExecutionCountStart__, __uExecutionCountStop__ )
148 #endif
149 
150 #ifndef AK_INSTRUMENT_BEGIN
151  #define AK_INSTRUMENT_BEGIN( _zone_name_ )
152  #define AK_INSTRUMENT_END( _zone_name_ )
153  #define AK_INSTRUMENT_SCOPE( _zone_name_ )
154 
155  #define AK_INSTRUMENT_BEGIN_C(_colour_, _zone_name_ )
156 
157  #define AK_INSTRUMENT_IDLE_BEGIN( _zone_name_ )
158  #define AK_INSTRUMENT_IDLE_END( _zone_name_ )
159  #define AK_INSTRUMENT_IDLE_SCOPE( _zone_name_ )
160 
161  #define AK_INSTRUMENT_STALL_BEGIN( _zone_name_ )
162  #define AK_INSTRUMENT_STALL_END( _zone_name_ )
163  #define AK_INSTRUMENT_STALL_SCOPE( _zone_name_ )
164 
165  #define AK_INSTRUMENT_THREAD_START( _thread_name_ )
166 #endif
167 
168 #endif // _AK_TOOLS_COMMON_AKPLATFORMFUNCS_H
Audiokinetic namespace.
int nPriority
Thread priority.
Definition: AkPlatformFuncs.h:74
AkForceInline void AkGetDefaultThreadProperties(AkThreadProperties &out_threadProperties)
Platform Independent Helper.
Definition: AkPlatformFuncs.h:240
void AkGetDefaultHighPriorityThreadProperties(AkThreadProperties &out_threadProperties)
Definition: AkPlatformFuncs.h:133
AkForceInline AkUInt32 GetNumNonZeroBits(AkUInt32 in_uWord)
Definition: AkPlatformFuncs.h:123