Deprecate profiler categories based on global enum

(to be supplanted by registered budgets in the future)

Signed-off-by: Jeremy Ong <jcong@amazon.com>
This commit is contained in:
Jeremy Ong
2021-08-17 12:10:57 -06:00
parent d15d40fec6
commit df9b4d4a2f
274 changed files with 1435 additions and 1965 deletions
@@ -274,7 +274,7 @@ namespace AzToolsFramework
*/
SliceCompilationResult CompileEditorSlice(const AZ::Data::Asset<AZ::SliceAsset>& sourceSliceAsset, const AZ::PlatformTagSet& platformTags, AZ::SerializeContext& serializeContext, const EditorOnlyEntityHandlers& editorOnlyEntityHandlers)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (!sourceSliceAsset)
{
return AZ::Failure(AZStd::string("Source slice is invalid."));
@@ -657,7 +657,7 @@ namespace AzToolsFramework
// tolerate ALL possible input errors (looping parents, invalid IDs, etc).
void SortTransformParentsBeforeChildren(AZStd::vector<AZ::Entity*>& entities)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// IDs of those present in 'entities'. Does not include parent ID if parent not found in 'entities'
AZStd::unordered_set<AZ::EntityId> existingEntityIds;
@@ -63,7 +63,7 @@ namespace AzToolsFramework
void Capture(const SliceTransaction::SliceAssetPtr& before, const SliceTransaction::SliceAssetPtr& after, const char* sliceAssetPath)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
m_sliceAssetPath = sliceAssetPath;
m_isNewAsset = !before.GetId().IsValid();
@@ -74,7 +74,7 @@ namespace AzToolsFramework
if (!m_isNewAsset)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDiskCommand::Capture:SaveBefore");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDiskCommand::Capture:SaveBefore");
AZ::SliceAsset* sliceBefore = before.Get();
AZ::Entity* sliceEntityBefore = sliceBefore->GetEntity();
AZ::IO::ByteContainerStream<ByteBuffer> beforeStream(&m_sliceAssetBeforeBuffer);
@@ -82,7 +82,7 @@ namespace AzToolsFramework
}
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDiskCommand::Capture:SaveAfter");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDiskCommand::Capture:SaveAfter");
AZ::SliceAsset* sliceAfter = after.Get();
AZ::Entity* sliceEntityAfter = sliceAfter->GetEntity();
AZ::IO::ByteContainerStream<ByteBuffer> afterStream(&m_sliceAssetAfterBuffer);
@@ -105,13 +105,13 @@ namespace AzToolsFramework
void Redo() override
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
m_redoResult = Internal::SaveSliceToDisk(m_sliceAssetPath.c_str(), m_sliceAssetAfterBuffer);
}
void Undo() override
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (m_isNewAsset)
{
// New asset means we didn't have an existing asset, so we should instead remove the newly created asset as our undo
@@ -149,7 +149,7 @@ namespace AzToolsFramework
AZ::SerializeContext* serializeContext,
AZ::u32 sliceCreationFlags)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (!serializeContext)
{
@@ -179,7 +179,7 @@ namespace AzToolsFramework
SliceTransaction::TransactionPtr SliceTransaction::BeginSliceOverwrite(const SliceAssetPtr& asset, const AZ::SliceComponent& overwriteComponent, AZ::SerializeContext* serializeContext)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (!serializeContext)
{
@@ -212,7 +212,7 @@ namespace AzToolsFramework
AZ::SerializeContext* serializeContext,
AZ::u32 /*slicePushFlags*/)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (!serializeContext)
{
@@ -515,7 +515,7 @@ namespace AzToolsFramework
SliceTransaction::PostSaveCallback postSaveCallback,
AZ::u32 sliceCommitFlags)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// Clone asset for final modifications and save.
// This also releases borrowed entities and slice instances.
@@ -702,7 +702,7 @@ namespace AzToolsFramework
SliceTransaction::PostSaveCallback postSaveCallback,
AZ::u32 sliceCommitFlags)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZStd::string sliceAssetPath;
AZ::Data::AssetCatalogRequestBus::BroadcastResult(sliceAssetPath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, targetAssetId);
@@ -762,7 +762,7 @@ namespace AzToolsFramework
//=========================================================================
SliceTransaction::SliceAssetPtr SliceTransaction::CloneAssetForSave()
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// Move included slice instances to the target asset temporarily so that they are included in the clone
for (auto& addedSliceInstanceIt : m_addedSliceInstances)
@@ -868,7 +868,7 @@ namespace AzToolsFramework
//=========================================================================
SliceTransaction::Result SliceTransaction::PreSave(const char* fullPath, SliceAssetPtr& asset, PreSaveCallback preSaveCallback, AZ::u32 /*sliceCommitFlags*/)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// Remap live Ids back to those of the asset.
AZ::EntityUtils::SerializableEntityContainer assetEntities;
@@ -904,7 +904,7 @@ namespace AzToolsFramework
//=========================================================================
AZ::EntityId SliceTransaction::FindTargetAncestorAndUpdateInstanceIdMap(AZ::EntityId entityId, AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetIdMap, const AZ::SliceComponent::SliceInstanceAddress* ignoreSliceInstance) const
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::SliceComponent* slice = m_targetAsset.Get()->GetComponent();
@@ -1036,7 +1036,7 @@ namespace AzToolsFramework
//=========================================================================
SliceTransaction::Result SaveSliceToDisk(const char* targetPath, AZStd::vector<AZ::u8>& sliceAssetEntityMemoryBuffer, AZ::SerializeContext* serializeContext)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
AZ_Assert(fileIO, "File IO is not initialized.");
@@ -1058,7 +1058,7 @@ namespace AzToolsFramework
// Write the in-memory copy to file
bool savedToFile;
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:SaveToFileStream");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:SaveToFileStream");
memoryStream.Seek(0, AZ::IO::GenericStream::ST_SEEK_BEGIN);
savedToFile = fileStream.Write(memoryStream.GetLength(), memoryStream.GetData()->data()) != 0;
}
@@ -1066,14 +1066,14 @@ namespace AzToolsFramework
if (savedToFile)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement");
// Copy scratch file to target location.
const bool targetFileExists = fileIO->Exists(targetPath);
bool removedTargetFile;
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:RemoveTarget");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:RemoveTarget");
removedTargetFile = fileIO->Remove(targetPath);
}
@@ -1083,7 +1083,7 @@ namespace AzToolsFramework
}
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:RenameTempFile");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:RenameTempFile");
AZ::IO::Result renameResult = fileIO->Rename(tempFilePath.c_str(), targetPath);
if (!renameResult)
{
@@ -1093,7 +1093,7 @@ namespace AzToolsFramework
// Bump the slice asset up in the asset processor's queue.
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:GetAssetStatus");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::Internal::SaveSliceToDisk:TempToTargetFileReplacement:GetAssetStatus");
EBUS_EVENT(AzFramework::AssetSystemRequestBus, EscalateAssetBySearchTerm, targetPath);
}
return AZ::Success();
@@ -405,7 +405,7 @@ namespace AzToolsFramework
bool QueryAndPruneMissingExternalReferences(AzToolsFramework::EntityIdSet& entities, AzToolsFramework::EntityIdSet& selectedAndReferencedEntities,
bool& useReferencedEntities, bool defaultMoveExternalRefs = false)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:HandleNotIncludedReferences");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:HandleNotIncludedReferences");
useReferencedEntities = false;
AZStd::string includedEntities;
@@ -440,7 +440,7 @@ namespace AzToolsFramework
{
if (!defaultMoveExternalRefs)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:HandleNotIncludedReferences:UserDialog");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:HandleNotIncludedReferences:UserDialog");
const AZStd::string message = AZStd::string::format(
"Entity references may not be valid if the entity IDs change or if the entities do not exist when the slice is instantiated.\r\n\r\nSelected Entities\n%s\nReferenced Entities\n%s\n",
@@ -510,7 +510,7 @@ namespace AzToolsFramework
while (true)
{
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:SaveAsDialog");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:SaveAsDialog");
saveAs = QFileDialog::getSaveFileName(nullptr, QString("Save As..."), saveAsInitialSuggestedFullPath.c_str(), QString("Slices (*.slice)"));
}
@@ -608,7 +608,7 @@ namespace AzToolsFramework
bool silenceWarningPopups,
AZ::SerializeContext* serializeContext)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
if (entities.empty())
{
@@ -702,7 +702,7 @@ namespace AzToolsFramework
{
if (inheritSlices)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:CloneExistingSliceEntities");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:CloneExistingSliceEntities");
const AZ::EntityId dummyParentId;
@@ -801,14 +801,14 @@ namespace AzToolsFramework
// Setup and execute transaction for the new slice.
//
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:SetupAndExecuteTransaction");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:SetupAndExecuteTransaction");
// PreSaveCallback for slice creation: Before saving slice, we ensure it has a single root by optionally auto-creating one for the user
SliceTransaction::PreSaveCallback preSaveCallback =
[&sliceName, &sliceRootEntityPosition, &sliceRootEntityRotation, &activeWindow, &defaultGenerateSharedRoot]
(SliceTransaction::TransactionPtr transaction, const char* fullPath, SliceTransaction::SliceAssetPtr& asset) -> SliceTransaction::Result
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:PreSaveCallback");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:PreSaveCallback");
AZ::SliceComponent::EntityIdToEntityIdMap assetToLiveEntityIDMap;
const AZ::SliceComponent::EntityIdToEntityIdMap& liveToAssetEntityIDMap = transaction->GetLiveToAssetEntityIdMap();
@@ -855,7 +855,7 @@ namespace AzToolsFramework
// Add entities
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::MakeNewSlice:SetupAndExecuteTransaction:AddEntities");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::MakeNewSlice:SetupAndExecuteTransaction:AddEntities");
for (const AZ::EntityId& entityId : entitiesToIncludeInAsset)
{
SliceTransaction::Result addResult = transaction->AddEntity(entityId, !inheritSlices ? SliceTransaction::SliceAddEntityFlags::DiscardSliceAncestry : 0);
@@ -914,7 +914,7 @@ namespace AzToolsFramework
void GatherAllReferencedEntities(AzToolsFramework::EntityIdSet& entitiesWithReferences,
AZ::SerializeContext& serializeContext)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZStd::vector<AZ::EntityId> floodQueue;
floodQueue.reserve(entitiesWithReferences.size());
@@ -1038,7 +1038,7 @@ namespace AzToolsFramework
const AZ::SliceComponent::SliceInstance& instance,
AZ::SerializeContext& serializeContext)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ_Assert(instance.GetEntityIdMap().find(sourceEntity.GetId()) != instance.GetEntityIdMap().end(), "Provided source entity is not a member of the provided slice instance.");
@@ -1494,7 +1494,7 @@ namespace AzToolsFramework
//=========================================================================
SliceTransaction::Result SlicePreSaveCallbackForWorldEntities(SliceTransaction::TransactionPtr transaction, const char* fullPath, SliceTransaction::SliceAssetPtr& asset)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::SlicePreSaveCallbackForWorldEntities");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::SlicePreSaveCallbackForWorldEntities");
// Apply standard root transform rules. Zero out root entity translation, ensure single root, ensure slice root has no parent in slice.
SliceTransaction::Result worldTransformRulesResult = VerifyAndApplySliceWorldTransformRules(asset);
@@ -1536,7 +1536,7 @@ namespace AzToolsFramework
void SlicePostSaveCallbackForNewSlice(SliceTransaction::TransactionPtr transaction, const char* fullPath, const SliceTransaction::SliceAssetPtr& transactionAsset)
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::SlicePostSaveCallbackForNewSlice");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::SlicePostSaveCallbackForNewSlice");
const char* undoMessage = "Create Slice Asset";
ScopedUndoBatch undoBatch(undoMessage);
@@ -1568,7 +1568,7 @@ namespace AzToolsFramework
bool CheckSliceAdditionCyclicDependencySafe(const AZ::SliceComponent::SliceInstanceAddress& instanceToAdd,
const AZ::SliceComponent::SliceInstanceAddress& targetInstanceToAddTo)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ_Assert(instanceToAdd.IsValid(), "Invalid instanceToAdd passed to CheckSliceADditionCyclicDependencySafe.");
@@ -1706,7 +1706,7 @@ namespace AzToolsFramework
void PopulateSliceSubMenus(QMenu& outerMenu, const AzToolsFramework::EntityIdList& inputEntities, SliceSelectedCallback sliceSelectedCallback, SliceSelectedCallback sliceRelationshipViewCallback)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// The find slice menu only works with a single entity selected.
if (inputEntities.size() != 1)
{
@@ -2244,7 +2244,7 @@ namespace AzToolsFramework
//=========================================================================
bool DoEntitiesHaveOverrides(const AzToolsFramework::EntityIdList& inputEntities)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::SerializeContext* serializeContext = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
@@ -2287,7 +2287,7 @@ namespace AzToolsFramework
//=========================================================================
bool IsReparentNonTrivial(const AZ::EntityId& entityId, const AZ::EntityId& newParentId)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::EntityId oldParentId;
AZ::TransformBus::EventResult(oldParentId, entityId, &AZ::TransformBus::Events::GetParentId);
@@ -2358,7 +2358,7 @@ namespace AzToolsFramework
void ReparentNonTrivialSliceInstanceHierarchy(const AZ::EntityId& entityId, const AZ::EntityId& newParentId)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::SliceComponent::SliceInstanceEntityIdRemapList subslicesToDetach;
AzToolsFramework::EntityIdList entitiesToDetach;
@@ -2892,7 +2892,7 @@ namespace AzToolsFramework
//=========================================================================
void GenerateSuggestedSliceFilenameFromEntities(const AzToolsFramework::EntityIdList& entities, AZStd::string& outName)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// Determine suggested save name for slice based on entity names
// For example, with entities Entity0, Entity1, and Entity2, we would end up with
@@ -2962,7 +2962,7 @@ namespace AzToolsFramework
//=========================================================================
void GenerateSuggestedSlicePath(const AZStd::string& sliceName, const AZStd::string& targetDirectory, AZStd::string& suggestedFullPath)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
// Generate full suggested path from sliceName - if given NewSlice as sliceName,
// NewSlice_001.slice would be tried, and if that already existed we would suggest
@@ -3079,7 +3079,7 @@ namespace AzToolsFramework
QWidget* activeWindow,
bool defaultGenerateSharedRoot)
{
AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzToolsFramework);
AZ_PROFILE_FUNCTION(AzToolsFramework);
AZ::SerializeContext* serializeContext = nullptr;
AZ::ComponentApplicationBus::BroadcastResult(serializeContext, &AZ::ComponentApplicationBus::Events::GetSerializeContext);
@@ -3105,7 +3105,7 @@ namespace AzToolsFramework
{
int response;
{
AZ_PROFILE_SCOPE(AZ::Debug::ProfileCategory::AzToolsFramework, "SliceUtilities::CheckAndAddSliceRoot:SingleRootUserQuery");
AZ_PROFILE_SCOPE(AzToolsFramework, "SliceUtilities::CheckAndAddSliceRoot:SingleRootUserQuery");
response = QMessageBox::warning(activeWindow,
QStringLiteral("Cannot Create Slice"),
QString("The slice cannot be created because no single transform root is defined. "