Merge branch 'main' into ly-as-sdk/LYN-2948
commit
debbfc38d8
@ -1,402 +0,0 @@
|
||||
<!--
|
||||
= Platform names =
|
||||
(case insensitive)
|
||||
"ANDROID"
|
||||
"PROVO"
|
||||
"PC"
|
||||
"LINUX"
|
||||
"MAC"
|
||||
|
||||
= Basic Layout =
|
||||
<ThreadConfig>
|
||||
<Platform name="XXX">
|
||||
<ThreadDefault Affinity="XX" Priority="XX" StackSizeKB="XX">
|
||||
<Thread name ="A" Affinity="XX" Priority="XX" StackSizeKB="XX">
|
||||
<Thread name ="B" Affinity="XX" >
|
||||
...
|
||||
</Platform>
|
||||
|
||||
<Platform name="YYY">
|
||||
...
|
||||
</Platform>
|
||||
</ThreadConfig>
|
||||
|
||||
= Parser Order for Platform =
|
||||
1. PlatformName_Common (valid for all potential platform configurations. Can be overridden by concert platform configuration)
|
||||
2. PlatformName or PlatformName_X (for platforms with unknown CPU count where X is the number of potential cores. The equal or next lower matching configuration for the identified core count at runtime will be taken)
|
||||
|
||||
Note: Overriding of thread configuration by later parsed configuration allowed.
|
||||
|
||||
= <ThreadDefault> and <Thread> XML attributes =
|
||||
|
||||
!!!
|
||||
Note: Use "ignore" as value if you do not want the thread system to set the value specifically!
|
||||
If a value is not defines the <ThreadDefault> value of the parameter will be used.
|
||||
This is useful when dealing with 3rdParty threads where you are not in control of the parameter setup.
|
||||
!!!
|
||||
|
||||
Name:
|
||||
"x" (string) : Name of thread
|
||||
"x*y" (string) : Name of thread with wildcard character
|
||||
|
||||
Affinity:
|
||||
"-1" : Put SW thread affinity in the hands of the scheduler - (default) -
|
||||
"x" : Run thread on specified core
|
||||
"x, y, ..." : Run thread on specified cores
|
||||
|
||||
Priority:
|
||||
"idle" : Hint to CryEngine to run thread with pre-set priority
|
||||
"below_normal" : Hint to CryEngine to run thread with pre-set priority
|
||||
"normal" : Hint to CryEngine to run thread with pre-set priority - (default) -
|
||||
"above_normal" : Hint to CryEngine to run thread with pre-set priority
|
||||
"highest" : Hint to CryEngine to run thread with pre-set priority
|
||||
"time_critical" : Hint to CryEngine to run thread with pre-set priority
|
||||
|
||||
"x" (number) : User defined thread priority number
|
||||
|
||||
StackSizeKB:
|
||||
"0" : Let platform decide on the stack size - (default) -
|
||||
"x" : Create thread with "x" KB of stack size
|
||||
|
||||
DisablePriorityBoost:
|
||||
"true" : Disable priority boosting - (default) -
|
||||
"false" : Enable priority boosting
|
||||
-->
|
||||
|
||||
|
||||
<ThreadConfig>
|
||||
<!-- ============= -->
|
||||
<!-- === PROVO === -->
|
||||
<!-- ============= -->
|
||||
<Platform name="Provo">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="64"/>
|
||||
|
||||
<!-- [PROCESS] -->
|
||||
<Thread name ="Main" Affinity="0" Priority="Above_Normal"/>
|
||||
|
||||
<!-- [RenderDLL] -->
|
||||
<Thread name ="RenderThread" Affinity="2" Priority="Highest" StackSizeKB="128"/>
|
||||
<Thread name ="RenderLoadingThread" Affinity="1" Priority="Above_Normal" StackSizeKB="72"/>
|
||||
<Thread name ="ShaderCompile"/>
|
||||
|
||||
<!-- [SYSTEM] -->
|
||||
<Thread name ="GFxMeshCacheReset"/>
|
||||
<Thread name ="MTrace NetPump" Priority="25"/>
|
||||
<Thread name ="NotificationNetwork"/>
|
||||
<Thread name ="ReplayRecord"/>
|
||||
<Thread name ="ResourceActivator"/>
|
||||
<Thread name ="StatoscopeDataWriter"/>
|
||||
<Thread name ="RemoteCommandClient"/>
|
||||
<Thread name ="RemoteCommandServer"/>
|
||||
<Thread name ="ServiceNetwork"/>
|
||||
<Thread name ="SysCrashTestOnThread"/>
|
||||
|
||||
<!-- [SYSTEM] - JobSystem -->
|
||||
<Thread name ="JobSystem_Worker_0(Blocking)" Affinity="1"/>
|
||||
|
||||
<Thread name ="JobSystem_Worker_0(Regular)" Affinity="1" StackSizeKB="256"/>
|
||||
<Thread name ="JobSystem_Worker_1(Regular)" Affinity="3" StackSizeKB="256"/>
|
||||
<Thread name ="JobSystem_Worker_2(Regular)" Affinity="4" StackSizeKB="256"/>
|
||||
<Thread name ="JobSystem_Worker_3(Regular)" Affinity="5" StackSizeKB="256"/>
|
||||
|
||||
<!-- [SYSTEM] - Physics -->
|
||||
<Thread name ="Physics" StackSizeKB="128"/>
|
||||
<Thread name ="PhysicsWorkerThread_*" StackSizeKB="128"/>
|
||||
|
||||
<!-- [SYSTEM] - Streaming -->
|
||||
<Thread name ="Streaming File IO HDD" Priority="Above_Normal" Affinity="1"/>
|
||||
<Thread name ="Streaming File IO Optical" Priority="Above_Normal" Affinity="1"/>
|
||||
<Thread name ="Streaming File IO InMemory" Priority="Above_Normal" Affinity="1"/>
|
||||
|
||||
<Thread name ="Streaming AsyncCallback" Affinity="5"/>
|
||||
<Thread name ="Streaming AsyncCallback Pak 0" Affinity="5"/>
|
||||
|
||||
<!-- [SYSTEM] - Console -->
|
||||
<Thread name ="RemoteConsoleServer"/>
|
||||
<Thread name ="RemoteConsoleClient"/>
|
||||
|
||||
<!-- [NETWORK] -->
|
||||
<Thread name ="Network"/>
|
||||
<Thread name ="ServerProbe"/>
|
||||
<Thread name ="NetworkDebugKit"/>
|
||||
<Thread name ="NetFileDownload"/>
|
||||
<Thread name ="NetworkWatchdog"/>
|
||||
<Thread name ="NetAddressSolver"/>
|
||||
|
||||
<!-- [AI] -->
|
||||
<Thread name ="NavigationSystemBackgroundUpdate"/>
|
||||
|
||||
<!-- [AUDIO] -->
|
||||
<Thread name ="MainAudioThread" Affinity="1,3,4,5" Priority="below_normal" StackSize="ignore"/>
|
||||
|
||||
<Thread name ="Wwise_Device" Affinity="5" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_BankManager" Affinity="5" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_LEngine" Affinity="5" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_Monitor" Affinity="5" Priority="ignore" StackSize="ignore"/>
|
||||
|
||||
<!-- [ACTION] -->
|
||||
<Thread name ="NetworkStallTicker"/>
|
||||
<Thread name ="ZLibCompressor" Priority="Normal"/>
|
||||
|
||||
<!-- [INPUT] -->
|
||||
<Thread name ="InputWorker"/>
|
||||
<Thread name ="Synergy"/>
|
||||
|
||||
<!-- [LIVE_CREATE]-->
|
||||
<Thread name ="LiveCreate_Server"/>
|
||||
<Thread name ="LiveCreate_FileSync"/>
|
||||
<Thread name ="LiveCreatePlatformService"/>
|
||||
<Thread name ="LiveCreateUtilityService"/>
|
||||
|
||||
<!-- [SCALEFORM][3rd Party] -->
|
||||
<Thread name ="GFxVideo_SoundUpdate" Affinity="5" Priority="time_critical" DisablePriorityBoost="ignore" StackSizeKB="ignore"/>
|
||||
<Thread name ="GFxVideo_Decoder" Affinity="4" Priority="highest" DisablePriorityBoost="ignore" StackSizeKB="ignore"/>
|
||||
<Thread name ="GFxVideo_Reader" Affinity="5" Priority="highest" DisablePriorityBoost="ignore" StackSizeKB="ignore"/>
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === PC_Common === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="PC_Common">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="32"/>
|
||||
|
||||
<!-- [PROCESS] -->
|
||||
<Thread name ="Main" Affinity="-1" Priority="Normal"/>
|
||||
|
||||
<!-- [SYSTEM] - JobSystem -->
|
||||
<Thread name ="JobSystem_Worker_*(Blocking)" StackSizeKB="32"/>
|
||||
<Thread name ="JobSystem_Worker_*(Regular)" StackSizeKB="256"/>
|
||||
|
||||
<!-- [SYSTEM] - Physics -->
|
||||
<Thread name ="Physics" StackSizeKB="128"/>
|
||||
<Thread name ="PhysicsWorkerThread_*" StackSizeKB="128"/>
|
||||
|
||||
<!-- [RenderDLL] -->
|
||||
<Thread name ="RenderThread" StackSizeKB="128"/>
|
||||
<Thread name ="RenderLoadingThread" Priority="Above_Normal" StackSizeKB="72"/>
|
||||
<Thread name ="ShaderCompile"/>
|
||||
|
||||
<!-- [SYSTEM] -->
|
||||
<Thread name ="GFxMeshCacheReset"/>
|
||||
<Thread name ="MTrace NetPump" Priority="25" StackSizeKB="64"/>
|
||||
<Thread name ="NotificationNetwork"/>
|
||||
<Thread name ="ReplayRecord"/>
|
||||
<Thread name ="ResourceActivator"/>
|
||||
<Thread name ="StatoscopeDataWriter"/>
|
||||
<Thread name ="RemoteCommandClient"/>
|
||||
<Thread name ="RemoteCommandServer"/>
|
||||
<Thread name ="ServiceNetwork"/>
|
||||
<Thread name ="SysCrashTestOnThread"/>
|
||||
|
||||
<!-- [SYSTEM] - Streaming -->
|
||||
<Thread name ="Streaming File IO HDD" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO Optical" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO InMemory" Priority="Above_Normal"/>
|
||||
|
||||
<Thread name ="Streaming AsyncCallback"/>
|
||||
<Thread name ="Streaming AsyncCallback Pak 0"/>
|
||||
|
||||
<!-- [SYSTEM] - Console -->
|
||||
<Thread name ="RemoteConsoleServer"/>
|
||||
<Thread name ="RemoteConsoleClient"/>
|
||||
<Thread name ="WindowsConsoleInput"/>
|
||||
<Thread name ="UNIXConsoleInput"/>
|
||||
|
||||
<!-- [NETWORK] -->
|
||||
<Thread name ="Network"/>
|
||||
<Thread name ="ServerProbe"/>
|
||||
<Thread name ="NetworkDebugKit"/>
|
||||
<Thread name ="NetFileDownload"/>
|
||||
<Thread name ="NetworkWatchdog" StackSizeKB="8"/>
|
||||
<Thread name ="NetAddressSolver" StackSizeKB="16"/>
|
||||
|
||||
<!-- [AUDIO] -->
|
||||
<Thread name ="MainAudioThread" Affinity="ignore" Priority="below_normal" StackSize="ignore"/>
|
||||
|
||||
<Thread name ="Wwise_Device" Affinity="ignore" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_BankManager" Affinity="ignore" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_LEngine" Affinity="ignore" Priority="ignore" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_Monitor" Affinity="ignore" Priority="ignore" StackSize="ignore"/>
|
||||
|
||||
<!-- [AI] -->
|
||||
<Thread name ="NavigationSystemBackgroundUpdate"/>
|
||||
|
||||
<!-- [ACTION] -->
|
||||
<Thread name ="NetworkStallTicker"/>
|
||||
<Thread name ="ZLibCompressor" Priority="Normal" StackSizeKB="32"/>
|
||||
|
||||
<!-- [INPUT] -->
|
||||
<Thread name ="InputWorker"/>
|
||||
<Thread name ="Synergy"/>
|
||||
|
||||
<!-- [LIVE_CREATE]-->
|
||||
<Thread name ="LiveCreate_Server"/>
|
||||
<Thread name ="LiveCreate_FileSync"/>
|
||||
<Thread name ="LiveCreatePlatformService"/>
|
||||
<Thread name ="LiveCreateUtilityService"/>
|
||||
|
||||
<!-- [SCALEFORM][3rd Party] -->
|
||||
<Thread name ="GFxVideo_SoundUpdate" Affinity="ignore" Priority="highest" DisablePriorityBoost="ignore" StackSizeKB="16"/>
|
||||
|
||||
<!-- Special case, to add additional decoder threads add a threads with an increase incremental number. "GFxVideo_Decoder_0" sets thread priority for all other decoder threads-->
|
||||
<Thread name ="GFxVideo_Decoder_0" Affinity="ignore" Priority="normal" DisablePriorityBoost="ignore" StackSizeKB="ignore"/>
|
||||
<Thread name ="GFxVideo_Decoder_1" Affinity="ignore" Priority="normal" DisablePriorityBoost="ignore" StackSizeKB="ignore"/>
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === PC_8 === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="PC_8">
|
||||
<!-- Empty Example - Extend for 8 core specific machines. May override Common settings -->
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === MAC_Common === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="MAC_Common">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="32"/>
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === LINUX_Common === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="LINUX_Common">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="64"/>
|
||||
|
||||
<!-- [PROCESS] -->
|
||||
<Thread name ="Main" Affinity="-1" Priority="Above_Normal"/>
|
||||
|
||||
<!-- [SYSTEM] - JobSystem -->
|
||||
<Thread name ="JobSystem_Worker_*(Blocking)" StackSizeKB="32"/>
|
||||
<Thread name ="JobSystem_Worker_*(Regular)" StackSizeKB="256"/>
|
||||
|
||||
<!-- [SYSTEM] - Physics -->
|
||||
<Thread name ="Physics" StackSizeKB="128"/>
|
||||
<Thread name ="PhysicsWorkerThread_*" StackSizeKB="128"/>
|
||||
|
||||
<!-- [RenderDLL] -->
|
||||
<Thread name ="RenderThread" Priority="Above_Normal" StackSizeKB="128"/>
|
||||
<Thread name ="RenderLoadingThread" Priority="Above_Normal" StackSizeKB="72"/>
|
||||
<Thread name ="ShaderCompile"/>
|
||||
|
||||
<!-- [SYSTEM] -->
|
||||
<Thread name ="GFxMeshCacheReset"/>
|
||||
<Thread name ="MTrace NetPump" Priority="25" StackSizeKB="64"/>
|
||||
<Thread name ="NotificationNetwork"/>
|
||||
<Thread name ="ReplayRecord"/>
|
||||
<Thread name ="ResourceActivator"/>
|
||||
<Thread name ="StatoscopeDataWriter"/>
|
||||
<Thread name ="RemoteCommandClient"/>
|
||||
<Thread name ="RemoteCommandServer"/>
|
||||
<Thread name ="ServiceNetwork"/>
|
||||
<Thread name ="SysCrashTestOnThread"/>
|
||||
|
||||
<!-- [SYSTEM] - Streaming -->
|
||||
<Thread name ="Streaming File IO HDD" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO Optical" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO InMemory" Priority="Above_Normal"/>
|
||||
|
||||
<Thread name ="Streaming AsyncCallback"/>
|
||||
<Thread name ="Streaming AsyncCallback Pak 0"/>
|
||||
|
||||
<!-- [SYSTEM] - Console -->
|
||||
<Thread name ="RemoteConsoleServer"/>
|
||||
<Thread name ="RemoteConsoleClient"/>
|
||||
<Thread name ="UNIXConsoleInput"/>
|
||||
|
||||
<!-- [NETWORK] -->
|
||||
<Thread name ="Network"/>
|
||||
<Thread name ="ServerProbe"/>
|
||||
<Thread name ="NetworkDebugKit"/>
|
||||
<Thread name ="NetFileDownload"/>
|
||||
<Thread name ="NetworkWatchdog" StackSizeKB="8"/>
|
||||
<Thread name ="NetAddressSolver"/>
|
||||
|
||||
<!-- [AUDIO] -->
|
||||
<Thread name ="MainAudioThread" Affinity="ignore" Priority="below_normal" StackSize="ignore"/>
|
||||
|
||||
<Thread name ="Wwise_Device" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_BankManager" Affinity="ignore" Priority="50" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_LEngine" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_Monitor" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
|
||||
<!-- [AI] -->
|
||||
<Thread name ="NavigationSystemBackgroundUpdate"/>
|
||||
|
||||
<!-- [ACTION] -->
|
||||
<Thread name ="NetworkStallTicker"/>
|
||||
<Thread name ="ZLibCompressor" Priority="Normal" StackSizeKB="32"/>
|
||||
|
||||
<!-- [INPUT] -->
|
||||
<Thread name ="InputWorker"/>
|
||||
<Thread name ="Synergy"/>
|
||||
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === ANDROID_Common === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="ANDROID_Common">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="32"/>
|
||||
|
||||
<!-- [PROCESS] -->
|
||||
<Thread name ="Main" Priority="Above_Normal"/>
|
||||
|
||||
<!-- [SYSTEM] - JobSystem -->
|
||||
<Thread name ="JobSystem_Worker_*(Blocking)" StackSizeKB="32"/>
|
||||
<Thread name ="JobSystem_Worker_*(Regular)" StackSizeKB="256"/>
|
||||
|
||||
<!-- [SYSTEM] - Physics -->
|
||||
<Thread name ="Physics" StackSizeKB="128"/>
|
||||
<Thread name ="PhysicsWorkerThread_*" StackSizeKB="128"/>
|
||||
|
||||
<!-- [RenderDLL] -->
|
||||
<Thread name ="RenderThread" Affinity="ignore" Priority="Above_Normal" StackSizeKB="128"/>
|
||||
<Thread name ="RenderLoadingThread" Affinity="ignore" Priority="Above_Normal" StackSizeKB="72"/>
|
||||
<Thread name ="ShaderCompile"/>
|
||||
|
||||
<!-- [SYSTEM] -->
|
||||
<Thread name ="GFxMeshCacheReset"/>
|
||||
<Thread name ="MTrace NetPump" Priority="25" StackSizeKB="64"/>
|
||||
<Thread name ="NotificationNetwork"/>
|
||||
<Thread name ="ReplayRecord"/>
|
||||
<Thread name ="ResourceActivator"/>
|
||||
<Thread name ="StatoscopeDataWriter"/>
|
||||
<Thread name ="RemoteCommandClient"/>
|
||||
<Thread name ="RemoteCommandServer"/>
|
||||
<Thread name ="ServiceNetwork"/>
|
||||
<Thread name ="SysCrashTestOnThread"/>
|
||||
|
||||
<!-- [AUDIO] -->
|
||||
<Thread name ="MainAudioThread" Affinity="ignore" Priority="below_normal" StackSize="ignore"/>
|
||||
|
||||
<Thread name ="Wwise_Device" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_BankManager" Affinity="ignore" Priority="50" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_LEngine" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
<Thread name ="Wwise_Monitor" Affinity="ignore" Priority="99" StackSize="ignore"/>
|
||||
|
||||
<!-- [SYSTEM] - Streaming -->
|
||||
<Thread name ="Streaming File IO HDD" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO Optical" Priority="Above_Normal"/>
|
||||
<Thread name ="Streaming File IO InMemory" Priority="Above_Normal"/>
|
||||
|
||||
<Thread name ="Streaming AsyncCallback"/>
|
||||
<Thread name ="Streaming AsyncCallback Pak 0"/>
|
||||
|
||||
<!-- [SYSTEM] - Console -->
|
||||
<Thread name ="RemoteConsoleServer"/>
|
||||
|
||||
<!-- [NETWORK] -->
|
||||
<Thread name ="Network"/>
|
||||
<Thread name ="ServerProbe"/>
|
||||
<Thread name ="NetworkDebugKit"/>
|
||||
<Thread name ="NetFileDownload"/>
|
||||
<Thread name ="NetworkWatchdog" StackSizeKB="8"/>
|
||||
<Thread name ="NetAddressSolver" StackSizeKB="16"/>
|
||||
|
||||
<!-- [ACTION] -->
|
||||
<Thread name ="NetworkStallTicker"/>
|
||||
<Thread name ="ZLibCompressor" Affinity="ignore" Priority="Above_Normal" StackSizeKB="32"/>
|
||||
</Platform>
|
||||
|
||||
</ThreadConfig>
|
||||
@ -1,128 +0,0 @@
|
||||
<!--
|
||||
= Platform names =
|
||||
(case insensitive)
|
||||
"ANDROID"
|
||||
"PROVO"
|
||||
"PC"
|
||||
"MAC"
|
||||
|
||||
= Basic Layout =
|
||||
<ThreadConfig>
|
||||
<Platform name="XXX">
|
||||
<ThreadDefault Affinity="XX" Priority="XX" StackSizeKB="XX">
|
||||
<Thread name ="A" Affinity="XX" Priority="XX" StackSizeKB="XX">
|
||||
<Thread name ="B" Affinity="XX" >
|
||||
...
|
||||
</Platform>
|
||||
|
||||
<Platform name="YYY">
|
||||
...
|
||||
</Platform>
|
||||
</ThreadConfig>
|
||||
|
||||
= Parser Order for Platform =
|
||||
1. PlatformName_Common (valid for all potential platform configurations. Can be overridden by concert platform configuration)
|
||||
2. PlatformName or PlatformName_X (for platforms with unknown CPU count where X is the number of potential cores. The equal or next lower matching configuration for the identified core count at runtime will be taken)
|
||||
|
||||
Note: Overriding of thread configuration by later parsed configuration allowed.
|
||||
|
||||
= <ThreadDefault> and <Thread> XML attributes =
|
||||
|
||||
!!!
|
||||
Note: Use "ignore" as value if you do not want the thread system to set the value specifically!
|
||||
If a value is not defines the <ThreadDefault> value of the parameter will be used.
|
||||
This is useful when dealing with 3rdParty threads where you are not in control of the parameter setup.
|
||||
!!!
|
||||
|
||||
Name:
|
||||
"x" (string) : Name of thread
|
||||
"x*y" (string) : Name of thread with wildcard character
|
||||
|
||||
Affinity:
|
||||
"-1" : Put SW thread affinity in the hands of the scheduler - (default) -
|
||||
"x" : Run thread on specified core
|
||||
"x, y, ..." : Run thread on specified cores
|
||||
|
||||
Priority:
|
||||
"idle" : Hint to CryEngine to run thread with pre-set priority
|
||||
"below_normal" : Hint to CryEngine to run thread with pre-set priority
|
||||
"normal" : Hint to CryEngine to run thread with pre-set priority - (default) -
|
||||
"above_normal" : Hint to CryEngine to run thread with pre-set priority
|
||||
"highest" : Hint to CryEngine to run thread with pre-set priority
|
||||
"time_critical" : Hint to CryEngine to run thread with pre-set priority
|
||||
|
||||
"x" (number) : User defined thread priority number
|
||||
|
||||
StackSizeKB:
|
||||
"0" : Let platform decide on the stack size - (default) -
|
||||
"x" : Create thread with "x" KB of stack size
|
||||
|
||||
DisablePriorityBoost:
|
||||
"true" : Disable priority boosting - (default) -
|
||||
"false" : Enable priority boosting
|
||||
-->
|
||||
|
||||
|
||||
<ThreadConfig>
|
||||
<!-- ============ -->
|
||||
<!-- === PC_Common === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="PC_Common">
|
||||
<ThreadDefault Affinity="-1" Priority="Normal" StackSizeKB="32"/>
|
||||
|
||||
<!-- [SANDBOX] -->
|
||||
<Thread name ="TextureViewer"/>
|
||||
<Thread name ="TextureDatabaseCreator"/>
|
||||
|
||||
<Thread name ="MaterialFilesScanning"/>
|
||||
<Thread name ="FileChangeMonitor"/>
|
||||
|
||||
<Thread name ="FileSystemSearcher"/>
|
||||
<Thread name ="BackgroundTask_IO"/>
|
||||
<Thread name ="BackgroundTask_*"/>
|
||||
|
||||
<!-- [SANDBOX] - Dialogues -->
|
||||
<Thread name ="ResourceCompilerDialog"/>
|
||||
|
||||
<!-- [SANDBOX] - Telemetry -->
|
||||
<Thread name ="TelemetryPipeThread"/>
|
||||
|
||||
<!-- [SANDBOX] - Asset Browser -->
|
||||
<Thread name ="AssetMetaDataFileDB_CachingInfo"/>
|
||||
<Thread name ="AssetMetaDataFileDB_LoadAndUpdate"/>
|
||||
|
||||
<!-- [SANDBOX] - Console -->
|
||||
<Thread name ="ConsoleHotUpdate"/>
|
||||
<Thread name ="Console Synchronization"/>
|
||||
|
||||
<!-- [SANDBOX] - LiveCreate -->
|
||||
<Thread name ="LiveCreate_PeerComm"/>
|
||||
<Thread name ="LiveCreate_SyncFiles"/>
|
||||
<Thread name ="LiveCreate_CheckPowerOn"/>
|
||||
|
||||
<!-- [SANDBOX] - Plug-ins -->
|
||||
<Thread name ="PerforcePlugin"/>
|
||||
|
||||
<!-- [SANDBOX] - Utility -->
|
||||
<Thread name ="FileIndexing"/>
|
||||
<Thread name ="LODChainGenerateThread"/>
|
||||
<Thread name ="VisualChangeCalculatorView"/>
|
||||
|
||||
<!-- [SANDBOX] - Segmented World -->
|
||||
<Thread name ="SegWorld_MapUpdater"/>
|
||||
<Thread name ="SegWorld_WorldUpdater"/>
|
||||
<Thread name ="SegWorld_ExportSurfaceTexture_*"/>
|
||||
|
||||
<!-- [SANDBOX] - Indirect Lighting -->
|
||||
<Thread name ="SHLighting_*" StackSizeKB="1024"/>
|
||||
<Thread name ="SHLighting_TriRaster" StackSizeKB="1024"/>
|
||||
|
||||
</Platform>
|
||||
|
||||
<!-- ============ -->
|
||||
<!-- === PC_8 === -->
|
||||
<!-- ============ -->
|
||||
<Platform name="PC_8">
|
||||
<!-- Empty Example - Extend for 8 core specific machines. May override Common settings -->
|
||||
</Platform>
|
||||
</ThreadConfig>
|
||||
@ -0,0 +1,76 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
"""
|
||||
|
||||
# fmt:off
|
||||
class Tests():
|
||||
find_empty_entity = ("Entity: 'EmptyEntity' found", "Entity: 'EmptyEntity' *not* found in level")
|
||||
empty_entity_pos = ("'EmptyEntity' position is at the expected position", "'EmptyEntity' position is *not* at the expected position")
|
||||
find_pxentity = ("Entity: 'EntityWithPxCollider' found", "Entity: 'EntityWithPxCollider' *not* found in level")
|
||||
pxentity_component = ("Entity: 'EntityWithPxCollider' has a Physx Collider", "Entity: 'EntityWithPxCollider' does *not* have a Physx Collider")
|
||||
|
||||
# fmt:on
|
||||
|
||||
def PrefabLevel_OpensLevelWithEntities():
|
||||
"""
|
||||
Opens the level that contains 2 entities, "EmptyEntity" and "EntityWithPxCollider".
|
||||
This test makes sure that both entities exist after opening the level and that:
|
||||
- EmptyEntity is at Position: (10, 20, 30)
|
||||
- EntityWithPxCollider has a PhysXCollider component
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
|
||||
import editor_python_test_tools.hydra_editor_utils as hydra
|
||||
|
||||
import azlmbr.entity as entity
|
||||
import azlmbr.bus as bus
|
||||
from azlmbr.math import Vector3
|
||||
|
||||
EXPECTED_EMPTY_ENTITY_POS = Vector3(10.00, 20.0, 30.0)
|
||||
|
||||
helper.init_idle()
|
||||
helper.open_level("prefab", "PrefabLevel_OpensLevelWithEntities")
|
||||
|
||||
def find_entity(entity_name):
|
||||
searchFilter = entity.SearchFilter()
|
||||
searchFilter.names = [entity_name]
|
||||
entityIds = entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter)
|
||||
if entityIds[0].IsValid():
|
||||
return entityIds[0]
|
||||
return None
|
||||
#Checks for an entity called "EmptyEntity"
|
||||
helper.wait_for_condition(lambda: find_entity("EmptyEntity").IsValid(), 5.0)
|
||||
empty_entity_id = find_entity("EmptyEntity")
|
||||
Report.result(Tests.find_empty_entity, empty_entity_id.IsValid())
|
||||
|
||||
# Checks if the EmptyEntity is in the correct position and if it fails, it will provide the expected postion and the actual postion of the entity in the Editor log
|
||||
empty_entity_pos = azlmbr.components.TransformBus(azlmbr.bus.Event, "GetWorldTranslation", empty_entity_id)
|
||||
is_at_position = empty_entity_pos.IsClose(EXPECTED_EMPTY_ENTITY_POS)
|
||||
Report.result(Tests.empty_entity_pos, is_at_position)
|
||||
if not is_at_position:
|
||||
Report.info(f'Expected position: {EXPECTED_EMPTY_ENTITY_POS.ToString()}, actual position: {empty_entity_pos.ToString()}')
|
||||
|
||||
#Checks for an entity called "EntityWithPxCollider" and if it has the PhysX Collider component
|
||||
pxentity = find_entity("EntityWithPxCollider")
|
||||
Report.result(Tests.find_pxentity, pxentity.IsValid())
|
||||
|
||||
pxcollider_id = hydra.get_component_type_id("PhysX Collider")
|
||||
hasComponent = azlmbr.editor.EditorComponentAPIBus(azlmbr.bus.Broadcast, 'HasComponentOfType', pxentity, pxcollider_id)
|
||||
Report.result(Tests.pxentity_component, hasComponent)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
Report.start_test (PrefabLevel_OpensLevelWithEntities)
|
||||
@ -0,0 +1,35 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
||||
"""
|
||||
|
||||
# This suite consists of all test cases that are passing and have been verified.
|
||||
|
||||
import pytest
|
||||
import os
|
||||
import sys
|
||||
|
||||
from ly_test_tools import LAUNCHERS
|
||||
|
||||
sys.path.append (os.path.dirname (os.path.abspath (__file__)) + '/../automatedtesting_shared')
|
||||
|
||||
from base import TestAutomationBase
|
||||
|
||||
@pytest.mark.SUITE_main
|
||||
@pytest.mark.parametrize("launcher_platform", ['windows_editor'])
|
||||
@pytest.mark.parametrize("project", ["AutomatedTesting"])
|
||||
class TestAutomation(TestAutomationBase):
|
||||
|
||||
def _run_prefab_test(self, request, workspace, editor, test_module):
|
||||
self._run_test(request, workspace, editor, test_module, ["--regset=/Amazon/Preferences/EnablePrefabSystem=true"])
|
||||
|
||||
def test_PrefabLevel_OpensLevelWithEntities(self, request, workspace, editor, launcher_platform):
|
||||
from . import PrefabLevel_OpensLevelWithEntities as test_module
|
||||
self._run_prefab_test(request, workspace, editor, test_module)
|
||||
@ -0,0 +1,10 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
"""
|
||||
@ -0,0 +1,117 @@
|
||||
"""
|
||||
All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
its licensors.
|
||||
|
||||
For complete copyright and license terms please see the LICENSE at the root of this
|
||||
distribution (the "License"). All use of this software is governed by the License,
|
||||
or, if provided, by the license below or the license accompanying this file. Do not
|
||||
remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
"""
|
||||
|
||||
|
||||
# fmt: off
|
||||
class Tests():
|
||||
node_duplicated = ("Successfully duplicated node", "Failed to duplicate the node")
|
||||
# fmt: on
|
||||
|
||||
|
||||
def Node_HappyPath_DuplicateNode():
|
||||
"""
|
||||
Summary:
|
||||
Duplicating node in graph
|
||||
|
||||
Expected Behavior:
|
||||
Upon selecting a node and pressing Ctrl+D, the node will be duplicated
|
||||
|
||||
Test Steps:
|
||||
1) Open Script Canvas window (Tools > Script Canvas)
|
||||
2) Open a new graph
|
||||
3) Add node to graph
|
||||
4) Duplicate node
|
||||
5) Verify the node was duplicated6) Verify the node was duplicated
|
||||
|
||||
Note:
|
||||
- This test file must be called from the Open 3D Engine Editor command terminal
|
||||
- Any passed and failed tests are written to the Editor.log file.
|
||||
Parsing the file or running a log_monitor are required to observe the test results.
|
||||
|
||||
:return: None
|
||||
"""
|
||||
from PySide2 import QtWidgets, QtTest
|
||||
from PySide2.QtCore import Qt
|
||||
|
||||
from editor_python_test_tools.utils import Report
|
||||
from editor_python_test_tools.utils import TestHelper as helper
|
||||
import editor_python_test_tools.pyside_utils as pyside_utils
|
||||
|
||||
import azlmbr.legacy.general as general
|
||||
|
||||
WAIT_FRAMES = 200
|
||||
|
||||
NODE_NAME = "Print"
|
||||
NODE_CATEGORY = "Debug"
|
||||
EXPECTED_STRING = f"{NODE_NAME} - {NODE_CATEGORY} (2 Selected)"
|
||||
|
||||
def command_line_input(command_str):
|
||||
cmd_action = pyside_utils.find_child_by_pattern(
|
||||
sc_main, {"objectName": "action_ViewCommandLine", "type": QtWidgets.QAction}
|
||||
)
|
||||
cmd_action.trigger()
|
||||
textbox = sc.findChild(QtWidgets.QLineEdit, "commandText")
|
||||
QtTest.QTest.keyClicks(textbox, command_str)
|
||||
QtTest.QTest.keyClick(textbox, Qt.Key_Enter, Qt.NoModifier)
|
||||
|
||||
def grab_title_text():
|
||||
scroll_area = node_inspector.findChild(QtWidgets.QScrollArea, "")
|
||||
QtTest.QTest.keyClick(graph, "a", Qt.ControlModifier, WAIT_FRAMES)
|
||||
background = scroll_area.findChild(QtWidgets.QFrame, "Background")
|
||||
title = background.findChild(QtWidgets.QLabel, "Title")
|
||||
text = title.findChild(QtWidgets.QLabel, "Title")
|
||||
return text.text()
|
||||
|
||||
# 1) Open Script Canvas window (Tools > Script Canvas)
|
||||
general.idle_enable(True)
|
||||
general.open_pane("Script Canvas")
|
||||
helper.wait_for_condition(lambda: general.is_pane_visible("Script Canvas"), 5.0)
|
||||
|
||||
# 2) Open a new graph
|
||||
editor_window = pyside_utils.get_editor_main_window()
|
||||
sc = editor_window.findChild(QtWidgets.QDockWidget, "Script Canvas")
|
||||
sc_main = sc.findChild(QtWidgets.QMainWindow)
|
||||
create_new_graph = pyside_utils.find_child_by_pattern(
|
||||
sc_main, {"objectName": "action_New_Script", "type": QtWidgets.QAction}
|
||||
)
|
||||
if sc.findChild(QtWidgets.QDockWidget, "NodeInspector") is None:
|
||||
action = pyside_utils.find_child_by_pattern(sc, {"text": "Node Inspector", "type": QtWidgets.QAction})
|
||||
action.trigger()
|
||||
node_inspector = sc.findChild(QtWidgets.QDockWidget, "NodeInspector")
|
||||
create_new_graph.trigger()
|
||||
|
||||
# 3) Add node
|
||||
command_line_input("add_node Print")
|
||||
|
||||
# 4) Duplicate node
|
||||
graph_view = sc.findChild(QtWidgets.QFrame, "graphicsViewFrame")
|
||||
graph = graph_view.findChild(QtWidgets.QWidget, "")
|
||||
# There are currently no utilities available to directly duplicate the node,
|
||||
# therefore the node is selected using CTRL+A on the graph to select
|
||||
# it and then CTRL+D to duplicate
|
||||
sc_main.activateWindow()
|
||||
QtTest.QTest.keyClick(graph, "a", Qt.ControlModifier, WAIT_FRAMES)
|
||||
QtTest.QTest.keyClick(graph, "d", Qt.ControlModifier, WAIT_FRAMES)
|
||||
|
||||
# 5) Verify the node was duplicated
|
||||
# As direct interaction with node is not available the text on the label
|
||||
# inside the Node Inspector is validated showing two nodes exist
|
||||
after_dup = grab_title_text()
|
||||
Report.result(Tests.node_duplicated, after_dup == EXPECTED_STRING)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import ImportPathHelper as imports
|
||||
|
||||
imports.init()
|
||||
from editor_python_test_tools.utils import Report
|
||||
|
||||
Report.start_test(Node_HappyPath_DuplicateNode)
|
||||
@ -0,0 +1,171 @@
|
||||
{
|
||||
"Source": "Levels/PrefabLevel_OpensLevelWithEntities/PrefabLevel_OpensLevelWithEntities.prefab",
|
||||
"ContainerEntity": {
|
||||
"Id": "Entity_[403811863694]",
|
||||
"Name": "Level",
|
||||
"Components": {
|
||||
"Component_[10582285743525614098]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 10582285743525614098
|
||||
},
|
||||
"Component_[12253783095375428046]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 12253783095375428046
|
||||
},
|
||||
"Component_[13764860261821571747]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 13764860261821571747,
|
||||
"Parent Entity": ""
|
||||
},
|
||||
"Component_[15844324401733835865]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 15844324401733835865
|
||||
},
|
||||
"Component_[1605854641405361768]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 1605854641405361768
|
||||
},
|
||||
"Component_[17698173984524983803]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 17698173984524983803
|
||||
},
|
||||
"Component_[3444251662966224826]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 3444251662966224826
|
||||
},
|
||||
"Component_[4231768881195179982]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 4231768881195179982
|
||||
},
|
||||
"Component_[4722360315410084479]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 4722360315410084479
|
||||
},
|
||||
"Component_[7614719100624882952]": {
|
||||
"$type": "EditorPrefabComponent",
|
||||
"Id": 7614719100624882952
|
||||
},
|
||||
"Component_[9585901769691795481]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 9585901769691795481
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
},
|
||||
"Entities": {
|
||||
"Entity_[438171602062]": {
|
||||
"Id": "Entity_[438171602062]",
|
||||
"Name": "EntityWithPxCollider",
|
||||
"Components": {
|
||||
"Component_[11161653124805884473]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 11161653124805884473
|
||||
},
|
||||
"Component_[13116773315299882093]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 13116773315299882093
|
||||
},
|
||||
"Component_[15820915681461536711]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 15820915681461536711
|
||||
},
|
||||
"Component_[2222061938345834243]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 2222061938345834243
|
||||
},
|
||||
"Component_[3861913165076405600]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 3861913165076405600
|
||||
},
|
||||
"Component_[7118587015611303204]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 7118587015611303204
|
||||
},
|
||||
"Component_[7751174327125555504]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7751174327125555504
|
||||
},
|
||||
"Component_[8304730147756374057]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 8304730147756374057,
|
||||
"Parent Entity": "Entity_[403811863694]",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
0.0,
|
||||
20.0,
|
||||
34.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[8866353210615920259]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 8866353210615920259
|
||||
},
|
||||
"Component_[8988181228601932779]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 8988181228601932779
|
||||
},
|
||||
"Component_[7103333782129541775]": {
|
||||
"$type": "EditorColliderComponent",
|
||||
"Id": 7103333782129541775
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
},
|
||||
"Entity_[532660882574]": {
|
||||
"Id": "Entity_[532660882574]",
|
||||
"Name": "EmptyEntity",
|
||||
"Components": {
|
||||
"Component_[16437814751543997955]": {
|
||||
"$type": "EditorEntitySortComponent",
|
||||
"Id": 16437814751543997955
|
||||
},
|
||||
"Component_[16751517102089557119]": {
|
||||
"$type": "EditorPendingCompositionComponent",
|
||||
"Id": 16751517102089557119
|
||||
},
|
||||
"Component_[16773275259304187949]": {
|
||||
"$type": "EditorInspectorComponent",
|
||||
"Id": 16773275259304187949
|
||||
},
|
||||
"Component_[17283539636910567200]": {
|
||||
"$type": "SelectionComponent",
|
||||
"Id": 17283539636910567200
|
||||
},
|
||||
"Component_[250004123617033400]": {
|
||||
"$type": "EditorLockComponent",
|
||||
"Id": 250004123617033400
|
||||
},
|
||||
"Component_[2791138963683667073]": {
|
||||
"$type": "{27F1E1A1-8D9D-4C3B-BD3A-AFB9762449C0} TransformComponent",
|
||||
"Id": 2791138963683667073,
|
||||
"Parent Entity": "Entity_[403811863694]",
|
||||
"Transform Data": {
|
||||
"Translate": [
|
||||
10.0,
|
||||
20.0,
|
||||
30.0
|
||||
]
|
||||
}
|
||||
},
|
||||
"Component_[3296942400051129145]": {
|
||||
"$type": "EditorEntityIconComponent",
|
||||
"Id": 3296942400051129145
|
||||
},
|
||||
"Component_[3422076964671342434]": {
|
||||
"$type": "EditorOnlyEntityComponent",
|
||||
"Id": 3422076964671342434
|
||||
},
|
||||
"Component_[3431895414183121731]": {
|
||||
"$type": "EditorVisibilityComponent",
|
||||
"Id": 3431895414183121731
|
||||
},
|
||||
"Component_[7072085777705148766]": {
|
||||
"$type": "EditorDisabledCompositionComponent",
|
||||
"Id": 7072085777705148766
|
||||
}
|
||||
},
|
||||
"IsDependencyReady": true
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
.backup/
|
||||
.cache/
|
||||
*.log
|
||||
*.akd
|
||||
*.dat
|
||||
*.prof
|
||||
*.validationcache
|
||||
*.wsettings
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:803ddb37eb27cba666f9320c2f5905219193e1a069d1144a64df92fab0e31878
|
||||
size 1243
|
||||
oid sha256:c9e6a4ef3d2f33f31827ce2bba2ed8bad87324f3fe86f79389ef2956b304a924
|
||||
size 1180
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PluginInfo Project="Helios" Platform="Windows" BasePlatform="Windows">
|
||||
<PluginInfo Project="AutomatedTesting" Platform="Windows" BasePlatform="Windows">
|
||||
<Plugins>
|
||||
<Plugin Name="Wwise Tone Generator" ID="6684674" DLL="AkToneGen"/>
|
||||
<Plugin Name="System" ID="11403271" DLL="DefaultSink"/>
|
||||
<Plugin Name="No Output" ID="11862023" DLL="DefaultSink"/>
|
||||
<Plugin Name="Wwise Motion" ID="33226759" DLL="AkMotion"/>
|
||||
<Plugin Name="Wwise Tone Generator" ID="6684674" DLL="AkToneGen" StaticLib="AkToneSource"/>
|
||||
<Plugin Name="System" ID="11403271"/>
|
||||
<Plugin Name="No Output" ID="11862023"/>
|
||||
</Plugins>
|
||||
</PluginInfo>
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:94ea13931c13592deba669bd4920328ff96f17e6f8fce280d03f00251a96327a
|
||||
size 94122
|
||||
oid sha256:3db299d7d823b649ff20a7ffc986dccfce1fa3189f178491e2712d6c00b317af
|
||||
size 94126
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:ad73fd0981e47fe3313eff51d2841ea5fd522a99103684d696849e7353277ea9
|
||||
size 430
|
||||
oid sha256:1bdaed4dc5cc514a8a3ddfaf990f59061514af7962a7a112eb677ad5c45fcb85
|
||||
size 434
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:33eabaa646e9567017946bee05b1b5a835e91862f63145ebe5a2fbdd9c9f5a49
|
||||
size 226
|
||||
oid sha256:57c75cf8745b31071a788a20d8de5a60cedbfb8a6155eae1a461b8c6501e5479
|
||||
size 230
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:79d308f3c50fece383fd82fd0060e26558e6a2e78a4ecd5d8afe24907489a88f
|
||||
oid sha256:3a635f7d1ccb256caed90d18ca566cd0fa56d49b491af7c88c0b5da55a3ef4fe
|
||||
size 142234
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
In Memory Audio ID Name Audio source file Wwise Object Path Notes Data Size
|
||||
666825490 test_sfx_5_bank4_embedded Q:\audio\dev\AutomatedTesting\sounds\wwise_project\.cache\Windows\SFX\AMZN_sfx_env_commsarray_apllyupdate_end_56D34C19.wem \Actor-Mixer Hierarchy\Default Work Unit\test_sfx_5_bank4_embedded 142170
|
||||
666825490 test_sfx_5_bank4_embedded D:\code\o3de\AutomatedTesting\sounds\wwise_project\.cache\Windows\SFX\AMZN_sfx_env_commsarray_apllyupdate_end_56D34C19.wem \Actor-Mixer Hierarchy\Default Work Unit\test_sfx_5_bank4_embedded 142170
|
||||
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:80c02f30d439ffcfb479e4a82b0269fe4f479c50019028e51f0fa6e3fea0bfdd
|
||||
size 290
|
||||
oid sha256:fa329eeb83184e88b7ab26fbff2479a98232210bcd130801041b20ccb3bcf16e
|
||||
size 294
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:07d132d54b2c747e2409a56c05a4adca0dfa4407b791ffaa6bb14531f92f89aa
|
||||
size 494
|
||||
oid sha256:80d3014fcfd3a8ff37219515f0c9d67a2a674094002538ac6741702dca07c14d
|
||||
size 498
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
version https://git-lfs.github.com/spec/v1
|
||||
oid sha256:990538a33c72e79d63cab0c191b4e0f199688b923bb6bdcc8888aab375e7d11d
|
||||
size 226
|
||||
oid sha256:0de33094b9792d7f9ff8042e16b153dd76729e9010d6713e1824d2229c653042
|
||||
size 230
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<WwiseDocument Type="WorkUnit" ID="{CED370BF-940B-4409-81D6-5065B816B3E1}" SchemaVersion="103">
|
||||
<Metadatas>
|
||||
<WorkUnit Name="Default Work Unit" ID="{CED370BF-940B-4409-81D6-5065B816B3E1}" PersistMode="Standalone"/>
|
||||
</Metadatas>
|
||||
</WwiseDocument>
|
||||
@ -1,6 +0,0 @@
|
||||
#Ignore these directories
|
||||
SDKs
|
||||
|
||||
#ColinB (8/26)- I know there are depot files that this will ignore... But these files should not be
|
||||
#here, they should all be in 3rdParty... so we will ignore them until I can move them, it should
|
||||
#be OK for now because they shouldn't change at all anyway.
|
||||
@ -1,173 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef __animtime_h__
|
||||
#define __animtime_h__
|
||||
|
||||
#include <IXml.h>
|
||||
#include <AzCore/Casting/numeric_cast.h>
|
||||
#include <Serialization/IArchive.h>
|
||||
|
||||
struct SAnimTime
|
||||
{
|
||||
static const uint numTicksPerSecond = 6000;
|
||||
|
||||
// List of possible frame rates (dividers of 6000). Most commonly used ones first.
|
||||
enum EFrameRate
|
||||
{
|
||||
// Common
|
||||
eFrameRate_30fps, eFrameRate_60fps, eFrameRate_120fps,
|
||||
|
||||
// Possible
|
||||
eFrameRate_10fps, eFrameRate_12fps, eFrameRate_15fps, eFrameRate_24fps,
|
||||
eFrameRate_25fps, eFrameRate_40fps, eFrameRate_48fps, eFrameRate_50fps,
|
||||
eFrameRate_75fps, eFrameRate_80fps, eFrameRate_100fps, eFrameRate_125fps,
|
||||
eFrameRate_150fps, eFrameRate_200fps, eFrameRate_240fps, eFrameRate_250fps,
|
||||
eFrameRate_300fps, eFrameRate_375fps, eFrameRate_400fps, eFrameRate_500fps,
|
||||
eFrameRate_600fps, eFrameRate_750fps, eFrameRate_1000fps, eFrameRate_1200fps,
|
||||
eFrameRate_1500fps, eFrameRate_2000fps, eFrameRate_3000fps, eFrameRate_6000fps,
|
||||
|
||||
eFrameRate_Num
|
||||
};
|
||||
|
||||
SAnimTime()
|
||||
: m_ticks(0) {}
|
||||
explicit SAnimTime(int32 ticks)
|
||||
: m_ticks(ticks) {}
|
||||
explicit SAnimTime(float time)
|
||||
: m_ticks(aznumeric_caster(std::lround(static_cast<double>(time) * numTicksPerSecond))) {}
|
||||
|
||||
static uint GetFrameRateValue(EFrameRate frameRate)
|
||||
{
|
||||
const uint frameRateValues[eFrameRate_Num] =
|
||||
{
|
||||
// Common
|
||||
30, 60, 120,
|
||||
|
||||
// Possible
|
||||
10, 12, 15, 24, 25, 40, 48, 50, 75, 80, 100, 125,
|
||||
150, 200, 240, 250, 300, 375, 400, 500, 600, 750,
|
||||
1000, 1200, 1500, 2000, 3000, 6000
|
||||
};
|
||||
|
||||
return frameRateValues[frameRate];
|
||||
}
|
||||
|
||||
static const char* GetFrameRateName(EFrameRate frameRate)
|
||||
{
|
||||
const char* frameRateNames[eFrameRate_Num] =
|
||||
{
|
||||
// Common
|
||||
"30 fps", "60 fps", "120 fps",
|
||||
|
||||
// Possible
|
||||
"10 fps", "12 fps", "15 fps", "24 fps",
|
||||
"25 fps", "40 fps", "48 fps", "50 fps",
|
||||
"75 fps", "80 fps", "100 fps", "125 fps",
|
||||
"150 fps", "200 fps", "240 fps", "250 fps",
|
||||
"300 fps", "375 fps", "400 fps", "500 fps",
|
||||
"600 fps", "750 fps", "1000 fps", "1200 fps",
|
||||
"1500 fps", "2000 fps", "3000 fps", "6000 fps"
|
||||
};
|
||||
|
||||
return frameRateNames[frameRate];
|
||||
}
|
||||
|
||||
float ToFloat() const { return static_cast<float>(m_ticks) / numTicksPerSecond; }
|
||||
|
||||
void Serialize(Serialization::IArchive& ar)
|
||||
{
|
||||
ar(m_ticks, "ticks", "Ticks");
|
||||
}
|
||||
|
||||
// Helper to serialize from ticks or old float time
|
||||
void Serialize(XmlNodeRef keyNode, bool bLoading, const char* pName, const char* pLegacyName)
|
||||
{
|
||||
if (bLoading)
|
||||
{
|
||||
int32 ticks;
|
||||
if (!keyNode->getAttr(pName, ticks))
|
||||
{
|
||||
// Backwards compatibility
|
||||
float time = 0.0f;
|
||||
keyNode->getAttr(pLegacyName, time);
|
||||
*this = SAnimTime(time);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ticks = ticks;
|
||||
}
|
||||
}
|
||||
else if (m_ticks > 0)
|
||||
{
|
||||
keyNode->setAttr(pName, m_ticks);
|
||||
}
|
||||
}
|
||||
|
||||
int32 GetTicks() const { return m_ticks; }
|
||||
|
||||
static SAnimTime Min() { SAnimTime minTime; minTime.m_ticks = std::numeric_limits<int32>::lowest(); return minTime; }
|
||||
static SAnimTime Max() { SAnimTime maxTime; maxTime.m_ticks = (std::numeric_limits<int32>::max)(); return maxTime; }
|
||||
|
||||
SAnimTime operator-() const { return SAnimTime(-m_ticks); }
|
||||
SAnimTime operator-(SAnimTime r) const { SAnimTime temp = *this; temp.m_ticks -= r.m_ticks; return temp; }
|
||||
SAnimTime operator+(SAnimTime r) const { SAnimTime temp = *this; temp.m_ticks += r.m_ticks; return temp; }
|
||||
SAnimTime operator*(SAnimTime r) const { SAnimTime temp = *this; temp.m_ticks *= r.m_ticks; return temp; }
|
||||
SAnimTime operator/(SAnimTime r) const { SAnimTime temp; temp.m_ticks = static_cast<int32>((static_cast<int64>(m_ticks) * numTicksPerSecond) / r.m_ticks); return temp; }
|
||||
SAnimTime operator%(SAnimTime r) const { SAnimTime temp = *this; temp.m_ticks %= r.m_ticks; return temp; }
|
||||
SAnimTime operator*(float r) const { SAnimTime temp; temp.m_ticks = aznumeric_caster(std::lround(static_cast<double>(m_ticks) * r)); return temp; }
|
||||
SAnimTime operator/(float r) const { SAnimTime temp; temp.m_ticks = aznumeric_caster(std::lround(static_cast<double>(m_ticks) / r)); return temp; }
|
||||
SAnimTime& operator+=(SAnimTime r) { *this = *this + r; return *this; }
|
||||
SAnimTime& operator-=(SAnimTime r) { *this = *this - r; return *this; }
|
||||
SAnimTime& operator*=(SAnimTime r) { *this = *this * r; return *this; }
|
||||
SAnimTime& operator/=(SAnimTime r) { *this = *this / r; return *this; }
|
||||
SAnimTime& operator%=(SAnimTime r) { *this = *this % r; return *this; }
|
||||
SAnimTime& operator*=(float r) { *this = *this * r; return *this; }
|
||||
SAnimTime& operator/=(float r) { *this = *this / r; return *this; }
|
||||
|
||||
bool operator<(SAnimTime r) const { return m_ticks < r.m_ticks; }
|
||||
bool operator<=(SAnimTime r) const { return m_ticks <= r.m_ticks; }
|
||||
bool operator>(SAnimTime r) const { return m_ticks > r.m_ticks; }
|
||||
bool operator>=(SAnimTime r) const { return m_ticks >= r.m_ticks; }
|
||||
bool operator==(SAnimTime r) const { return m_ticks == r.m_ticks; }
|
||||
bool operator!=(SAnimTime r) const { return m_ticks != r.m_ticks; }
|
||||
|
||||
// Snap to nearest multiple of given frame rate
|
||||
SAnimTime SnapToNearest(const EFrameRate frameRate)
|
||||
{
|
||||
const int sign = sgn(m_ticks);
|
||||
const int32 absTicks = abs(m_ticks);
|
||||
|
||||
const int framesMod = numTicksPerSecond / GetFrameRateValue(frameRate);
|
||||
const int32 remainder = absTicks % framesMod;
|
||||
const bool bNextMultiple = remainder >= (framesMod / 2);
|
||||
return SAnimTime(sign * ((absTicks - remainder) + (bNextMultiple ? framesMod : 0)));
|
||||
}
|
||||
|
||||
private:
|
||||
int32 m_ticks;
|
||||
|
||||
friend bool Serialize(Serialization::IArchive& ar, SAnimTime& animTime, const char* name, const char* label);
|
||||
};
|
||||
|
||||
inline bool Serialize(Serialization::IArchive& ar, SAnimTime& animTime, const char* name, const char* label)
|
||||
{
|
||||
return ar(animTime.m_ticks, name, label);
|
||||
}
|
||||
|
||||
inline SAnimTime abs(SAnimTime time)
|
||||
{
|
||||
return (time >= SAnimTime(0)) ? time : -time;
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,321 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef __BEZIER_H__
|
||||
#define __BEZIER_H__
|
||||
|
||||
#include <AnimTime.h>
|
||||
#include <Serialization/IArchive.h>
|
||||
#include <Serialization/Math.h>
|
||||
|
||||
struct SBezierControlPoint
|
||||
{
|
||||
SBezierControlPoint()
|
||||
: m_value(0.0f)
|
||||
, m_inTangent(ZERO)
|
||||
, m_outTangent(ZERO)
|
||||
, m_inTangentType(eTangentType_Auto)
|
||||
, m_outTangentType(eTangentType_Auto)
|
||||
, m_bBreakTangents(false)
|
||||
{
|
||||
}
|
||||
|
||||
enum ETangentType
|
||||
{
|
||||
eTangentType_Custom,
|
||||
eTangentType_Auto,
|
||||
eTangentType_Zero,
|
||||
eTangentType_Step,
|
||||
eTangentType_Linear,
|
||||
};
|
||||
|
||||
void Serialize(Serialization::IArchive& ar)
|
||||
{
|
||||
ar(m_value, "value", "Value");
|
||||
|
||||
if (ar.IsOutput())
|
||||
{
|
||||
bool breakTangents = m_bBreakTangents;
|
||||
ar(breakTangents, "breakTangents", "Break Tangents");
|
||||
}
|
||||
else
|
||||
{
|
||||
bool breakTangents = false;
|
||||
ar(breakTangents, "breakTangents", "Break Tangents");
|
||||
m_bBreakTangents = breakTangents;
|
||||
}
|
||||
|
||||
if (ar.IsOutput())
|
||||
{
|
||||
ETangentType inTangentType = m_inTangentType;
|
||||
ar(inTangentType, "inTangentType", "Incoming tangent type");
|
||||
}
|
||||
else
|
||||
{
|
||||
ETangentType inTangentType = eTangentType_Auto;
|
||||
ar(inTangentType, "inTangentType", "Incoming tangent type");
|
||||
m_inTangentType = inTangentType;
|
||||
}
|
||||
|
||||
ar(m_inTangent, "inTangent", (m_inTangentType == eTangentType_Custom) ? "Incoming Tangent" : NULL);
|
||||
|
||||
if (ar.IsOutput())
|
||||
{
|
||||
ETangentType outTangentType = m_outTangentType;
|
||||
ar(outTangentType, "outTangentType", "Outgoing tangent type");
|
||||
}
|
||||
else
|
||||
{
|
||||
ETangentType outTangentType = eTangentType_Auto;
|
||||
ar(outTangentType, "outTangentType", "Outgoing tangent type");
|
||||
m_outTangentType = outTangentType;
|
||||
}
|
||||
|
||||
ar(m_outTangent, "outTangent", (m_outTangentType == eTangentType_Custom) ? "Outgoing Tangent" : NULL);
|
||||
}
|
||||
|
||||
float m_value;
|
||||
|
||||
// For 1D Bezier only the Y component is used
|
||||
Vec2 m_inTangent;
|
||||
Vec2 m_outTangent;
|
||||
|
||||
ETangentType m_inTangentType : 4;
|
||||
ETangentType m_outTangentType : 4;
|
||||
bool m_bBreakTangents : 1;
|
||||
};
|
||||
|
||||
struct SBezierKey
|
||||
{
|
||||
SBezierKey()
|
||||
: m_time(0) {}
|
||||
|
||||
void Serialize(Serialization::IArchive& ar)
|
||||
{
|
||||
ar(m_time, "time", "Time");
|
||||
ar(m_controlPoint, "controlPoint", "Control Point");
|
||||
}
|
||||
|
||||
SAnimTime m_time;
|
||||
SBezierControlPoint m_controlPoint;
|
||||
};
|
||||
|
||||
namespace Bezier
|
||||
{
|
||||
inline float Evaluate(float t, float p0, float p1, float p2, float p3)
|
||||
{
|
||||
const float a = 1 - t;
|
||||
const float aSq = a * a;
|
||||
const float tSq = t * t;
|
||||
return (aSq * a * p0) + (3.0f * aSq * t * p1) + (3.0f * a * tSq * p2) + (tSq * t * p3);
|
||||
}
|
||||
|
||||
inline float EvaluateDeriv(float t, float p0, float p1, float p2, float p3)
|
||||
{
|
||||
const float a = 1 - t;
|
||||
const float ta = t * a;
|
||||
const float aSq = a * a;
|
||||
const float tSq = t * t;
|
||||
return 3.0f * ((-p2 * tSq) + (p3 * tSq) - (p0 * aSq) + (p1 * aSq) + 2.0f * ((-p1 * ta) + (p2 * ta)));
|
||||
}
|
||||
|
||||
inline float EvaluateX(const float t, const float duration, const SBezierControlPoint& start, const SBezierControlPoint& end)
|
||||
{
|
||||
const float p0 = 0.0f;
|
||||
const float p1 = p0 + start.m_outTangent.x;
|
||||
const float p3 = duration;
|
||||
const float p2 = p3 + end.m_inTangent.x;
|
||||
return Evaluate(t, p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
inline float EvaluateY(const float t, const SBezierControlPoint& start, const SBezierControlPoint& end)
|
||||
{
|
||||
const float p0 = start.m_value;
|
||||
const float p1 = p0 + start.m_outTangent.y;
|
||||
const float p3 = end.m_value;
|
||||
const float p2 = p3 + end.m_inTangent.y;
|
||||
return Evaluate(t, p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
// Duration = (time at end key) - (time at start key)
|
||||
inline float EvaluateDerivX(const float t, const float duration, const SBezierControlPoint& start, const SBezierControlPoint& end)
|
||||
{
|
||||
const float p0 = 0.0f;
|
||||
const float p1 = p0 + start.m_outTangent.x;
|
||||
const float p3 = duration;
|
||||
const float p2 = p3 + end.m_inTangent.x;
|
||||
return EvaluateDeriv(t, p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
inline float EvaluateDerivY(const float t, const SBezierControlPoint& start, const SBezierControlPoint& end)
|
||||
{
|
||||
const float p0 = start.m_value;
|
||||
const float p1 = p0 + start.m_outTangent.y;
|
||||
const float p3 = end.m_value;
|
||||
const float p2 = p3 + end.m_inTangent.y;
|
||||
return EvaluateDeriv(t, p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
// Find interpolation factor where 2D bezier curve has the given x value. Works only for curves where x is monotonically increasing.
|
||||
// The passed x must be in range [0, duration]. Uses the Newton-Raphson root finding method. Usually takes 2 or 3 iterations.
|
||||
//
|
||||
// Note: This is for "1D" 2D bezier curves as used in TrackView. The curves are restricted by the curve editor to be monotonically increasing.
|
||||
//
|
||||
inline float InterpolationFactorFromX(const float x, const float duration, const SBezierControlPoint& start, const SBezierControlPoint& end)
|
||||
{
|
||||
float t = (x / duration);
|
||||
|
||||
const float epsilon = 0.00001f;
|
||||
const uint maxSteps = 10;
|
||||
|
||||
for (uint i = 0; i < maxSteps; ++i)
|
||||
{
|
||||
const float currentX = EvaluateX(t, duration, start, end) - x;
|
||||
if (fabs(currentX) <= epsilon)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
const float currentXDeriv = EvaluateDerivX(t, duration, start, end);
|
||||
t -= currentX / currentXDeriv;
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
inline SBezierControlPoint CalculateInTangent(
|
||||
float time, const SBezierControlPoint& point,
|
||||
float leftTime, const SBezierControlPoint* pLeftPoint,
|
||||
float rightTime, const SBezierControlPoint* pRightPoint)
|
||||
{
|
||||
SBezierControlPoint newPoint = point;
|
||||
|
||||
// In tangent X can never be positive
|
||||
newPoint.m_inTangent.x = std::min(point.m_inTangent.x, 0.0f);
|
||||
|
||||
if (pLeftPoint)
|
||||
{
|
||||
switch (point.m_inTangentType)
|
||||
{
|
||||
case SBezierControlPoint::eTangentType_Custom:
|
||||
{
|
||||
// Need to clamp tangent if it is reaching over last point
|
||||
const float deltaTime = time - leftTime;
|
||||
if (deltaTime < -newPoint.m_inTangent.x)
|
||||
{
|
||||
if (newPoint.m_inTangent.x == 0)
|
||||
{
|
||||
newPoint.m_inTangent = Vec2(ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
float scaleFactor = deltaTime / -newPoint.m_inTangent.x;
|
||||
newPoint.m_inTangent.x = -deltaTime;
|
||||
newPoint.m_inTangent.y *= scaleFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SBezierControlPoint::eTangentType_Zero:
|
||||
// Fall through. Zero for y is same as Auto, x is set to 0.0f
|
||||
case SBezierControlPoint::eTangentType_Auto:
|
||||
{
|
||||
const SBezierControlPoint& rightPoint = pRightPoint ? *pRightPoint : point;
|
||||
const float deltaTime = (pRightPoint ? rightTime : time) - leftTime;
|
||||
if (deltaTime > 0.0f)
|
||||
{
|
||||
const float ratio = (time - leftTime) / deltaTime;
|
||||
const float deltaValue = rightPoint.m_value - pLeftPoint->m_value;
|
||||
const bool bIsZeroTangent = (point.m_inTangentType == SBezierControlPoint::eTangentType_Zero);
|
||||
newPoint.m_inTangent = Vec2(-(deltaTime * ratio) / 3.0f, bIsZeroTangent ? 0.0f : -(deltaValue * ratio) / 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPoint.m_inTangent = Vec2(ZERO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SBezierControlPoint::eTangentType_Linear:
|
||||
newPoint.m_inTangent = Vec2((leftTime - time) / 3.0f,
|
||||
(pLeftPoint->m_value - point.m_value) / 3.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return newPoint;
|
||||
}
|
||||
|
||||
inline SBezierControlPoint CalculateOutTangent(
|
||||
float time, const SBezierControlPoint& point,
|
||||
float leftTime, const SBezierControlPoint* pLeftPoint,
|
||||
float rightTime, const SBezierControlPoint* pRightPoint)
|
||||
{
|
||||
SBezierControlPoint newPoint = point;
|
||||
|
||||
// Out tangent X can never be negative
|
||||
newPoint.m_outTangent.x = std::max(point.m_outTangent.x, 0.0f);
|
||||
|
||||
if (pRightPoint)
|
||||
{
|
||||
switch (point.m_outTangentType)
|
||||
{
|
||||
case SBezierControlPoint::eTangentType_Custom:
|
||||
{
|
||||
// Need to clamp tangent if it is reaching over next point
|
||||
const float deltaTime = rightTime - time;
|
||||
if (deltaTime < newPoint.m_outTangent.x)
|
||||
{
|
||||
if (newPoint.m_outTangent.x == 0)
|
||||
{
|
||||
newPoint.m_outTangent = Vec2(ZERO);
|
||||
}
|
||||
else
|
||||
{
|
||||
float scaleFactor = deltaTime / newPoint.m_outTangent.x;
|
||||
newPoint.m_outTangent.x = deltaTime;
|
||||
newPoint.m_outTangent.y *= scaleFactor;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SBezierControlPoint::eTangentType_Zero:
|
||||
// Fall through. Zero for y is same as Auto, x is set to 0.0f
|
||||
case SBezierControlPoint::eTangentType_Auto:
|
||||
{
|
||||
const SBezierControlPoint& leftPoint = pLeftPoint ? *pLeftPoint : point;
|
||||
const float deltaTime = rightTime - (pLeftPoint ? leftTime : time);
|
||||
if (deltaTime > 0.0f)
|
||||
{
|
||||
const float ratio = (rightTime - time) / deltaTime;
|
||||
const float deltaValue = pRightPoint->m_value - leftPoint.m_value;
|
||||
const bool bIsZeroTangent = (point.m_outTangentType == SBezierControlPoint::eTangentType_Zero);
|
||||
newPoint.m_outTangent = Vec2((deltaTime * ratio) / 3.0f, bIsZeroTangent ? 0.0f : (deltaValue * ratio) / 3.0f);
|
||||
}
|
||||
else
|
||||
{
|
||||
newPoint.m_outTangent = Vec2(ZERO);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case SBezierControlPoint::eTangentType_Linear:
|
||||
newPoint.m_outTangent = Vec2((rightTime - time) / 3.0f,
|
||||
(pRightPoint->m_value - point.m_value) / 3.0f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return newPoint;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_CRYCREATECLASSINSTANCE_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_CRYCREATECLASSINSTANCE_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "ICryUnknown.h"
|
||||
#include "ICryFactory.h"
|
||||
#include "ICryFactoryRegistry.h"
|
||||
#include <ISystem.h> // <> required for Interfuscator
|
||||
|
||||
|
||||
template <class T>
|
||||
bool CryCreateClassInstance(const CryClassID& cid, AZStd::shared_ptr<T>& p)
|
||||
{
|
||||
p = AZStd::shared_ptr<T>();
|
||||
ICryFactoryRegistry* pFactoryReg = gEnv->pSystem->GetCryFactoryRegistry();
|
||||
if (pFactoryReg)
|
||||
{
|
||||
ICryFactory* pFactory = pFactoryReg->GetFactory(cid);
|
||||
if (pFactory && pFactory->ClassSupports(cryiidof<T>()))
|
||||
{
|
||||
ICryUnknownPtr pUnk = pFactory->CreateClassInstance();
|
||||
AZStd::shared_ptr<T> pT = cryinterface_cast<T>(pUnk);
|
||||
if (pT)
|
||||
{
|
||||
p = pT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return p.get() != NULL;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool CryCreateClassInstance(const char* cname, AZStd::shared_ptr<T>& p)
|
||||
{
|
||||
p = AZStd::shared_ptr<T>();
|
||||
ICryFactoryRegistry* pFactoryReg = gEnv->pSystem->GetCryFactoryRegistry();
|
||||
if (pFactoryReg)
|
||||
{
|
||||
ICryFactory* pFactory = pFactoryReg->GetFactory(cname);
|
||||
if (pFactory != NULL && pFactory->ClassSupports(cryiidof<T>()))
|
||||
{
|
||||
ICryUnknownPtr pUnk = pFactory->CreateClassInstance();
|
||||
AZStd::shared_ptr<T> pT = cryinterface_cast<T>(pUnk);
|
||||
if (pT)
|
||||
{
|
||||
p = pT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return p.get() != NULL;
|
||||
}
|
||||
|
||||
|
||||
template <class T>
|
||||
bool CryCreateClassInstanceForInterface(const CryInterfaceID& iid, AZStd::shared_ptr<T>& p)
|
||||
{
|
||||
p = AZStd::shared_ptr<T>();
|
||||
ICryFactoryRegistry* pFactoryReg = gEnv->pSystem->GetCryFactoryRegistry();
|
||||
if (pFactoryReg)
|
||||
{
|
||||
size_t numFactories = 1;
|
||||
ICryFactory* pFactory = 0;
|
||||
pFactoryReg->IterateFactories(iid, &pFactory, numFactories);
|
||||
if (numFactories == 1 && pFactory)
|
||||
{
|
||||
ICryUnknownPtr pUnk = pFactory->CreateClassInstance();
|
||||
AZStd::shared_ptr<T> pT = cryinterface_cast<T>(pUnk);
|
||||
if (pT)
|
||||
{
|
||||
p = pT;
|
||||
}
|
||||
}
|
||||
}
|
||||
return p.get() != NULL;
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_CRYCREATECLASSINSTANCE_H
|
||||
@ -1,123 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_CRYGUID_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_CRYGUID_H
|
||||
#pragma once
|
||||
|
||||
#include "Serialization/IArchive.h"
|
||||
#include "Random.h"
|
||||
|
||||
#include <functional>
|
||||
|
||||
struct CryGUID
|
||||
{
|
||||
uint64 hipart;
|
||||
uint64 lopart;
|
||||
|
||||
// !!! Do NOT turn CryGUID into a non-aggregate !!!
|
||||
// It will prevent inlining and type list unrolling opportunities within
|
||||
// cryinterface_cast<T>() and cryiidof<T>(). As such prevent constructors,
|
||||
// non-public members, base classes and virtual functions!
|
||||
|
||||
//CryGUID() : hipart(0), lopart(0) {}
|
||||
//CryGUID(uint64 h, uint64 l) : hipart(h), lopart(l) {}
|
||||
|
||||
static CryGUID Construct(const uint64& hipart, const uint64& lopart)
|
||||
{
|
||||
CryGUID guid = {hipart, lopart};
|
||||
return guid;
|
||||
}
|
||||
|
||||
static CryGUID Create()
|
||||
{
|
||||
uint64 lopart = 0;
|
||||
uint64 hipart = 0;
|
||||
while (lopart == 0 || hipart == 0)
|
||||
{
|
||||
const uint32 a = cry_random_uint32();
|
||||
const uint32 b = cry_random_uint32();
|
||||
const uint32 c = cry_random_uint32();
|
||||
const uint32 d = cry_random_uint32();
|
||||
lopart = (uint64)a | ((uint64)b << 32);
|
||||
hipart = (uint64)c | ((uint64)d << 32);
|
||||
}
|
||||
|
||||
return Construct(lopart, hipart);
|
||||
}
|
||||
|
||||
static CryGUID Null()
|
||||
{
|
||||
return Construct(0, 0);
|
||||
}
|
||||
|
||||
bool operator ==(const CryGUID& rhs) const {return hipart == rhs.hipart && lopart == rhs.lopart; }
|
||||
bool operator !=(const CryGUID& rhs) const {return hipart != rhs.hipart || lopart != rhs.lopart; }
|
||||
bool operator <(const CryGUID& rhs) const {return hipart == rhs.hipart ? lopart < rhs.lopart : hipart < rhs.hipart; }
|
||||
|
||||
void Serialize(Serialization::IArchive& ar)
|
||||
{
|
||||
if (ar.IsInput())
|
||||
{
|
||||
uint32 dwords[4];
|
||||
ar(dwords, "guid");
|
||||
lopart = (((uint64)dwords[1]) << 32) | (uint64)dwords[0];
|
||||
hipart = (((uint64)dwords[3]) << 32) | (uint64)dwords[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 guid[4] = {
|
||||
(uint32)(lopart & 0xFFFFFFFF), (uint32)((lopart >> 32) & 0xFFFFFFFF),
|
||||
(uint32)(hipart & 0xFFFFFFFF), (uint32)((hipart >> 32) & 0xFFFFFFFF)
|
||||
};
|
||||
ar(guid, "guid");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// This is only used by the editor where we use C++ 11.
|
||||
namespace std
|
||||
{
|
||||
template<>
|
||||
struct hash<CryGUID>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const CryGUID& guid) const
|
||||
{
|
||||
std::hash<uint64> hasher;
|
||||
return hasher(guid.lopart) ^ hasher(guid.hipart);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace AZStd
|
||||
{
|
||||
template<>
|
||||
struct hash<CryGUID>
|
||||
{
|
||||
public:
|
||||
size_t operator()(const CryGUID& guid) const
|
||||
{
|
||||
std::hash<CryGUID> hasher;
|
||||
return hasher(guid);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#define MAKE_CRYGUID(high, low) CryGUID::Construct((uint64) high##LL, (uint64) low##LL)
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_CRYGUID_H
|
||||
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_CRYTYPEID_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_CRYTYPEID_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CryGUID.h"
|
||||
|
||||
|
||||
typedef CryGUID CryInterfaceID;
|
||||
typedef CryGUID CryClassID;
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_CRYTYPEID_H
|
||||
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_ICRYFACTORY_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_ICRYFACTORY_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CryTypeID.h"
|
||||
#include <SmartPointersHelpers.h>
|
||||
|
||||
struct ICryUnknown;
|
||||
DECLARE_SMART_POINTERS(ICryUnknown);
|
||||
|
||||
struct ICryFactory
|
||||
{
|
||||
virtual const char* GetName() const = 0;
|
||||
virtual const CryClassID& GetClassID() const = 0;
|
||||
virtual bool ClassSupports(const CryInterfaceID& iid) const = 0;
|
||||
virtual void ClassSupports(const CryInterfaceID*& pIIDs, size_t& numIIDs) const = 0;
|
||||
virtual ICryUnknownPtr CreateClassInstance() const = 0;
|
||||
|
||||
protected:
|
||||
// prevent explicit destruction from client side (delete, shared_ptr, etc)
|
||||
virtual ~ICryFactory() {}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_ICRYFACTORY_H
|
||||
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_ICRYFACTORYREGISTRY_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_ICRYFACTORYREGISTRY_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CryTypeID.h"
|
||||
|
||||
|
||||
struct ICryFactory;
|
||||
|
||||
|
||||
struct ICryFactoryRegistry
|
||||
{
|
||||
virtual ICryFactory* GetFactory(const char* cname) const = 0;
|
||||
virtual ICryFactory* GetFactory(const CryClassID& cid) const = 0;
|
||||
/**
|
||||
* Iterates all factories implementing the interface specified by \p iid.
|
||||
* \param[in] iid ID of the interface to iterate. Often procured using cryiidof<...>().
|
||||
* \param[out] pFactories A pointer of the array of factories to fill in. May be nullptr (see below).
|
||||
* \param[in] Size (in elements) of the pFactories array [out] Number of elements actually written to pFactories or, when pFactories is null, the number of elements that would be written if sufficient storage was available.
|
||||
*
|
||||
* Example:
|
||||
* \code{.cpp}
|
||||
* size_t factoryCount = 0;
|
||||
* // Assigns the number of found factories to factoryCount
|
||||
* factoryRegistry->IterateFactories(cryiidof<TPointer>(), 0, factoryCount);
|
||||
* // Allocate an array of the proper length on the stack
|
||||
* ICryFactory** factories = static_cast<ICryFactory**>(alloca(sizeof(ICryFactory*) * factoryCount);
|
||||
* // Fill in factories with factoryCount results.
|
||||
* factoryRegistry->IterateFactories(cryiidof<TPointer>(), factories, factoryCount);
|
||||
* \endcode
|
||||
*/
|
||||
virtual void IterateFactories(const CryInterfaceID& iid, ICryFactory** pFactories, size_t& numFactories) const = 0;
|
||||
|
||||
protected:
|
||||
// prevent explicit destruction from client side (delete, shared_ptr, etc)
|
||||
virtual ~ICryFactoryRegistry() {}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_ICRYFACTORYREGISTRY_H
|
||||
@ -1,224 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_ICRYUNKNOWN_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_ICRYUNKNOWN_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "CryTypeID.h"
|
||||
#include <SmartPointersHelpers.h>
|
||||
|
||||
|
||||
struct ICryFactory;
|
||||
struct ICryUnknown;
|
||||
|
||||
namespace InterfaceCastSemantics
|
||||
{
|
||||
template <class T>
|
||||
const CryInterfaceID& cryiidof()
|
||||
{
|
||||
return T::IID();
|
||||
}
|
||||
|
||||
#define _BEFRIEND_CRYIIDOF() \
|
||||
template <class T> \
|
||||
friend const CryInterfaceID&InterfaceCastSemantics::cryiidof();
|
||||
|
||||
|
||||
template <class Dst, class Src>
|
||||
Dst* cryinterface_cast(Src* p)
|
||||
{
|
||||
return static_cast<Dst*>(p ? p->QueryInterface(cryiidof<Dst>()) : 0);
|
||||
}
|
||||
|
||||
template <class Dst, class Src>
|
||||
Dst* cryinterface_cast(const Src* p)
|
||||
{
|
||||
return static_cast<const Dst*>(p ? p->QueryInterface(cryiidof<Dst>()) : 0);
|
||||
}
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
template <class Dst, class Src>
|
||||
struct cryinterface_cast_shared_ptr_helper;
|
||||
|
||||
template <class Dst, class Src>
|
||||
struct cryinterface_cast_shared_ptr_helper
|
||||
{
|
||||
static AZStd::shared_ptr<Dst> Op(const AZStd::shared_ptr<Src>& p)
|
||||
{
|
||||
Dst* dp = cryinterface_cast<Dst>(p.get());
|
||||
return dp ? AZStd::shared_ptr<Dst>(p, dp) : AZStd::shared_ptr<Dst>();
|
||||
}
|
||||
};
|
||||
|
||||
template <class Src>
|
||||
struct cryinterface_cast_shared_ptr_helper<ICryUnknown, Src>
|
||||
{
|
||||
static AZStd::shared_ptr<ICryUnknown> Op(const AZStd::shared_ptr<Src>& p)
|
||||
{
|
||||
ICryUnknown* dp = cryinterface_cast<ICryUnknown>(p.get());
|
||||
return dp ? AZStd::shared_ptr<ICryUnknown>(*((const AZStd::shared_ptr<ICryUnknown>*) & p), dp) : AZStd::shared_ptr<ICryUnknown>();
|
||||
}
|
||||
};
|
||||
|
||||
template <class Src>
|
||||
struct cryinterface_cast_shared_ptr_helper<const ICryUnknown, Src>
|
||||
{
|
||||
static AZStd::shared_ptr<const ICryUnknown> Op(const AZStd::shared_ptr<Src>& p)
|
||||
{
|
||||
const ICryUnknown* dp = cryinterface_cast<const ICryUnknown>(p.get());
|
||||
return dp ? AZStd::shared_ptr<const ICryUnknown>(*((const AZStd::shared_ptr<const ICryUnknown>*) & p), dp) : AZStd::shared_ptr<const ICryUnknown>();
|
||||
}
|
||||
};
|
||||
} // namespace Internal
|
||||
|
||||
template <class Dst, class Src>
|
||||
AZStd::shared_ptr<Dst> cryinterface_cast(const AZStd::shared_ptr<Src>& p)
|
||||
{
|
||||
return Internal::cryinterface_cast_shared_ptr_helper<Dst, Src>::Op(p);
|
||||
}
|
||||
|
||||
#define _BEFRIEND_CRYINTERFACE_CAST() \
|
||||
template <class Dst, class Src> \
|
||||
friend Dst * InterfaceCastSemantics::cryinterface_cast(Src*); \
|
||||
template <class Dst, class Src> \
|
||||
friend Dst * InterfaceCastSemantics::cryinterface_cast(const Src*); \
|
||||
template <class Dst, class Src> \
|
||||
friend AZStd::shared_ptr<Dst> InterfaceCastSemantics::cryinterface_cast(const AZStd::shared_ptr<Src>&);
|
||||
} // namespace InterfaceCastSemantics
|
||||
|
||||
using InterfaceCastSemantics::cryiidof;
|
||||
using InterfaceCastSemantics::cryinterface_cast;
|
||||
|
||||
|
||||
template <class S, class T>
|
||||
bool CryIsSameClassInstance(S* p0, T* p1)
|
||||
{
|
||||
return static_cast<const void*>(p0) == static_cast<const void*>(p1) || cryinterface_cast<const ICryUnknown>(p0) == cryinterface_cast<const ICryUnknown>(p1);
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
bool CryIsSameClassInstance(const AZStd::shared_ptr<S>& p0, T* p1)
|
||||
{
|
||||
return CryIsSameClassInstance(p0.get(), p1);
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
bool CryIsSameClassInstance(S* p0, const AZStd::shared_ptr<T>& p1)
|
||||
{
|
||||
return CryIsSameClassInstance(p0, p1.get());
|
||||
}
|
||||
|
||||
template <class S, class T>
|
||||
bool CryIsSameClassInstance(const AZStd::shared_ptr<S>& p0, const AZStd::shared_ptr<T>& p1)
|
||||
{
|
||||
return CryIsSameClassInstance(p0.get(), p1.get());
|
||||
}
|
||||
|
||||
|
||||
namespace CompositeQuerySemantics
|
||||
{
|
||||
template <class Src>
|
||||
AZStd::shared_ptr<ICryUnknown> crycomposite_query(Src* p, const char* name, bool* pExposed = 0)
|
||||
{
|
||||
void* pComposite = p ? p->QueryComposite(name) : 0;
|
||||
pExposed ? *pExposed = pComposite != 0 : 0;
|
||||
return pComposite ? *static_cast<AZStd::shared_ptr<ICryUnknown>*>(pComposite) : AZStd::shared_ptr<ICryUnknown>();
|
||||
}
|
||||
|
||||
template <class Src>
|
||||
AZStd::shared_ptr<const ICryUnknown> crycomposite_query(const Src* p, const char* name, bool* pExposed = 0)
|
||||
{
|
||||
void* pComposite = p ? p->QueryComposite(name) : 0;
|
||||
pExposed ? *pExposed = pComposite != 0 : 0;
|
||||
return pComposite ? *static_cast<AZStd::shared_ptr<const ICryUnknown>*>(pComposite) : AZStd::shared_ptr<const ICryUnknown>();
|
||||
}
|
||||
|
||||
template <class Src>
|
||||
AZStd::shared_ptr<ICryUnknown> crycomposite_query(const AZStd::shared_ptr<Src>& p, const char* name, bool* pExposed = 0)
|
||||
{
|
||||
return crycomposite_query(p.get(), name, pExposed);
|
||||
}
|
||||
|
||||
template <class Src>
|
||||
AZStd::shared_ptr<const ICryUnknown> crycomposite_query(const AZStd::shared_ptr<const Src>& p, const char* name, bool* pExposed = 0)
|
||||
{
|
||||
return crycomposite_query(p.get(), name, pExposed);
|
||||
}
|
||||
|
||||
#define _BEFRIEND_CRYCOMPOSITE_QUERY() \
|
||||
template <class Src> \
|
||||
friend AZStd::shared_ptr<ICryUnknown> CompositeQuerySemantics::crycomposite_query(Src*, const char*, bool*); \
|
||||
template <class Src> \
|
||||
friend AZStd::shared_ptr<const ICryUnknown> CompositeQuerySemantics::crycomposite_query(const Src*, const char*, bool*); \
|
||||
template <class Src> \
|
||||
friend AZStd::shared_ptr<ICryUnknown> CompositeQuerySemantics::crycomposite_query(const AZStd::shared_ptr<Src>&, const char*, bool*); \
|
||||
template <class Src> \
|
||||
friend AZStd::shared_ptr<const ICryUnknown> CompositeQuerySemantics::crycomposite_query(const AZStd::shared_ptr<const Src>&, const char*, bool*);
|
||||
} // namespace CompositeQuerySemantics
|
||||
|
||||
using CompositeQuerySemantics::crycomposite_query;
|
||||
|
||||
|
||||
#define _BEFRIEND_MAKE_SHARED() \
|
||||
template <class T> \
|
||||
friend class AZStd::Internal::sp_ms_deleter; \
|
||||
template <class T> \
|
||||
friend AZStd::shared_ptr<T> AZStd::make_shared(); \
|
||||
template <class T, class A> \
|
||||
friend AZStd::shared_ptr<T> AZStd::allocate_shared(A const& a);
|
||||
|
||||
// prevent explicit destruction from client side
|
||||
#define _PROTECTED_DTOR(iname) \
|
||||
protected: \
|
||||
virtual ~iname() {}
|
||||
|
||||
|
||||
// Befriending cryinterface_cast<T>() and crycomposite_query() via CRYINTERFACE_DECLARE is actually only needed for ICryUnknown
|
||||
// since QueryInterface() and QueryComposite() are usually not redeclared in derived interfaces but it doesn't hurt either
|
||||
#define CRYINTERFACE_DECLARE(iname, iidHigh, iidLow) \
|
||||
_BEFRIEND_CRYIIDOF() \
|
||||
_BEFRIEND_CRYINTERFACE_CAST() \
|
||||
_BEFRIEND_CRYCOMPOSITE_QUERY() \
|
||||
_BEFRIEND_MAKE_SHARED() \
|
||||
_PROTECTED_DTOR(iname) \
|
||||
\
|
||||
private: \
|
||||
static const CryInterfaceID& IID() \
|
||||
{ \
|
||||
static const CryInterfaceID iid = {(uint64) iidHigh##LL, (uint64) iidLow##LL}; \
|
||||
return iid; \
|
||||
} \
|
||||
public:
|
||||
|
||||
|
||||
struct ICryUnknown
|
||||
{
|
||||
CRYINTERFACE_DECLARE(ICryUnknown, 0x1000000010001000, 0x1000100000000000)
|
||||
|
||||
virtual ICryFactory * GetFactory() const = 0;
|
||||
|
||||
protected:
|
||||
virtual void* QueryInterface(const CryInterfaceID& iid) const = 0;
|
||||
virtual void* QueryComposite(const char* name) const = 0;
|
||||
};
|
||||
|
||||
DECLARE_SMART_POINTERS(ICryUnknown);
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_ICRYUNKNOWN_H
|
||||
@ -1,461 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_IMPL_CLASSWEAVER_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_IMPL_CLASSWEAVER_H
|
||||
#pragma once
|
||||
|
||||
#include "TypeList.h"
|
||||
#include "Conversion.h"
|
||||
#include "RegFactoryNode.h"
|
||||
#include "../ICryUnknown.h"
|
||||
#include "../ICryFactory.h"
|
||||
#include <AzCore/Memory/Memory.h>
|
||||
|
||||
namespace CW
|
||||
{
|
||||
namespace Internal
|
||||
{
|
||||
template <class Dst>
|
||||
struct InterfaceCast;
|
||||
|
||||
template <class Dst>
|
||||
struct InterfaceCast
|
||||
{
|
||||
template <class T>
|
||||
static void* Op(T* p)
|
||||
{
|
||||
return (Dst*) p;
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct InterfaceCast<ICryUnknown>
|
||||
{
|
||||
template <class T>
|
||||
static void* Op(T* p)
|
||||
{
|
||||
return const_cast<ICryUnknown*>(static_cast<const ICryUnknown*>(static_cast<const void*>(p)));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
template <class TList>
|
||||
struct InterfaceCast;
|
||||
|
||||
template <>
|
||||
struct InterfaceCast<TL::NullType>
|
||||
{
|
||||
template <class T>
|
||||
static void* Op(T*, const CryInterfaceID&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct InterfaceCast<TL::Typelist<Head, Tail> >
|
||||
{
|
||||
template <class T>
|
||||
static void* Op(T* p, const CryInterfaceID& iid)
|
||||
{
|
||||
if (cryiidof<Head>() == iid)
|
||||
{
|
||||
return Internal::InterfaceCast<Head>::Op(p);
|
||||
}
|
||||
return InterfaceCast<Tail>::Op(p, iid);
|
||||
}
|
||||
};
|
||||
|
||||
template <class TList>
|
||||
struct FillIIDs;
|
||||
|
||||
template <>
|
||||
struct FillIIDs<TL::NullType>
|
||||
{
|
||||
static void Op(CryInterfaceID*)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct FillIIDs<TL::Typelist<Head, Tail> >
|
||||
{
|
||||
static void Op(CryInterfaceID* p)
|
||||
{
|
||||
*p++ = cryiidof<Head>();
|
||||
FillIIDs<Tail>::Op(p);
|
||||
}
|
||||
};
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
template <bool, typename S>
|
||||
struct PickList;
|
||||
|
||||
template <bool, typename S>
|
||||
struct PickList
|
||||
{
|
||||
typedef TL::BuildTypelist<>::Result Result;
|
||||
};
|
||||
|
||||
template <typename S>
|
||||
struct PickList<true, S>
|
||||
{
|
||||
typedef typename S::FullCompositeList Result;
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct ProbeFullCompositeList
|
||||
{
|
||||
private:
|
||||
typedef char y[1];
|
||||
typedef char n[2];
|
||||
|
||||
template <typename S>
|
||||
static y& test(typename S::FullCompositeList*);
|
||||
|
||||
template <typename>
|
||||
static n& test(...);
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
listFound = sizeof(test<T>(0)) == sizeof(y)
|
||||
};
|
||||
|
||||
typedef typename Internal::PickList<listFound, T>::Result ListType;
|
||||
};
|
||||
|
||||
namespace Internal
|
||||
{
|
||||
template <class TList>
|
||||
struct CompositeQuery;
|
||||
|
||||
template <>
|
||||
struct CompositeQuery<TL::NullType>
|
||||
{
|
||||
template<typename T>
|
||||
static void* Op(const T&, const char*)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct CompositeQuery<TL::Typelist<Head, Tail> >
|
||||
{
|
||||
template<typename T>
|
||||
static void* Op(const T& ref, const char* name)
|
||||
{
|
||||
void* p = ref.Head::CompositeQueryImpl(name);
|
||||
return p ? p : CompositeQuery<Tail>::Op(ref, name);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
struct CompositeQuery
|
||||
{
|
||||
template <typename T>
|
||||
static void* Op(const T& ref, const char* name)
|
||||
{
|
||||
return Internal::CompositeQuery<typename ProbeFullCompositeList<T>::ListType>::Op(ref, name);
|
||||
}
|
||||
};
|
||||
|
||||
inline bool NameMatch(const char* name, const char* compositeName)
|
||||
{
|
||||
if (!name || !compositeName)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
size_t i = 0;
|
||||
for (; name[i] && name[i] == compositeName[i]; ++i)
|
||||
{
|
||||
}
|
||||
return name[i] == compositeName[i];
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void* CheckCompositeMatch(const char* name, const AZStd::shared_ptr<T>& composite, const char* compositeName)
|
||||
{
|
||||
typedef TC::SuperSubClass<ICryUnknown, T> Rel;
|
||||
COMPILE_TIME_ASSERT(Rel::exists);
|
||||
return NameMatch(name, compositeName) ? const_cast<void*>(static_cast<const void*>(&composite)) : 0;
|
||||
}
|
||||
} // namespace CW
|
||||
|
||||
|
||||
#define CRYINTERFACE_BEGIN() \
|
||||
private: \
|
||||
typedef TL::BuildTypelist < ICryUnknown
|
||||
|
||||
#define CRYINTERFACE_ADD(iname) , iname
|
||||
|
||||
#define CRYINTERFACE_END() > ::Result _UserDefinedPartialInterfaceList; \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_UserDefinedPartialInterfaceList>::Result FullInterfaceList;
|
||||
|
||||
#define _CRY_TPL_APPEND0(base) TL::Append<base::FullInterfaceList, _UserDefinedPartialInterfaceList>::Result
|
||||
#define _CRY_TPL_APPEND(base, intermediate) TL::Append<base::FullInterfaceList, intermediate>::Result
|
||||
|
||||
#define CRYINTERFACE_ENDWITHBASE(base) > ::Result _UserDefinedPartialInterfaceList; \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_CRY_TPL_APPEND0(base)>::Result FullInterfaceList;
|
||||
|
||||
#define CRYINTERFACE_ENDWITHBASE2(base0, base1) > ::Result _UserDefinedPartialInterfaceList; \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_CRY_TPL_APPEND(base0, _CRY_TPL_APPEND0(base1))>::Result FullInterfaceList;
|
||||
|
||||
#define CRYINTERFACE_ENDWITHBASE3(base0, base1, base2) > ::Result _UserDefinedPartialInterfaceList; \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_CRY_TPL_APPEND(base0, _CRY_TPL_APPEND(base1, _CRY_TPL_APPEND0(base2)))>::Result FullInterfaceList;
|
||||
|
||||
#define CRYINTERFACE_SIMPLE(iname) \
|
||||
CRYINTERFACE_BEGIN() \
|
||||
CRYINTERFACE_ADD(iname) \
|
||||
CRYINTERFACE_END()
|
||||
|
||||
#define CRYCOMPOSITE_BEGIN() \
|
||||
private: \
|
||||
void* CompositeQueryImpl(const char* name) const \
|
||||
{ \
|
||||
(void)(name); \
|
||||
void* res = 0; (void)(res); \
|
||||
|
||||
#define CRYCOMPOSITE_ADD(member, membername) \
|
||||
COMPILE_TIME_ASSERT((sizeof(membername) / sizeof(membername[0])) > 1); \
|
||||
if ((res = CW::CheckCompositeMatch(name, member, membername)) != 0) { \
|
||||
return res; }
|
||||
|
||||
#define _CRYCOMPOSITE_END(implclassname) \
|
||||
return 0; \
|
||||
}; \
|
||||
protected: \
|
||||
typedef TL::BuildTypelist<implclassname>::Result _PartialCompositeList; \
|
||||
\
|
||||
template <bool, typename S> \
|
||||
friend struct CW::Internal::PickList;
|
||||
|
||||
#define CRYCOMPOSITE_END(implclassname) \
|
||||
_CRYCOMPOSITE_END(implclassname) \
|
||||
protected: \
|
||||
typedef _PartialCompositeList FullCompositeList;
|
||||
|
||||
#define _CRYCOMPOSITE_APPEND0(base) TL::Append<_PartialCompositeList, CW::ProbeFullCompositeList<base>::ListType>::Result
|
||||
#define _CRYCOMPOSITE_APPEND(base, intermediate) TL::Append<intermediate, CW::ProbeFullCompositeList<base>::ListType>::Result
|
||||
|
||||
#define CRYCOMPOSITE_ENDWITHBASE(implclassname, base) \
|
||||
_CRYCOMPOSITE_END(implclassname) \
|
||||
protected: \
|
||||
typedef _CRYCOMPOSITE_APPEND0 (base) FullCompositeList;
|
||||
|
||||
#define CRYCOMPOSITE_ENDWITHBASE2(implclassname, base0, base1) \
|
||||
_CRYCOMPOSITE_END(implclassname) \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_CRYCOMPOSITE_APPEND(base1, _CRYCOMPOSITE_APPEND0(base0))>::Result FullCompositeList;
|
||||
|
||||
#define CRYCOMPOSITE_ENDWITHBASE3(implclassname, base0, base1, base2) \
|
||||
_CRYCOMPOSITE_END(implclassname) \
|
||||
protected: \
|
||||
typedef TL::NoDuplicates<_CRYCOMPOSITE_APPEND(base2, _CRYCOMPOSITE_APPEND(base1, _CRYCOMPOSITE_APPEND0(base0)))>::Result FullCompositeList;
|
||||
|
||||
template<typename T>
|
||||
class CFactory
|
||||
: public ICryFactory
|
||||
{
|
||||
public:
|
||||
virtual const char* GetName() const
|
||||
{
|
||||
return T::GetCName();
|
||||
}
|
||||
|
||||
virtual const CryClassID& GetClassID() const
|
||||
{
|
||||
return T::GetCID();
|
||||
}
|
||||
|
||||
virtual bool ClassSupports(const CryInterfaceID& iid) const
|
||||
{
|
||||
for (size_t i = 0; i < m_numIIDs; ++i)
|
||||
{
|
||||
if (iid == m_pIIDs[i])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual void ClassSupports(const CryInterfaceID*& pIIDs, size_t& numIIDs) const
|
||||
{
|
||||
pIIDs = m_pIIDs;
|
||||
numIIDs = m_numIIDs;
|
||||
}
|
||||
public:
|
||||
virtual ICryUnknownPtr CreateClassInstance() const
|
||||
{
|
||||
AZStd::shared_ptr<T> p = AZStd::make_shared<T>();
|
||||
return cryinterface_cast<ICryUnknown> (p);
|
||||
}
|
||||
|
||||
CFactory<T>()
|
||||
: m_numIIDs(0)
|
||||
, m_pIIDs(0)
|
||||
, m_regFactory()
|
||||
{
|
||||
static CryInterfaceID supportedIIDs[TL::Length < typename T::FullInterfaceList > ::value];
|
||||
CW::FillIIDs<typename T::FullInterfaceList>::Op(supportedIIDs);
|
||||
m_pIIDs = &supportedIIDs[0];
|
||||
m_numIIDs = TL::Length<typename T::FullInterfaceList>::value;
|
||||
new(&m_regFactory)SRegFactoryNode(this);
|
||||
}
|
||||
|
||||
protected:
|
||||
CFactory(const CFactory&);
|
||||
CFactory& operator =(const CFactory&);
|
||||
|
||||
|
||||
size_t m_numIIDs;
|
||||
CryInterfaceID* m_pIIDs;
|
||||
SRegFactoryNode m_regFactory;
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
class CSingletonFactory
|
||||
: public CFactory<T>
|
||||
{
|
||||
public:
|
||||
CSingletonFactory()
|
||||
: CFactory<T>()
|
||||
, m_csCreateClassInstance()
|
||||
{
|
||||
}
|
||||
|
||||
virtual ICryUnknownPtr CreateClassInstance() const
|
||||
{
|
||||
CryAutoLock<CryCriticalSection> lock(m_csCreateClassInstance);
|
||||
// override the allocator. These function static instances are being destroyed after the AZ alloctor has been deleted.
|
||||
// On win, TerminateProcess() prevents these destructors from being called, but that is not the case on OSX.
|
||||
static typename AZStd::aligned_storage<sizeof(AZStd::Internal::sp_counted_impl_pda<T*, AZStd::Internal::sp_ms_deleter<T>,SingletonAllocator>), AZStd::alignment_of<T>::value>::type m_storage;
|
||||
static ICryUnknownPtr p = AZStd::allocate_shared<T>(SingletonAllocator(AZStd::addressof(m_storage)));
|
||||
return p;
|
||||
}
|
||||
|
||||
mutable CryCriticalSection m_csCreateClassInstance;
|
||||
|
||||
struct SingletonAllocator
|
||||
{
|
||||
SingletonAllocator(void* ptr) :
|
||||
m_data(ptr)
|
||||
{}
|
||||
void* allocate(size_t /*byteSize*/, size_t /*alignment*/, int /*flags*/ = 0)
|
||||
{
|
||||
return m_data;
|
||||
}
|
||||
void deallocate(void* /*ptr*/, size_t /*byteSize*/, size_t /*alignment*/)
|
||||
{
|
||||
// nothing to see here
|
||||
}
|
||||
void* m_data;
|
||||
};
|
||||
};
|
||||
|
||||
#define _CRYFACTORY_DECLARE(implclassname) \
|
||||
private: \
|
||||
friend class CFactory<implclassname>; \
|
||||
static CFactory<implclassname> s_factory;
|
||||
|
||||
#define _CRYFACTORY_DECLARE_SINGLETON(implclassname) \
|
||||
private: \
|
||||
friend class CFactory<implclassname>; \
|
||||
friend void* Get##implclassname##Factory(); \
|
||||
static CSingletonFactory<implclassname> s_factory;
|
||||
|
||||
#define _IMPLEMENT_ICRYUNKNOWN() \
|
||||
public: \
|
||||
virtual ICryFactory* GetFactory() const \
|
||||
{ \
|
||||
return &s_factory; \
|
||||
} \
|
||||
\
|
||||
protected: \
|
||||
virtual void* QueryInterface(const CryInterfaceID&iid) const \
|
||||
{ \
|
||||
return CW::InterfaceCast<FullInterfaceList>::Op(this, iid); \
|
||||
} \
|
||||
\
|
||||
template <class TList> \
|
||||
friend struct CW::Internal::CompositeQuery; \
|
||||
\
|
||||
virtual void* QueryComposite(const char* name) const \
|
||||
{ \
|
||||
return CW::CompositeQuery::Op(*this, name); \
|
||||
}
|
||||
|
||||
#define _ENFORCE_CRYFACTORY_USAGE(implclassname, cname, cidHigh, cidLow) \
|
||||
public: \
|
||||
static const char* GetCName() \
|
||||
{ \
|
||||
return cname; \
|
||||
} \
|
||||
static const CryClassID& GetCID() \
|
||||
{ \
|
||||
static const CryClassID cid = {(uint64) cidHigh##LL, (uint64) cidLow##LL}; \
|
||||
return cid; \
|
||||
} \
|
||||
static AZStd::shared_ptr<implclassname> CreateClassInstance() \
|
||||
{ \
|
||||
ICryUnknownPtr p = s_factory.CreateClassInstance(); \
|
||||
return AZStd::shared_ptr<implclassname>(*static_cast<AZStd::shared_ptr<implclassname>*>(static_cast<void*>(&p))); \
|
||||
} \
|
||||
\
|
||||
protected: \
|
||||
implclassname(); \
|
||||
virtual ~implclassname();
|
||||
|
||||
#define _BEFRIEND_OPS() \
|
||||
_BEFRIEND_CRYINTERFACE_CAST() \
|
||||
_BEFRIEND_CRYCOMPOSITE_QUERY() \
|
||||
_BEFRIEND_MAKE_SHARED()
|
||||
|
||||
#define CRYGENERATE_CLASS(implclassname, cname, cidHigh, cidLow) \
|
||||
_CRYFACTORY_DECLARE(implclassname) \
|
||||
_BEFRIEND_OPS() \
|
||||
_IMPLEMENT_ICRYUNKNOWN() \
|
||||
_ENFORCE_CRYFACTORY_USAGE(implclassname, cname, cidHigh, cidLow)
|
||||
|
||||
#define CRYGENERATE_SINGLETONCLASS(implclassname, cname, cidHigh, cidLow) \
|
||||
_CRYFACTORY_DECLARE_SINGLETON(implclassname) \
|
||||
_BEFRIEND_OPS() \
|
||||
_IMPLEMENT_ICRYUNKNOWN() \
|
||||
_ENFORCE_CRYFACTORY_USAGE(implclassname, cname, cidHigh, cidLow)
|
||||
|
||||
|
||||
#define CRYREGISTER_CLASS(implclassname) \
|
||||
CFactory<implclassname> implclassname::s_factory;
|
||||
|
||||
#define DECLARE_CRYREGISTER_SINGLETON_CLASS(implclassname) \
|
||||
void* Get##implclassname##Factory();
|
||||
|
||||
#define CRYREGISTER_SINGLETON_CLASS(implclassname) \
|
||||
CSingletonFactory<implclassname> implclassname::s_factory; \
|
||||
void* Get##implclassname##Factory() { \
|
||||
return &implclassname::s_factory; \
|
||||
}
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_IMPL_CLASSWEAVER_H
|
||||
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_IMPL_CONVERSION_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_IMPL_CONVERSION_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace TC
|
||||
{
|
||||
//template <class T, class U>
|
||||
//struct Conversion
|
||||
//{
|
||||
//private:
|
||||
// typedef char y[1];
|
||||
// typedef char n[2];
|
||||
// static y& Test(U);
|
||||
// static n& Test(...);
|
||||
// static T MakeT();
|
||||
|
||||
//public:
|
||||
// enum
|
||||
// {
|
||||
// exists = sizeof(Test(MakeT())) == sizeof(y),
|
||||
// sameType = false
|
||||
// };
|
||||
//};
|
||||
|
||||
//template <class T>
|
||||
//struct Conversion<T, T>
|
||||
//{
|
||||
//public:
|
||||
// enum
|
||||
// {
|
||||
// exists = true,
|
||||
// sameType = true
|
||||
// };
|
||||
//};
|
||||
|
||||
//template<typename Base, typename Derived>
|
||||
//struct CheckInheritance
|
||||
//{
|
||||
// enum
|
||||
// {
|
||||
// exists = Conversion<const Derived*, const Base*>::exists && !Conversion<const Base*, const void*>::sameType
|
||||
// };
|
||||
//};
|
||||
|
||||
//template<typename Base, typename Derived>
|
||||
//struct CheckStrictInheritance
|
||||
//{
|
||||
// enum
|
||||
// {
|
||||
// exists = CheckInheritance<Base, Derived>::exists && !Conversion<const Base*, const Derived*>::sameType
|
||||
// };
|
||||
//};
|
||||
|
||||
|
||||
template <typename Base, typename Derived>
|
||||
struct SuperSubClass
|
||||
{
|
||||
private:
|
||||
typedef char y[1];
|
||||
typedef char n[2];
|
||||
|
||||
template<typename T>
|
||||
static y& check(const volatile Derived&, T);
|
||||
static n& check(const volatile Base&, int);
|
||||
|
||||
struct C
|
||||
{
|
||||
operator const volatile Base&() const;
|
||||
operator const volatile Derived&();
|
||||
};
|
||||
|
||||
static C getC();
|
||||
|
||||
public:
|
||||
enum
|
||||
{
|
||||
exists = sizeof(check(getC(), 0)) == sizeof(y),
|
||||
sameType = false
|
||||
};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
struct SuperSubClass<T, T>
|
||||
{
|
||||
enum
|
||||
{
|
||||
exists = true
|
||||
};
|
||||
};
|
||||
} // namespace TC
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_IMPL_CONVERSION_H
|
||||
@ -1,67 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_IMPL_CRYGUIDHELPER_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_IMPL_CRYGUIDHELPER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../CryGUID.h"
|
||||
#include "../../CryString.h"
|
||||
|
||||
|
||||
namespace CryGUIDHelper
|
||||
{
|
||||
string Print(const CryGUID& val)
|
||||
{
|
||||
char buf[39]; // sizeof("{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}")
|
||||
|
||||
static const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
|
||||
char* p = buf;
|
||||
*p++ = '{';
|
||||
for (int i = 15; i >= 8; --i)
|
||||
{
|
||||
*p++ = hex[(unsigned char) ((val.hipart >> (i << 2)) & 0xF)];
|
||||
}
|
||||
*p++ = '-';
|
||||
for (int i = 7; i >= 4; --i)
|
||||
{
|
||||
*p++ = hex[(unsigned char) ((val.hipart >> (i << 2)) & 0xF)];
|
||||
}
|
||||
*p++ = '-';
|
||||
for (int i = 3; i >= 0; --i)
|
||||
{
|
||||
*p++ = hex[(unsigned char) ((val.hipart >> (i << 2)) & 0xF)];
|
||||
}
|
||||
*p++ = '-';
|
||||
for (int i = 15; i >= 12; --i)
|
||||
{
|
||||
*p++ = hex[(unsigned char) ((val.lopart >> (i << 2)) & 0xF)];
|
||||
}
|
||||
*p++ = '-';
|
||||
for (int i = 11; i >= 0; --i)
|
||||
{
|
||||
*p++ = hex[(unsigned char) ((val.lopart >> (i << 2)) & 0xF)];
|
||||
}
|
||||
*p++ = '}';
|
||||
*p++ = '\0';
|
||||
|
||||
return string(buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_IMPL_CRYGUIDHELPER_H
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_IMPL_ICRYFACTORYREGISTRYIMPL_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_IMPL_ICRYFACTORYREGISTRYIMPL_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "../ICryFactoryRegistry.h"
|
||||
|
||||
|
||||
struct SRegFactoryNode;
|
||||
|
||||
|
||||
struct ICryFactoryRegistryCallback
|
||||
{
|
||||
virtual void OnNotifyFactoryRegistered(ICryFactory* pFactory) = 0;
|
||||
virtual void OnNotifyFactoryUnregistered(ICryFactory* pFactory) = 0;
|
||||
|
||||
protected:
|
||||
virtual ~ICryFactoryRegistryCallback() {}
|
||||
};
|
||||
|
||||
|
||||
struct ICryFactoryRegistryImpl
|
||||
: public ICryFactoryRegistry
|
||||
{
|
||||
virtual ICryFactory* GetFactory(const char* cname) const = 0;
|
||||
virtual ICryFactory* GetFactory(const CryClassID& cid) const = 0;
|
||||
virtual void IterateFactories(const CryInterfaceID& iid, ICryFactory** pFactories, size_t& numFactories) const = 0;
|
||||
|
||||
virtual void RegisterCallback(ICryFactoryRegistryCallback* pCallback) = 0;
|
||||
virtual void UnregisterCallback(ICryFactoryRegistryCallback* pCallback) = 0;
|
||||
|
||||
virtual void RegisterFactories(const SRegFactoryNode* pFactories) = 0;
|
||||
virtual void UnregisterFactories(const SRegFactoryNode* pFactories) = 0;
|
||||
|
||||
virtual void UnregisterFactory(ICryFactory* const pFactory) = 0;
|
||||
|
||||
protected:
|
||||
// prevent explicit destruction from client side (delete, shared_ptr, etc)
|
||||
virtual ~ICryFactoryRegistryImpl() {}
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_IMPL_ICRYFACTORYREGISTRYIMPL_H
|
||||
@ -1,52 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_IMPL_REGFACTORYNODE_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_IMPL_REGFACTORYNODE_H
|
||||
#pragma once
|
||||
|
||||
struct ICryFactory;
|
||||
struct SRegFactoryNode;
|
||||
|
||||
extern SRegFactoryNode* g_pHeadToRegFactories;
|
||||
|
||||
struct SRegFactoryNode
|
||||
{
|
||||
SRegFactoryNode()
|
||||
{
|
||||
}
|
||||
|
||||
SRegFactoryNode(ICryFactory* pFactory)
|
||||
: m_pFactory(pFactory)
|
||||
, m_pNext(g_pHeadToRegFactories)
|
||||
{
|
||||
g_pHeadToRegFactories = this;
|
||||
}
|
||||
|
||||
static void* operator new(size_t, void* p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
static void operator delete(void*, void*)
|
||||
{
|
||||
}
|
||||
|
||||
ICryFactory* m_pFactory;
|
||||
SRegFactoryNode* m_pNext;
|
||||
};
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_IMPL_REGFACTORYNODE_H
|
||||
@ -1,236 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
// Description : Part of CryEngine's extension framework.
|
||||
|
||||
|
||||
#ifndef CRYINCLUDE_CRYEXTENSION_TYPELIST_H
|
||||
#define CRYINCLUDE_CRYEXTENSION_TYPELIST_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace TL
|
||||
{
|
||||
// typelist terminator
|
||||
class NullType
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
// structure for typelist generation
|
||||
template <class T, class U = NullType>
|
||||
struct Typelist
|
||||
{
|
||||
typedef T Head;
|
||||
typedef U Tail;
|
||||
};
|
||||
|
||||
|
||||
// helper structure to automatically build typelists containing n types
|
||||
template
|
||||
<
|
||||
typename T0 = NullType, typename T1 = NullType, typename T2 = NullType, typename T3 = NullType, typename T4 = NullType,
|
||||
typename T5 = NullType, typename T6 = NullType, typename T7 = NullType, typename T8 = NullType, typename T9 = NullType,
|
||||
typename T10 = NullType, typename T11 = NullType, typename T12 = NullType, typename T13 = NullType, typename T14 = NullType,
|
||||
typename T15 = NullType, typename T16 = NullType, typename T17 = NullType, typename T18 = NullType, typename T19 = NullType
|
||||
>
|
||||
struct BuildTypelist
|
||||
{
|
||||
private:
|
||||
typedef typename BuildTypelist<T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19>::Result TailResult;
|
||||
|
||||
public:
|
||||
typedef Typelist<T0, TailResult> Result;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct BuildTypelist<>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
// typelist operation : Length
|
||||
template <class TList>
|
||||
struct Length;
|
||||
|
||||
template <>
|
||||
struct Length<NullType>
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = 0
|
||||
};
|
||||
};
|
||||
|
||||
template <class T, class U>
|
||||
struct Length<Typelist<T, U> >
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = 1 + Length<U>::value
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : TypeAt
|
||||
template <class TList, unsigned int index>
|
||||
struct TypeAt;
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct TypeAt<Typelist<Head, Tail>, 0>
|
||||
{
|
||||
typedef Head Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail, unsigned int index>
|
||||
struct TypeAt<Typelist<Head, Tail>, index>
|
||||
{
|
||||
typedef typename TypeAt<Tail, index - 1>::Result Result;
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : IndexOf
|
||||
template <class TList, class T>
|
||||
struct IndexOf;
|
||||
|
||||
template <class T>
|
||||
struct IndexOf<NullType, T>
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = -1
|
||||
};
|
||||
};
|
||||
|
||||
template <class T, class Tail>
|
||||
struct IndexOf<Typelist<T, Tail>, T>
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = 0
|
||||
};
|
||||
};
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct IndexOf<Typelist<Head, Tail>, T>
|
||||
{
|
||||
private:
|
||||
enum
|
||||
{
|
||||
temp = IndexOf<Tail, T>::value
|
||||
};
|
||||
public:
|
||||
enum
|
||||
{
|
||||
value = temp == -1 ? -1 : 1 + temp
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : Append
|
||||
template <class TList, class T>
|
||||
struct Append;
|
||||
|
||||
template <>
|
||||
struct Append<NullType, NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
struct Append<NullType, T>
|
||||
{
|
||||
typedef Typelist<T, NullType> Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct Append<NullType, Typelist<Head, Tail> >
|
||||
{
|
||||
typedef Typelist<Head, Tail> Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct Append<Typelist<Head, Tail>, T>
|
||||
{
|
||||
typedef Typelist<Head, typename Append<Tail, T>::Result> Result;
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : Erase
|
||||
template <class TList, class T>
|
||||
struct Erase;
|
||||
|
||||
template <class T>
|
||||
struct Erase<NullType, T>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
template <class T, class Tail>
|
||||
struct Erase<Typelist<T, Tail>, T>
|
||||
{
|
||||
typedef Tail Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct Erase<Typelist<Head, Tail>, T>
|
||||
{
|
||||
typedef Typelist<Head, typename Erase<Tail, T>::Result> Result;
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : Erase All
|
||||
template <class TList, class T>
|
||||
struct EraseAll;
|
||||
|
||||
template <class T>
|
||||
struct EraseAll<NullType, T>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
template <class T, class Tail>
|
||||
struct EraseAll<Typelist<T, Tail>, T>
|
||||
{
|
||||
typedef typename EraseAll<Tail, T>::Result Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail, class T>
|
||||
struct EraseAll<Typelist<Head, Tail>, T>
|
||||
{
|
||||
typedef Typelist<Head, typename EraseAll<Tail, T>::Result> Result;
|
||||
};
|
||||
|
||||
|
||||
// typelist operation : NoDuplicates
|
||||
template <class TList>
|
||||
struct NoDuplicates;
|
||||
|
||||
template <>
|
||||
struct NoDuplicates<NullType>
|
||||
{
|
||||
typedef NullType Result;
|
||||
};
|
||||
|
||||
template <class Head, class Tail>
|
||||
struct NoDuplicates<Typelist<Head, Tail> >
|
||||
{
|
||||
private:
|
||||
typedef typename NoDuplicates<Tail>::Result L1;
|
||||
typedef typename Erase<L1, Head>::Result L2;
|
||||
public:
|
||||
typedef Typelist<Head, L2> Result;
|
||||
};
|
||||
} // namespace TL
|
||||
|
||||
#endif // CRYINCLUDE_CRYEXTENSION_TYPELIST_H
|
||||
@ -1,207 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_ALLOCATOR_H
|
||||
#define CRYINCLUDE_CRYPOOL_ALLOCATOR_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
template<class TPool, class TItem>
|
||||
class CFirstFit
|
||||
: public TPool
|
||||
{
|
||||
public:
|
||||
ILINE CFirstFit()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
//fastpath?
|
||||
if (TPool::m_pEmpty && TPool::m_pEmpty->Available(Size, Align))
|
||||
{
|
||||
TItem* pItem = TPool::Split(TPool::m_pEmpty, Size, Align);
|
||||
if (!pItem)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pItem->InUse(Align);
|
||||
TPool::AllocatedMemory(pItem->MemSize());
|
||||
|
||||
//not fully occupied empty space?
|
||||
TPool::m_pEmpty = pItem != TPool::m_pEmpty ? TPool::m_pEmpty : 0;
|
||||
return TPool::Handle(pItem);
|
||||
}
|
||||
|
||||
TItem* pBestItem;
|
||||
for (pBestItem = TPool::m_Items.First(); pBestItem; pBestItem = pBestItem->Next())
|
||||
{
|
||||
if (pBestItem->Available(Size, Align)) // && (!pBestItem || pItem->MemSize()<pBestItem->MemSize()))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!pBestItem)
|
||||
{
|
||||
return 0; //out of mem
|
||||
}
|
||||
TItem* pItem = TPool::Split(pBestItem, Size, Align);
|
||||
if (!pItem) //no free node
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pItem->InUse(Align);
|
||||
TPool::AllocatedMemory(pItem->MemSize());
|
||||
|
||||
//not fully occupied empty space?
|
||||
TPool::m_pEmpty = pItem != pBestItem ? pBestItem : 0;
|
||||
return TPool::Handle(pItem);
|
||||
}
|
||||
template<class T>
|
||||
ILINE bool Free(T Handle, bool ForceBoundsCheck = false)
|
||||
{
|
||||
return Handle ? TPool::Free(Handle, ForceBoundsCheck) : false;
|
||||
}
|
||||
};
|
||||
|
||||
template<class TPool, class TItem>
|
||||
class CWorstFit
|
||||
: public TPool
|
||||
{
|
||||
public:
|
||||
ILINE CWorstFit()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
TItem* pBestItem = 0;
|
||||
for (TItem* pItem = TPool::m_Items.First(); pItem; pItem = pItem->Next())
|
||||
{
|
||||
if (pItem->IsFree() && (!pBestItem || pItem->MemSize() > pBestItem->MemSize()))
|
||||
{
|
||||
pBestItem = pItem;
|
||||
}
|
||||
}
|
||||
if (!pBestItem || !pBestItem->Available(Size, Align))
|
||||
{
|
||||
return 0; //out of mem
|
||||
}
|
||||
TItem* pItem = Split(pBestItem, Size, Align);
|
||||
if (!pItem) //no free node
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pItem->InUse(Align);
|
||||
AllocatedMemory(pItem->MemSize());
|
||||
return Handle(pItem);
|
||||
}
|
||||
};
|
||||
|
||||
template<class TPool, class TItem>
|
||||
class CBestFit
|
||||
: public TPool
|
||||
{
|
||||
public:
|
||||
ILINE CBestFit()
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
TItem* pBestItem = 0;
|
||||
for (TItem* pItem = TPool::m_Items.First(); pItem; pItem = pItem->Next())
|
||||
{
|
||||
if ((!pBestItem || pItem->MemSize() < pBestItem->MemSize()) && pItem->Available(Size, Align))
|
||||
{
|
||||
if (pItem->MemSize() == Size)
|
||||
{
|
||||
pItem->InUse(Align);
|
||||
AllocatedMemory(pItem->MemSize());
|
||||
return (T)Handle(pItem);
|
||||
}
|
||||
pBestItem = pItem;
|
||||
}
|
||||
}
|
||||
if (!pBestItem)
|
||||
{
|
||||
return 0; //out of mem
|
||||
}
|
||||
TItem* pItem = Split(pBestItem, Size, Align);
|
||||
if (!pItem) //no free node
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
pItem->InUse(Align);
|
||||
AllocatedMemory(pItem->MemSize());
|
||||
return (T)Handle(pItem);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
template<class TAllocator>
|
||||
class CReallocator
|
||||
: public TAllocator
|
||||
{
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
ILINE bool Reallocate(T* pData, size_t Size, size_t Alignment)
|
||||
{
|
||||
//special cases
|
||||
if (!Size) //just free?
|
||||
{
|
||||
TAllocator::Free(*pData);
|
||||
*pData = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!*pData) //just alloc?
|
||||
{
|
||||
*pData = TAllocator::template Allocate<T>(Size, Alignment);
|
||||
return *pData != 0;
|
||||
}
|
||||
|
||||
//same size, nothing to do at all?
|
||||
if (TAllocator::Item(*pData)->MemSize() == Size)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (TAllocator::ReSize(pData, Size))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
T pNewData = TAllocator::template Allocate<T>(Size, Alignment);
|
||||
if (!pNewData)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
memcpy(TAllocator::template Resolve<uint8*>(pNewData),
|
||||
TAllocator::template Resolve<uint8*>(*pData), min(TAllocator::Item(*pData)->MemSize(), Size));
|
||||
TAllocator::template Free(*pData);
|
||||
*pData = pNewData;
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_ALLOCATOR_H
|
||||
|
||||
@ -1,655 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_CONTAINER_H
|
||||
#define CRYINCLUDE_CRYPOOL_CONTAINER_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
template<size_t TElementCount, class TElement>
|
||||
class CPool
|
||||
: public CMemoryStatic<TElementCount* sizeof(TElement)>
|
||||
{
|
||||
class CPoolNode;
|
||||
class CPoolNode
|
||||
: public CListItem<CPoolNode>
|
||||
{
|
||||
};
|
||||
CList<CPoolNode> m_List;
|
||||
public:
|
||||
ILINE CPool()
|
||||
{
|
||||
CPoolNode* pPrev = 0;
|
||||
CPoolNode* pNode = 0;
|
||||
for (size_t a = 1; a < TElementCount; a++) //skip first element as it would be counted as zero ptr
|
||||
{
|
||||
uint8* pData = &CMemoryStatic<TElementCount* sizeof(TElement)>::Data()[a * sizeof(TElement)];
|
||||
pNode = reinterpret_cast<CPoolNode*>(pData);
|
||||
pNode->Prev(pPrev);
|
||||
if (pPrev)
|
||||
{
|
||||
pPrev->Next(pNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_List.First(pNode);
|
||||
}
|
||||
pPrev = pNode;
|
||||
// m_List.AddLast(pNode);
|
||||
}
|
||||
if (pPrev)
|
||||
{
|
||||
pPrev->Next(0);
|
||||
m_List.Last(pPrev);
|
||||
}
|
||||
}
|
||||
ILINE uint8* Allocate([[maybe_unused]] size_t Size, [[maybe_unused]] size_t Align = 1)
|
||||
{
|
||||
CPoolNode* pNode = m_List.PopFirst();
|
||||
return reinterpret_cast<uint8*>(pNode);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE void Free(T* pData)
|
||||
{
|
||||
if (pData)
|
||||
{
|
||||
CPoolNode* pNode = reinterpret_cast<CPoolNode*>(pData);
|
||||
m_List.AddLast(pNode);
|
||||
}
|
||||
}
|
||||
|
||||
ILINE TElement& operator[](uint32 Idx)
|
||||
{
|
||||
uint8* pData = &CMemoryStatic<TElementCount* sizeof(TElement)>::Data()[Idx * sizeof(TElement)];
|
||||
return *reinterpret_cast<TElement*>(pData);
|
||||
}
|
||||
|
||||
ILINE const TElement& operator[](uint32 Idx) const
|
||||
{
|
||||
const uint8* pData = &CMemoryStatic<TElementCount* sizeof(TElement)>::Data()[Idx * sizeof(TElement)];
|
||||
return *reinterpret_cast<const TElement*>(pData);
|
||||
}
|
||||
};
|
||||
|
||||
template<class TMemory, bool BoundsCheck = false>
|
||||
class CInPlace
|
||||
: public TMemory
|
||||
{
|
||||
protected:
|
||||
CList<CListItemInPlace> m_Items;
|
||||
size_t m_Allocated;
|
||||
CListItemInPlace* m_pEmpty;
|
||||
|
||||
|
||||
ILINE void AllocatedMemory(size_t S)
|
||||
{
|
||||
m_Allocated += S + sizeof(CListItemInPlace);
|
||||
}
|
||||
ILINE void FreedMemory(size_t S)
|
||||
{
|
||||
m_Allocated -= S + sizeof(CListItemInPlace);
|
||||
}
|
||||
ILINE void Stack(CListItemInPlace* pItem)
|
||||
{
|
||||
}
|
||||
public:
|
||||
ILINE CInPlace()
|
||||
: m_Allocated(0)
|
||||
{
|
||||
}
|
||||
|
||||
ILINE void InitMem(const size_t S = 0, uint8* pData = 0)
|
||||
{
|
||||
TMemory::InitMem(S, pData);
|
||||
if (!TMemory::MemSize())
|
||||
{
|
||||
return;
|
||||
}
|
||||
pData = TMemory::Data();
|
||||
CListItemInPlace* pFirst = reinterpret_cast<CListItemInPlace*>(pData);
|
||||
CListItemInPlace* pFree = pFirst + 1;
|
||||
CListItemInPlace* pLast = reinterpret_cast<CListItemInPlace*>(pData + TMemory::MemSize()) - 1;
|
||||
m_Items.~CList<CListItemInPlace>();
|
||||
new (&m_Items)CList<CListItemInPlace>();
|
||||
m_Items.AddLast(pFirst);
|
||||
m_Items.AddLast(pFree);
|
||||
m_Items.AddLast(pLast);
|
||||
|
||||
pFirst->InUse(0); //static first item
|
||||
pFree->Free();
|
||||
pLast->InUse(0); //static last item
|
||||
m_pEmpty = pFree;
|
||||
m_Allocated = 0;
|
||||
}
|
||||
|
||||
ILINE size_t FragmentCount() const
|
||||
{
|
||||
return m_Items.Count();
|
||||
}
|
||||
|
||||
ILINE CListItemInPlace* Split(CListItemInPlace* pItem, size_t Size, size_t Align)
|
||||
{
|
||||
size_t Offset = reinterpret_cast<size_t>(pItem->Data());
|
||||
Offset += pItem->MemSize(); //ptr to end
|
||||
Offset -= Size; //minus size
|
||||
Size += Offset & (Align - 1); //adjust size to fit required alignment
|
||||
Offset -= Offset & (Align - 1);
|
||||
size_t TSize = sizeof(CListItemInPlace);
|
||||
Offset -= TSize; //header
|
||||
|
||||
if (Offset <= reinterpret_cast<size_t>(pItem + 1)) //not enough space for splitting?
|
||||
{
|
||||
return pItem;
|
||||
}
|
||||
|
||||
CListItemInPlace* pItemNext = reinterpret_cast<CListItemInPlace*>(Offset);
|
||||
|
||||
const size_t Offset2 = reinterpret_cast<size_t>(pItemNext->Data());
|
||||
CPA_ASSERT(!(Offset2 & (Align - 1)));
|
||||
m_Items.AddBehind(pItemNext, pItem);
|
||||
//pItemNext->Prev(pItem);
|
||||
//pItemNext->Next(pItem->Next());
|
||||
|
||||
// if(pItem->Next())
|
||||
// pItem->Next()->Prev(pItemNext);
|
||||
|
||||
// pItem->Next(pItemNext);
|
||||
pItemNext->Free();
|
||||
return pItemNext;
|
||||
}
|
||||
|
||||
ILINE void Merge(CListItemInPlace* pItem)
|
||||
{
|
||||
//merge with next if possible
|
||||
CListItemInPlace* pItemNext = pItem->Next();
|
||||
if (pItemNext->IsFree())
|
||||
{
|
||||
if (m_pEmpty == pItemNext)
|
||||
{
|
||||
m_pEmpty = pItem;
|
||||
}
|
||||
m_Items.Remove(pItemNext);
|
||||
//pItem->Next(pItemNext->Next());
|
||||
//pItem->Next()->Prev(pItem);
|
||||
}
|
||||
//merge with prev if possible
|
||||
CListItemInPlace* pItemPrev = pItem->Prev();
|
||||
if (pItemPrev->IsFree())
|
||||
{
|
||||
if (m_pEmpty == pItem)
|
||||
{
|
||||
m_pEmpty = pItemPrev;
|
||||
}
|
||||
m_Items.Remove(pItem);
|
||||
//pItemPrev->Next(pItem->Next());
|
||||
//pItem->Next()->Prev(pItemPrev);
|
||||
pItem = pItemPrev;
|
||||
}
|
||||
}
|
||||
template<class T>
|
||||
ILINE T Resolve(void* rItem) const
|
||||
{
|
||||
return reinterpret_cast<T>(rItem);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE size_t Size(const T* pData) const
|
||||
{
|
||||
const CListItemInPlace* pItem = Item(pData);
|
||||
return pItem->MemSize();
|
||||
}
|
||||
|
||||
bool InBounds(const void* pData, const bool Check) const
|
||||
{
|
||||
return !Check || (
|
||||
reinterpret_cast<size_t>(pData) >= reinterpret_cast<size_t>(TMemory::Data()) &&
|
||||
reinterpret_cast<size_t>(pData) < reinterpret_cast<size_t>(TMemory::Data()) + TMemory::MemSize());
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE bool Free(T* pData, bool ForceBoundsCheck = false)
|
||||
{
|
||||
if (pData && InBounds(pData, BoundsCheck | ForceBoundsCheck))
|
||||
{
|
||||
CListItemInPlace* pItem = Item(pData);
|
||||
FreedMemory(pItem->MemSize());
|
||||
pItem->Free();
|
||||
Merge(pItem);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ILINE bool Beat(){return false; }//dummy beat in case no defragmentator is wraping
|
||||
ILINE size_t MemFree() const{return TMemory::MemSize() - m_Allocated; }
|
||||
ILINE size_t MemSize() const{return TMemory::MemSize(); }
|
||||
|
||||
ILINE uint8* Handle(CListItemInPlace* pItem) const
|
||||
{
|
||||
return pItem->Data();
|
||||
}
|
||||
template<class T>
|
||||
ILINE CListItemInPlace* Item(T* pData)
|
||||
{
|
||||
return reinterpret_cast<CListItemInPlace*>(pData) - 1;
|
||||
}
|
||||
template<class T>
|
||||
ILINE const CListItemInPlace* Item(const T* pData) const
|
||||
{
|
||||
return reinterpret_cast<const CListItemInPlace*>(pData) - 1;
|
||||
}
|
||||
ILINE static bool Defragmentable(){return false; }
|
||||
|
||||
template<class T>
|
||||
ILINE bool ReSize(T* pData, size_t SizeNew)
|
||||
{
|
||||
//special cases
|
||||
CListItemInPlace* pItem = Item(*pData);
|
||||
const size_t SizeOld = pItem->MemSize();
|
||||
|
||||
//reduction
|
||||
if (SizeOld > SizeNew)
|
||||
{
|
||||
if (pItem->Next()->IsFree())
|
||||
{
|
||||
CListItemInPlace* pNextNext = pItem->Next()->Next();
|
||||
size_t Offset = reinterpret_cast<size_t>(pItem->Data());
|
||||
Offset += SizeNew; //Offset to next
|
||||
CListItemInPlace* pItemNext = reinterpret_cast<CListItemInPlace*>(Offset);
|
||||
pItem->Next(pItemNext);
|
||||
pNextNext->Prev(pItemNext);
|
||||
pItemNext->Prev(pItem);
|
||||
pItemNext->Next(pNextNext);
|
||||
pItemNext->Free();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SizeOld - SizeNew <= sizeof(CListItemInPlace))
|
||||
{
|
||||
return true; //header is bigger than the amount of freed memory
|
||||
}
|
||||
//split
|
||||
size_t Offset = reinterpret_cast<size_t>(pItem->Data());
|
||||
Offset += SizeNew; //Offset to next
|
||||
CListItemInPlace* pItemNext = reinterpret_cast<CListItemInPlace*>(Offset);
|
||||
m_Items.AddBehind(pItemNext, pItem);
|
||||
pItemNext->Free();
|
||||
return true;
|
||||
}
|
||||
|
||||
//SizeOld<SizeNew grow
|
||||
CListItemInPlace* pNext = pItem->Next();
|
||||
CListItemInPlace* pNextNext = pNext->Next();
|
||||
const size_t SizeNext = pNext->IsFree() ? pNext->MemSize() + sizeof(CListItemInPlace) : 0;
|
||||
if (SizeNew <= SizeNext + SizeOld)
|
||||
{
|
||||
if (SizeNew + sizeof(CListItemInPlace) + 1 < SizeNext + SizeOld)
|
||||
{
|
||||
size_t Offset = reinterpret_cast<size_t>(pItem->Data());
|
||||
Offset += SizeNew; //Offset to next
|
||||
CListItemInPlace* pItemNext = reinterpret_cast<CListItemInPlace*>(Offset);
|
||||
pItem->Next(pItemNext);
|
||||
pNextNext->Prev(pItemNext);
|
||||
pItemNext->Prev(pItem);
|
||||
pItemNext->Next(pNextNext);
|
||||
pItemNext->Free();
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->Next(pNextNext);
|
||||
pNextNext->Prev(pItem);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false; //no further in-place realloc possible
|
||||
}
|
||||
};
|
||||
|
||||
template<class TMemory, size_t TNodeCount, bool BoundsCheck = false>
|
||||
class CReferenced
|
||||
: public TMemory
|
||||
{
|
||||
typedef CPool<TNodeCount, CListItemReference> tdNodePool;
|
||||
|
||||
protected:
|
||||
tdNodePool m_NodePool;
|
||||
CList<CListItemReference> m_Items;
|
||||
size_t m_Allocated;
|
||||
CListItemReference* m_pEmpty;
|
||||
|
||||
ILINE void AllocatedMemory(size_t S)
|
||||
{
|
||||
m_Allocated += S;
|
||||
}
|
||||
ILINE void FreedMemory(size_t S)
|
||||
{
|
||||
m_Allocated -= S;
|
||||
}
|
||||
ILINE void Stack(CListItemReference* pItem)
|
||||
{
|
||||
m_Items.Validate(pItem);
|
||||
CListItemReference* pItem2 = 0;
|
||||
CListItemReference* pNext = pItem->Next();
|
||||
uint8* pData = pItem->Data(pNext->Align());
|
||||
if (pData != pItem->Data()) //needs splitting 'cause of alignment?
|
||||
{
|
||||
pItem2 = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
if (!pItem2) //no free node found for splitting?
|
||||
{
|
||||
return; //failed to stack -> return
|
||||
}
|
||||
}
|
||||
|
||||
memmove(pData, pNext->Data(), pNext->MemSize());
|
||||
|
||||
if (pItem2) //was not aligned?
|
||||
{
|
||||
//then keep the current ITem
|
||||
const size_t SizeItem = pItem->MemSize();
|
||||
const size_t SizeNext = pNext->MemSize();
|
||||
m_Items.AddBehind(pItem2, pNext);
|
||||
pItem2->Data(pData + SizeNext);
|
||||
pNext->Data(pData);
|
||||
pItem2->MemSize(pItem2->Next()->Data() - pItem2->Data());
|
||||
pNext->MemSize(SizeNext);
|
||||
pItem->MemSize(pNext->Data() - pItem->Data());
|
||||
m_Items.Validate(pItem);
|
||||
m_Items.Validate(pItem2);
|
||||
m_Items.Validate(pNext);
|
||||
}
|
||||
else
|
||||
{
|
||||
const size_t SizeItem = pItem->MemSize();
|
||||
const size_t SizeNext = pNext->MemSize();
|
||||
m_Items.Remove(pItem);
|
||||
m_Items.AddBehind(pItem, pNext);
|
||||
pItem->Data(pNext->Data());
|
||||
pNext->Data(pData);
|
||||
pNext->MemSize(SizeItem);
|
||||
pItem->MemSize(SizeNext);
|
||||
m_Items.Validate(pItem);
|
||||
m_Items.Validate(pNext);
|
||||
}
|
||||
}
|
||||
public:
|
||||
ILINE CReferenced()
|
||||
: m_Allocated(0)
|
||||
{
|
||||
}
|
||||
|
||||
ILINE void InitMem(const size_t S = 0, uint8* pData = 0)
|
||||
{
|
||||
TMemory::InitMem(S, pData);
|
||||
if (!TMemory::MemSize())
|
||||
{
|
||||
return;
|
||||
}
|
||||
pData = TMemory::Data();
|
||||
CListItemReference* pItem = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
CListItemReference* pLast = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
m_Items.AddFirst(pItem);
|
||||
m_Items.AddLast(pLast);
|
||||
pLast->Init(pData + TMemory::MemSize(), 0, pItem, 0);
|
||||
pLast->InUse(0);
|
||||
pItem->Init(pData, TMemory::MemSize(), 0, pLast);
|
||||
pItem->Free();
|
||||
m_pEmpty = pItem;
|
||||
m_Allocated = 0;
|
||||
}
|
||||
|
||||
ILINE size_t FragmentCount() const
|
||||
{
|
||||
return m_Items.Count();
|
||||
}
|
||||
|
||||
ILINE CListItemReference* Split(CListItemReference* pItem, size_t Size, size_t Align)
|
||||
{
|
||||
size_t Offset = reinterpret_cast<size_t>(pItem->Data());
|
||||
if (!(Offset & (Align - 1))) //perfectly aligned?
|
||||
{
|
||||
if (pItem->MemSize() != Size) //not perfectly fitting?
|
||||
{ //then split
|
||||
CListItemReference* pItemPrev = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
if (!pItemPrev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const size_t OrgSize = pItem->MemSize();
|
||||
m_Items.AddBefore(pItemPrev, pItem);
|
||||
pItemPrev->Data(pItem->Data());
|
||||
pItem->Data(pItem->Data() + Size);
|
||||
pItem->MemSize(OrgSize - Size);
|
||||
pItemPrev->MemSize(Size);
|
||||
pItem = pItemPrev;
|
||||
}
|
||||
return pItem;
|
||||
}
|
||||
|
||||
//not aligned to block start
|
||||
//then lets try to align to block end
|
||||
Offset += pItem->MemSize(); //ptr to end
|
||||
Offset -= Size; //minus size
|
||||
if (!(Offset & (Align - 1))) //perfectly aligned?
|
||||
{
|
||||
CListItemReference* pItemPrev = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
if (!pItemPrev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const size_t OrgSize = pItem->MemSize();
|
||||
m_Items.AddBefore(pItemPrev, pItem);
|
||||
pItemPrev->Data(pItem->Data());
|
||||
pItem->Data(reinterpret_cast<uint8*>(Offset));
|
||||
pItemPrev->MemSize(OrgSize - Size);
|
||||
pItem->MemSize(Size);
|
||||
pItemPrev->Free();
|
||||
return pItem;
|
||||
}
|
||||
//last resort, fragment it into 3 parts
|
||||
|
||||
//Size +=Offset&(Align-1); //adjust size to fit required alignment
|
||||
Offset -= Offset & (Align - 1);
|
||||
|
||||
CListItemReference* pItemPrev = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
CListItemReference* pItemNext = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
if (!pItemPrev || !pItemNext)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
const size_t OrgSize = pItem->MemSize();
|
||||
|
||||
m_Items.AddBefore(pItemPrev, pItem);
|
||||
m_Items.AddBehind(pItemNext, pItem);
|
||||
|
||||
pItemPrev->Data(pItem->Data());
|
||||
pItem->Data(reinterpret_cast<uint8*>(Offset));
|
||||
pItemNext->Data(pItem->Data() + Size);
|
||||
pItemPrev->MemSize(pItem->Data() - pItemPrev->Data());
|
||||
pItemNext->MemSize(OrgSize - pItemPrev->MemSize() - Size);
|
||||
pItem->MemSize(Size);
|
||||
|
||||
pItemPrev->Free();
|
||||
pItemNext->Free();
|
||||
return pItem;
|
||||
}
|
||||
|
||||
ILINE void Merge(CListItemReference* pItem)
|
||||
{
|
||||
m_Items.Validate(pItem);
|
||||
|
||||
//merge with next if possible
|
||||
CListItemReference* pItemNext = pItem->Next();
|
||||
if (pItemNext && pItemNext->IsFree())
|
||||
{
|
||||
if (m_pEmpty == pItemNext)
|
||||
{
|
||||
m_pEmpty = pItem;
|
||||
}
|
||||
const size_t OrgSize = pItem->MemSize();
|
||||
const size_t NextSize = pItemNext->MemSize();
|
||||
m_Items.Remove(pItemNext);
|
||||
pItem->MemSize(OrgSize + NextSize);
|
||||
m_NodePool.Free(pItemNext);
|
||||
}
|
||||
//merge with prev if possible
|
||||
CListItemReference* pItemPrev = pItem->Prev();
|
||||
if (pItemPrev && pItemPrev->IsFree())
|
||||
{
|
||||
if (m_pEmpty == pItem)
|
||||
{
|
||||
m_pEmpty = pItemPrev;
|
||||
}
|
||||
const size_t OrgSize = pItem->MemSize();
|
||||
const size_t PrevSize = pItemPrev->MemSize();
|
||||
m_Items.Remove(pItem);
|
||||
pItemPrev->MemSize(PrevSize + OrgSize);
|
||||
m_NodePool.Free(pItem);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Resolve(const uint32 ID)
|
||||
{
|
||||
CPA_ASSERT(ID); //0 is invalid
|
||||
return reinterpret_cast<T>(Item(ID)->Data());
|
||||
}
|
||||
|
||||
ILINE uint32 AddressToHandle(void* pData)
|
||||
{
|
||||
for (CListItemReference* pItem = m_Items.First(); pItem; pItem = pItem->Next())
|
||||
{
|
||||
if (pItem->Data() == pData)
|
||||
{
|
||||
return Handle(pItem);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE size_t Size(T ID) const
|
||||
{
|
||||
CPA_ASSERT(ID); //0 is invalid
|
||||
return Item(ID)->MemSize();
|
||||
}
|
||||
template<class T>
|
||||
bool InBounds([[maybe_unused]] T ID, [[maybe_unused]] const bool Check) const
|
||||
{
|
||||
//boundscheck doesn't work for Referenced containers
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE bool Free(T ID, bool ForceBoundsCheck = false)
|
||||
{
|
||||
IF (!ID, false)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
IF (!InBounds(ID, BoundsCheck | ForceBoundsCheck), false)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
CListItemReference* pItem = Item(ID);
|
||||
FreedMemory(pItem->MemSize());
|
||||
pItem->Free();
|
||||
Merge(pItem);
|
||||
return true;
|
||||
}
|
||||
|
||||
ILINE bool Beat(){return false; }//dummy beat in case no defragmentator is wraping
|
||||
|
||||
ILINE size_t MemFree() const{return TMemory::MemSize() - m_Allocated; }
|
||||
|
||||
ILINE size_t MemSize() const{return TMemory::MemSize(); }
|
||||
|
||||
ILINE uint32 Handle(CListItemReference* pItem) const
|
||||
{
|
||||
return static_cast<uint32>(pItem - &m_NodePool[0]);
|
||||
}
|
||||
ILINE CListItemReference* Item(uint32 ID)
|
||||
{
|
||||
return &m_NodePool[ID];
|
||||
}
|
||||
ILINE const CListItemReference* Item(uint32 ID) const
|
||||
{
|
||||
return &m_NodePool[ID];
|
||||
}
|
||||
ILINE static bool Defragmentable(){return true; }
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
ILINE bool ReSize(T* pData, size_t SizeNew)
|
||||
{
|
||||
CListItemReference* pItem = Item(*pData);
|
||||
const size_t SizeOld = pItem->MemSize();
|
||||
|
||||
//reduction
|
||||
if (SizeOld > SizeNew)
|
||||
{
|
||||
if (pItem->Next()->IsFree())
|
||||
{
|
||||
CListItemReference* pNext = pItem->Next();
|
||||
const size_t NextSize = pNext->MemSize();
|
||||
pNext->Data(pNext->Data() + SizeNew - SizeOld);
|
||||
pNext->MemSize(NextSize - SizeNew + SizeOld);
|
||||
pItem->MemSize(SizeNew);
|
||||
return true;
|
||||
}
|
||||
|
||||
//split
|
||||
CListItemReference* pItemNext = reinterpret_cast<CListItemReference*>(m_NodePool.Allocate(1, 1));
|
||||
m_Items.AddBehind(pItemNext, pItem);
|
||||
pItemNext->Data(pItem->Data() + SizeNew);
|
||||
pItem->MemSize(SizeNew);
|
||||
pItemNext->MemSize(SizeOld - SizeNew);
|
||||
pItemNext->Free();
|
||||
return true;
|
||||
}
|
||||
|
||||
//SizeOld<SizeNew grow
|
||||
CListItemReference* pNext = pItem->Next();
|
||||
const size_t SizeNext = pNext->IsFree() ? pNext->MemSize() : 0;
|
||||
if (SizeNew <= SizeNext + SizeOld)
|
||||
{
|
||||
if (SizeNew == SizeNext + SizeOld)
|
||||
{
|
||||
m_Items.Remove(pNext);
|
||||
m_NodePool.Free(pNext);
|
||||
}
|
||||
else
|
||||
{
|
||||
pNext->Data(pNext->Data() + SizeNew - SizeOld);
|
||||
pNext->MemSize(SizeNext - SizeNew + SizeOld);
|
||||
}
|
||||
pItem->MemSize(SizeNew);
|
||||
return true;
|
||||
}
|
||||
return false; //no further in-place realloc possible
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_CONTAINER_H
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_DEFRAG_H
|
||||
#define CRYINCLUDE_CRYPOOL_DEFRAG_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
template<class T>
|
||||
class CDefragStacked
|
||||
: public T
|
||||
{
|
||||
template<class TItem>
|
||||
ILINE bool DefragElement(TItem* pItem)
|
||||
{
|
||||
T::m_Items.Validate();
|
||||
if (pItem)
|
||||
{
|
||||
for (; pItem->Next(); pItem = pItem->Next())
|
||||
{
|
||||
if (!pItem->IsFree())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (pItem->Next()->Locked())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (!pItem->Available(pItem->Next()->Align(), pItem->Next()->Align()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
T::m_Items.Validate(pItem);
|
||||
Stack(pItem);
|
||||
T::m_Items.Validate(pItem);
|
||||
Merge(pItem);
|
||||
T::m_Items.Validate();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public:
|
||||
ILINE bool Beat()
|
||||
{
|
||||
return T::Defragmentable() && DefragElement(T::m_Items.First());
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_DEFRAG_H
|
||||
|
||||
@ -1,81 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_FALLBACK_H
|
||||
#define CRYINCLUDE_CRYPOOL_FALLBACK_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
enum EFallbackMode
|
||||
{
|
||||
EFM_DISABLED,
|
||||
EFM_ENABLED,
|
||||
EFM_ALWAYS
|
||||
};
|
||||
template<class TAllocator>
|
||||
class CFallback
|
||||
: public TAllocator
|
||||
{
|
||||
EFallbackMode m_Fallback;
|
||||
public:
|
||||
ILINE CFallback()
|
||||
: m_Fallback(EFM_DISABLED)
|
||||
{
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
if (EFM_ALWAYS == m_Fallback)
|
||||
{
|
||||
return reinterpret_cast<T>(CPA_ALLOC(Align, Size));
|
||||
}
|
||||
T pRet = TAllocator::template Allocate<T>(Size, Align);
|
||||
if (!pRet && EFM_ENABLED == m_Fallback)
|
||||
{
|
||||
return reinterpret_cast<T>(CPA_ALLOC(Align, Size));
|
||||
}
|
||||
return pRet;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE bool Free(T Handle)
|
||||
{
|
||||
if (!Handle)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
if (EFM_ALWAYS == m_Fallback)
|
||||
{
|
||||
CPA_FREE(Handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
if (EFM_ENABLED == m_Fallback && TAllocator::InBounds(Handle, true))
|
||||
{
|
||||
CPA_FREE(Handle);
|
||||
return true;
|
||||
}
|
||||
return TAllocator::template Free<T>(Handle);
|
||||
}
|
||||
|
||||
void FallbackMode(EFallbackMode M){m_Fallback = M; }
|
||||
EFallbackMode FallbaclMode() const{return m_Fallback; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_FALLBACK_H
|
||||
|
||||
@ -1,203 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_INSPECTOR_H
|
||||
#define CRYINCLUDE_CRYPOOL_INSPECTOR_H
|
||||
#pragma once
|
||||
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
template<class TAllocator>
|
||||
class CInspector
|
||||
: public TAllocator
|
||||
{
|
||||
enum
|
||||
{
|
||||
EITableSize = 30
|
||||
};
|
||||
size_t m_Allocations[EITableSize];
|
||||
size_t m_Alignment[EITableSize];
|
||||
char m_LogFileName[1024];
|
||||
size_t m_AllocCount;
|
||||
size_t m_FreeCount;
|
||||
size_t m_ResizeCount;
|
||||
size_t m_FailAllocCount;
|
||||
size_t m_FailFreeCount;
|
||||
size_t m_FailResizeCount;
|
||||
|
||||
void WriteOut(const char* pFileName, uint32 Stack, const char* pFormat, ...) const
|
||||
{
|
||||
/*
|
||||
if(!pFileName)
|
||||
{
|
||||
if(!*m_LogFileName)
|
||||
return;
|
||||
pFileName = m_LogFileName;
|
||||
}
|
||||
FILE* File = fopen(pFileName,"a");
|
||||
if(File)
|
||||
{
|
||||
|
||||
char Buffer[1024];
|
||||
for(uint32 a=0;a<Stack;a++)
|
||||
Buffer[a]=' ';
|
||||
va_list args;
|
||||
va_start(args,pFormat);
|
||||
vsprintf(Buffer+Stack,pFormat,args);
|
||||
fwrite(Buffer,1,strlen(Buffer),File);
|
||||
fclose(File);
|
||||
va_end(args);
|
||||
}
|
||||
*/
|
||||
}
|
||||
size_t Bit(size_t C) const
|
||||
{
|
||||
size_t Count = 0;
|
||||
C >>= 1;
|
||||
while (C)
|
||||
{
|
||||
Count++;
|
||||
C >>= 1;
|
||||
}
|
||||
return Count >= EITableSize ? EITableSize - 1 : Count;
|
||||
}
|
||||
public:
|
||||
CInspector()
|
||||
{
|
||||
for (size_t a = 0; a < EITableSize; a++)
|
||||
{
|
||||
m_Allocations[a] = m_Alignment[a] = 0;
|
||||
}
|
||||
|
||||
m_LogFileName[0] = 0;
|
||||
m_AllocCount = 0;
|
||||
m_FreeCount = 0;
|
||||
m_ResizeCount = 0;
|
||||
m_FailAllocCount = 0;
|
||||
m_FailFreeCount = 0;
|
||||
m_FailResizeCount = 0;
|
||||
}
|
||||
|
||||
bool LogFileName(const char* pFileName)
|
||||
{
|
||||
const size_t Size = strlen(pFileName) + 1;
|
||||
if (Size > sizeof(m_LogFileName))
|
||||
{
|
||||
m_LogFileName[0] = 0;
|
||||
return false;
|
||||
}
|
||||
memcpy(m_LogFileName, pFileName, Size);
|
||||
WriteOut(0, "[log start]\n");
|
||||
return true;
|
||||
}
|
||||
void SaveStats(const char* pFileName) const
|
||||
{
|
||||
WriteOut(pFileName, 0, "stats:\n");
|
||||
|
||||
WriteOut(pFileName, 1, "Counter calls|fails\n");
|
||||
WriteOut(pFileName, 2, "Alloc: %6d|%6d\n", m_AllocCount, m_FailAllocCount);
|
||||
WriteOut(pFileName, 2, "Free: %6d|%6d\n", m_FreeCount, m_FailFreeCount);
|
||||
WriteOut(pFileName, 2, "Resize:%6d|%6d\n", m_ResizeCount, m_FailResizeCount);
|
||||
|
||||
WriteOut(pFileName, 1, "Allocations:\n");
|
||||
for (size_t a = 0; a < EITableSize; a++)
|
||||
{
|
||||
WriteOut(pFileName, 2, "%9dByte: %8d\n", 1 << a, m_Allocations[a]);
|
||||
}
|
||||
|
||||
WriteOut(pFileName, 1, "Alignment:\n");
|
||||
for (size_t a = 0; a < EITableSize; a++)
|
||||
{
|
||||
WriteOut(pFileName, 2, "%9dByte: %8d\n", 1 << a, m_Alignment[a]);
|
||||
}
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
m_AllocCount++;
|
||||
m_Allocations[Bit(Size)]++;
|
||||
m_Alignment[Bit(Align)]++;
|
||||
T pData = TAllocator::template Allocate<T>(Size, Align);
|
||||
WriteOut(0, 0, "[A|%d|%d|%d]", (int)pData, Size, Align);
|
||||
if (!pData)
|
||||
{
|
||||
m_FailAllocCount++;
|
||||
WriteOut(0, 0, "[failed]", Size, Align);
|
||||
}
|
||||
return pData;
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
ILINE bool Free(T pData, bool ForceBoundsCheck = false)
|
||||
{
|
||||
m_FreeCount++;
|
||||
const bool Ret = TAllocator::Free(pData, ForceBoundsCheck);
|
||||
WriteOut(0, 0, "[F|%d|%d|%d]", (int)pData, (int)ForceBoundsCheck, (int)Ret);
|
||||
m_FailFreeCount += !Ret;
|
||||
return Ret;
|
||||
}
|
||||
//template<class T>
|
||||
//ILINE bool Free(T pData)
|
||||
// {
|
||||
// m_FreeCount++;
|
||||
// const bool Ret = TAllocator::Free(pData);
|
||||
// WriteOut(0,0,"[F|%d|%d|%d]",(int)pData,(int)-1,(int)Ret);
|
||||
// m_FailFreeCount+=!Ret;
|
||||
// return Ret;
|
||||
// }
|
||||
|
||||
template<class T>
|
||||
ILINE bool Resize(T** pData, size_t Size, size_t Alignment)
|
||||
{
|
||||
m_ResizeCount++;
|
||||
const bool Ret = TAllocator::Resize(pData, Size, Alignment);
|
||||
WriteOut(0, 0, "[R|%d|%d|%d]", (int)*pData, (int)-1, (int)Ret);
|
||||
m_FailResizeCount += !Ret;
|
||||
return Ret;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE size_t FindBiggest(const T* pItem)
|
||||
{
|
||||
size_t Biggest = 0;
|
||||
while (pItem)
|
||||
{
|
||||
if (pItem->IsFree() && pItem->MemSize() > Biggest)
|
||||
{
|
||||
Biggest = pItem->MemSize();
|
||||
}
|
||||
pItem = pItem->Next();
|
||||
}
|
||||
return Biggest;
|
||||
}
|
||||
|
||||
ILINE size_t BiggestFreeBlock()
|
||||
{
|
||||
return FindBiggest(TAllocator::m_Items.First());
|
||||
}
|
||||
|
||||
ILINE uint8* FirstItem()
|
||||
{
|
||||
return TAllocator::m_Items.First()->Data();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_INSPECTOR_H
|
||||
|
||||
@ -1,366 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_LIST_H
|
||||
#define CRYINCLUDE_CRYPOOL_LIST_H
|
||||
#pragma once
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
class CListItemInPlace;
|
||||
class CListItemReference;
|
||||
|
||||
template<typename TItem>
|
||||
class CListItem
|
||||
{
|
||||
TItem* m_pPrev;
|
||||
TItem* m_pNext;
|
||||
public:
|
||||
|
||||
ILINE TItem* Prev(){return m_pPrev; }
|
||||
ILINE TItem* Next(){return m_pNext; }
|
||||
ILINE const TItem* Prev() const{return m_pPrev; }
|
||||
ILINE const TItem* Next() const{return m_pNext; }
|
||||
ILINE void Prev(TItem* pPrev){ m_pPrev = pPrev; }
|
||||
ILINE void Next(TItem* pNext){ m_pNext = pNext; }
|
||||
|
||||
//debugging
|
||||
void Validate();
|
||||
};
|
||||
|
||||
template<typename TItem>
|
||||
class CListItemFlagged
|
||||
: public CListItem<TItem>
|
||||
{
|
||||
enum
|
||||
{
|
||||
ELIF_INUSE = (1 << 0),
|
||||
ELIF_LOCKED = (1 << 1),
|
||||
};
|
||||
uint32 m_Flags : 8;
|
||||
uint32 m_Align : 24;
|
||||
public:
|
||||
ILINE CListItemFlagged()
|
||||
: m_Flags(0)
|
||||
{
|
||||
}
|
||||
ILINE bool IsFree() const{return (m_Flags & ELIF_INUSE) != ELIF_INUSE; }
|
||||
ILINE void Free(){m_Flags &= ~ELIF_INUSE; }
|
||||
ILINE void InUse(uint32 A){m_Flags |= ELIF_INUSE; m_Align = A; }
|
||||
ILINE bool Locked() const{return ELIF_LOCKED == (m_Flags & ELIF_LOCKED); }
|
||||
ILINE void Lock(){m_Flags |= ELIF_LOCKED; }
|
||||
ILINE void Unlock(){m_Flags &= ~ELIF_LOCKED; }
|
||||
ILINE uint32 Align() const{return m_Align; }
|
||||
};
|
||||
|
||||
class CListItemInPlace
|
||||
: public CListItemFlagged<CListItemInPlace>
|
||||
{
|
||||
public:
|
||||
ILINE void Init([[maybe_unused]] uint8* pData, [[maybe_unused]] size_t Size, CListItemInPlace* pPrev, CListItemInPlace* pNext)
|
||||
{
|
||||
Prev(pPrev);
|
||||
Next(pNext);
|
||||
CPA_ASSERT(Size == MemSize());
|
||||
}
|
||||
|
||||
ILINE bool Available(size_t Size, size_t Align) const
|
||||
{
|
||||
size_t Offset = reinterpret_cast<size_t>(Data());
|
||||
if (Offset & (Align - 1)) //not aligned?
|
||||
{
|
||||
Size += sizeof(CListItemInPlace) + Align - 1; //then an intermedian node needs to fit
|
||||
}
|
||||
return Size <= MemSize() && IsFree();
|
||||
}
|
||||
ILINE uint8* Data(){return reinterpret_cast<uint8*>(this) + sizeof(CListItemInPlace); }
|
||||
ILINE const uint8* Data() const{return reinterpret_cast<const uint8*>(this) + sizeof(CListItemInPlace); }
|
||||
ILINE size_t MemSize() const
|
||||
{
|
||||
const uint8* pNext = reinterpret_cast<const uint8*>(Next());
|
||||
const uint8* pThis = reinterpret_cast<const uint8*>(this);
|
||||
const size_t ESize = sizeof(CListItemInPlace);
|
||||
size_t Delta = pNext - pThis;
|
||||
Delta -= ESize;
|
||||
return Delta;
|
||||
}
|
||||
};
|
||||
|
||||
class CListItemReference
|
||||
: public CListItemFlagged<CListItemReference>
|
||||
{
|
||||
uint8* m_pData;
|
||||
// size_t m_Size;
|
||||
public:
|
||||
ILINE void Init(uint8* pData, size_t Size, CListItemReference* pPrev, CListItemReference* pNext)
|
||||
{
|
||||
Data(pData);
|
||||
Prev(pPrev);
|
||||
Next(pNext);
|
||||
MemSize(Size);
|
||||
}
|
||||
ILINE bool Available(size_t Size, size_t Align) const
|
||||
{
|
||||
size_t Offset = reinterpret_cast<size_t>(Data());
|
||||
if ((Offset & (Align - 1)))
|
||||
{
|
||||
Size += Align - (Offset & (Align - 1));
|
||||
}
|
||||
return Size <= MemSize() && IsFree();
|
||||
}
|
||||
ILINE void Data(uint8* pData){m_pData = pData; }
|
||||
ILINE uint8* Data(size_t Align)
|
||||
{
|
||||
Align--;
|
||||
size_t Offset = reinterpret_cast<size_t>(m_pData);
|
||||
Offset = (Offset + Align) & ~Align;
|
||||
return reinterpret_cast<uint8*>(Offset);
|
||||
}
|
||||
ILINE uint8* Data(){return m_pData; }
|
||||
ILINE const uint8* Data() const{return m_pData; }
|
||||
ILINE void MemSize([[maybe_unused]] size_t Size) { }
|
||||
ILINE size_t MemSize() const
|
||||
{
|
||||
const size_t T = reinterpret_cast<size_t>(Data());
|
||||
const size_t N = Next() ? reinterpret_cast<size_t>(Next()->Data()) : T;
|
||||
return N - T;
|
||||
}
|
||||
//ILINE void MemSize(size_t Size){m_Size=Size;}
|
||||
//ILINE size_t MemSize()const{return m_Size;}
|
||||
};
|
||||
|
||||
template<class TItem, bool VALIDATE = false>
|
||||
class CList
|
||||
{
|
||||
TItem* m_pFirst;
|
||||
TItem* m_pLast;
|
||||
size_t m_Count;
|
||||
public:
|
||||
ILINE CList()
|
||||
: m_pFirst(0)
|
||||
, m_pLast(0)
|
||||
, m_Count(0)
|
||||
{
|
||||
}
|
||||
|
||||
ILINE void First(TItem* pItem){m_pFirst = pItem; }
|
||||
ILINE TItem* First(){return m_pFirst; }
|
||||
ILINE void Last(TItem* pItem){m_pLast = pItem; }
|
||||
ILINE TItem* Last(){return m_pLast; }
|
||||
ILINE bool Empty() const{return m_pFirst == 0; }
|
||||
|
||||
ILINE TItem* PopFirst()
|
||||
{
|
||||
Validate();
|
||||
|
||||
if (!m_pFirst)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TItem* pRet = m_pFirst;
|
||||
|
||||
m_pFirst = m_pFirst->Next();
|
||||
|
||||
if (m_pFirst) //if any element exists
|
||||
{
|
||||
m_pFirst->Prev(0); //set prev ptr of this element to 0
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLast = 0; //set ptr to last element to 0 if ptr to first is zero as well
|
||||
}
|
||||
Validate();
|
||||
m_Count--;
|
||||
return pRet;
|
||||
}
|
||||
|
||||
ILINE TItem* PopLast()
|
||||
{
|
||||
Validate();
|
||||
|
||||
if (!m_pLast)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
TItem* pRet = m_pLast;
|
||||
|
||||
m_pLast = m_pLast->Prev();
|
||||
|
||||
if (m_pLast) //if any element exists
|
||||
{
|
||||
m_pLast->Next(0); //set prev ptr of this element to 0
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFirst = 0; //set ptr to last element to 0 if ptr to first is zero as well
|
||||
}
|
||||
Validate();
|
||||
m_Count--;
|
||||
return pRet;
|
||||
}
|
||||
|
||||
ILINE void AddFirst(TItem* pItem)
|
||||
{
|
||||
CPA_ASSERT(pItem); //ERROR AddFirst got 0 pointer
|
||||
|
||||
Validate();
|
||||
|
||||
pItem->Prev(0);
|
||||
pItem->Next(m_pFirst);
|
||||
if (!m_pFirst)
|
||||
{
|
||||
m_pLast = pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pFirst->Prev(pItem);
|
||||
}
|
||||
m_pFirst = pItem;
|
||||
|
||||
m_Count++;
|
||||
Validate();
|
||||
}
|
||||
|
||||
ILINE void AddLast(TItem* pItem)
|
||||
{
|
||||
CPA_ASSERT(pItem); //ERROR AddLast got 0 pointer
|
||||
|
||||
Validate();
|
||||
|
||||
pItem->Prev(m_pLast);
|
||||
pItem->Next(0);
|
||||
if (!m_pLast)
|
||||
{
|
||||
m_pFirst = pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pLast->Next(pItem);
|
||||
}
|
||||
m_pLast = pItem;
|
||||
|
||||
m_Count++;
|
||||
Validate();
|
||||
}
|
||||
ILINE void AddBefore(TItem* pItem, TItem* pItemSuccessor)
|
||||
{
|
||||
CPA_ASSERT(pItem);
|
||||
CPA_ASSERT(pItemSuccessor);
|
||||
|
||||
Validate();
|
||||
|
||||
pItem->Next(pItemSuccessor);
|
||||
pItem->Prev(pItemSuccessor->Prev());
|
||||
pItemSuccessor->Prev(pItem);
|
||||
|
||||
if (pItemSuccessor == m_pFirst)
|
||||
{
|
||||
m_pFirst = pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->Prev()->Next(pItem);
|
||||
}
|
||||
|
||||
m_Count++;
|
||||
Validate();
|
||||
}
|
||||
ILINE void AddBehind(TItem* pItem, TItem* pItemPredecessor)
|
||||
{
|
||||
CPA_ASSERT(pItem);
|
||||
CPA_ASSERT(pItemPredecessor);
|
||||
|
||||
Validate();
|
||||
|
||||
pItem->Next(pItemPredecessor->Next());
|
||||
pItem->Prev(pItemPredecessor);
|
||||
pItemPredecessor->Next(pItem);
|
||||
|
||||
if (pItemPredecessor == m_pLast)
|
||||
{
|
||||
m_pLast = pItem;
|
||||
}
|
||||
else
|
||||
{
|
||||
pItem->Next()->Prev(pItem);
|
||||
}
|
||||
|
||||
m_Count++;
|
||||
Validate();
|
||||
}
|
||||
|
||||
ILINE void Remove(TItem* pItem)
|
||||
{
|
||||
CPA_ASSERT(pItem); //ERROR releasing empty item
|
||||
|
||||
if (pItem == m_pFirst)
|
||||
{
|
||||
PopFirst();
|
||||
return;
|
||||
}
|
||||
if (pItem == m_pLast)
|
||||
{
|
||||
PopLast();
|
||||
return;
|
||||
}
|
||||
|
||||
Validate(pItem);
|
||||
|
||||
pItem->Prev()->Next(pItem->Next());
|
||||
pItem->Next()->Prev(pItem->Prev());
|
||||
|
||||
m_Count--;
|
||||
Validate();
|
||||
}
|
||||
|
||||
//debug
|
||||
ILINE void Validate(TItem* pReferenceItem = 0)
|
||||
{
|
||||
if (!VALIDATE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//one-sided empty?
|
||||
CPA_ASSERT((!First() && !Last()) || (First() && Last())); //ERROR validating item-list, just one end is 0
|
||||
|
||||
// endles linking?
|
||||
TItem* pPrev = 0;
|
||||
TItem* pItem = First();
|
||||
while (pItem)
|
||||
{
|
||||
if (pReferenceItem == pItem)
|
||||
{
|
||||
pReferenceItem = 0;
|
||||
}
|
||||
CPA_ASSERT(pPrev == pItem->Prev()); //ERROR validating item-list, endless linking NULL
|
||||
pPrev = pItem;
|
||||
pItem = pItem->Next();
|
||||
}
|
||||
|
||||
CPA_ASSERT(pPrev == Last()); //ERROR validating item-list, broken list, does not end at specified Last item
|
||||
CPA_ASSERT(!pReferenceItem); //ERROR reference item not found in the item-list
|
||||
}
|
||||
ILINE size_t Count() const{return m_Count; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_LIST_H
|
||||
|
||||
@ -1,70 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_MEMORY_H
|
||||
#define CRYINCLUDE_CRYPOOL_MEMORY_H
|
||||
#pragma once
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
class CMemoryDynamic
|
||||
{
|
||||
size_t m_Size;
|
||||
uint8* m_pData;
|
||||
|
||||
protected:
|
||||
ILINE CMemoryDynamic()
|
||||
: m_Size(0)
|
||||
, m_pData(0){}
|
||||
|
||||
public:
|
||||
ILINE void InitMem(const size_t S, uint8* pData)
|
||||
{
|
||||
m_Size = S;
|
||||
m_pData = pData;
|
||||
CPA_ASSERT(S);
|
||||
CPA_ASSERT(pData);
|
||||
}
|
||||
|
||||
ILINE size_t MemSize() const{return m_Size; }
|
||||
ILINE uint8* Data(){return m_pData; }
|
||||
ILINE const uint8* Data() const{return m_pData; }
|
||||
};
|
||||
|
||||
template<size_t TSize>
|
||||
class CMemoryStatic
|
||||
{
|
||||
uint8 m_Data[TSize];
|
||||
|
||||
protected:
|
||||
ILINE CMemoryStatic()
|
||||
{
|
||||
}
|
||||
public:
|
||||
ILINE void InitMem(const size_t S, uint8* pData)
|
||||
{
|
||||
}
|
||||
ILINE size_t MemSize() const{return TSize; }
|
||||
ILINE uint8* Data(){return m_Data; }
|
||||
ILINE const uint8* Data() const{return m_Data; }
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_MEMORY_H
|
||||
|
||||
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(POOLALLOCTESTSUIT)
|
||||
//cheat just for unit testing on windows
|
||||
#include "BaseTypes.h"
|
||||
#define ILINE inline
|
||||
#endif
|
||||
|
||||
// Traits
|
||||
#if defined(AZ_RESTRICTED_PLATFORM)
|
||||
#include AZ_RESTRICTED_FILE(CryPool/PoolAlloc_h)
|
||||
#elif defined(APPLE) || defined(LINUX)
|
||||
#define POOLALLOC_H_TRAIT_USE_MEMALIGN 1
|
||||
#endif
|
||||
|
||||
|
||||
#if POOLALLOC_H_TRAIT_USE_MEMALIGN
|
||||
#define CPA_ALLOC memalign
|
||||
#define CPA_FREE free
|
||||
#else
|
||||
#define CPA_ALLOC _aligned_malloc
|
||||
#define CPA_FREE _aligned_free
|
||||
#endif
|
||||
#define CPA_ASSERT assert
|
||||
#define CPA_ASSERT_STATIC(X) {uint8 assertdata[(X) ? 0 : 1]; }
|
||||
#define CPA_BREAK __debugbreak()
|
||||
|
||||
#include "List.h"
|
||||
#include "Memory.h"
|
||||
#include "Container.h"
|
||||
#include "Allocator.h"
|
||||
#include "Defrag.h"
|
||||
#include "STLWrapper.h"
|
||||
#include "Inspector.h"
|
||||
#include "Fallback.h"
|
||||
#if !defined(POOLALLOCTESTSUIT)
|
||||
#include "ThreadSafe.h"
|
||||
#endif
|
||||
|
||||
#undef CPA_ASSERT
|
||||
#undef CPA_ASSERT_STATIC
|
||||
#undef CPA_BREAK
|
||||
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_STLWRAPPER_H
|
||||
#define CRYINCLUDE_CRYPOOL_STLWRAPPER_H
|
||||
#pragma once
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
//namespace CSTLPoolAllocWrapperHelper
|
||||
//{
|
||||
// inline void destruct(char *) {}
|
||||
// inline void destruct(wchar_t*) {}
|
||||
// template <typename T>
|
||||
// inline void destruct(T *t) {t->~T();}
|
||||
//}
|
||||
|
||||
//template <size_t S, class L, size_t A, typename T>
|
||||
//struct CSTLPoolAllocWrapperStatic
|
||||
//{
|
||||
// static PoolAllocator<S, L, A> * allocator;
|
||||
//};
|
||||
|
||||
//template <class T, class L, size_t A>
|
||||
//struct CSTLPoolAllocWrapperKungFu : public CSTLPoolAllocWrapperStatic<sizeof(T),L,A,T>
|
||||
//{
|
||||
//};
|
||||
|
||||
template <class T, class TCont>
|
||||
class CSTLPoolAllocWrapper
|
||||
{
|
||||
private:
|
||||
static TCont* m_pContainer;
|
||||
public:
|
||||
typedef size_t size_type;
|
||||
typedef ptrdiff_t difference_type;
|
||||
typedef T* pointer;
|
||||
typedef const T* const_pointer;
|
||||
typedef T& reference;
|
||||
typedef const T& const_reference;
|
||||
typedef T value_type;
|
||||
|
||||
static TCont* Container(){return m_pContainer; }
|
||||
static void Container(TCont* pContainer){m_pContainer = pContainer; }
|
||||
|
||||
|
||||
template <class U>
|
||||
struct rebind
|
||||
{
|
||||
typedef CSTLPoolAllocWrapper<T, TCont> other;
|
||||
};
|
||||
|
||||
CSTLPoolAllocWrapper() throw()
|
||||
{
|
||||
}
|
||||
|
||||
CSTLPoolAllocWrapper(const CSTLPoolAllocWrapper&) throw()
|
||||
{
|
||||
}
|
||||
|
||||
template <class TTemp, class TTempCont>
|
||||
CSTLPoolAllocWrapper(const CSTLPoolAllocWrapper<TTemp, TTempCont>&) throw()
|
||||
{
|
||||
}
|
||||
|
||||
~CSTLPoolAllocWrapper() throw()
|
||||
{
|
||||
}
|
||||
|
||||
pointer address(reference x) const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
const_pointer address(const_reference x) const
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
pointer allocate(size_type n = 1, const_pointer hint = 0)
|
||||
{
|
||||
TCont* pContainer = Container();
|
||||
uint8* pData = pContainer->TCont::template Allocate<uint8*>(n * sizeof(T), sizeof(T));
|
||||
return pContainer->TCont::template Resolve<pointer>(pData);
|
||||
// return Container()?Container()->Allocate<void*>(n*sizeof(T),sizeof(T)):0
|
||||
}
|
||||
|
||||
void deallocate(pointer p, size_type n = 1)
|
||||
{
|
||||
if (Container())
|
||||
{
|
||||
Container()->Free(p);
|
||||
}
|
||||
}
|
||||
|
||||
size_type max_size() const throw()
|
||||
{
|
||||
return Container() ? Container()->MemSize() : 0;
|
||||
}
|
||||
|
||||
void construct(pointer p, const T& val)
|
||||
{
|
||||
new(static_cast<void*>(p))T(val);
|
||||
}
|
||||
|
||||
void construct(pointer p)
|
||||
{
|
||||
new(static_cast<void*>(p))T();
|
||||
}
|
||||
|
||||
void destroy(pointer p)
|
||||
{
|
||||
p->~T();
|
||||
}
|
||||
|
||||
pointer new_pointer()
|
||||
{
|
||||
return new(allocate())T();
|
||||
}
|
||||
|
||||
pointer new_pointer(const T& val)
|
||||
{
|
||||
return new(allocate())T(val);
|
||||
}
|
||||
|
||||
void delete_pointer(pointer p)
|
||||
{
|
||||
p->~T();
|
||||
deallocate(p);
|
||||
}
|
||||
|
||||
bool operator==(const CSTLPoolAllocWrapper&) {return true; }
|
||||
bool operator!=(const CSTLPoolAllocWrapper&) {return false; }
|
||||
};
|
||||
}
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_STLWRAPPER_H
|
||||
|
||||
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
|
||||
* its licensors.
|
||||
*
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this
|
||||
* distribution (the "License"). All use of this software is governed by the License,
|
||||
* or, if provided, by the license below or the license accompanying this file. Do not
|
||||
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
*
|
||||
*/
|
||||
// Original file Copyright Crytek GMBH or its affiliates, used under license.
|
||||
|
||||
#ifndef CRYINCLUDE_CRYPOOL_THREADSAFE_H
|
||||
#define CRYINCLUDE_CRYPOOL_THREADSAFE_H
|
||||
#pragma once
|
||||
|
||||
|
||||
#include <CryThread.h>
|
||||
|
||||
namespace NCryPoolAlloc
|
||||
{
|
||||
template<class TAllocator>
|
||||
class CThreadSafe
|
||||
: public TAllocator
|
||||
{
|
||||
CryCriticalSection m_Mutex;
|
||||
public:
|
||||
|
||||
template<class T>
|
||||
ILINE T Allocate(size_t Size, size_t Align = 1)
|
||||
{
|
||||
CryAutoLock<CryCriticalSection> lock(m_Mutex);
|
||||
return TAllocator::template Allocate<T>(Size, Align);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
ILINE bool Free(T pData, bool ForceBoundsCheck = false)
|
||||
{
|
||||
CryAutoLock<CryCriticalSection> lock(m_Mutex);
|
||||
return TAllocator::Free(pData, ForceBoundsCheck);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
ILINE bool Resize(T** pData, size_t Size, size_t Alignment)
|
||||
{
|
||||
CryAutoLock<CryCriticalSection> lock(m_Mutex);
|
||||
return TAllocator::Resize(pData, Size, Alignment);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // CRYINCLUDE_CRYPOOL_THREADSAFE_H
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue