Merge branch 'development' into memory/overrideshim_removal

Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>

# Conflicts:
#	Code/Framework/AzCore/AzCore/Memory/AllocatorBase.cpp
#	Code/Framework/AzCore/AzCore/Memory/BestFitExternalMapAllocator.cpp
#	Code/Framework/AzCore/AzCore/Memory/BestFitExternalMapSchema.cpp
#	Code/Framework/AzCore/AzCore/Memory/PoolSchema.cpp
#	Code/Framework/AzCore/AzCore/Memory/SystemAllocator.cpp
#	Code/Framework/AzCore/Tests/Memory/AllocatorBenchmarks.cpp
This commit is contained in:
Esteban Papp
2022-01-05 11:34:52 -08:00
1267 changed files with 157305 additions and 27177 deletions
@@ -199,7 +199,7 @@ namespace AzFramework
{
activeFile = &m_filePaths[m_activeCacheSlot];
}
// Estimate requests in this stack entry.
for (FileRequest* request : m_pendingRequests)
{
@@ -279,7 +279,7 @@ namespace AzFramework
using namespace AZ::IO;
AZ_PROFILE_FUNCTION(AzCore);
auto data = AZStd::get_if<FileRequest::ReadData>(&request->GetCommand());
AZ_Assert(data, "Request doing reading in the RemoteStorageDrive didn't contain read data.");
@@ -292,7 +292,7 @@ namespace AzFramework
file = m_fileHandles[cacheIndex];
m_fileLastUsed[cacheIndex] = AZStd::chrono::high_resolution_clock::now();
}
// If the file is not open, eject the oldest entry from the cache and open the file for reading.
if (file == InvalidHandle)
{
@@ -325,7 +325,7 @@ namespace AzFramework
}
m_activeCacheSlot = cacheIndex;
AZ_Assert(file != InvalidHandle,
AZ_Assert(file != InvalidHandle,
"While searching for file '%s' RemoteStorageDevice::ReadFile encountered a problem that wasn't reported.", data->m_path.GetRelativePath());
{
TIMED_AVERAGE_WINDOW_SCOPE(m_readTimeAverage);
@@ -357,7 +357,7 @@ namespace AzFramework
}
}
m_readSizeAverage.PushEntry(data->m_size);
request->SetStatus(IStreamerTypes::RequestStatus::Completed);
m_context->MarkRequestAsCompleted(request);
}
@@ -507,7 +507,7 @@ namespace AzFramework
using namespace AZ::IO;
using DoubleSeconds = AZStd::chrono::duration<double>;
double totalBytesReadMB = m_readSizeAverage.GetTotal() / (1024.0 * 1024.0);
double totalReadTimeSec = AZStd::chrono::duration_cast<DoubleSeconds>(m_readTimeAverage.GetTotal()).count();
if (m_readSizeAverage.GetTotal() > 1) // A default is always added.
@@ -53,7 +53,7 @@ namespace AzFramework
protected:
static constexpr AZ::s32 s_maxRequests = 1;
void ReadFile(AZ::IO::FileRequest* request);
bool CancelRequest(AZ::IO::FileRequest* cancelRequest, AZ::IO::FileRequestPtr& target);
void FileExistsRequest(AZ::IO::FileRequest* request);
@@ -142,7 +142,7 @@ namespace AzFramework
AZ::Outcome<void, AZStd::string> CompileScript(ScriptCompileRequest& request, AZ::ScriptContext& scriptContext)
{
AZ_TracePrintf(request.m_errorWindow.data(), "Starting script compile.\n");
AZStd::string debugName = "@";
debugName += request.m_sourceFile;
AZStd::to_lower(debugName.begin(), debugName.end());
@@ -180,14 +180,14 @@ namespace AzFramework
{
using namespace AZ::IO;
FileIOStream outputStream;
if (!outputStream.Open(request.m_destPath.c_str(), OpenMode::ModeWrite | OpenMode::ModeBinary))
{
return AZ::Failure(AZStd::string("Failed to open output file %s", request.m_destPath.data()));
}
request.m_output = &outputStream;
if (writeAssetInfo)
{
if (request.m_prewriteCallback)
@@ -292,7 +292,7 @@ namespace AzFramework
namespace Internal
{
AZStd::string PrintLuaValue(lua_State* lua, int stackIdx, int depth = 0)
{
constexpr int MaxDepth = 4;
@@ -302,7 +302,7 @@ namespace AzFramework
}
const int elementType = lua_type(lua, stackIdx);
switch (elementType)
{
case LUA_TSTRING:
@@ -347,7 +347,7 @@ namespace AzFramework
{
keyValuePairs += " ";
}
}
}
}
tableStr += keyValuePairs.length() < 1024 ? keyValuePairs : AZStd::string::format("too many keys (%i)!", keyCount);
@@ -891,18 +891,18 @@ namespace AzFramework
// This is the root table (properties) it will be used as properties for all sub tables
// ScriptComponents can share the same lua script asset, but each instance's Properties table needs to be unique.
// This way the script can change a property at runtime and not affect the other ScriptComponents which are using the same script.
// For normal properties we will create new variable instances, but NetSynched variables aren't stored in Lua, and instead
// For normal properties we will create new variable instances, but NetSynched variables aren't stored in Lua, and instead
// are retrieved using the __index and __newIndex metamethods.
// Ensure that this instance of Properties table has the proper __index and __newIndex metamethods.
lua_newtable(lua); // This new table will become the Properties instance metatable. Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {}
lua_newtable(lua); // This new table will become the Properties instance metatable. Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {}
lua_pushliteral(lua, "__index"); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index
lua_pushcclosure(lua, &Internal::Properties__Index, 0); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {} __index function
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index}
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index}
lua_pushliteral(lua, "__newindex");
lua_pushcclosure(lua, &Internal::Properties__NewIndex, 0);
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex}
lua_setmetatable(lua, -2); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {Meta{__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex} }
lua_rawset(lua, -3); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {} {__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex}
lua_setmetatable(lua, -2); // Stack: ScriptRootTable PropertiesTable EntityTable "Properties" {Meta{__index=Internal::Properties__Index __newindex=Internal::Properties__NewIndex} }
metatableIndex = lua_gettop(lua); // This will be the metatable for all subtables
}
@@ -213,27 +213,33 @@ namespace AzFramework
Camera Cameras::StepCamera(const Camera& targetCamera, const ScreenVector& cursorDelta, const float scrollDelta, const float deltaTime)
{
for (int i = 0; i < m_idleCameraInputs.size();)
for (int idleIndex = 0; idleIndex < m_idleCameraInputs.size();)
{
auto& cameraInput = m_idleCameraInputs[i];
auto& cameraInput = m_idleCameraInputs[idleIndex];
const bool canBegin = cameraInput->Beginning() &&
AZStd::all_of(m_activeCameraInputs.cbegin(), m_activeCameraInputs.cend(),
[](const auto& input)
{
return !input->Exclusive();
}) &&
(!cameraInput->Exclusive() || (cameraInput->Exclusive() && m_activeCameraInputs.empty()));
(!cameraInput->Exclusive() || m_activeCameraInputs.empty());
if (canBegin)
{
m_activeCameraInputs.push_back(cameraInput);
using AZStd::swap;
swap(m_idleCameraInputs[i], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
swap(m_idleCameraInputs[idleIndex], m_idleCameraInputs[m_idleCameraInputs.size() - 1]);
m_idleCameraInputs.pop_back();
}
else
{
i++;
// if a camera attempted to start but was not allowed to, ensure activation is cancelled
if (!cameraInput->Idle())
{
cameraInput->CancelActivation();
}
idleIndex++;
}
}
@@ -245,21 +251,21 @@ namespace AzFramework
return acc;
});
for (int i = 0; i < m_activeCameraInputs.size();)
for (int activeIndex = 0; activeIndex < m_activeCameraInputs.size();)
{
auto& cameraInput = m_activeCameraInputs[i];
auto& cameraInput = m_activeCameraInputs[activeIndex];
if (cameraInput->Ending())
{
cameraInput->ClearActivation();
m_idleCameraInputs.push_back(cameraInput);
using AZStd::swap;
swap(m_activeCameraInputs[i], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
swap(m_activeCameraInputs[activeIndex], m_activeCameraInputs[m_activeCameraInputs.size() - 1]);
m_activeCameraInputs.pop_back();
}
else
{
cameraInput->ContinueActivation();
i++;
activeIndex++;
}
}
@@ -470,9 +476,10 @@ namespace AzFramework
{
if (input->m_state == InputChannel::State::Began)
{
m_translation |= TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
if (m_translation != TranslationType::Nil)
if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
translation != TranslationType::Nil)
{
m_translation |= translation;
BeginActivation();
}
@@ -484,11 +491,16 @@ namespace AzFramework
// ensure we don't process end events in the idle state
else if (input->m_state == InputChannel::State::Ended && !Idle())
{
m_translation &= ~(TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds));
if (m_translation == TranslationType::Nil)
if (auto translation = TranslationFromKey(input->m_channelId, m_translateCameraInputChannelIds);
translation != TranslationType::Nil)
{
EndActivation();
m_translation &= ~translation;
if (m_translation == TranslationType::Nil)
{
EndActivation();
}
}
if (input->m_channelId == m_translateCameraInputChannelIds.m_boostChannelId)
{
m_boost = false;
@@ -185,6 +185,11 @@ namespace AzFramework
m_activation = Activation::Ending;
}
void CancelActivation()
{
m_activation = Activation::Idle;
}
void ContinueActivation()
{
// continue activation is called after the first step of the camera input,
@@ -10,6 +10,7 @@
#include <AzCore/Casting/numeric_cast.h>
#include <AzCore/Math/Vector2.h>
#include <AzCore/Math/Vector3.h>
#include <AzCore/RTTI/TypeInfoSimple.h>
#include <AzCore/base.h>
@@ -203,6 +204,12 @@ namespace AzFramework
return AZ::Vector2(aznumeric_cast<float>(screenPoint.m_x), aznumeric_cast<float>(screenPoint.m_y));
}
//! Return an AZ::Vector3 from a ScreenPoint (including z/depth value, defaulting to 0.0f).
inline AZ::Vector3 Vector3FromScreenPoint(const ScreenPoint& screenPoint, const float z = 0.0f)
{
return AZ::Vector3(aznumeric_cast<float>(screenPoint.m_x), aznumeric_cast<float>(screenPoint.m_y), z);
}
//! Return an AZ::Vector2 from a ScreenVector.
inline AZ::Vector2 Vector2FromScreenVector(const ScreenVector& screenVector)
{
@@ -270,8 +270,6 @@ set(FILES
Physics/WindBus.h
Process/ProcessCommunicator.cpp
Process/ProcessCommunicator.h
Process/ProcessWatcher.cpp
Process/ProcessWatcher.h
Process/ProcessCommon_fwd.h
Process/ProcessCommunicator.h
Process/ProcessWatcher.cpp
@@ -83,4 +83,9 @@ namespace AzFramework
{
}
AZStd::string ProcessLauncher::ProcessLaunchInfo::GetCommandLineParametersAsString() const
{
return AZStd::string{};
}
} //namespace AzFramework
@@ -14,7 +14,7 @@
#include <Psapi.h>
AZ_CVAR(bool, ap_tether_lifetime, false, nullptr, AZ::ConsoleFunctorFlags::Null,
AZ_CVAR(bool, ap_tether_lifetime, true, nullptr, AZ::ConsoleFunctorFlags::Null,
"If enabled, a parent process that launches the AP will terminate the AP on exit");
namespace AzFramework::AssetSystem::Platform
@@ -96,7 +96,7 @@ namespace AzFramework
AZStd::string operator()(const AZStd::vector<AZStd::string>& commandLineArray) const
{
AZStd::string commandLineResult;
Az::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " ");
AZ::StringFunc::Join(commandLineResult, commandLineArray.begin(), commandLineArray.end(), " ");
return commandLineResult;
}
};
@@ -92,11 +92,7 @@ protected:
};
#if AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
TEST_F(APConnectionTest, DISABLED_TestAddRemoveCallbacks)
#else
TEST_F(APConnectionTest, TestAddRemoveCallbacks)
#endif // AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
{
using namespace AzFramework;
@@ -218,11 +214,7 @@ TEST_F(APConnectionTest, TestAddRemoveCallbacks)
EXPECT_TRUE(WaitForConnectionStateToBeEqual(apConnection, SocketConnection::EConnectionState::Disconnected));
}
#if AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
TEST_F(APConnectionTest, DISABLED_TestAddRemoveCallbacks_RemoveDuringCallback_DoesNotCrash)
#else
TEST_F(APConnectionTest, TestAddRemoveCallbacks_RemoveDuringCallback_DoesNotCrash)
#endif // AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
{
using namespace AzFramework;
@@ -313,11 +305,7 @@ TEST_F(APConnectionTest, TestAddRemoveCallbacks_RemoveDuringCallback_DoesNotCras
EXPECT_TRUE(WaitForConnectionStateToBeEqual(apConnection, SocketConnection::EConnectionState::Disconnected));
}
#if AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
TEST_F(APConnectionTest, DISABLED_TestAddRemoveCallbacks_AddDuringCallback_DoesNotCrash)
#else
TEST_F(APConnectionTest, TestAddRemoveCallbacks_AddDuringCallback_DoesNotCrash)
#endif // AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
{
using namespace AzFramework;
@@ -451,11 +439,7 @@ TEST_F(APConnectionTest, TestAddRemoveCallbacks_AddDuringCallback_DoesNotCrash)
EXPECT_TRUE(WaitForConnectionStateToBeEqual(apConnection, SocketConnection::EConnectionState::Disconnected));
}
#if AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
TEST_F(APConnectionTest, DISABLED_TestConnection)
#else
TEST_F(APConnectionTest, TestConnection)
#endif // AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
{
using namespace AzFramework;
@@ -557,11 +541,7 @@ TEST_F(APConnectionTest, TestConnection)
EXPECT_TRUE(WaitForConnectionStateToBeEqual(apListener, SocketConnection::EConnectionState::Disconnected));
}
#if AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
TEST_F(APConnectionTest, DISABLED_TestReconnect)
#else
TEST_F(APConnectionTest, TestReconnect)
#endif // AZ_TRAIT_DISABLE_FAILED_AP_CONNECTION_TESTS
{
using namespace AzFramework;
@@ -416,4 +416,78 @@ namespace UnitTest
using ::testing::FloatNear;
EXPECT_THAT(m_camera.m_pitch, FloatNear(expectedPitch, 0.001f));
}
TEST_F(CameraInputFixture, InvalidTranslationInputKeyCannotBeginTranslateCameraInputAgain)
{
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
const bool consumed =
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
using ::testing::IsFalse;
using ::testing::IsTrue;
EXPECT_THAT(consumed, IsTrue());
EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse());
EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue());
}
TEST_F(CameraInputFixture, InvalidTranslationInputKeyDownCannotBeginTranslateCameraInputAgain)
{
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
const bool consumed =
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
using ::testing::IsFalse;
using ::testing::IsTrue;
EXPECT_THAT(consumed, IsTrue());
EXPECT_THAT(m_firstPersonTranslateCamera->Beginning(), IsFalse());
EXPECT_THAT(m_firstPersonTranslateCamera->Active(), IsTrue());
}
TEST_F(CameraInputFixture, InvalidTranslationInputKeyUpDoesNotAffectTranslateCameraInputEnd)
{
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
const bool consumed =
m_cameraSystem->HandleEvents(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Ended });
using ::testing::IsFalse;
using ::testing::IsTrue;
EXPECT_THAT(consumed, IsTrue());
EXPECT_THAT(m_firstPersonTranslateCamera->Idle(), IsTrue());
}
TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBegin)
{
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
using ::testing::IsFalse;
using ::testing::IsTrue;
EXPECT_THAT(m_orbitCamera->Beginning(), IsFalse());
EXPECT_THAT(m_orbitCamera->Idle(), IsTrue());
}
TEST_F(CameraInputFixture, OrbitCameraInputCannotBeLeftInInvalidStateIfItCannotFullyBeginAfterInputChannelBeginAndEnd)
{
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_translateCameraInputChannelIds.m_forwardChannelId,
AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Began });
HandleEventAndUpdate(AzFramework::DiscreteInputEvent{ m_orbitChannelId, AzFramework::InputChannel::State::Ended });
using ::testing::IsFalse;
using ::testing::IsTrue;
EXPECT_THAT(m_orbitCamera->Ending(), IsFalse());
EXPECT_THAT(m_orbitCamera->Idle(), IsTrue());
}
} // namespace UnitTest