diff --git a/Code/Editor/CryEditDoc.cpp b/Code/Editor/CryEditDoc.cpp index e5988918f5..647732a895 100644 --- a/Code/Editor/CryEditDoc.cpp +++ b/Code/Editor/CryEditDoc.cpp @@ -1047,7 +1047,7 @@ static bool TryRenameFile(const QString& oldPath, const QString& newPath, int re bool CCryEditDoc::SaveLevel(const QString& filename) { - AZ_PROFILE_FUNCTION(AzToolsFramework); + AZ_PROFILE_FUNCTION(Editor); QWaitCursor wait; CAutoCheckOutDialogEnableForAll enableForAll; @@ -1067,7 +1067,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename) { - AZ_PROFILE_SCOPE(AzToolsFramework, "CCryEditDoc::SaveLevel BackupBeforeSave"); + AZ_PROFILE_SCOPE(Editor, "CCryEditDoc::SaveLevel BackupBeforeSave"); BackupBeforeSave(); } @@ -1178,7 +1178,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename) CPakFile pakFile; { - AZ_PROFILE_SCOPE(AzToolsFramework, "CCryEditDoc::SaveLevel Open PakFile"); + AZ_PROFILE_SCOPE(Editor, "CCryEditDoc::SaveLevel Open PakFile"); if (!pakFile.Open(tempSaveFile.toUtf8().data(), false)) { gEnv->pLog->LogWarning("Unable to open pack file %s for writing", tempSaveFile.toUtf8().data()); @@ -1209,7 +1209,7 @@ bool CCryEditDoc::SaveLevel(const QString& filename) AZ::IO::ByteContainerStream> entitySaveStream(&entitySaveBuffer); { - AZ_PROFILE_SCOPE(AzToolsFramework, "CCryEditDoc::SaveLevel Save Entities To Stream"); + AZ_PROFILE_SCOPE(Editor, "CCryEditDoc::SaveLevel Save Entities To Stream"); EBUS_EVENT_RESULT( savedEntities, AzToolsFramework::EditorEntityContextRequestBus, SaveToStreamForEditor, entitySaveStream, layerEntities, instancesInLayers); diff --git a/Code/Editor/EditorDefs.h b/Code/Editor/EditorDefs.h index 423f4c5f73..4115e8433a 100644 --- a/Code/Editor/EditorDefs.h +++ b/Code/Editor/EditorDefs.h @@ -8,8 +8,6 @@ #pragma once -#ifndef CRYINCLUDE_EDITOR_EDITORDEFS_H -#define CRYINCLUDE_EDITOR_EDITORDEFS_H #include @@ -186,5 +184,3 @@ #endif #endif - -#endif // CRYINCLUDE_EDITOR_EDITORDEFS_H diff --git a/Code/Editor/EditorViewportWidget.cpp b/Code/Editor/EditorViewportWidget.cpp index 779c0093a0..c15fc0363e 100644 --- a/Code/Editor/EditorViewportWidget.cpp +++ b/Code/Editor/EditorViewportWidget.cpp @@ -393,8 +393,6 @@ void EditorViewportWidget::UpdateContent(int flags) ////////////////////////////////////////////////////////////////////////// void EditorViewportWidget::Update() { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - if (Editor::EditorQtApplication::instance()->isMovingOrResizing()) { return; @@ -956,15 +954,11 @@ AzFramework::CameraState EditorViewportWidget::GetCameraState() AZ::Vector3 EditorViewportWidget::PickTerrain(const AzFramework::ScreenPoint& point) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - return LYVec3ToAZVec3(ViewToWorld(AzToolsFramework::ViewportInteraction::QPointFromScreenPoint(point), nullptr, true)); } AZ::EntityId EditorViewportWidget::PickEntity(const AzFramework::ScreenPoint& point) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - PreWidgetRendering(); AZ::EntityId entityId; @@ -991,8 +985,6 @@ float EditorViewportWidget::TerrainHeight(const AZ::Vector2& position) void EditorViewportWidget::FindVisibleEntities(AZStd::vector& visibleEntitiesOut) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End()); } diff --git a/Code/Editor/IEditor.h b/Code/Editor/IEditor.h index 7d0fc653fa..de7b0ec3f9 100644 --- a/Code/Editor/IEditor.h +++ b/Code/Editor/IEditor.h @@ -6,9 +6,6 @@ * */ - -#ifndef CRYINCLUDE_EDITOR_IEDITOR_H -#define CRYINCLUDE_EDITOR_IEDITOR_H #pragma once #ifdef PLUGIN_EXPORTS @@ -25,6 +22,7 @@ #include #include +#include class QMenu; @@ -738,4 +736,5 @@ struct IInitializeUIInfo virtual void SetInfoText(const char* text) = 0; }; -#endif // CRYINCLUDE_EDITOR_IEDITOR_H +AZ_DECLARE_BUDGET(Editor); + diff --git a/Code/Editor/IEditorImpl.cpp b/Code/Editor/IEditorImpl.cpp index 1e268d64ef..8f4abae9dd 100644 --- a/Code/Editor/IEditorImpl.cpp +++ b/Code/Editor/IEditorImpl.cpp @@ -405,8 +405,6 @@ void CEditorImpl::Update() // Make sure this is not called recursively m_bUpdates = false; - FUNCTION_PROFILER(GetSystem(), PROFILE_EDITOR); - //@FIXME: Restore this latter. //if (GetGameEngine() && GetGameEngine()->IsLevelLoaded()) { diff --git a/Code/Editor/Objects/BaseObject.cpp b/Code/Editor/Objects/BaseObject.cpp index c89bd50559..c653830e70 100644 --- a/Code/Editor/Objects/BaseObject.cpp +++ b/Code/Editor/Objects/BaseObject.cpp @@ -38,7 +38,6 @@ // To use the Andrew's algorithm in order to make convex hull from the points, this header is needed. #include "Util/GeometryUtil.h" - namespace { QColor kLinkColorParent = QColor(0, 255, 255); QColor kLinkColorChild = QColor(0, 0, 255); @@ -1928,7 +1927,7 @@ bool CBaseObject::HitTestRectBounds(HitContext& hc, const AABB& box) ////////////////////////////////////////////////////////////////////////// bool CBaseObject::HitTestRect(HitContext& hc) { - AZ_PROFILE_FUNCTION(Entity); + AZ_PROFILE_FUNCTION(Editor); AABB box; @@ -1965,7 +1964,7 @@ bool CBaseObject::HitHelperTest(HitContext& hc) ////////////////////////////////////////////////////////////////////////// bool CBaseObject::HitHelperAtTest(HitContext& hc, const Vec3& pos) { - AZ_PROFILE_FUNCTION(Entity); + AZ_PROFILE_FUNCTION(Editor); bool bResult = false; diff --git a/Code/Editor/Objects/DisplayContextShared.inl b/Code/Editor/Objects/DisplayContextShared.inl index 5af04d821e..90c6ba09b0 100644 --- a/Code/Editor/Objects/DisplayContextShared.inl +++ b/Code/Editor/Objects/DisplayContextShared.inl @@ -1261,10 +1261,6 @@ void DisplayContext::DrawTextureLabel(const Vec3& pos, int nWidth, int nHeight, ////////////////////////////////////////////////////////////////////////// void DisplayContext::Flush2D() { -#ifndef PHYSICS_EDITOR - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); -#endif - if (m_textureLabels.empty()) { return; diff --git a/Code/Editor/Objects/EntityObject.cpp b/Code/Editor/Objects/EntityObject.cpp index 68264f9ea4..6e2354998c 100644 --- a/Code/Editor/Objects/EntityObject.cpp +++ b/Code/Editor/Objects/EntityObject.cpp @@ -497,7 +497,7 @@ bool CEntityObject::HitTestRect(HitContext& hc) ////////////////////////////////////////////////////////////////////////// int CEntityObject::MouseCreateCallback(CViewport* view, EMouseEvent event, QPoint& point, int flags) { - AZ_PROFILE_FUNCTION(Editor); + AZ_PROFILE_FUNCTION(Entity); if (event == eMouseMove || event == eMouseLDown) { diff --git a/Code/Editor/Objects/GizmoManager.cpp b/Code/Editor/Objects/GizmoManager.cpp index e0fdd69c8e..1704fd9322 100644 --- a/Code/Editor/Objects/GizmoManager.cpp +++ b/Code/Editor/Objects/GizmoManager.cpp @@ -18,8 +18,6 @@ ////////////////////////////////////////////////////////////////////////// void CGizmoManager::Display(DisplayContext& dc) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - AABB bbox; std::vector todelete; for (Gizmos::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it) diff --git a/Code/Editor/Objects/ObjectManager.cpp b/Code/Editor/Objects/ObjectManager.cpp index 940ef5b551..aec5835565 100644 --- a/Code/Editor/Objects/ObjectManager.cpp +++ b/Code/Editor/Objects/ObjectManager.cpp @@ -37,7 +37,6 @@ AZ_CVAR( bool, ed_visibility_use, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Enable/disable using the new IVisibilitySystem for Entity visibility determination"); - /*! * Class Description used for object templates. * This description filled from Xml template files. diff --git a/Code/Editor/Objects/ObjectManagerLegacyUndo.cpp b/Code/Editor/Objects/ObjectManagerLegacyUndo.cpp index 08a7f4cf48..10f3a25b6d 100644 --- a/Code/Editor/Objects/ObjectManagerLegacyUndo.cpp +++ b/Code/Editor/Objects/ObjectManagerLegacyUndo.cpp @@ -19,7 +19,6 @@ #include "Objects/ObjectLoader.h" #include "Objects/SelectionGroup.h" - ////////////////////////////////////////////////////////////////////////// // CUndoBaseObjectNew implementation. ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Plugins/EditorAssetImporter/AssetImporterDocument.cpp b/Code/Editor/Plugins/EditorAssetImporter/AssetImporterDocument.cpp index c7e14d9c4e..105a5b4954 100644 --- a/Code/Editor/Plugins/EditorAssetImporter/AssetImporterDocument.cpp +++ b/Code/Editor/Plugins/EditorAssetImporter/AssetImporterDocument.cpp @@ -31,6 +31,7 @@ #include #include #include +#include #include #include diff --git a/Code/Editor/Plugins/EditorAssetImporter/ImporterRootDisplay.cpp b/Code/Editor/Plugins/EditorAssetImporter/ImporterRootDisplay.cpp index 4f942a4251..2c00edbc39 100644 --- a/Code/Editor/Plugins/EditorAssetImporter/ImporterRootDisplay.cpp +++ b/Code/Editor/Plugins/EditorAssetImporter/ImporterRootDisplay.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include ImporterRootDisplay::ImporterRootDisplay(AZ::SerializeContext* serializeContext, QWidget* parent) diff --git a/Code/Editor/TopRendererWnd.cpp b/Code/Editor/TopRendererWnd.cpp index 7bbefdd63f..541e967dd0 100644 --- a/Code/Editor/TopRendererWnd.cpp +++ b/Code/Editor/TopRendererWnd.cpp @@ -148,8 +148,6 @@ void QTopRendererWnd::UpdateContent(int flags) ////////////////////////////////////////////////////////////////////////// void QTopRendererWnd::Draw([[maybe_unused]] DisplayContext& dc) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - //////////////////////////////////////////////////////////////////////// // Perform the rendering for this window //////////////////////////////////////////////////////////////////////// diff --git a/Code/Editor/Util/GeometryUtil.cpp b/Code/Editor/Util/GeometryUtil.cpp index d4442e8d03..6025f0c771 100644 --- a/Code/Editor/Util/GeometryUtil.cpp +++ b/Code/Editor/Util/GeometryUtil.cpp @@ -41,7 +41,6 @@ struct SPointSorter //=================================================================== void ConvexHull2DGraham(std::vector& ptsOut, const std::vector& ptsIn) { - FUNCTION_PROFILER(gEnv->pSystem, PROFILE_AI); const unsigned nPtsIn = ptsIn.size(); if (nPtsIn < 3) { @@ -66,7 +65,6 @@ void ConvexHull2DGraham(std::vector& ptsOut, const std::vector& ptsI std::swap(ptsSorted[0], ptsSorted[iBotRight]); { - FRAME_PROFILER("SORT Graham", gEnv->pSystem, PROFILE_AI) std::sort(ptsSorted.begin() + 1, ptsSorted.end(), SPointSorter(ptsSorted[0])); } ptsSorted.erase(std::unique(ptsSorted.begin(), ptsSorted.end(), ptEqual), ptsSorted.end()); @@ -196,7 +194,6 @@ inline bool PointSorterAndrew(const Vec3& lhs, const Vec3& rhs) //=================================================================== SANDBOX_API void ConvexHull2DAndrew(std::vector& ptsOut, const std::vector& ptsIn) { - FUNCTION_PROFILER(gEnv->pSystem, PROFILE_AI); const int n = (int)ptsIn.size(); if (n < 3) { @@ -206,7 +203,6 @@ SANDBOX_API void ConvexHull2DAndrew(std::vector& ptsOut, const std::vector std::vector P = ptsIn; { - FRAME_PROFILER("SORT Andrew", gEnv->pSystem, PROFILE_AI) std::sort(P.begin(), P.end(), PointSorterAndrew); } diff --git a/Code/Editor/Viewport.cpp b/Code/Editor/Viewport.cpp index 3c34f464b8..0ddad5c31e 100644 --- a/Code/Editor/Viewport.cpp +++ b/Code/Editor/Viewport.cpp @@ -400,7 +400,6 @@ void QtViewport::UpdateContent(int flags) ////////////////////////////////////////////////////////////////////////// void QtViewport::Update() { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); m_viewportUi.Update(); m_bAdvancedSelectMode = false; @@ -1436,9 +1435,6 @@ bool QtViewport::MouseCallback(EMouseEvent event, const QPoint& point, Qt::Keybo ////////////////////////////////////////////////////////////////////////// void QtViewport::ProcessRenderLisneters(DisplayContext& rstDisplayContext) { - FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - - size_t nCount(0); size_t nTotal(0); diff --git a/Code/Framework/AzCore/AzCore/AzCoreModule.cpp b/Code/Framework/AzCore/AzCore/AzCoreModule.cpp index d2b1b141a9..c60ea1bd72 100644 --- a/Code/Framework/AzCore/AzCore/AzCoreModule.cpp +++ b/Code/Framework/AzCore/AzCore/AzCoreModule.cpp @@ -10,7 +10,6 @@ // Component includes #include -#include #include #include #include @@ -36,7 +35,6 @@ namespace AZ JsonSystemComponent::CreateDescriptor(), AssetManagerComponent::CreateDescriptor(), UserSettingsComponent::CreateDescriptor(), - Debug::FrameProfilerComponent::CreateDescriptor(), SliceComponent::CreateDescriptor(), SliceSystemComponent::CreateDescriptor(), SliceMetadataInfoComponent::CreateDescriptor(), diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp index 5114ea19ec..383da71653 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.cpp @@ -51,7 +51,6 @@ #include #include #include -#include #include #include #include @@ -546,6 +545,10 @@ namespace AZ m_entityActivatedEvent.DisconnectAllHandlers(); m_entityDeactivatedEvent.DisconnectAllHandlers(); +#if !defined(_RELEASE) + m_budgetTracker.Reset(); +#endif + DestroyAllocator(); } @@ -594,6 +597,10 @@ namespace AZ CreateOSAllocator(); CreateSystemAllocator(); +#if !defined(_RELEASE) + m_budgetTracker.Init(); +#endif + // This can be moved to the ComponentApplication constructor if need be // This is reading the *.setreg files using SystemFile and merging the settings // to the settings registry. @@ -625,8 +632,6 @@ namespace AZ m_eventLogger->Start(outputPath.Native(), baseFileName); } - CreateDrillers(); - Sfmt::Create(); CreateReflectionManager(); @@ -746,12 +751,6 @@ namespace AZ ComponentApplicationBus::Handler::BusDisconnect(); TickRequestBus::Handler::BusDisconnect(); - if (m_drillerManager) - { - Debug::DrillerManager::Destroy(m_drillerManager); - m_drillerManager = nullptr; - } - m_eventLogger->Stop(); // Clear the descriptor to deallocate all strings (owned by ModuleDescriptor) @@ -899,33 +898,6 @@ namespace AZ allocatorManager.FinalizeConfiguration(); } - //========================================================================= - // CreateDrillers - // [2/20/2013] - //========================================================================= - void ComponentApplication::CreateDrillers() - { - // Create driller manager and register drillers if requested - if (m_descriptor.m_enableDrilling) - { - m_drillerManager = Debug::DrillerManager::Create(); - // Memory driller is responsible for tracking allocations. - // Tracking type and overhead is determined by app configuration. - - // Only one MemoryDriller is supported at a time - // Only create the memory driller if there is no handlers connected to the MemoryDrillerBus - if (!Debug::MemoryDrillerBus::HasHandlers()) - { - m_drillerManager->Register(aznew Debug::MemoryDriller); - } - // Profiler driller will consume resources only when started. - m_drillerManager->Register(aznew Debug::ProfilerDriller); - // Trace messages driller will consume resources only when started. - m_drillerManager->Register(aznew Debug::TraceMessagesDriller); - m_drillerManager->Register(aznew Debug::EventTraceDriller); - } - } - void ComponentApplication::MergeSettingsToRegistry(SettingsRegistryInterface& registry) { SettingsRegistryInterface::Specializations specializations; @@ -1416,10 +1388,6 @@ namespace AZ EBUS_EVENT(TickBus, OnTick, m_deltaTime, ScriptTimePoint(now)); } } - if (m_drillerManager) - { - m_drillerManager->FrameUpdate(); - } } //========================================================================= diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h index d2da86c368..3768a75d83 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplication.h @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -225,11 +226,6 @@ namespace AZ /// Returns the path to the folder the executable is in. const char* GetExecutableFolder() const override { return m_exeDirectory.c_str(); } - - /// Returns pointer to the driller manager if it's enabled, otherwise NULL. - Debug::DrillerManager* GetDrillerManager() override { return m_drillerManager; } - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// /// TickRequestBus float GetTickDeltaTime() override; @@ -324,9 +320,6 @@ namespace AZ /// Create the system allocator using the data in the m_descriptor void CreateSystemAllocator(); - /// Create the drillers - void CreateDrillers(); - virtual void MergeSettingsToRegistry(SettingsRegistryInterface& registry); //! Sets the specializations that will be used when loading the Settings Registry. Extend this in derived @@ -402,6 +395,10 @@ namespace AZ // from the m_console member when it goes out of scope AZ::SettingsRegistryConsoleUtils::ConsoleFunctorHandle m_settingsRegistryConsoleFunctors; +#if !defined(_RELEASE) + Debug::BudgetTracker m_budgetTracker; +#endif + // this is used when no argV/ArgC is supplied. // in order to have the same memory semantics (writable, non-const) // we create a buffer that can be written to (up to AZ_MAX_PATH_LEN) and then @@ -409,8 +406,6 @@ namespace AZ char m_commandLineBuffer[AZ_MAX_PATH_LEN]; char* m_commandLineBufferAddress{ m_commandLineBuffer }; - Debug::DrillerManager* m_drillerManager{ nullptr }; - StartupParameters m_startupParameters; char** m_argV{ nullptr }; diff --git a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h index 1e4a9082f7..0c0977384a 100644 --- a/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h +++ b/Code/Framework/AzCore/AzCore/Component/ComponentApplicationBus.h @@ -187,11 +187,6 @@ namespace AZ //! @return a pointer to the name of the path that contains the application's executable. virtual const char* GetExecutableFolder() const = 0; - //! Returns a pointer to the driller manager, if driller is enabled. - //! The driller manager manages all active driller sessions and driller factories. - //! @return A pointer to the driller manager. If driller is not enabled, this function returns null. - virtual Debug::DrillerManager* GetDrillerManager() = 0; - //! ResolveModulePath is called whenever LoadDynamicModule wants to resolve a module in order to actually load it. //! You can override this if you need to load modules from a different path or hijack module loading in some other way. //! If you do, ensure that you use platform-specific conventions to do so, as this is called by multiple platforms. diff --git a/Code/Framework/AzCore/AzCore/Component/Entity.h b/Code/Framework/AzCore/AzCore/Component/Entity.h index becb0b085a..7ec63a56ac 100644 --- a/Code/Framework/AzCore/AzCore/Component/Entity.h +++ b/Code/Framework/AzCore/AzCore/Component/Entity.h @@ -16,6 +16,7 @@ #pragma once #include +#include #include #include #include @@ -438,3 +439,4 @@ namespace AZ return component; } } // namespace AZ + diff --git a/Code/Framework/AzCore/AzCore/Debug/Budget.cpp b/Code/Framework/AzCore/AzCore/Debug/Budget.cpp new file mode 100644 index 0000000000..f9fe7e462a --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Debug/Budget.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include "Budget.h" + +#include +#include +#include + +AZ_DEFINE_BUDGET(Animation); +AZ_DEFINE_BUDGET(Audio); +AZ_DEFINE_BUDGET(AzCore); +AZ_DEFINE_BUDGET(Editor); +AZ_DEFINE_BUDGET(Entity); +AZ_DEFINE_BUDGET(Game); +AZ_DEFINE_BUDGET(System); +AZ_DEFINE_BUDGET(Physics); + +namespace AZ::Debug +{ + struct BudgetImpl + { + AZ_CLASS_ALLOCATOR(BudgetImpl, AZ::SystemAllocator, 0); + // TODO: Budget implementation for tracking budget wall time per-core, memory, etc. + }; + + Budget::Budget(const char* name) + : m_name{ name } + , m_crc{ Crc32(name) } + { + } + + Budget::Budget(const char* name, uint32_t crc) + : m_name{ name } + , m_crc{ crc } + { + m_impl = aznew BudgetImpl; + } + + Budget::~Budget() + { + if (m_impl) + { + delete m_impl; + } + } + + // TODO:Budgets Methods below are stubbed pending future work to both update budget data and visualize it + + void Budget::PerFrameReset() + { + } + + void Budget::BeginProfileRegion() + { + } + + void Budget::EndProfileRegion() + { + } + + void Budget::TrackAllocation(uint64_t) + { + } + + void Budget::UntrackAllocation(uint64_t) + { + } +} // namespace AZ::Debug diff --git a/Code/Framework/AzCore/AzCore/Debug/Budget.h b/Code/Framework/AzCore/AzCore/Debug/Budget.h new file mode 100644 index 0000000000..4646ef8b2c --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Debug/Budget.h @@ -0,0 +1,88 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ +#pragma once + +#include +#include + +namespace AZ::Debug +{ + // A budget collates per-frame resource utilization and memory for a particular category + class Budget final + { + public: + explicit Budget(const char* name); + Budget(const char* name, uint32_t crc); + ~Budget(); + + void PerFrameReset(); + void BeginProfileRegion(); + void EndProfileRegion(); + void TrackAllocation(uint64_t bytes); + void UntrackAllocation(uint64_t bytes); + + const char* Name() const + { + return m_name; + } + + uint32_t Crc() const + { + return m_crc; + } + + private: + const char* m_name; + const uint32_t m_crc; + struct BudgetImpl* m_impl = nullptr; + }; +} // namespace AZ::Debug + +// The budget is usable in the same file it was defined without needing an additional declaration. +// If you encounter a linker error complaining that this function is not defined, you have likely forgotten to either +// define or declare the budget used in a profile or memory marker. See AZ_DEFINE_BUDGET and AZ_DECLARE_BUDGET below +// for usage. +#define AZ_BUDGET_GETTER(name) GetAzBudget##name + +#if defined(_RELEASE) +#define AZ_DEFINE_BUDGET(name) \ + ::AZ::Debug::Budget* AZ_BUDGET_GETTER(name)() \ + { \ + return nullptr; \ + } +#else +// Usage example: +// In a single C++ source file: +// AZ_DEFINE_BUDGET(AzCore); +// +// Anywhere the budget is used, the budget must be declared (either in a header or in the source file itself) +// AZ_DECLARE_BUDGET(AzCore); +#define AZ_DEFINE_BUDGET(name) \ + ::AZ::Debug::Budget* AZ_BUDGET_GETTER(name)() \ + { \ + constexpr static uint32_t crc = AZ_CRC_CE(#name); \ + static ::AZ::Debug::Budget* budget = ::AZ::Debug::BudgetTracker::GetBudgetFromEnvironment(#name, crc); \ + return budget; \ + } +#endif + +// If using a budget defined in a different C++ source file, add AZ_DECLARE_BUDGET(yourBudget); somewhere in your source file at namespace +// scope Alternatively, AZ_DECLARE_BUDGET can be used in a header to declare the budget for use across any users of the header +#define AZ_DECLARE_BUDGET(name) ::AZ::Debug::Budget* AZ_BUDGET_GETTER(name)() + +// Declare budgets that are core engine budgets, or may be shared/needed across multiple external gems +// You should NOT need to declare user-space or budgets with isolated usage here. Prefer declaring them local to the module(s) that use +// the budget and defining them within a single module to avoid needing to recompile the entire engine. +AZ_DECLARE_BUDGET(Animation); +AZ_DECLARE_BUDGET(Audio); +AZ_DECLARE_BUDGET(AzCore); +AZ_DECLARE_BUDGET(Editor); +AZ_DECLARE_BUDGET(Entity); +AZ_DECLARE_BUDGET(Game); +AZ_DECLARE_BUDGET(System); +AZ_DECLARE_BUDGET(Physics); diff --git a/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp new file mode 100644 index 0000000000..255a740e32 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.cpp @@ -0,0 +1,72 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#include + +#include +#include +#include +#include +#include +#include + +namespace AZ::Debug +{ + constexpr static const char* BudgetTrackerEnvName = "budgetTrackerEnv"; + + struct BudgetTracker::BudgetTrackerImpl + { + AZStd::unordered_map m_budgets; + }; + + Budget* BudgetTracker::GetBudgetFromEnvironment(const char* budgetName, uint32_t crc) + { + BudgetTracker* tracker = Interface::Get(); + if (tracker) + { + return &tracker->GetBudget(budgetName, crc); + } + return nullptr; + } + + BudgetTracker::~BudgetTracker() + { + Reset(); + } + + bool BudgetTracker::Init() + { + if (Interface::Get()) + { + return false; + } + + Interface::Register(this); + m_impl = new BudgetTrackerImpl; + return true; + } + + void BudgetTracker::Reset() + { + if (m_impl) + { + Interface::Unregister(this); + delete m_impl; + m_impl = nullptr; + } + } + + Budget& BudgetTracker::GetBudget(const char* budgetName, uint32_t crc) + { + AZStd::scoped_lock lock{ m_mutex }; + + auto it = m_impl->m_budgets.try_emplace(budgetName, budgetName, crc).first; + + return it->second; + } +} // namespace AZ::Debug diff --git a/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.h b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.h new file mode 100644 index 0000000000..1357bb5870 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Debug/BudgetTracker.h @@ -0,0 +1,43 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +#pragma once + +#include +#include +#include + +namespace AZ::Debug +{ + class Budget; + + class BudgetTracker + { + public: + AZ_RTTI(BudgetTracker, "{E14A746D-BFFE-4C02-90FB-4699B79864A5}"); + static Budget* GetBudgetFromEnvironment(const char* budgetName, uint32_t crc); + + ~BudgetTracker(); + + // Returns false if the budget tracker was already present in the environment (initialized already elsewhere) + bool Init(); + void Reset(); + + Budget& GetBudget(const char* budgetName, uint32_t crc); + + private: + struct BudgetTrackerImpl; + + AZStd::mutex m_mutex; + + // The BudgetTracker is likely included in proportionally high number of files throughout the + // engine, so indirection is used here to avoid imposing excessive recompilation in periods + // while the budget system is iterated on. + BudgetTrackerImpl* m_impl = nullptr; + }; +} // namespace AZ::Debug diff --git a/Code/Framework/AzCore/AzCore/Debug/FrameProfiler.h b/Code/Framework/AzCore/AzCore/Debug/FrameProfiler.h deleted file mode 100644 index 2b86168b82..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/FrameProfiler.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef AZCORE_FRAME_PROFILER_H -#define AZCORE_FRAME_PROFILER_H - -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace Debug - { - namespace FrameProfiler - { - /** - * This structure is used for frame data history, make sure it's memory efficient. - */ - struct FrameData - { - unsigned int m_frameId; ///< Id of the frame this data belongs to. - union - { - ProfilerRegister::TimeData m_timeData; - ProfilerRegister::ValuesData m_userValues; - }; - }; - - struct RegisterData - { - ////////////////////////////////////////////////////////////////////////// - // Profile register snapshot - /// data that doesn't change - const char* m_name; ///< Name of the profiler register. - const char* m_function; ///< Function name in the code. - int m_line; ///< Line number if the code. - AZ::u32 m_systemId; ///< Register system id. - ProfilerRegister::Type m_type; - RegisterData* m_lastParent; ///< Pointer to the last parent register data. - AZStd::ring_buffer m_frames; ///< History of all frame deltas (basically the data you want to display) - }; - - struct ThreadData - { - typedef AZStd::unordered_map RegistersMap; - AZStd::thread_id m_id; ///< Thread id (same as AZStd::thread::id) - RegistersMap m_registers; ///< Map with all the registers (with history) - }; - - typedef AZStd::fixed_vector ThreadDataArray; ///< Array with samplers for all threads - } // namespace FrameProfiler - } // namespace Debug -} // namespace AZ - -#endif // AZCORE_FRAME_PROFILER_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerBus.h b/Code/Framework/AzCore/AzCore/Debug/FrameProfilerBus.h deleted file mode 100644 index 93fd8be8bb..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerBus.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef AZCORE_FRAME_PROFILER_BUS_H -#define AZCORE_FRAME_PROFILER_BUS_H - -#include -#include - -namespace AZ -{ - namespace Debug - { - class FrameProfilerComponent; - - /** - * Interface class for frame profiler events. - */ - class FrameProfilerEvents - : public AZ::EBusTraits - { - public: - virtual ~FrameProfilerEvents() {} - - /// Called when the frame profiler has computed a new frame (even is there is no new data). - virtual void OnFrameProfilerData(const FrameProfiler::ThreadDataArray& data) = 0; - }; - - typedef AZ::EBus FrameProfilerBus; - } // namespace Debug -} // namespace AZ - -#endif // AZCORE_FRAME_PROFILER_BUS_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.cpp b/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.cpp deleted file mode 100644 index 1bd825b7af..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -#include -#include - -#include - -namespace AZ -{ - namespace Debug - { - //========================================================================= - // FrameProfilerComponent - // [12/5/2012] - //========================================================================= - FrameProfilerComponent::FrameProfilerComponent() - : m_numFramesStored(2) - , m_frameId(0) - , m_pauseOnFrame(0) - , m_currentThreadData(NULL) - { - } - - //========================================================================= - // ~FrameProfilerComponent - // [12/5/2012] - //========================================================================= - FrameProfilerComponent::~FrameProfilerComponent() - { - } - - //========================================================================= - // Activate - // [12/5/2012] - //========================================================================= - void FrameProfilerComponent::Activate() - { - if (!Profiler::IsReady()) - { - Profiler::Create(); - } - - Profiler::AddReference(); - - TickBus::Handler::BusConnect(); - AZ_Assert(m_numFramesStored >= 1, "We must have at least one frame to store, otherwise this component is useless!"); - } - - //========================================================================= - // Deactivate - // [12/5/2012] - //========================================================================= - void FrameProfilerComponent::Deactivate() - { - TickBus::Handler::BusDisconnect(); - - Profiler::ReleaseReference(); - } - - //========================================================================= - // OnTick - // [12/5/2012] - //========================================================================= - void FrameProfilerComponent::OnTick(float deltaTime, ScriptTimePoint time) - { - (void)deltaTime; - (void)time; - ++m_frameId; - AZ_Error("Profiler", m_frameId != m_pauseOnFrame, "Triggered user pause/error on this frame! Check FrameProfilerComponent pauseOnFrame value!"); - - if (!Profiler::IsReady()) - { - return; // we can't sample registers without profiler - } - // collect data from the profiler - m_currentThreadData = NULL; - Profiler::Instance().ReadRegisterValues(AZStd::bind(&FrameProfilerComponent::ReadProfilerRegisters, this, AZStd::placeholders::_1, AZStd::placeholders::_2)); - - // process all the resulting data here, not while reading the registers - for (size_t iThread = 0; iThread < m_threads.size(); ++iThread) - { - FrameProfiler::ThreadData& td = m_threads[iThread]; - FrameProfiler::ThreadData::RegistersMap::iterator it = td.m_registers.begin(); - FrameProfiler::ThreadData::RegistersMap::iterator last = td.m_registers.end(); - for (; it != last; ++it) - { - // fix up parents - FrameProfiler::RegisterData& rd = it->second; - if (rd.m_type == ProfilerRegister::PRT_TIME) - { - const FrameProfiler::FrameData& fd = rd.m_frames.back(); - if (fd.m_timeData.m_lastParent != nullptr) - { - FrameProfiler::ThreadData::RegistersMap::iterator parentIt = td.m_registers.find(fd.m_timeData.m_lastParent); - AZ_Assert(parentIt != td.m_registers.end(), "We have a parent register that is not in our register map. This should not happen!"); - rd.m_lastParent = &parentIt->second; - } - else - { - rd.m_lastParent = NULL; - } - } - } - } - - // send an even to whomever cares - EBUS_EVENT(FrameProfilerBus, OnFrameProfilerData, m_threads); - } - - int FrameProfilerComponent::GetTickOrder() - { - // Even it's not critical we should tick last to capture the current frame - // so TICK_LAST (since it's not the last int +1 is a valid assumption) - return TICK_LAST + 1; - } - - //========================================================================= - // ReadRegisterCallback - // [12/5/2012] - //========================================================================= - bool FrameProfilerComponent::ReadProfilerRegisters(const ProfilerRegister& reg, const AZStd::thread_id& id) - { - if (m_currentThreadData == NULL || m_currentThreadData->m_id != id) - { - m_currentThreadData = NULL; - - // find the thread and cache it, as we will received registers thread by thread... so we don't search. - for (size_t i = 0; i < m_threads.size(); ++i) - { - FrameProfiler::ThreadData* td = &m_threads[i]; - if (td->m_id == id) - { - m_currentThreadData = td; - break; - } - } - - if (m_currentThreadData == NULL) - { - m_threads.push_back(); - m_currentThreadData = &m_threads.back(); - m_currentThreadData->m_id = id; - } - } - - const ProfilerRegister* profReg = ® - FrameProfiler::ThreadData::RegistersMap::pair_iter_bool pairIterBool = m_currentThreadData->m_registers.insert_key(profReg); - FrameProfiler::RegisterData& regData = pairIterBool.first->second; - - // now update dynamic data with as little as possible computation (we must be fast) - FrameProfiler::FrameData fd; // we can actually move this computation (FrameData and push) for later but we will need to use more memory - fd.m_frameId = m_frameId; - - if (pairIterBool.second) - { - // when insert copy the static data only once - regData.m_name = profReg->m_name; - regData.m_function = profReg->m_function; - regData.m_line = profReg->m_line; - regData.m_systemId = profReg->m_systemId; - regData.m_frames.set_capacity(m_numFramesStored); - regData.m_type = static_cast(profReg->m_type); - } - - switch (regData.m_type) - { - case ProfilerRegister::PRT_TIME: - { - fd.m_timeData.m_time = profReg->m_timeData.m_time; - fd.m_timeData.m_childrenTime = profReg->m_timeData.m_childrenTime; - fd.m_timeData.m_calls = profReg->m_timeData.m_calls; - fd.m_timeData.m_childrenCalls = profReg->m_timeData.m_childrenCalls; - fd.m_timeData.m_lastParent = profReg->m_timeData.m_lastParent; - } break; - case ProfilerRegister::PRT_VALUE: - { - fd.m_userValues.m_value1 = profReg->m_userValues.m_value1; - fd.m_userValues.m_value2 = profReg->m_userValues.m_value2; - fd.m_userValues.m_value3 = profReg->m_userValues.m_value3; - fd.m_userValues.m_value4 = profReg->m_userValues.m_value4; - fd.m_userValues.m_value5 = profReg->m_userValues.m_value5; - } break; - } - - regData.m_frames.push_back(fd); - return true; - } - - //========================================================================= - // GetProvidedServices - //========================================================================= - void FrameProfilerComponent::GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided) - { - provided.push_back(AZ_CRC("FrameProfilerService", 0x05d1bb90)); - } - - //========================================================================= - // GetIncompatibleServices - //========================================================================= - void FrameProfilerComponent::GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible) - { - incompatible.push_back(AZ_CRC("FrameProfilerService", 0x05d1bb90)); - } - - //========================================================================= - // GetDependentServices - //========================================================================= - void FrameProfilerComponent::GetDependentServices(ComponentDescriptor::DependencyArrayType& dependent) - { - dependent.push_back(AZ_CRC("MemoryService", 0x5c4d473c)); - } - - //========================================================================= - // Reflect - //========================================================================= - void FrameProfilerComponent::Reflect(ReflectContext* context) - { - if (SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ->Field("numFramesStored", &FrameProfilerComponent::m_numFramesStored) - ->Field("pauseOnFrame", &FrameProfilerComponent::m_pauseOnFrame) - ; - - if (EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class( - "Frame Profiler", "Performs per frame profiling (FPS counter, registers, etc.)") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::Category, "Profiling") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &FrameProfilerComponent::m_numFramesStored, "Number of Frames", "How many frames we will keep with the RUNTIME buffers.") - ->Attribute(AZ::Edit::Attributes::Min, 1) - ->DataElement(AZ::Edit::UIHandlers::SpinBox, &FrameProfilerComponent::m_pauseOnFrame, "Pause on frame", "Paused the engine (debug break) on a specific frame. 0 means no pause!") - ; - } - } - } - } // namespace Debug -} // namespace AZ diff --git a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.h b/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.h deleted file mode 100644 index a92202ed7d..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/FrameProfilerComponent.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef AZCORE_FRAME_PROFILER_COMPONENT_H -#define AZCORE_FRAME_PROFILER_COMPONENT_H - -#include -#include -#include -#include -#include - -namespace AZ -{ - namespace Debug - { - /** - * Frame profiler component provides a frame profiling information - * (from FPS counter to profiler registers manipulation and so on). - * It's a debug system so it should not be active in release - */ - class FrameProfilerComponent - : public Component - , public AZ::TickBus::Handler - { - public: - AZ_COMPONENT(AZ::Debug::FrameProfilerComponent, "{B81739EF-ED77-4F67-9D05-6ADF94F0431A}") - - FrameProfilerComponent(); - virtual ~FrameProfilerComponent(); - - private: - ////////////////////////////////////////////////////////////////////////// - // Component base - void Activate() override; - void Deactivate() override; - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Tick bus - void OnTick(float deltaTime, ScriptTimePoint time) override; - int GetTickOrder() override; - ////////////////////////////////////////////////////////////////////////// - - /// \ref ComponentDescriptor::GetProvidedServices - static void GetProvidedServices(ComponentDescriptor::DependencyArrayType& provided); - /// \ref ComponentDescriptor::GetIncompatibleServices - static void GetIncompatibleServices(ComponentDescriptor::DependencyArrayType& incompatible); - /// \ref ComponentDescriptor::GetDependentServices - static void GetDependentServices(ComponentDescriptor::DependencyArrayType& dependent); - /// \red ComponentDescriptor::Reflect - static void Reflect(ReflectContext* reflection); - - /// callback for reading profiler registers - bool ReadProfilerRegisters(const ProfilerRegister& reg, const AZStd::thread_id& id); - - // Keep in mind memory usage, increases quickly. Prefer remote tools (where the history is kept on the PC) instead of keeping long history - unsigned int m_numFramesStored; ///< Number of frames that we will store in history buffers. >= 1 - unsigned int m_frameId; ///< Frame id (it's just counted from the start). - - unsigned int m_pauseOnFrame; ///< Allows you to specify a frame the code will pause onto. - - - FrameProfiler::ThreadDataArray m_threads; ///< Array with samplers for all threads - FrameProfiler::ThreadData* m_currentThreadData; ///< Cached pointer to the last accessed thread data. - }; - } -} - -#endif // AZCORE_FRAME_PROFILER_COMPONENT_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp b/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp index 649bb0b8d7..0bb92b923d 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.cpp @@ -7,664 +7,4 @@ */ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AZ -{ - uint32_t ProfileScope::GetSystemID(const char* system) - { - // TODO: stable ids for registered budgets - return AZ::Crc32(system); - } - - namespace Debug - { - ////////////////////////////////////////////////////////////////////////// - // Globals - AZStd::chrono::microseconds ProfilerRegister::TimeData::s_startStopOverheadPer1000Calls(0); - Profiler* Profiler::s_instance = nullptr; - u64 Profiler::s_id = 0; - int Profiler::s_useCount = 0; - ////////////////////////////////////////////////////////////////////////// - - /** - * Profile data stored per thread. - */ - struct ProfilerThreadData - { - static const int m_maxStackSize = 32; - typedef AZStd::list ProfilerRegisterList; - typedef AZStd::fixed_vector ProfilerSectionStack; - - AZStd::thread::id m_id; ///< Thread id. - ProfilerRegisterList m_registers; ///< Thread profiler registers (for this thread). - mutable AZStd::shared_spin_mutex m_registersLock; ///< Lock for accessing thread profiler entries. Sadly the only reason for this to exists is so we can read safe the register counters. - ProfilerSectionStack m_stack; ///< Current active sections stack. - }; - - struct ProfilerSystemData - { - AZ::u32 m_id; - const char* m_name; - bool m_isActive; - }; - - /** - * Profiler class data (hidden in from the header file) - */ - struct ProfilerData - { - AZ_CLASS_ALLOCATOR(ProfilerData, OSAllocator, 0); - - AZStd::fixed_vector m_threads; ///< Array with thread with all belonging information. - AZStd::shared_spin_mutex m_threadDataMutex; ///< Spin read/write lock (shared_mutex) for access to the m_threads. - AZStd::fixed_vector m_systems; ///< Array with systems (profiler/timer groups) that you can enable/disable. - }; - - //========================================================================= - // Profiler - // [12/3/2012] - //========================================================================= - Profiler::Profiler(const Descriptor& desc) - { - (void)desc; - m_data = aznew ProfilerData; - - // we can periodically call this function (like the end of every frame to refresh the current estimation). - ProfilerRegister::TimerComputeStartStopOverhead(); - - // use a timestamp as and id. - s_id = AZStd::GetTimeUTCMilliSecond(); - } - - //========================================================================= - // ~Profiler - // [12/3/2012] - //========================================================================= - Profiler::~Profiler() - { - AZ_Assert(s_useCount == 0, "You deleted the profiler while it's still in use."); - s_id = 0; - delete m_data; - } - - //========================================================================= - // Create - // [12/3/2012] - //========================================================================= - bool Profiler::Create(const Descriptor& desc) - { - AZ_Assert(s_instance == nullptr, "Profiler is already created!"); - if (s_instance != nullptr) - { - return false; - } - s_instance = azcreate(Profiler, (desc), AZ::OSAllocator, "Profiler", 0); - return true; - } - - //========================================================================= - // Destroy - // [12/3/2012] - //========================================================================= - void Profiler::Destroy() - { - AZ_Assert(s_instance != nullptr, "Profiler not created"); - if (s_instance) - { - azdestroy(s_instance, AZ::OSAllocator); - s_instance = nullptr; - } - } - - //========================================================================= - // AddReference - // [5/24/2013] - //========================================================================= - void Profiler::AddReference() - { - ++s_useCount; - } - - //========================================================================= - // - // [5/24/2013] - //========================================================================= - void Profiler::ReleaseReference() - { - AZ_Assert(s_useCount > 0, "Use count is already 0, you can't release it!"); - --s_useCount; - if (s_useCount == 0) - { - Destroy(); - } - } - - //========================================================================= - // RegisterSystem - // [12/3/2012] - //========================================================================= - bool Profiler::RegisterSystem(AZ::u32 systemId, const char* name, bool isActive) - { - for (size_t i = 0; i < m_data->m_systems.size(); ++i) - { - if (m_data->m_systems[i].m_id == systemId) - { - return false; - } - } - ProfilerSystemData sd; - sd.m_id = systemId; - sd.m_isActive = isActive; - sd.m_name = name; - m_data->m_systems.push_back(sd); - return true; - } - - //========================================================================= - // UnregisterSystem - // [12/3/2012] - //========================================================================= - bool Profiler::UnregisterSystem(AZ::u32 systemId) - { - size_t i = 0; - for (; i < m_data->m_systems.size(); ++i) - { - ProfilerSystemData& sd = m_data->m_systems[i]; - if (sd.m_id == systemId) - { - if (sd.m_isActive) - { - DeactivateSystem(sd.m_name); - } - // Make sure we triggest driller message when the m_threadDataMutex is NOT locked - // as we lock them in reverse order when we update the profile driller. - AZ_Assert(false, "Currently this code is unused. If we do use it, we should make call EBUS even outside of this function. Where m_threadDataMutex is NOT locked!"); - //EBUS_DBG_EVENT(ProfilerDrillerBus,OnUnregisterSystem,systemId); - break; - } - } - if (i < m_data->m_systems.size()) - { - m_data->m_systems.erase(m_data->m_systems.begin() + i); - return true; - } - return false; - } - - //========================================================================= - // ActivateSystem - // [12/3/2012] - //========================================================================= - bool Profiler::SetSystemState(AZ::u32 systemId, bool isActive) - { - for (size_t i = 0; i < m_data->m_systems.size(); ++i) - { - ProfilerSystemData& sd = m_data->m_systems[i]; - if (sd.m_id == systemId) - { - if (sd.m_isActive != isActive) - { - sd.m_isActive = isActive; - size_t numThreads = m_data->m_threads.size(); - for (size_t j = 0; j < numThreads; ++j) - { - ProfilerThreadData& data = m_data->m_threads[j]; - ProfilerThreadData::ProfilerRegisterList::iterator it = data.m_registers.begin(); - ProfilerThreadData::ProfilerRegisterList::iterator end = data.m_registers.end(); - for (; it != end; ++it) - { - ProfilerRegister& reg = *it; - // This is a big question since this is the only writer - // and the timers are readers and value should be read atomically (1 byte) - // we should be safe without a synchronization here (as data should be written as we exit) - // at worst we can put a volatile in front of the bool. Either way this should not cause - // crashes or anything - if (reg.m_systemId == systemId) - { - reg.m_isActive = isActive ? 1 : 0; - } - } - } - } - return true; - } - } - return false; - } - - //========================================================================= - // ActivateSystem - // [5/24/2013] - //========================================================================= - void Profiler::ActivateSystem(const char* systemName) - { - AZ::u32 systemId = AZ::Crc32(systemName); - bool isNewSystem = false; - { - AZStd::unique_lock writeLock(m_data->m_threadDataMutex); - if (!SetSystemState(systemId, true)) - { - // if the system is new add it - RegisterSystem(systemId, systemName, true); - isNewSystem = true; - } - } - if (isNewSystem) - { - // Make sure we triggest driller message when the m_threadDataMutex is NOT locked - // as we lock them in reverse order when we update the profile driller. - EBUS_DBG_EVENT(ProfilerDrillerBus, OnRegisterSystem, systemId, systemName); - } - } - - //========================================================================= - // DeactivateSystem - // [5/24/2013] - //========================================================================= - void Profiler::DeactivateSystem(const char* systemName) - { - AZ::u32 systemId = AZ::Crc32(systemName); - bool isNewSystem = false; - { - AZStd::unique_lock writeLock(m_data->m_threadDataMutex); - if (!SetSystemState(systemId, false)) - { - // if the system is new add it - RegisterSystem(systemId, systemName, false); - isNewSystem = true; - } - } - if (isNewSystem) - { - // Make sure we triggest driller message when the m_threadDataMutex is NOT locked - // as we lock them in reverse order when we update the profile driller. - EBUS_DBG_EVENT(ProfilerDrillerBus, OnRegisterSystem, systemId, systemName); - } - } - - - //========================================================================= - // IsSystemActive - // [5/24/2013] - //========================================================================= - bool Profiler::IsSystemActive(const char* systemName) const - { - return IsSystemActive(AZ::Crc32(systemName)); - } - - //========================================================================= - // IsSystemActive - // [12/3/2012] - //========================================================================= - bool Profiler::IsSystemActive(AZ::u32 systemId) const - { - for (size_t i = 0; i < m_data->m_systems.size(); ++i) - { - if (m_data->m_systems[i].m_id == systemId) - { - return m_data->m_systems[i].m_isActive != 0; - } - } - return false; - } - - //========================================================================= - // GetNumberOfSystems - // [12/3/2012] - //========================================================================= - int Profiler::GetNumberOfSystems() const - { - return static_cast(m_data->m_systems.size()); - } - - //========================================================================= - // GetSystemName - // [12/3/2012] - //========================================================================= - const char* Profiler::GetSystemName(int index) const - { - return m_data->m_systems[index].m_name; - } - - //========================================================================= - // GetSystemName - // [12/3/2012] - //========================================================================= - const char* Profiler::GetSystemName(AZ::u32 systemId) const - { - for (size_t i = 0; i < m_data->m_systems.size(); ++i) - { - if (m_data->m_systems[i].m_id == systemId) - { - return m_data->m_systems[i].m_name; - } - } - return NULL; - } - - //========================================================================= - // RemoveThreadData - // [12/3/2012] - //========================================================================= - void Profiler::RemoveThreadData(AZStd::thread_id id) - { - // this is very tricky we must be sure that thread is no longer operational - // otherwise we will crash badly. We can do only because nobody should - // reference this registers but the thread local data. - AZStd::unique_lock writeLock(m_data->m_threadDataMutex); - size_t numThreads = m_data->m_threads.size(); - ProfilerThreadData* threadData = NULL; - for (size_t i = 0; i < numThreads; ++i) - { - ProfilerThreadData& data = m_data->m_threads[i]; - if (data.m_id == id) - { - threadData = &data; - break; - } - } - - if (threadData) - { - // delete all registers, we can remove the thread data too, but we will need to switch the structure to list - // so far this is super minimal overhead, registers are more. - threadData->m_registers.clear(); - } - } - - //========================================================================= - // ReadRegisterValues - // [12/3/2012] - //========================================================================= - void Profiler::ReadRegisterValues(const ReadProfileRegisterCB& callback, AZ::u32 systemFilter, const AZStd::thread_id* threadFilter) const - { - AZStd::shared_lock readLock(s_instance->m_data->m_threadDataMutex); - size_t numThreads = Profiler::s_instance->m_data->m_threads.size(); - for (size_t i = 0; i < numThreads; ++i) - { - const ProfilerThreadData& data = s_instance->m_data->m_threads[i]; - if (threadFilter && *threadFilter != data.m_id) - { - continue; - } - { - AZStd::shared_lock registersLock(data.m_registersLock); - ProfilerThreadData::ProfilerRegisterList::const_iterator it = data.m_registers.begin(); - ProfilerThreadData::ProfilerRegisterList::const_iterator end = data.m_registers.end(); - for (; it != end; ++it) - { - const ProfilerRegister& reg = *it; - if (!reg.m_isActive || (systemFilter != 0 && systemFilter != reg.m_systemId)) - { - continue; - } - if (!callback(reg, data.m_id)) - { - return; - } - } - } - } - } - - //========================================================================= - // ResetRegisters - // [12/4/2012] - //========================================================================= - void Profiler::ResetRegisters() - { - AZStd::unique_lock writeLock(s_instance->m_data->m_threadDataMutex); - size_t numThreads = Profiler::s_instance->m_data->m_threads.size(); - for (size_t i = 0; i < numThreads; ++i) - { - ProfilerThreadData& data = s_instance->m_data->m_threads[i]; - { - AZStd::unique_lock registersLock(data.m_registersLock); - ProfilerThreadData::ProfilerRegisterList::iterator it = data.m_registers.begin(); - ProfilerThreadData::ProfilerRegisterList::iterator end = data.m_registers.end(); - for (; it != end; ++it) - { - ProfilerRegister& reg = *it; - reg.Reset(); - } - } - } - - // Reset registers event - } - - //========================================================================= - // CreateRegister - // [6/28/2013] - //========================================================================= - ProfilerRegister* - ProfilerRegister::CreateRegister(const char* systemName, const char* name, const char* function, int line, ProfilerRegister::Type type) - { - static AZ_THREAD_LOCAL ProfilerThreadData* threadData = nullptr; - static AZ_THREAD_LOCAL u64 profilerId = 0; - if (profilerId != Profiler::s_id) - { - threadData = nullptr; // profiler has changed - profilerId = Profiler::s_id; - } - AZ::u32 systemId = AZ::Crc32(systemName); - ProfilerRegister* reg; - { - AZStd::unique_lock writeLock(Profiler::s_instance->m_data->m_threadDataMutex); - - // make sure we have the system registered. This function will just return false if the system exists. - if (systemName) - { - Profiler::s_instance->RegisterSystem(systemId, systemName, true); - } - - if (threadData == nullptr) // if this is a new thread add the data - { - AZStd::thread::id threadId = AZStd::this_thread::get_id(); - Profiler::s_instance->m_data->m_threads.push_back(); - threadData = &Profiler::s_instance->m_data->m_threads.back(); - threadData->m_id = threadId; - } - threadData->m_registers.push_back(); - reg = &threadData->m_registers.back(); - reg->m_name = name; - reg->m_function = function; - reg->m_line = line; - reg->m_systemId = systemId; - reg->m_isActive = Profiler::s_instance->IsSystemActive(systemId) ? 1 : 0; - reg->m_type = type; - reg->m_threadData = threadData; - - reg->Reset(); - } - // Make sure we triggest driller message when the m_threadDataMutex is NOT locked - // as we lock them in reverse order when we update the profile driller. - EBUS_DBG_EVENT(ProfilerDrillerBus, OnNewRegister, *reg, threadData->m_id); - - return reg; - } - - //========================================================================= - // TimerCreateAndStart - // [11/30/2012] - //========================================================================= - ProfilerRegister* - ProfilerRegister::TimerCreateAndStart(const char* systemName, const char* name, ProfilerSection * section, const char* function, int line) - { - AZStd::chrono::system_clock::time_point start = AZStd::chrono::system_clock::now(); - ProfilerRegister* reg = CreateRegister(systemName, name, function, line, ProfilerRegister::PRT_TIME); - AZStd::chrono::system_clock::time_point end = AZStd::chrono::system_clock::now(); - - // adjust the parent timer with the overhead we incur during timer operations. (TODO with TLS this is so fast that we might not need to do it) - if (!reg->m_threadData->m_stack.empty()) // if we are not he last element - { - AZStd::chrono::microseconds elapsed = end - start; - reg->m_threadData->m_stack.back()->m_childTime += elapsed; // no need to check if we go in the future as this will happen on Stop - } - - if (reg->m_isActive) - { - section->m_register = reg; - section->m_start = end; - reg->m_threadData->m_stack.push_back(section); - } - else - { - section->m_register = nullptr; - } - - return reg; - } - - //========================================================================= - // ValueCreate - // [6/28/2013] - //========================================================================= - ProfilerRegister* - ProfilerRegister::ValueCreate(const char* systemName, const char* name, const char* function, int line) - { - return CreateRegister(systemName, name, function, line, ProfilerRegister::PRT_VALUE); - } - - //========================================================================= - // TimerStart - // [11/29/2012] - //========================================================================= - void ProfilerRegister::TimerStart(ProfilerSection* section) - { - ProfilerRegister* reg = this; - - if (reg->m_isActive) - { - section->m_register = reg; - reg->m_threadData->m_stack.push_back(section); - section->m_start = AZStd::chrono::system_clock::now(); - } - else - { - section->m_register = nullptr; - } - } - - //========================================================================= - // TimerStop - // [11/29/2012] - //========================================================================= - void ProfilerRegister::TimerStop() - { - AZStd::chrono::system_clock::time_point end = AZStd::chrono::system_clock::now(); - ProfilerSection* section = m_threadData->m_stack.back(); - AZStd::chrono::microseconds elapsedTime = end - section->m_start; - { - m_threadData->m_registersLock.lock(); // lock for write - ++m_timeData.m_calls; - m_timeData.m_time += elapsedTime.count(); - m_timeData.m_childrenTime += section->m_childTime.count(); - m_timeData.m_childrenCalls += section->m_childCalls; - m_threadData->m_registersLock.unlock(); // unlock - } - m_threadData->m_stack.pop_back(); - - // adjust the parent timer with the overhead we incur during timer operations. - if (!m_threadData->m_stack.empty()) - { - ProfilerSection* parent = m_threadData->m_stack.back(); - m_timeData.m_lastParent = parent->m_register; - parent->m_childTime += elapsedTime /*+ s_startStopOverhead*/; // add the overhead since most of it is in Stop() - ++parent->m_childCalls; - } - } - - //========================================================================= - // Reset - // [12/4/2012] - //========================================================================= - void ProfilerRegister::Reset() - { - switch (m_type) - { - case PRT_TIME: - { - m_timeData.m_time = 0; - m_timeData.m_childrenTime = 0; - m_timeData.m_calls = 0; - m_timeData.m_childrenCalls = 0; - m_timeData.m_lastParent = nullptr; - } break; - case PRT_VALUE: - { - m_userValues.m_value1 = 0; - m_userValues.m_value2 = 0; - m_userValues.m_value3 = 0; - m_userValues.m_value4 = 0; - m_userValues.m_value5 = 0; - } break; - } - } - - //========================================================================= - // ComputeStartStopOverhead - // [12/3/2012] - //========================================================================= - void ProfilerRegister::TimerComputeStartStopOverhead() - { - // compute default thread start stop overhead - ProfilerThreadData sampleThreadData; - sampleThreadData.m_id = AZStd::this_thread::get_id(); - sampleThreadData.m_registers.push_back(); - ProfilerRegister& sampleRegister = sampleThreadData.m_registers.back(); - sampleRegister.m_isActive = true; - sampleRegister.m_name = nullptr; - sampleRegister.m_systemId = 0; - sampleRegister.m_threadData = &sampleThreadData; - - const int numSamples = 1000; - for (int iRepetition = 0; iRepetition < 1000; ++iRepetition) // just for test - { - ProfilerSection section; - sampleRegister.TimerStart(§ion); - AZStd::chrono::system_clock::time_point start = AZStd::chrono::system_clock::now(); - for (int i = 0; i < numSamples; ++i) - { - static AZ::Debug::ProfilerRegister* sampleRegisterPtr = &sampleRegister; // the creation is timed differently - ProfilerSection subSection; - if (sampleRegisterPtr != NULL) - { - sampleRegister.TimerStart(&subSection); - } - } - AZStd::chrono::microseconds elapsed = (AZStd::chrono::system_clock::now() - start); - if (TimeData::s_startStopOverheadPer1000Calls.count() == 0) // if first time set otherwise smooth average - { - TimeData::s_startStopOverheadPer1000Calls = elapsed; - } - else - { - float fNew = static_cast(elapsed.count()); - float fCurrent = static_cast(TimeData::s_startStopOverheadPer1000Calls.count()); - int deltaValue = static_cast((fNew - fCurrent) * 0.1f); - if (deltaValue < 0) - { - TimeData::s_startStopOverheadPer1000Calls -= AZStd::chrono::microseconds(-deltaValue); - } - else - { - TimeData::s_startStopOverheadPer1000Calls += AZStd::chrono::microseconds(deltaValue); - } - } - } - //AZ_TracePrintf("Profiler","Overhead %d microseconds per 1000 profile calls!\n",TimeData::s_startStopOverheadPer1000Calls.count()); - } - - } -} // namespace AZ diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.h b/Code/Framework/AzCore/AzCore/Debug/Profiler.h index f173bb8e17..c8911a6ac4 100644 --- a/Code/Framework/AzCore/AzCore/Debug/Profiler.h +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.h @@ -7,42 +7,49 @@ */ #pragma once -#include -#include +#include #ifdef USE_PIX #include #include #endif -#if defined(AZ_PROFILER_MACRO_DISABLE) // by default we never disable the profiler registers as their overhead should be minimal, you can still do that for your code though. -# define AZ_PROFILE_SCOPE(...) -# define AZ_PROFILE_FUNCTION(...) -# define AZ_PROFILE_BEGIN(...) -# define AZ_PROFILE_END(...) +#if defined(AZ_PROFILER_MACRO_DISABLE) // by default we never disable the profiler registers as their overhead should be minimal, you can + // still do that for your code though. +#define AZ_PROFILE_SCOPE(...) +#define AZ_PROFILE_FUNCTION(...) +#define AZ_PROFILE_BEGIN(...) +#define AZ_PROFILE_END(...) #else + /** * Macro to declare a profile section for the current scope { }. * format is: AZ_PROFILE_SCOPE(categoryName, const char* formatStr, ...) */ -# define AZ_PROFILE_SCOPE(category, ...) ::AZ::ProfileScope AZ_JOIN(azProfileScope, __LINE__){ #category, __VA_ARGS__ } -# define AZ_PROFILE_FUNCTION(category) AZ_PROFILE_SCOPE(category, AZ_FUNCTION_SIGNATURE) +#define AZ_PROFILE_SCOPE(budget, ...) \ + ::AZ::Debug::ProfileScope AZ_JOIN(azProfileScope, __LINE__) \ + { \ + AZ_BUDGET_GETTER(budget)(), __VA_ARGS__ \ + } + +#define AZ_PROFILE_FUNCTION(category) AZ_PROFILE_SCOPE(category, AZ_FUNCTION_SIGNATURE) // Prefer using the scoped macros which automatically end the event (AZ_PROFILE_SCOPE/AZ_PROFILE_FUNCTION) -# define AZ_PROFILE_BEGIN(category, ...) ::AZ::ProfileScope::BeginRegion(#category, __VA_ARGS__) -# define AZ_PROFILE_END() ::AZ::ProfileScope::EndRegion() +#define AZ_PROFILE_BEGIN(budget, ...) ::AZ::Debug::ProfileScope::BeginRegion(AZ_BUDGET_GETTER(budget)(), __VA_ARGS__) +#define AZ_PROFILE_END(budget) ::AZ::Debug::ProfileScope::EndRegion(AZ_BUDGET_GETTER(budget)()) + #endif // AZ_PROFILER_MACRO_DISABLE #ifndef AZ_PROFILE_INTERVAL_START -# define AZ_PROFILE_INTERVAL_START(...) -# define AZ_PROFILE_INTERVAL_START_COLORED(...) -# define AZ_PROFILE_INTERVAL_END(...) -# define AZ_PROFILE_INTERVAL_SCOPED(...) +#define AZ_PROFILE_INTERVAL_START(...) +#define AZ_PROFILE_INTERVAL_START_COLORED(...) +#define AZ_PROFILE_INTERVAL_END(...) +#define AZ_PROFILE_INTERVAL_SCOPED(...) #endif #ifndef AZ_PROFILE_DATAPOINT -# define AZ_PROFILE_DATAPOINT(...) -# define AZ_PROFILE_DATAPOINT_PERCENT(...) +#define AZ_PROFILE_DATAPOINT(...) +#define AZ_PROFILE_DATAPOINT_PERCENT(...) #endif namespace AZStd @@ -50,340 +57,25 @@ namespace AZStd struct thread_id; // forward declare. This is the same type as AZStd::thread::id } -namespace AZ +namespace AZ::Debug { class ProfileScope { public: - static uint32_t GetSystemID(const char* system); - template - static void BeginRegion([[maybe_unused]] const char* system, [[maybe_unused]] const char* eventName, [[maybe_unused]] T const&... args) - { - // TODO: Verification that the supplied system name corresponds to a known budget -#if defined(USE_PIX) - PIXBeginEvent(PIX_COLOR_INDEX(GetSystemID(system) & 0xff), eventName, args...); -#endif - // TODO: injecting instrumentation for other profilers - // NOTE: external profiler registration won't occur inline in a header necessarily in this manner, but the exact mechanism - // will be introduced in a future PR - } + static void BeginRegion([[maybe_unused]] Budget* budget, [[maybe_unused]] const char* eventName, [[maybe_unused]] T const&... args); - static void EndRegion() - { -#if defined(USE_PIX) - PIXEndEvent(); -#endif - } + static void EndRegion([[maybe_unused]] Budget* budget); template - ProfileScope(const char* system, char const* eventName, T const&... args) - { - BeginRegion(system, eventName, args...); - } - - ~ProfileScope() - { - EndRegion(); - } - }; - - namespace Debug - { - class ProfilerSection; - class ProfilerRegister; - struct ProfilerThreadData; - struct ProfilerData; - - /** - * - */ - class Profiler - { - friend class ProfilerRegister; - friend struct ProfilerData; - public: - /// Max number of threads supported by the profiler. - static const int m_maxNumberOfThreads = 32; - /// Max number of systems supported by the profiler. (We can switch this container if needed) - static const int m_maxNumberOfSystems = 64; - - ~Profiler(); - - struct Descriptor - { - }; - - static bool Create(const Descriptor& desc = Descriptor()); - static void Destroy(); - static bool IsReady() { return s_instance != NULL; } - static Profiler& Instance() { return *s_instance; } - static u64 GetId() { return s_id; } - - /// Increment the use count. - static void AddReference(); - /// Release the use count if 0 a Destroy will be called automatically. - static void ReleaseReference(); - - void ActivateSystem(const char* systemName); - void DeactivateSystem(const char* systemName); - bool IsSystemActive(const char* systemName) const; - bool IsSystemActive(AZ::u32 systemId) const; - int GetNumberOfSystems() const; - const char* GetSystemName(int index) const; - const char* GetSystemName(AZ::u32 systemId) const; - - /** Callback to read a single register. Make sure you read the data as fast as possible. Don't compute inside the callback - * it will lock and hold all the registers that we process. The best is just to read the value and push it into a - * history buffer. - */ - typedef AZStd::function ReadProfileRegisterCB; - /** - * Read register values, make sure the code here is fast and efficient as we are holding a lock. - * provide a callback that will be called for each register. - * You can choose to filter your values by thread or a system. Use this filter only to narrow you samples. Don't - * use it for multiple calls to sort your counters, use the history data. - * It addition keep in mind that you can run this function is parallel, as we only read the values. - */ - void ReadRegisterValues(const ReadProfileRegisterCB& callback, AZ::u32 systemFilter = 0, const AZStd::thread_id* threadFilter = NULL) const; - /** - * This is slow operation that will cause contention try to avoid using it. A better way will be each frame instead of reset to read and store - * register values (this is good for history too) and make the difference that way. - */ - void ResetRegisters(); - - /// You can remove thread data ONLY IF YOU ARE SURE THIS THREAD IS NO LONGER ACTIVE! This will work only is specific cases. - void RemoveThreadData(AZStd::thread_id id); - - private: - /// Register a new system in the profiler. Make sure the proper locks are LOCKED when calling this function (m_threadDataMutex) - bool RegisterSystem(AZ::u32 systemId, const char* name, bool isActive); - /// Unregister a system. Make sure the proper locks are LOCKED when calling this function (m_threadDataMutex) - bool UnregisterSystem(AZ::u32 systemId); - /// Sets the system active/inactive state. Make sure the proper locks are LOCKED when calling this function (m_threadDataMutex) - bool SetSystemState(AZ::u32 systemId, bool isActive); - - Profiler(const Descriptor& desc); - Profiler& operator=(const Profiler&); - - ProfilerData* m_data; ///< Hidden data to reduce the number of header files included; - static Profiler* s_instance; ///< The only instance of the profiler. - static u64 s_id; ///< Profiler unique (over time) id (don't use the pointer as it might be reused). - static int s_useCount; - }; - - /** - * A profiler "virtual" register that contains data about a certain place in the code. - */ - class ProfilerRegister - { - friend class Profiler; - public: - ProfilerRegister() - {} - - enum Type - { - PRT_TIME = 0, ///< Time (members m_time,m_childrenTime,m_calls, m_childrenCalls and m_lastParant are used) register. - PRT_VALUE, ///< Value register - }; + ProfileScope(Budget* budget, char const* eventName, T const&... args); - /// Time register data. - struct TimeData - { - AZ::u64 m_time; ///< Total inclusive time current and children in microseconds. - AZ::u64 m_childrenTime; ///< Time taken by child profilers in microseconds. - AZ::s64 m_calls; ///< Number of calls for this register. - AZ::s64 m_childrenCalls;///< Number of children calls. - ProfilerRegister* m_lastParent; ///< Pointer to the last parent register. + ~ProfileScope(); - static AZStd::chrono::microseconds s_startStopOverheadPer1000Calls; ///< Static constant representing a standard start stop overhead per 1000 calls. You can use this to adjust timings. - }; - - /// Value register data. - struct ValuesData - { - AZ::s64 m_value1; - AZ::s64 m_value2; - AZ::s64 m_value3; - AZ::s64 m_value4; - AZ::s64 m_value5; - }; - - static ProfilerRegister* TimerCreateAndStart(const char* systemName, const char* name, ProfilerSection* section, const char* function, int line); - static ProfilerRegister* ValueCreate(const char* systemName, const char* name, const char* function, int line); - void TimerStart(ProfilerSection* section); - - void ValueSet(const AZ::s64& v1); - void ValueSet(const AZ::s64& v1, const AZ::s64& v2); - void ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3); - void ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4); - void ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4, const AZ::s64& v5); - - void ValueAdd(const AZ::s64& v1); - void ValueAdd(const AZ::s64& v1, const AZ::s64& v2); - void ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3); - void ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4); - void ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4, const AZ::s64& v5); - - // Dynamic register data - union - { - TimeData m_timeData; - ValuesData m_userValues; - }; - - // Static value data. - const char* m_name; ///< Name of the profiler register. - const char* m_function; ///< Function name in the code. - int m_line; ///< Line number if the code. - AZ::u32 m_systemId; ///< ID of the system this profiler belongs to. - unsigned char m_type : 7; ///< Register type - unsigned char m_isActive : 1; ///< Flag if the profiler is active. - - private: - friend class ProfilerSection; - - static ProfilerRegister* CreateRegister(const char* systemName, const char* name, const char* function, int line, ProfilerRegister::Type type); - - /// Compute static start/stop overhead approximation. You can call this periodically (or not) to update the overhead. - static void TimerComputeStartStopOverhead(); - - void TimerStop(); - - void Reset(); - - ProfilerRegister* GetValueRegisterForThisThread(); - - ProfilerThreadData* m_threadData; ///< Pointer to this entry thread data. - }; - - /** - * Scoped stop register count on destruction. - */ - class ProfilerSection - { - friend class ProfilerRegister; - public: - ProfilerSection() - : m_register(nullptr) - , m_profilerId(AZ::Debug::Profiler::GetId()) - , m_childTime(0) - , m_childCalls(0) - {} - - ~ProfilerSection() - { - // If we have a valid register and the profiler did not change while we were active stop the register. - if (m_register && m_profilerId == AZ::Debug::Profiler::GetId()) - { - m_register->TimerStop(); - } - } - - void Stop() - { - // If we have a valid register and the profiler did not change while we were active stop the register. - if (m_register && m_profilerId == AZ::Debug::Profiler::GetId()) - { - m_register->TimerStop(); - } - m_register = nullptr; - } - private: - ProfilerRegister* m_register; ///< Pointer to the owning profiler register. - u64 m_profilerId; ///< Id of the profiler when we started this section. - AZStd::chrono::system_clock::time_point m_start; ///< Start mark. - AZStd::chrono::microseconds m_childTime; ///< Time spent in child profilers. - int m_childCalls; ///< Number of children calls. - }; - - AZ_FORCE_INLINE ProfilerRegister* ProfilerRegister::GetValueRegisterForThisThread() - { - return this; - } - - AZ_FORCE_INLINE void ProfilerRegister::ValueSet(const AZ::s64& v1) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 = v1; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueSet(const AZ::s64& v1, const AZ::s64& v2) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 = v1; - reg->m_userValues.m_value2 = v2; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 = v1; - reg->m_userValues.m_value2 = v2; - reg->m_userValues.m_value3 = v3; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 = v1; - reg->m_userValues.m_value2 = v2; - reg->m_userValues.m_value3 = v3; - reg->m_userValues.m_value4 = v4; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueSet(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4, const AZ::s64& v5) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 = v1; - reg->m_userValues.m_value2 = v2; - reg->m_userValues.m_value3 = v3; - reg->m_userValues.m_value4 = v4; - reg->m_userValues.m_value5 = v5; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueAdd(const AZ::s64& v1) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 += v1; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueAdd(const AZ::s64& v1, const AZ::s64& v2) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 += v1; - reg->m_userValues.m_value2 += v2; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 += v1; - reg->m_userValues.m_value2 += v2; - reg->m_userValues.m_value3 += v3; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 += v1; - reg->m_userValues.m_value2 += v2; - reg->m_userValues.m_value3 += v3; - reg->m_userValues.m_value4 += v4; - } - AZ_FORCE_INLINE void ProfilerRegister::ValueAdd(const AZ::s64& v1, const AZ::s64& v2, const AZ::s64& v3, const AZ::s64& v4, const AZ::s64& v5) - { - ProfilerRegister* reg = GetValueRegisterForThisThread(); - reg->m_userValues.m_value1 += v1; - reg->m_userValues.m_value2 += v2; - reg->m_userValues.m_value3 += v3; - reg->m_userValues.m_value4 += v4; - reg->m_userValues.m_value5 += v5; - } - } // namespace Debug - - namespace Internal - { - struct RegisterData - { - AZ::Debug::ProfilerRegister* m_register; ///< Pointer to the register data. - AZ::u64 m_profilerId; ///< Profiler ID which create the \ref register data. - }; - } -} // namespace AZ + private: + Budget* m_budget; + }; +} // namespace AZ::Debug #ifdef USE_PIX // The pix3 header unfortunately brings in other Windows macros we need to undef @@ -391,3 +83,5 @@ namespace AZ #undef LoadImage #undef GetCurrentTime #endif + +#include diff --git a/Code/Framework/AzCore/AzCore/Debug/Profiler.inl b/Code/Framework/AzCore/AzCore/Debug/Profiler.inl new file mode 100644 index 0000000000..8ca8368ce1 --- /dev/null +++ b/Code/Framework/AzCore/AzCore/Debug/Profiler.inl @@ -0,0 +1,57 @@ +/* + * Copyright (c) Contributors to the Open 3D Engine Project. + * For complete copyright and license terms please see the LICENSE at the root of this distribution. + * + * SPDX-License-Identifier: Apache-2.0 OR MIT + * + */ + +namespace AZ::Debug +{ + template + void ProfileScope::BeginRegion( + [[maybe_unused]] Budget* budget, [[maybe_unused]] const char* eventName, [[maybe_unused]] T const&... args) + { + if (!budget) + { + return; + } +#if !defined(_RELEASE) + // TODO: Verification that the supplied system name corresponds to a known budget +#if defined(USE_PIX) + PIXBeginEvent(PIX_COLOR_INDEX(budget->Crc() & 0xff), eventName, args...); +#endif + budget->BeginProfileRegion(); +// TODO: injecting instrumentation for other profilers +// NOTE: external profiler registration won't occur inline in a header necessarily in this manner, but the exact mechanism +// will be introduced in a future PR +#endif + } + + inline void ProfileScope::EndRegion([[maybe_unused]] Budget* budget) + { + if (!budget) + { + return; + } +#if !defined(_RELEASE) + budget->EndProfileRegion(); +#if defined(USE_PIX) + PIXEndEvent(); +#endif +#endif + } + + template + ProfileScope::ProfileScope(Budget* budget, char const* eventName, T const&... args) + : m_budget{ budget } + { + BeginRegion(budget, eventName, args...); + } + + inline ProfileScope::~ProfileScope() + { + EndRegion(m_budget); + } + +} // namespace AZ::Debug diff --git a/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.cpp b/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.cpp deleted file mode 100644 index a2dd2f4f5d..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include - -#include -#include -#include - -namespace AZ -{ - namespace Debug - { - //========================================================================= - // ProfilerDriller - // [7/9/2013] - //========================================================================= - ProfilerDriller::ProfilerDriller() - { - AZStd::ThreadDrillerEventBus::Handler::BusConnect(); - } - - //========================================================================= - // ~ProfilerDriller - // [7/9/2013] - //========================================================================= - ProfilerDriller::~ProfilerDriller() - { - AZStd::ThreadDrillerEventBus::Handler::BusDisconnect(); - } - - //========================================================================= - // Start - // [5/24/2013] - //========================================================================= - void ProfilerDriller::Start(const Param* params, int numParams) - { - for (int i = 0; i < m_numberOfSystemFilters; ++i) - { - m_systemFilters[i].desc = "SystemID of the system which counters we are interested in"; - m_systemFilters[i].type = Param::PT_INT; - m_systemFilters[i].value = 0; - } - - // Copy valid filters. - m_numberOfValidFilters = 0; - if (params) - { - for (int i = 0; i < numParams; ++i) - { - if (params[i].type == Param::PT_INT && params[i].value != 0) - { - m_systemFilters[m_numberOfValidFilters++].value = params[i].value; - } - } - } - - // output current threads - for (ThreadArrayType::iterator it = m_threads.begin(); it != m_threads.end(); ++it) - { - OutputThreadEnter(*it); - } - - ProfilerDrillerBus::Handler::BusConnect(); - - if (!Profiler::IsReady()) - { - Profiler::Create(); - } - - Profiler::AddReference(); - } - - //========================================================================= - // Stop - // [5/24/2013] - //========================================================================= - void ProfilerDriller::Stop() - { - Profiler::ReleaseReference(); - ProfilerDrillerBus::Handler::BusDisconnect(); - } - - //========================================================================= - // OnError - // [2/8/2013] - //========================================================================= - void ProfilerDriller::Update() - { - // \note We could add thread_id in addition to the System ID, but I can't foresee many cases where we would like to profile only a specific thread. - if (m_numberOfValidFilters) - { - for (int iFilter = 0; iFilter < m_numberOfValidFilters; ++iFilter) - { - AZ::u32 systemFilter = *reinterpret_cast(&m_systemFilters[iFilter].value); - Profiler::Instance().ReadRegisterValues(AZStd::bind(&ProfilerDriller::ReadProfilerRegisters, this, AZStd::placeholders::_1, AZStd::placeholders::_2), systemFilter); - } - } - else - { - Profiler::Instance().ReadRegisterValues(AZStd::bind(&ProfilerDriller::ReadProfilerRegisters, this, AZStd::placeholders::_1, AZStd::placeholders::_2), 0); - } - } - - //========================================================================= - // ReadProfilerRegisters - // [2/11/2013] - //========================================================================= - bool ProfilerDriller::ReadProfilerRegisters(const ProfilerRegister& reg, const AZStd::thread_id& id) - { - (void)id; - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("UpdateRegister", 0x6c00b890)); - m_output->Write(AZ_CRC("Id", 0xbf396750), ®); - // Send only the data which is changing - switch (reg.m_type) - { - case ProfilerRegister::PRT_TIME: - { - m_output->Write(AZ_CRC("Time", 0x6f949845), reg.m_timeData.m_time); - m_output->Write(AZ_CRC("ChildrenTime", 0x46162d3f), reg.m_timeData.m_childrenTime); - m_output->Write(AZ_CRC("Calls", 0xdaa35c8f), reg.m_timeData.m_calls); - m_output->Write(AZ_CRC("ChildrenCalls", 0x6a5a4618), reg.m_timeData.m_childrenCalls); - m_output->Write(AZ_CRC("ParentId", 0x856a684c), reg.m_timeData.m_lastParent); - } break; - case ProfilerRegister::PRT_VALUE: - { - m_output->Write(AZ_CRC("Value1", 0xa2756c5a), reg.m_userValues.m_value1); - m_output->Write(AZ_CRC("Value2", 0x3b7c3de0), reg.m_userValues.m_value2); - m_output->Write(AZ_CRC("Value3", 0x4c7b0d76), reg.m_userValues.m_value3); - m_output->Write(AZ_CRC("Value4", 0xd21f98d5), reg.m_userValues.m_value4); - m_output->Write(AZ_CRC("Value5", 0xa518a843), reg.m_userValues.m_value5); - } break; - } - m_output->EndTag(AZ_CRC("UpdateRegister", 0x6c00b890)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - - return true; - } - - //========================================================================= - // OnThreadEnter - // [5/31/2013] - //========================================================================= - void ProfilerDriller::OnThreadEnter(const AZStd::thread_id& id, const AZStd::thread_desc* desc) - { - m_threads.push_back(); - ThreadInfo& info = m_threads.back(); - info.m_id = (size_t)id.m_id; - if (desc) - { - info.m_name = desc->m_name; - info.m_cpuId = desc->m_cpuId; - info.m_priority = desc->m_priority; - info.m_stackSize = desc->m_stackSize; - } - else - { - info.m_name = nullptr; - info.m_cpuId = -1; - info.m_priority = -100000; - info.m_stackSize = 0; - } - - if (m_output) - { - OutputThreadEnter(info); - } - } - - //========================================================================= - // OnThreadExit - // [5/31/2013] - //========================================================================= - void ProfilerDriller::OnThreadExit(const AZStd::thread_id& id) - { - ThreadArrayType::iterator it = m_threads.begin(); - while (it != m_threads.end()) - { - if (it->m_id == (size_t)id.m_id) - { - break; - } - ++it; - } - - if (it != m_threads.end()) - { - if (m_output) - { - OutputThreadExit(*it); - } - - m_threads.erase(it); - } - } - - //========================================================================= - // OutputThreadEnter - // [7/9/2013] - //========================================================================= - void ProfilerDriller::OutputThreadEnter(const ThreadInfo& threadInfo) - { - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("ThreadEnter", 0x60e4acfb)); - m_output->Write(AZ_CRC("Id", 0xbf396750), threadInfo.m_id); - if (threadInfo.m_name) - { - m_output->Write(AZ_CRC("Name", 0x5e237e06), threadInfo.m_name); - } - m_output->Write(AZ_CRC("CpuId", 0xdf558508), threadInfo.m_cpuId); - m_output->Write(AZ_CRC("Priority", 0x62a6dc27), threadInfo.m_priority); - m_output->Write(AZ_CRC("StackSize", 0x9cfaf35b), threadInfo.m_stackSize); - m_output->EndTag(AZ_CRC("ThreadEnter", 0x60e4acfb)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - } - - //========================================================================= - // OutputThreadExit - // [7/9/2013] - //========================================================================= - void ProfilerDriller::OutputThreadExit(const ThreadInfo& threadInfo) - { - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("OnThreadExit", 0x16042db9)); - m_output->Write(AZ_CRC("Id", 0xbf396750), threadInfo.m_id); - m_output->EndTag(AZ_CRC("OnThreadExit", 0x16042db9)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - } - - //========================================================================= - // OnRegisterSystem - // [5/31/2013] - //========================================================================= - void ProfilerDriller::OnRegisterSystem(AZ::u32 id, const char* name) - { - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("RegisterSystem", 0x957739ef)); - m_output->Write(AZ_CRC("Id", 0xbf396750), id); - m_output->Write(AZ_CRC("Name", 0x5e237e06), name); - m_output->EndTag(AZ_CRC("RegisterSystem", 0x957739ef)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - } - - //========================================================================= - // OnUnregisterSystem - // [5/31/2013] - //========================================================================= - void ProfilerDriller::OnUnregisterSystem(AZ::u32 id) - { - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("UnregisterSystem", 0xa20538e4)); - m_output->Write(AZ_CRC("Id", 0xbf396750), id); - m_output->EndTag(AZ_CRC("UnregisterSystem", 0xa20538e4)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - } - - //========================================================================= - // OnNewRegister - // [5/31/2013] - //========================================================================= - void ProfilerDriller::OnNewRegister(const ProfilerRegister& reg, const AZStd::thread_id& threadId) - { - m_output->BeginTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - m_output->BeginTag(AZ_CRC("NewRegister", 0xf0f2f287)); - m_output->Write(AZ_CRC("Id", 0xbf396750), ®); - m_output->Write(AZ_CRC("ThreadId", 0xd0fd9043), threadId.m_id); - if (reg.m_name) - { - m_output->Write(AZ_CRC("Name", 0x5e237e06), reg.m_name); - } - if (reg.m_function) - { - m_output->Write(AZ_CRC("Function", 0xcaae163d), reg.m_function); - } - m_output->Write(AZ_CRC("Line", 0xd114b4f6), reg.m_line); - m_output->Write(AZ_CRC("SystemId", 0x0dfecf6f), reg.m_systemId); - m_output->Write(AZ_CRC("Type", 0x8cde5729), reg.m_type); - - switch (reg.m_type) - { - case ProfilerRegister::PRT_TIME: - { - m_output->Write(AZ_CRC("Time", 0x6f949845), reg.m_timeData.m_time); - m_output->Write(AZ_CRC("ChildrenTime", 0x46162d3f), reg.m_timeData.m_childrenTime); - m_output->Write(AZ_CRC("Calls", 0xdaa35c8f), reg.m_timeData.m_calls); - m_output->Write(AZ_CRC("ChildrenCalls", 0x6a5a4618), reg.m_timeData.m_childrenCalls); - m_output->Write(AZ_CRC("ParentId", 0x856a684c), reg.m_timeData.m_lastParent); - } break; - case ProfilerRegister::PRT_VALUE: - { - m_output->Write(AZ_CRC("Value1", 0xa2756c5a), reg.m_userValues.m_value1); - m_output->Write(AZ_CRC("Value2", 0x3b7c3de0), reg.m_userValues.m_value2); - m_output->Write(AZ_CRC("Value3", 0x4c7b0d76), reg.m_userValues.m_value3); - m_output->Write(AZ_CRC("Value4", 0xd21f98d5), reg.m_userValues.m_value4); - m_output->Write(AZ_CRC("Value5", 0xa518a843), reg.m_userValues.m_value5); - } break; - } - m_output->EndTag(AZ_CRC("NewRegister", 0xf0f2f287)); - m_output->EndTag(AZ_CRC("ProfilerDriller", 0x172c5268)); - } - } // namespace Debug -} // namespace AZ diff --git a/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.h b/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.h deleted file mode 100644 index abcf3f08e7..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/ProfilerDriller.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef AZCORE_PROFILER_DRILLER_H -#define AZCORE_PROFILER_DRILLER_H 1 - -#include -#include -#include - -namespace AZStd -{ - struct thread_id; - struct thread_desc; -} - -namespace AZ -{ - namespace Debug - { - struct ProfilerSystemData; - class ProfilerRegister; - - /** - * ProfilerDriller or we can just make a Profiler driller and read the registers ourself. - */ - class ProfilerDriller - : public Driller - , public ProfilerDrillerBus::Handler - , public AZStd::ThreadDrillerEventBus::Handler - { - struct ThreadInfo - { - AZ::u64 m_id; - AZ::u32 m_stackSize; - AZ::s32 m_priority; - AZ::s32 m_cpuId; - const char* m_name; - }; - typedef vector::type ThreadArrayType; - - public: - - AZ_CLASS_ALLOCATOR(ProfilerDriller, OSAllocator, 0) - - ProfilerDriller(); - virtual ~ProfilerDriller(); - - protected: - ////////////////////////////////////////////////////////////////////////// - // Driller - virtual const char* GroupName() const { return "SystemDrillers"; } - virtual const char* GetName() const { return "ProfilerDriller"; } - virtual const char* GetDescription() const { return "Collects data from all available profile registers."; } - virtual int GetNumParams() const { return m_numberOfSystemFilters; } - virtual const Param* GetParam(int index) const { AZ_Assert(index >= 0 && index < m_numberOfSystemFilters, "Invalid index"); return &m_systemFilters[index]; } - virtual void Start(const Param* params = NULL, int numParams = 0); - virtual void Stop(); - virtual void Update(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Thread driller event bus - /// Called when we enter a thread, optional thread_desc is provided when the use provides one. - virtual void OnThreadEnter(const AZStd::thread_id& id, const AZStd::thread_desc* desc); - /// Called when we exit a thread. - virtual void OnThreadExit(const AZStd::thread_id& id); - - /// Output thread enter to stream. - void OutputThreadEnter(const ThreadInfo& threadInfo); - /// Output thread exit to stream. - void OutputThreadExit(const ThreadInfo& threadInfo); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Profiler Driller bus - virtual void OnRegisterSystem(AZ::u32 id, const char* name); - - virtual void OnUnregisterSystem(AZ::u32 id); - - virtual void OnNewRegister(const ProfilerRegister& reg, const AZStd::thread_id& threadId); - ////////////////////////////////////////////////////////////////////////// - - /// Read profile registers callback. - bool ReadProfilerRegisters(const ProfilerRegister& reg, const AZStd::thread_id& id); - - - - static const int m_numberOfSystemFilters = 16; - int m_numberOfValidFilters = 0 ; ///< Number of valid filter set when the driller was created. - Param m_systemFilters[m_numberOfSystemFilters]; ///< If != 0, it's a ID of specific System we would like to drill. - ThreadArrayType m_threads; - }; - } -} // namespace AZ - -#endif // AZCORE_PROFILER_DRILLER_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/Debug/ProfilerDrillerBus.h b/Code/Framework/AzCore/AzCore/Debug/ProfilerDrillerBus.h deleted file mode 100644 index 835c06a2ac..0000000000 --- a/Code/Framework/AzCore/AzCore/Debug/ProfilerDrillerBus.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef AZCORE_PROFILER_DRILLER_BUS_H -#define AZCORE_PROFILER_DRILLER_BUS_H - -#include - -namespace AZStd -{ - struct thread_id; -} - -namespace AZ -{ - namespace Debug - { - class ProfilerRegister; - - /** - * ProfilerDrillerInterface driller profiler event interface, that records events from the profiler system. - */ - class ProfilerDrillerInterface - : public DrillerEBusTraits - { - public: - virtual ~ProfilerDrillerInterface() {} - - virtual void OnRegisterSystem(AZ::u32 id, const char* name) = 0; - - virtual void OnUnregisterSystem(AZ::u32 id) = 0; - - virtual void OnNewRegister(const ProfilerRegister& reg, const AZStd::thread_id& threadId) = 0; - }; - - typedef AZ::EBus ProfilerDrillerBus; - } -} - -#endif // AZCORE_PROFILER_DRILLER_BUS_H -#pragma once diff --git a/Code/Framework/AzCore/AzCore/IO/FileIO.cpp b/Code/Framework/AzCore/AzCore/IO/FileIO.cpp index a6ce8cf101..837aca8d84 100644 --- a/Code/Framework/AzCore/AzCore/IO/FileIO.cpp +++ b/Code/Framework/AzCore/AzCore/IO/FileIO.cpp @@ -426,7 +426,6 @@ namespace AZ void FileIOStream::Seek(OffsetType bytes, SeekMode mode) { - AZ_PROFILE_SCOPE(AzCore, "FileIO Seek: %s", m_filename.c_str()); AZ_Assert(FileIOBase::GetInstance(), "FileIO is not initialized."); AZ_Assert(IsOpen(), "Cannot seek on a FileIOStream that is not open."); @@ -454,7 +453,6 @@ namespace AZ SizeType FileIOStream::Read(SizeType bytes, void* oBuffer) { - AZ_PROFILE_SCOPE(AzCore, "FileIO Read: %s", m_filename.c_str()); AZ_Assert(FileIOBase::GetInstance(), "FileIO is not initialized."); AZ_Assert(IsOpen(), "Cannot read from a FileIOStream that is not open."); diff --git a/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h b/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h index a23414700a..8f069da9dd 100644 --- a/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h +++ b/Code/Framework/AzCore/AzCore/UnitTest/MockComponentApplication.h @@ -44,7 +44,6 @@ namespace UnitTest MOCK_CONST_METHOD0(GetAppRoot, const char* ()); MOCK_CONST_METHOD0(GetEngineRoot, const char* ()); MOCK_CONST_METHOD0(GetExecutableFolder, const char* ()); - MOCK_METHOD0(GetDrillerManager, AZ::Debug::DrillerManager* ()); MOCK_CONST_METHOD1(QueryApplicationType, void(AZ::ApplicationTypeQuery&)); }; } // namespace UnitTest diff --git a/Code/Framework/AzCore/AzCore/UnitTest/TestTypes.h b/Code/Framework/AzCore/AzCore/UnitTest/TestTypes.h index eb5011bbfa..c3e3f5210a 100644 --- a/Code/Framework/AzCore/AzCore/UnitTest/TestTypes.h +++ b/Code/Framework/AzCore/AzCore/UnitTest/TestTypes.h @@ -11,6 +11,7 @@ #include #include +#include #include #include #include diff --git a/Code/Framework/AzCore/AzCore/azcore_files.cmake b/Code/Framework/AzCore/AzCore/azcore_files.cmake index 1a3acb2982..c2ee439645 100644 --- a/Code/Framework/AzCore/AzCore/azcore_files.cmake +++ b/Code/Framework/AzCore/AzCore/azcore_files.cmake @@ -93,20 +93,18 @@ set(FILES Debug/AssetTracking.h Debug/AssetTrackingTypesImpl.h Debug/AssetTrackingTypes.h + Debug/Budget.h + Debug/Budget.cpp + Debug/BudgetTracker.h + Debug/BudgetTracker.cpp Debug/LocalFileEventLogger.h Debug/LocalFileEventLogger.cpp - Debug/FrameProfiler.h - Debug/FrameProfilerBus.h - Debug/FrameProfilerComponent.cpp - Debug/FrameProfilerComponent.h Debug/IEventLogger.h Debug/MemoryProfiler.h Debug/Profiler.cpp + Debug/Profiler.inl Debug/Profiler.h Debug/ProfilerBus.h - Debug/ProfilerDriller.cpp - Debug/ProfilerDriller.h - Debug/ProfilerDrillerBus.h Debug/StackTracer.h Debug/EventTrace.h Debug/EventTrace.cpp @@ -572,8 +570,6 @@ set(FILES Statistics/StatisticalProfilerProxySystemComponent.cpp Statistics/StatisticalProfilerProxySystemComponent.h Statistics/StatisticsManager.h - Statistics/TimeDataStatisticsManager.cpp - Statistics/TimeDataStatisticsManager.h StringFunc/StringFunc.cpp StringFunc/StringFunc.h UserSettings/UserSettings.cpp diff --git a/Code/Framework/AzCore/Tests/BehaviorContextFixture.h b/Code/Framework/AzCore/Tests/BehaviorContextFixture.h index f6a8d8430c..1895f2e35b 100644 --- a/Code/Framework/AzCore/Tests/BehaviorContextFixture.h +++ b/Code/Framework/AzCore/Tests/BehaviorContextFixture.h @@ -62,7 +62,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} //// diff --git a/Code/Framework/AzCore/Tests/Components.cpp b/Code/Framework/AzCore/Tests/Components.cpp index 77524dabc9..55b1c193b3 100644 --- a/Code/Framework/AzCore/Tests/Components.cpp +++ b/Code/Framework/AzCore/Tests/Components.cpp @@ -22,8 +22,6 @@ #include #include -#include -#include #include #include diff --git a/Code/Framework/AzCore/Tests/Driller.cpp b/Code/Framework/AzCore/Tests/Driller.cpp deleted file mode 100644 index e135a23808..0000000000 --- a/Code/Framework/AzCore/Tests/Driller.cpp +++ /dev/null @@ -1,698 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -//#define AZ_CORE_DRILLER_COMPARE_TEST -#if defined(AZ_CORE_DRILLER_COMPARE_TEST) -# include -# include -# include -#endif - -#include - -using namespace AZ; -using namespace AZ::Debug; - -namespace UnitTest -{ - /** - * MyDriller event bus... - */ - class MyDrillerInterface - : public AZ::Debug::DrillerEBusTraits - { - public: - virtual ~MyDrillerInterface() {} - // define one event X - virtual void OnEventX(int data) = 0; - // define a string event - virtual void OnStringEvent() = 0; - }; - - class MyDrillerCommandInterface - : public AZ::Debug::DrillerEBusTraits - { - public: - virtual ~MyDrillerCommandInterface() {} - - virtual class MyDrilledObject* RequestDrilledObject() = 0; - }; - - typedef AZ::EBus MyDrillerBus; - typedef AZ::EBus MyDrillerCommandBus; - - class MyDrilledObject - : public MyDrillerCommandBus::Handler - { - int i; - public: - MyDrilledObject() - : i(0) - { - BusConnect(); - } - - ~MyDrilledObject() override - { - BusDisconnect(); - } - ////////////////////////////////////////////////////////////////////////// - // MyDrillerCommandBus - MyDrilledObject* RequestDrilledObject() override - { - return this; - } - ////////////////////////////////////////////////////////////////////////// - void OnEventX() - { - EBUS_EVENT(MyDrillerBus, OnEventX, i); - ++i; - } - - void OnStringEvent() - { - EBUS_DBG_EVENT(MyDrillerBus, OnStringEvent); - } - }; - - - /** - * My driller implements the driller interface and an handles the MyDrillerBus events... - */ - class MyDriller - : public Driller - , public MyDrillerBus::Handler - { - bool m_isDetailedCapture; - class MyDrilledObject* drilledObject; - typedef vector::type ParamArrayType; - ParamArrayType m_params; - public: - AZ_CLASS_ALLOCATOR(MyDriller, OSAllocator, 0); - - const char* GroupName() const override { return "TestDrillers"; } - const char* GetName() const override { return "MyTestDriller"; } - const char* GetDescription() const override { return "MyTestDriller description...."; } - int GetNumParams() const override { return static_cast(m_params.size()); } - const Param* GetParam(int index) const override { return &m_params[index]; } - - MyDriller() - : m_isDetailedCapture(false) - , drilledObject(NULL) - { - Param isDetailed; - isDetailed.desc = "IsDetailedDrill"; - isDetailed.name = AZ_CRC("IsDetailedDrill", 0x2155cef2); - isDetailed.type = Param::PT_BOOL; - isDetailed.value = 0; - m_params.push_back(isDetailed); - } - - void Start(const Param* params = NULL, int numParams = 0) override - { - m_isDetailedCapture = m_params[0].value != 0; - if (params) - { - for (int i = 0; i < numParams; i++) - { - if (params[i].name == m_params[0].name) - { - m_isDetailedCapture = params[i].value != 0; - } - } - } - - EBUS_EVENT_RESULT(drilledObject, MyDrillerCommandBus, RequestDrilledObject); - AZ_TEST_ASSERT(drilledObject != NULL); /// Make sure we have our object by the time we started the driller - - m_output->BeginTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - m_output->Write(AZ_CRC("OnStart", 0x8b372fca), m_isDetailedCapture); - // write drilled object initial state - m_output->EndTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - - BusConnect(); - } - void Stop() override - { - drilledObject = NULL; - m_output->BeginTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - m_output->Write(AZ_CRC("OnStop", 0xf6701caa), m_isDetailedCapture); - m_output->EndTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - BusDisconnect(); - } - - void OnEventX(int data) override - { - void* ptr = AZ_INVALID_POINTER; - float f = 3.2f; - m_output->BeginTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - m_output->Write(AZ_CRC("EventX", 0xc4558ec2), data); - m_output->Write(AZ_CRC("Pointer", 0x320468a8), ptr); - m_output->Write(AZ_CRC("Float", 0xc9a55e95), f); - m_output->EndTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - } - - void OnStringEvent() override - { - m_output->BeginTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - m_output->BeginTag(AZ_CRC("StringEvent", 0xd1e005df)); - m_output->Write(AZ_CRC("StringOne", 0x56efb231), "This is copied string"); - m_output->Write(AZ_CRC("StringTwo", 0x3d49bea6), "This is referenced string", false); // don't copy the string if we use string pool, this will be faster as we don't delete the string - m_output->EndTag(AZ_CRC("StringEvent", 0xd1e005df)); - m_output->EndTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - } - }; - - /** - * - */ - class FileStreamDrillerTest - : public AllocatorsFixture - { - DrillerManager* m_drillerManager = nullptr; - MyDriller* m_driller = nullptr; - public: - void SetUp() override - { - AllocatorsFixture::SetUp(); - - m_drillerManager = DrillerManager::Create(); - m_driller = aznew MyDriller; - // Register driller descriptor - m_drillerManager->Register(m_driller); - // check that our driller descriptor is registered - AZ_TEST_ASSERT(m_drillerManager->GetNumDrillers() == 1); - } - - void TearDown() override - { - // remove our driller descriptor - m_drillerManager->Unregister(m_driller); - AZ_TEST_ASSERT(m_drillerManager->GetNumDrillers() == 0); - DrillerManager::Destroy(m_drillerManager); - - AllocatorsFixture::TearDown(); - } - - /** - * My Driller data handler. - */ - class MyDrillerHandler - : public DrillerHandlerParser - { - public: - static const bool s_isWarnOnMissingDrillers = true; - int m_lastData; - - MyDrillerHandler() - : m_lastData(-1) {} - - // From the template query - DrillerHandlerParser* FindDrillerHandler(u32 drillerId) - { - if (drillerId == AZ_CRC("MyDriller", 0xc3b7dceb)) - { - return this; - } - return NULL; - } - - DrillerHandlerParser* OnEnterTag(u32 tagName) override - { - (void)tagName; - return NULL; - } - void OnData(const DrillerSAXParser::Data& dataNode) override - { - if (dataNode.m_name == AZ_CRC("OnStart", 0x8b372fca) || dataNode.m_name == AZ_CRC("OnStop", 0xf6701caa)) - { - bool isDetailedCapture; - dataNode.Read(isDetailedCapture); - AZ_TEST_ASSERT(isDetailedCapture == true); - } - else if (dataNode.m_name == AZ_CRC("EventX", 0xc4558ec2)) - { - int data; - dataNode.Read(data); - AZ_TEST_ASSERT(data > m_lastData); - m_lastData = data; - } - else if (dataNode.m_name == AZ_CRC("Pointer", 0x320468a8)) - { - AZ::u64 pointer = 0; //< read pointers in u64 to cover all platforms - dataNode.Read(pointer); - AZ_TEST_ASSERT(pointer == 0x0badf00dul); - } - else if (dataNode.m_name == AZ_CRC("Float", 0xc9a55e95)) - { - float f; - dataNode.Read(f); - AZ_TEST_ASSERT(f == 3.2f); - } - } - }; - - ////////////////////////////////////////////////////////////////////////// - - void run() - { - // get our driller descriptor - Driller* driller = m_drillerManager->GetDriller(0); - AZ_TEST_ASSERT(driller != NULL); - AZ_TEST_ASSERT(strcmp(driller->GetName(), "MyTestDriller") == 0); - AZ_TEST_ASSERT(driller->GetNumParams() == 1); - - // read the default params and make a copy... - Driller::Param param = *driller->GetParam(0); - AZ_TEST_ASSERT(strcmp(param.desc, "IsDetailedDrill") == 0); - AZ_TEST_ASSERT(param.name == AZ_CRC("IsDetailedDrill", 0x2155cef2)); - AZ_TEST_ASSERT(param.type == Driller::Param::PT_BOOL); - // tweak the default params by enabling detailed drilling - param.value = 1; - - // create a list of driller we what to drill - DrillerManager::DrillerListType dillersToDrill; - DrillerManager::DrillerInfo di; - di.id = driller->GetId(); // set driller id - di.params.push_back(param); // set driller custom params - dillersToDrill.push_back(di); - - // open a driller output file stream - // open a driller output file stream - AZStd::string testFileName = GetTestFolderPath() + "drilltest.dat"; - DrillerOutputFileStream drillerOutputStream; - drillerOutputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_CREATE | IO::SystemFile::SF_OPEN_WRITE_ONLY); - - ////////////////////////////////////////////////////////////////////////// - // Drill an object - MyDrilledObject myDrilledObject; - clock_t st = clock(); - - // start a driller session with the file stream and the list of drillers - DrillerSession* drillerSession = m_drillerManager->Start(drillerOutputStream, dillersToDrill); - // update for N frames - for (int i = 0; i < AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT; ++i) - { - // trigger event X that we want to drill... - myDrilledObject.OnEventX(); - m_drillerManager->FrameUpdate(); - } - // stop the drillers - m_drillerManager->Stop(drillerSession); - // Stop writing and flush all data - drillerOutputStream.Close(); - AZ_Printf("Driller", "Compression time %.09f seconds\n", (double)(clock() - st) / CLOCKS_PER_SEC); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // try to load the drill data - DrillerInputFileStream drillerInputStream; - drillerInputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_READ_ONLY); - DrillerDOMParser dp; - AZ_TEST_ASSERT(dp.CanParse() == true); - dp.ProcessStream(drillerInputStream); - AZ_TEST_ASSERT(dp.CanParse() == true); - drillerInputStream.Close(); - - u32 startDataId = AZ_CRC("StartData", 0xecf3f53f); - u32 frameId = AZ_CRC("Frame", 0xb5f83ccd); - - ////////////////////////////////////////////////////////////////////////// - // read all data - const DrillerDOMParser::Node* root = dp.GetRootNode(); - int lastFrame = -1; - int lastData = -1; - for (DrillerDOMParser::Node::NodeListType::const_iterator iter = root->m_tags.begin(); iter != root->m_tags.end(); ++iter) - { - const DrillerDOMParser::Node* node = &*iter; - u32 name = node->m_name; - AZ_TEST_ASSERT(name == startDataId || name == frameId); - if (name == startDataId) - { - unsigned int currentPlatform; - node->GetDataRequired(AZ_CRC("Platform", 0x3952d0cb))->Read(currentPlatform); - AZ_TEST_ASSERT(currentPlatform == static_cast(AZ::g_currentPlatform)); - const DrillerDOMParser::Node* drillerNode = node->GetTag(AZ_CRC("Driller", 0xa6e1fb73)); - AZ_TEST_ASSERT(drillerNode != NULL); - AZ::u32 drillerName; - drillerNode->GetDataRequired(AZ_CRC("Name", 0x5e237e06))->Read(drillerName); - AZ_TEST_ASSERT(drillerName == m_driller->GetId()); - const DrillerDOMParser::Node* paramNode = drillerNode->GetTag(AZ_CRC("Param", 0xa4fa7c89)); - AZ_TEST_ASSERT(paramNode != NULL); - u32 paramName; - char paramDesc[128]; - int paramType; - int paramValue; - paramNode->GetDataRequired(AZ_CRC("Name", 0x5e237e06))->Read(paramName); - AZ_TEST_ASSERT(paramName == param.name); - paramNode->GetDataRequired(AZ_CRC("Description", 0x6de44026))->Read(paramDesc, AZ_ARRAY_SIZE(paramDesc)); - AZ_TEST_ASSERT(strcmp(paramDesc, param.desc) == 0); - paramNode->GetDataRequired(AZ_CRC("Type", 0x8cde5729))->Read(paramType); - AZ_TEST_ASSERT(paramType == param.type); - paramNode->GetDataRequired(AZ_CRC("Value", 0x1d775834))->Read(paramValue); - AZ_TEST_ASSERT(paramValue == param.value); - } - else - { - int curFrame; - node->GetDataRequired(AZ_CRC("FrameNum", 0x85a1a919))->Read(curFrame); - AZ_TEST_ASSERT(curFrame > lastFrame); // check order - lastFrame = curFrame; - const DrillerDOMParser::Node* myDrillerNode = node->GetTag(AZ_CRC("MyDriller", 0xc3b7dceb)); - AZ_TEST_ASSERT(myDrillerNode != NULL); - const DrillerDOMParser::Data* dataEntry; - dataEntry = myDrillerNode->GetData(AZ_CRC("EventX", 0xc4558ec2)); - if (dataEntry) - { - int data; - dataEntry->Read(data); - AZ_TEST_ASSERT(data > lastData); - lastData = data; - dataEntry = myDrillerNode->GetData(AZ_CRC("Pointer", 0x320468a8)); - AZ_TEST_ASSERT(dataEntry); - unsigned int ptr; - dataEntry->Read(ptr); - AZ_TEST_ASSERT(static_cast(ptr) == reinterpret_cast(AZ_INVALID_POINTER)); - float f; - dataEntry = myDrillerNode->GetData(AZ_CRC("Float", 0xc9a55e95)); - AZ_TEST_ASSERT(dataEntry); - dataEntry->Read(f); - AZ_TEST_ASSERT(f == 3.2f); - } - else - { - bool isDetailedCapture; - dataEntry = myDrillerNode->GetData(AZ_CRC("OnStart", 0x8b372fca)); - if (dataEntry) - { - dataEntry->Read(isDetailedCapture); - } - else - { - myDrillerNode->GetDataRequired(AZ_CRC("OnStop", 0xf6701caa))->Read(isDetailedCapture); - } - AZ_TEST_ASSERT(isDetailedCapture == true); - } - } - } - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Read that with Tag Handlers - drillerInputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_READ_ONLY); - - DrillerRootHandler rootHandler; - DrillerSAXParserHandler dhp(&rootHandler); - dhp.ProcessStream(drillerInputStream); - // Verify that Default templates forked fine... - AZ_TEST_ASSERT(rootHandler.m_drillerSessionInfo.m_platform == static_cast(AZ::g_currentPlatform)); - AZ_TEST_ASSERT(rootHandler.m_drillerSessionInfo.m_drillers.size() == 1); - { - const DrillerManager::DrillerInfo& dinfo = rootHandler.m_drillerSessionInfo.m_drillers.front(); - AZ_TEST_ASSERT(dinfo.id == AZ_CRC("MyTestDriller", 0x5cc4edf5)); - AZ_TEST_ASSERT(dinfo.params.size() == 1); - AZ_TEST_ASSERT(strcmp(param.desc, "IsDetailedDrill") == 0); - AZ_TEST_ASSERT(param.name == AZ_CRC("IsDetailedDrill", 0x2155cef2)); - AZ_TEST_ASSERT(param.type == Driller::Param::PT_BOOL); - // tweak the default params by enabling detailed drilling - param.value = 1; - AZ_TEST_ASSERT(dinfo.params[0].name == AZ_CRC("IsDetailedDrill", 0x2155cef2)); - AZ_TEST_ASSERT(dinfo.params[0].desc == NULL); // ignored for now - AZ_TEST_ASSERT(dinfo.params[0].type == Driller::Param::PT_BOOL); - AZ_TEST_ASSERT(dinfo.params[0].value == 1); - } - drillerInputStream.Close(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // - - ////////////////////////////////////////////////////////////////////////// - } - }; - - TEST_F(FileStreamDrillerTest, Test) - { - run(); - } - - /** - * - */ - class StringPoolDrillerTest - : public AllocatorsFixture - { - DrillerManager* m_drillerManager = nullptr; - MyDriller* m_driller = nullptr; - public: - void SetUp() override - { - AllocatorsFixture::SetUp(); - - m_drillerManager = DrillerManager::Create(); - m_driller = aznew MyDriller; - // Register driller descriptor - m_drillerManager->Register(m_driller); - // check that our driller descriptor is registered - AZ_TEST_ASSERT(m_drillerManager->GetNumDrillers() == 1); - } - - void TearDown() override - { - // remove our driller descriptor - m_drillerManager->Unregister(m_driller); - AZ_TEST_ASSERT(m_drillerManager->GetNumDrillers() == 0); - DrillerManager::Destroy(m_drillerManager); - - AllocatorsFixture::TearDown(); - } - - /** - * My Driller data handler. - */ - class MyDrillerHandler - : public DrillerHandlerParser - { - public: - static const bool s_isWarnOnMissingDrillers = true; - - MyDrillerHandler() {} - - // From the template query - DrillerHandlerParser* FindDrillerHandler(u32 drillerId) - { - if (drillerId == AZ_CRC("MyDriller", 0xc3b7dceb)) - { - return this; - } - return NULL; - } - - DrillerHandlerParser* OnEnterTag(u32 tagName) override - { - if (tagName == AZ_CRC("StringEvent", 0xd1e005df)) - { - return this; - } - return NULL; - } - void OnData(const DrillerSAXParser::Data& dataNode) override - { - if (dataNode.m_name == AZ_CRC("OnStart", 0x8b372fca) || dataNode.m_name == AZ_CRC("OnStop", 0xf6701caa)) - { - bool isDetailedCapture; - dataNode.Read(isDetailedCapture); - AZ_TEST_ASSERT(isDetailedCapture == true); - } - else if (dataNode.m_name == AZ_CRC("StringOne", 0x56efb231)) - { - // read string as a copy - char stringCopy[256]; - dataNode.Read(stringCopy, AZ_ARRAY_SIZE(stringCopy)); - AZ_TEST_ASSERT(strcmp(stringCopy, "This is copied string") == 0); - } - else if (dataNode.m_name == AZ_CRC("StringTwo", 0x3d49bea6)) - { - // read string as reference if possible, otherwise read it as a copy - const char* stringRef = dataNode.ReadPooledString(); - AZ_TEST_ASSERT(strcmp(stringRef, "This is referenced string") == 0); - } - } - }; - - void run() - { - // get our driller descriptor - Driller* driller = m_drillerManager->GetDriller(0); - Driller::Param param = *driller->GetParam(0); - param.value = 1; - // create a list of driller we what to drill - DrillerManager::DrillerListType dillersToDrill; - DrillerManager::DrillerInfo di; - di.id = driller->GetId(); // set driller id - di.params.push_back(param); // set driller custom params - dillersToDrill.push_back(di); - - MyDrilledObject myDrilledObject; - - // open a driller output file stream - AZStd::string testFileName = GetTestFolderPath() + "stringpooldrilltest.dat"; - DrillerOutputFileStream drillerOutputStream; - DrillerInputFileStream drillerInputStream; - DrillerDefaultStringPool stringPool; - DrillerSession* drillerSession; - DrillerRootHandler rootHandler; - DrillerSAXParserHandler dhp(&rootHandler); - - ////////////////////////////////////////////////////////////////////////// - // Drill an object without string pools - drillerOutputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_CREATE | IO::SystemFile::SF_OPEN_WRITE_ONLY); - - // start a driller session with the file stream and the list of drillers - drillerSession = m_drillerManager->Start(drillerOutputStream, dillersToDrill); - // update for N frames - for (int i = 0; i < AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT; ++i) - { - myDrilledObject.OnStringEvent(); - m_drillerManager->FrameUpdate(); - } - // stop the drillers - m_drillerManager->Stop(drillerSession); - // Stop writing and flush all data - drillerOutputStream.Close(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Read all data that was written without string pool, in a stream that uses one. - drillerInputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_READ_ONLY); - drillerInputStream.SetStringPool(&stringPool); - - dhp.ProcessStream(drillerInputStream); - drillerInputStream.Close(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Drill an object without string pools - drillerOutputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_CREATE | IO::SystemFile::SF_OPEN_WRITE_ONLY); - stringPool.Reset(); - drillerOutputStream.SetStringPool(&stringPool); // set the string pool on save - - // start a driller session with the file stream and the list of drillers - drillerSession = m_drillerManager->Start(drillerOutputStream, dillersToDrill); - // update for N frames - for (int i = 0; i < AZ_TRAIT_UNIT_TEST_DILLER_TRIGGER_EVENT_COUNT; ++i) - { - myDrilledObject.OnStringEvent(); - m_drillerManager->FrameUpdate(); - } - // stop the drillers - m_drillerManager->Stop(drillerSession); - // Stop writing and flush all data - drillerOutputStream.Close(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // Read all data that was written without string pool, in a stream that uses one. - stringPool.Reset(); - drillerInputStream.Open(testFileName.c_str(), IO::SystemFile::SF_OPEN_READ_ONLY); - drillerInputStream.SetStringPool(&stringPool); - - dhp.ProcessStream(drillerInputStream); - drillerInputStream.Close(); - ////////////////////////////////////////////////////////////////////////// - } - }; - - TEST_F(StringPoolDrillerTest, Test) - { - run(); - } - - /** - * - */ - class DrillFileStreamCheck - { - public: - void run() - { - // open and read drilled file - } - }; - - /** - * Driller application test - */ - TEST(DrillerApplication, Test) - { - ComponentApplication app; - - ////////////////////////////////////////////////////////////////////////// - // Create application environment code driven - ComponentApplication::Descriptor appDesc; - appDesc.m_memoryBlocksByteSize = 10 * 1024 * 1024; - appDesc.m_enableDrilling = true; - Entity* systemEntity = app.Create(appDesc); - - systemEntity->CreateComponent(); - systemEntity->CreateComponent(); // note that this component is what registers the streamer driller - - systemEntity->Init(); - systemEntity->Activate(); - - { - // open a driller output file stream - char testFileName[AZ_MAX_PATH_LEN]; - MakePathFromTestFolder(testFileName, AZ_MAX_PATH_LEN, "drillapptest.dat"); - DrillerOutputFileStream fs; - fs.Open(testFileName, IO::SystemFile::SF_OPEN_CREATE | IO::SystemFile::SF_OPEN_WRITE_ONLY); - - // create a list of driller we what to drill - DrillerManager::DrillerListType drillersToDrill; - DrillerManager::DrillerInfo di; - di.id = AZ_CRC("TraceMessagesDriller", 0xa61d1b00); - drillersToDrill.push_back(di); - di.id = AZ_CRC("MemoryDriller", 0x1b31269d); - drillersToDrill.push_back(di); - - ASSERT_NE(nullptr, app.GetDrillerManager()); - DrillerSession* drillerSession = app.GetDrillerManager()->Start(fs, drillersToDrill); - ASSERT_NE(nullptr, drillerSession); - - const int numOfFrames = 10000; - void* memory = NULL; - for (int i = 0; i < numOfFrames; ++i) - { - memory = azmalloc(rand() % 2048 + 1); - azfree(memory); - app.Tick(); - } - - app.GetDrillerManager()->Stop(drillerSession); // stop session manually - fs.Close(); // close the file with driller info - } - - app.Destroy(); - ////////////////////////////////////////////////////////////////////////// - } -} diff --git a/Code/Framework/AzCore/Tests/Serialization.cpp b/Code/Framework/AzCore/Tests/Serialization.cpp index 05b739bf5f..9ff2925472 100644 --- a/Code/Framework/AzCore/Tests/Serialization.cpp +++ b/Code/Framework/AzCore/Tests/Serialization.cpp @@ -1242,7 +1242,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzCore/Tests/TimeDataStatistics.cpp b/Code/Framework/AzCore/Tests/TimeDataStatistics.cpp deleted file mode 100644 index 21b42fc451..0000000000 --- a/Code/Framework/AzCore/Tests/TimeDataStatistics.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include -#include -#include - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include - -using namespace AZ; -using namespace Debug; - -namespace UnitTest -{ - /** - * Validate functionality of the convenience class TimeDataStatisticsManager. - * It is a specialized version of RunningStatisticsManager that works with Timer type - * of registers that can be captured with the FrameProfilerBus::OnFrameProfilerData() - */ - class TimeDataStatisticsManagerTest - : public AllocatorsFixture - , public FrameProfilerBus::Handler - { - static constexpr const char* PARENT_TIMER_STAT = "ParentStat"; - static constexpr const char* CHILD_TIMER_STAT0 = "ChildStat0"; - static constexpr const char* CHILD_TIMER_STAT1 = "ChildStat1"; - - public: - TimeDataStatisticsManagerTest() - : AllocatorsFixture() - { - } - - void SetUp() override - { - AllocatorsFixture::SetUp(); - m_statsManager = AZStd::make_unique(); - } - - void TearDown() override - { - m_statsManager = nullptr; - AllocatorsFixture::TearDown(); - } - - ////////////////////////////////////////////////////////////////////////// - // FrameProfilerBus - virtual void OnFrameProfilerData(const FrameProfiler::ThreadDataArray& data) - { - for (size_t iThread = 0; iThread < data.size(); ++iThread) - { - const FrameProfiler::ThreadData& td = data[iThread]; - FrameProfiler::ThreadData::RegistersMap::const_iterator regIt = td.m_registers.begin(); - for (; regIt != td.m_registers.end(); ++regIt) - { - const FrameProfiler::RegisterData& rd = regIt->second; - u32 unitTestCrc = AZ_CRC("UnitTest", 0x8089cea8); - if (unitTestCrc != rd.m_systemId) - { - continue; //Not for us. - } - ASSERT_EQ(ProfilerRegister::PRT_TIME, rd.m_type); - const FrameProfiler::FrameData& fd = rd.m_frames.back(); - m_statsManager->PushTimeDataSample(rd.m_name, fd.m_timeData); - } - } - } - ////////////////////////////////////////////////////////////////////////// - - int ChildFunction0(int numIterations, int sleepTimeMilliseconds) - { - AZ_PROFILE_SCOPE(UnitTest, CHILD_TIMER_STAT0); - AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds)); - int result = 5; - for (int i = 0; i < numIterations; ++i) - { - result += i % 3; - } - return result; - } - - int ChildFunction1(int numIterations, int sleepTimeMilliseconds) - { - AZ_PROFILE_SCOPE(UnitTest, CHILD_TIMER_STAT1); - AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds)); - int result = 5; - for (int i = 0; i < numIterations; ++i) - { - result += i % 3; - } - return result; - } - - int ParentFunction(int numIterations, int sleepTimeMilliseconds) - { - AZ_PROFILE_SCOPE(UnitTest, PARENT_TIMER_STAT); - AZStd::this_thread::sleep_for(AZStd::chrono::milliseconds(sleepTimeMilliseconds)); - int result = 0; - result += ChildFunction0(numIterations, sleepTimeMilliseconds); - result += ChildFunction1(numIterations, sleepTimeMilliseconds); - return result; - } - - void run() - { - Debug::FrameProfilerBus::Handler::BusConnect(); - - ComponentApplication app; - ComponentApplication::Descriptor desc; - desc.m_useExistingAllocator = true; - desc.m_enableDrilling = false; // we already created a memory driller for the test (AllocatorsFixture) - ComponentApplication::StartupParameters startupParams; - startupParams.m_allocator = &AllocatorInstance::Get(); - Entity* systemEntity = app.Create(desc, startupParams); - systemEntity->CreateComponent(); - - systemEntity->Init(); - systemEntity->Activate(); // start frame component - - const int sleepTimeAllFuncsMillis = 1; - const int numIterations = 10; - for (int iterationCounter = 0; iterationCounter < numIterations; ++iterationCounter) - { - ParentFunction(numIterations, sleepTimeAllFuncsMillis); - //Collect all samples. - app.Tick(); - } - - //Verify we have three running stats. - { - AZStd::vector allStats; - m_statsManager->GetAllStatistics(allStats); - EXPECT_EQ(allStats.size(), 3); - } - - AZStd::string parentStatName(PARENT_TIMER_STAT); - AZStd::string child0StatName(CHILD_TIMER_STAT0); - AZStd::string child1StatName(CHILD_TIMER_STAT1); - ASSERT_TRUE(m_statsManager->GetStatistic(parentStatName) != nullptr); - ASSERT_TRUE(m_statsManager->GetStatistic(child0StatName) != nullptr); - ASSERT_TRUE(m_statsManager->GetStatistic(child1StatName) != nullptr); - - EXPECT_EQ(m_statsManager->GetStatistic(parentStatName)->GetNumSamples(), numIterations); - EXPECT_EQ(m_statsManager->GetStatistic(child0StatName)->GetNumSamples(), numIterations); - EXPECT_EQ(m_statsManager->GetStatistic(child1StatName)->GetNumSamples(), numIterations); - - const double minimumExpectDurationOfChildFunctionMicros = 1; - const double minimumExpectDurationOfParentFunctionMicros = 1; - - EXPECT_GE(m_statsManager->GetStatistic(parentStatName)->GetMinimum(), minimumExpectDurationOfParentFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(parentStatName)->GetAverage(), minimumExpectDurationOfParentFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(parentStatName)->GetMaximum(), minimumExpectDurationOfParentFunctionMicros); - - EXPECT_GE(m_statsManager->GetStatistic(child0StatName)->GetMinimum(), minimumExpectDurationOfChildFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(child0StatName)->GetAverage(), minimumExpectDurationOfChildFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(child0StatName)->GetMaximum(), minimumExpectDurationOfChildFunctionMicros); - - EXPECT_GE(m_statsManager->GetStatistic(child1StatName)->GetMinimum(), minimumExpectDurationOfChildFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(child1StatName)->GetAverage(), minimumExpectDurationOfChildFunctionMicros); - EXPECT_GE(m_statsManager->GetStatistic(child1StatName)->GetMaximum(), minimumExpectDurationOfChildFunctionMicros); - - //Let's validate TimeDataStatisticsManager::RemoveStatistics() - m_statsManager->RemoveStatistic(child1StatName); - ASSERT_TRUE(m_statsManager->GetStatistic(parentStatName) != nullptr); - ASSERT_TRUE(m_statsManager->GetStatistic(child0StatName) != nullptr); - EXPECT_EQ(m_statsManager->GetStatistic(child1StatName), nullptr); - - //Let's store the sample count for both parentStatName and child0StatName. - const AZ::u64 numSamplesParent = m_statsManager->GetStatistic(parentStatName)->GetNumSamples(); - const AZ::u64 numSamplesChild0 = m_statsManager->GetStatistic(child0StatName)->GetNumSamples(); - - //Let's call child1 function again and call app.Tick(). child1StatName should be readded to m_statsManager. - ChildFunction1(numIterations, sleepTimeAllFuncsMillis); - app.Tick(); - ASSERT_TRUE(m_statsManager->GetStatistic(child1StatName) != nullptr); - EXPECT_EQ(m_statsManager->GetStatistic(parentStatName)->GetNumSamples(), numSamplesParent); - EXPECT_EQ(m_statsManager->GetStatistic(child0StatName)->GetNumSamples(), numSamplesChild0); - EXPECT_EQ(m_statsManager->GetStatistic(child1StatName)->GetNumSamples(), 1); - - Debug::FrameProfilerBus::Handler::BusDisconnect(); - app.Destroy(); - } - - AZStd::unique_ptr m_statsManager; - };//class TimeDataStatisticsManagerTest - - // TODO:BUDGETS disabled until profiler budgets system comes online - // TEST_F(TimeDataStatisticsManagerTest, Test) - // { - // run(); - // } - //End of all Tests of TimeDataStatisticsManagerTest - -}//namespace UnitTest diff --git a/Code/Framework/AzCore/Tests/azcoretests_files.cmake b/Code/Framework/AzCore/Tests/azcoretests_files.cmake index 63d447e9e4..d4d107f094 100644 --- a/Code/Framework/AzCore/Tests/azcoretests_files.cmake +++ b/Code/Framework/AzCore/Tests/azcoretests_files.cmake @@ -29,7 +29,6 @@ set(FILES Console/ConsoleTests.cpp Debug.cpp DLL.cpp - Driller.cpp EBus.cpp EntityIdTests.cpp EntityTests.cpp @@ -66,7 +65,6 @@ set(FILES SystemFile.cpp TaskTests.cpp TickBusTest.cpp - TimeDataStatistics.cpp UUIDTests.cpp XML.cpp Debug/AssetTracking.cpp diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index abd97aee0d..e967fd6af1 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -60,7 +59,6 @@ #include #include #include -#include #include #include #include @@ -296,7 +294,6 @@ namespace AzFramework azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), - azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), @@ -312,7 +309,6 @@ namespace AzFramework #endif azrtti_typeid(), azrtti_typeid(), - azrtti_typeid(), #if !defined(AZCORE_EXCLUDE_LUA) azrtti_typeid(), @@ -374,7 +370,6 @@ namespace AzFramework azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), - azrtti_typeid(), azrtti_typeid(), azrtti_typeid(), AZ::Uuid("{624a7be2-3c7e-4119-aee2-1db2bdb6cc89}"), // ScriptDebugAgent diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.h b/Code/Framework/AzFramework/AzFramework/Application/Application.h index 9c98bd7e45..c6b1dfeaae 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.h +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.h @@ -191,3 +191,5 @@ namespace AzFramework }; } // namespace AzFramework +AZ_DECLARE_BUDGET(AzFramework); + diff --git a/Code/Framework/AzFramework/AzFramework/AzFrameworkModule.cpp b/Code/Framework/AzFramework/AzFramework/AzFrameworkModule.cpp index 4927dadc44..c5fee7ec9a 100644 --- a/Code/Framework/AzFramework/AzFramework/AzFrameworkModule.cpp +++ b/Code/Framework/AzFramework/AzFramework/AzFrameworkModule.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #include #include #include @@ -27,6 +26,8 @@ #include #include +AZ_DEFINE_BUDGET(AzFramework); + namespace AzFramework { AzFrameworkModule::AzFrameworkModule() @@ -46,7 +47,6 @@ namespace AzFramework AzFramework::CreateScriptDebugAgentFactory(), AzFramework::AssetSystem::AssetSystemComponent::CreateDescriptor(), AzFramework::InputSystemComponent::CreateDescriptor(), - AzFramework::DrillerNetworkAgentComponent::CreateDescriptor(), #if !defined(AZCORE_EXCLUDE_LUA) AzFramework::ScriptComponent::CreateDescriptor(), diff --git a/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.cpp b/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.cpp deleted file mode 100644 index 5d4b89ab5c..0000000000 --- a/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -#include -#include -#include - -namespace AzFramework -{ - void DrillToFileComponent::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ; - - if (serialize->FindClassData(DrillerInfo::RTTI_Type()) == nullptr) - { - serialize->Class() - ->Field("Id", &DrillerInfo::m_id) - ->Field("GroupName", &DrillerInfo::m_groupName) - ->Field("Name", &DrillerInfo::m_name) - ->Field("Description", &DrillerInfo::m_description); - } - } - } - - void DrillToFileComponent::Activate() - { - m_drillerSession = nullptr; - DrillerConsoleCommandBus::Handler::BusConnect(); - } - - void DrillToFileComponent::Deactivate() - { - DrillerConsoleCommandBus::Handler::BusDisconnect(); - StopDrillerSession(reinterpret_cast(this)); - } - - void DrillToFileComponent::WriteBinary(const void* data, unsigned int dataSize) - { - if (dataSize > 0) - { - m_frameBuffer.insert(m_frameBuffer.end(), reinterpret_cast(data), reinterpret_cast(data) + dataSize); - } - } - - void DrillToFileComponent::OnEndOfFrame() - { - AZStd::lock_guard lock(m_writerMutex); - m_writeQueue.push_back(); - m_writeQueue.back().swap(m_frameBuffer); - m_signal.notify_all(); - } - - void DrillToFileComponent::EnumerateAvailableDrillers() - { - DrillerInfoListType availableDrillers; - - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (mgr) - { - for (int i = 0; i < mgr->GetNumDrillers(); ++i) - { - AZ::Debug::Driller* driller = mgr->GetDriller(i); - AZ_Assert(driller, "DrillerManager returned a NULL driller. This is not legal!"); - availableDrillers.push_back(); - availableDrillers.back().m_id = driller->GetId(); - availableDrillers.back().m_groupName = driller->GroupName(); - availableDrillers.back().m_name = driller->GetName(); - availableDrillers.back().m_description = driller->GetDescription(); - } - } - - EBUS_EVENT(DrillerConsoleEventBus, OnDrillersEnumerated, availableDrillers); - } - - void DrillToFileComponent::StartDrillerSession(const AZ::Debug::DrillerManager::DrillerListType& requestedDrillers, AZ::u64 sessionId) - { - if (!m_drillerSession) - { - AZ_Assert(m_writeQueue.empty(), "write queue is not empty!"); - - m_sessionId = sessionId; - AZ::Debug::DrillerManager* mgr = nullptr; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (mgr) - { - SetStringPool(&m_stringPool);; - m_drillerSession = mgr->Start(*this, requestedDrillers); - - AZStd::unique_lock signalLock(m_writerMutex); - m_isWriterEnabled = true; - AZStd::thread_desc td; - td.m_name = "DrillToFileComponent Writer Thread"; - m_writerThread = AZStd::thread(AZStd::bind(&DrillToFileComponent::AsyncWritePump, this), &td); - m_signal.wait(signalLock); - - EBUS_EVENT(DrillerConsoleEventBus, OnDrillerSessionStarted, sessionId); - } - } - } - - void DrillToFileComponent::StopDrillerSession(AZ::u64 sessionId) - { - if (sessionId == m_sessionId) - { - if (m_drillerSession) - { - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (mgr) - { - mgr->Stop(m_drillerSession); - } - m_drillerSession = nullptr; - EBUS_EVENT(DrillerConsoleEventBus, OnDrillerSessionStopped, reinterpret_cast(this)); - } - - m_isWriterEnabled = false; - if (m_writerThread.joinable()) - { - m_writerMutex.lock(); - m_signal.notify_all(); - m_writerMutex.unlock(); - m_writerThread.join(); - } - SetStringPool(nullptr); - m_stringPool.Reset(); - m_frameBuffer.clear(); // there may be pending data but we don't want to write it because it's an incomplete frame. - } - } - void DrillToFileComponent::AsyncWritePump() - { - AZStd::unique_lock signalLock(m_writerMutex); - - AZStd::basic_string, AZ::OSStdAllocator> drillerOutputPath; - - // Try the log path first - AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance(); - if (fileIO) - { - const char* logLocation = fileIO->GetAlias("@log@"); - if (logLocation) - { - drillerOutputPath = logLocation; - drillerOutputPath.append("/"); - } - } - - // Try the executable path - if (drillerOutputPath.empty()) - { - EBUS_EVENT_RESULT(drillerOutputPath, AZ::ComponentApplicationBus, GetExecutableFolder); - drillerOutputPath.append("/"); - } - - drillerOutputPath.append("drillerdata.drl"); - AZ::IO::SystemFile output; - output.Open(drillerOutputPath.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY); - AZ_Assert(output.IsOpen(), "Failed to open driller output file!"); - - m_signal.notify_all(); - - while (true) - { - while (!m_writeQueue.empty()) - { - AZStd::vector outBuffer; - outBuffer.swap(m_writeQueue.front()); - m_writeQueue.pop_front(); - signalLock.unlock(); - - output.Write(outBuffer.data(), outBuffer.size()); - output.Flush(); - - signalLock.lock(); - } - if (!m_isWriterEnabled) - { - break; - } - m_signal.wait(signalLock); - } - - output.Close(); - } -} // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.h b/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.h deleted file mode 100644 index c1b0ac9a65..0000000000 --- a/Code/Framework/AzFramework/AzFramework/Driller/DrillToFileComponent.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include - -#include -#include -#include -#include -#include -#include - -//#define ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - -namespace AZ -{ - struct ClassDataReflection; -} - -namespace AzFramework -{ - /** - * Runs on the machine being drilled and is responsible for communications - * with the DrillerNetworkConsole running on the tool side as well as - * creating DrillerNetSessionStreams for each driller session being started. - */ - class DrillToFileComponent - : public AZ::Component - , public AZ::Debug::DrillerOutputStream - , public DrillerConsoleCommandBus::Handler - { - public: - AZ_COMPONENT(DrillToFileComponent, "{42BAA25D-7CEB-4A37-8BD4-4A1FE2253894}") - - ////////////////////////////////////////////////////////////////////////// - // AZ::Component - static void Reflect(AZ::ReflectContext* context); - void Activate() override; - void Deactivate() override; - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // DrillerOutputStream - void WriteBinary(const void* data, unsigned int dataSize) override; - void OnEndOfFrame() override; - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // DrillerConsoleCommandBus - void EnumerateAvailableDrillers() override; - void StartDrillerSession(const AZ::Debug::DrillerManager::DrillerListType& requestedDrillers, AZ::u64 sessionId) override; - void StopDrillerSession(AZ::u64 sessionId) override; - ////////////////////////////////////////////////////////////////////////// - - protected: - void AsyncWritePump(); - - AZ::u64 m_sessionId; - AZ::Debug::DrillerSession* m_drillerSession; - AZ::Debug::DrillerDefaultStringPool m_stringPool; - AZStd::vector m_frameBuffer; - AZStd::deque, AZ::OSStdAllocator> m_writeQueue; - AZStd::mutex m_writerMutex; - AZStd::condition_variable m_signal; - AZStd::thread m_writerThread; - bool m_isWriterEnabled; - }; -} // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Driller/DrillerConsoleAPI.h b/Code/Framework/AzFramework/AzFramework/Driller/DrillerConsoleAPI.h deleted file mode 100644 index 80bb7e3a0b..0000000000 --- a/Code/Framework/AzFramework/AzFramework/Driller/DrillerConsoleAPI.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#include -#include -#include - -namespace AzFramework -{ - /* - * Descriptors for drillers available on the target machine. - */ - struct DrillerInfo final - { - AZ_RTTI(DrillerInfo, "{197AC318-B65C-4B36-A109-BD25422BF7D0}"); - AZ::u32 m_id; - AZStd::string m_groupName; - AZStd::string m_name; - AZStd::string m_description; - }; - - typedef AZStd::vector DrillerInfoListType; - typedef AZStd::vector DrillerListType; - - /** - * Driller clients interested in receiving notification events from the - * console should implement this interface. - */ - class DrillerConsoleEvents - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - typedef AZ::OSStdAllocator AllocatorType; - ////////////////////////////////////////////////////////////////////////// - - virtual ~DrillerConsoleEvents() {} - - // A list of available drillers has been received from the target machine. - virtual void OnDrillersEnumerated(const DrillerInfoListType& availableDrillers) = 0; - virtual void OnDrillerSessionStarted(AZ::u64 sessionId) = 0; - virtual void OnDrillerSessionStopped(AZ::u64 sessionId) = 0; - }; - typedef AZ::EBus DrillerConsoleEventBus; - - /** - * Commands can be sent to the driller through this interface. - */ - class DrillerConsoleCommands - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - typedef AZ::OSStdAllocator AllocatorType; - - // there's only one driller console instance allowed - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - ////////////////////////////////////////////////////////////////////////// - - virtual ~DrillerConsoleCommands() {} - - // Request an enumeration of available drillers from the target machine - virtual void EnumerateAvailableDrillers() = 0; - // Start a drilling session. This function is normally called internally by DrillerRemoteSession - virtual void StartDrillerSession(const AZ::Debug::DrillerManager::DrillerListType& requestedDrillers, AZ::u64 sessionId) = 0; - // Stop a drilling session. This function is normally called internally by DrillerRemoteSession - virtual void StopDrillerSession(AZ::u64 sessionId) = 0; - }; - typedef AZ::EBus DrillerConsoleCommandBus; -} // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.cpp b/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.cpp deleted file mode 100644 index 232432c8d8..0000000000 --- a/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.cpp +++ /dev/null @@ -1,740 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace AzFramework -{ - //--------------------------------------------------------------------- - // TEMP FOR DEBUGGING ONLY!!! - //--------------------------------------------------------------------- - class DebugDrillerRemoteSession - : public DrillerRemoteSession - { - public: - AZ_CLASS_ALLOCATOR(DebugDrillerRemoteSession, AZ::OSAllocator, 0); - - DebugDrillerRemoteSession() - { - AZStd::string filename = AZStd::string::format("remotedrill_%llu", static_cast(reinterpret_cast(static_cast(this)))); - m_file.Open(filename.c_str(), AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY | AZ::IO::SystemFile::SF_OPEN_CREATE); - } - - ~DebugDrillerRemoteSession() - { - m_file.Close(); - } - - virtual void ProcessIncomingDrillerData(const char* streamIdentifier, const void* data, size_t dataSize) - { - (void)streamIdentifier; - - m_file.Write(data, dataSize); - } - - virtual void OnDrillerConnectionLost() - { - delete this; - } - - AZ::IO::SystemFile m_file; - }; - //--------------------------------------------------------------------- - - /** - * These are the different synchronization messages that are used. - */ - namespace NetworkDrillerSyncMsgId - { - static const AZ::Crc32 NetDrillMsg_RequestDrillerEnum = AZ_CRC("NetDrillMsg_RequestEnum", 0x517cca25); - static const AZ::Crc32 NetDrillMsg_RequestStartSession = AZ_CRC("NetDrillMsg_RequestStartSession", 0x5238b5fe); - static const AZ::Crc32 NetDrillMsg_RequestStopSession = AZ_CRC("NetDrillMsg_RequestStopSession", 0x1abe6888); - static const AZ::Crc32 NetDrillMsg_DrillerEnum = AZ_CRC("NetDrillMsg_Enum", 0x3d0a0f76); - }; - - struct NetDrillerStartSessionRequest - : public TmMsg - { - AZ_CLASS_ALLOCATOR(NetDrillerStartSessionRequest, AZ::OSAllocator, 0); - AZ_RTTI(NetDrillerStartSessionRequest, "{FF899D61-A445-44B5-9B67-8319ACC8BB06}"); - - NetDrillerStartSessionRequest() - : TmMsg(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStartSession) {} - - // TODO: Replace this with the DrillerListType from driller.h - DrillerListType m_drillerIds; - AZ::u64 m_sessionId; - }; - - struct NetDrillerStopSessionRequest - : public TmMsg - { - AZ_CLASS_ALLOCATOR(NetDrillerStopSessionRequest, AZ::OSAllocator, 0); - AZ_RTTI(NetDrillerStopSessionRequest, "{BCC6524F-287F-48D2-A21A-029215DB24DD}"); - - NetDrillerStopSessionRequest(AZ::u64 sessionId = 0) - : TmMsg(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStopSession) - , m_sessionId(sessionId) {} - - AZ::u64 m_sessionId; - }; - - struct NetDrillerEnumeration - : public TmMsg - { - AZ_CLASS_ALLOCATOR(NetDrillerEnumeration, AZ::OSAllocator, 0); - AZ_RTTI(NetDrillerEnumeration, "{60E5BED2-F492-4A55-8EF6-2628CD390991}"); - - NetDrillerEnumeration() - : TmMsg(NetworkDrillerSyncMsgId::NetDrillMsg_DrillerEnum) {} - - DrillerInfoListType m_enumeration; - }; - - //--------------------------------------------------------------------- - // DrillerRemoteSession - //--------------------------------------------------------------------- - DrillerRemoteSession::DrillerRemoteSession() -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - : m_decompressor(&AZ::AllocatorInstance::Get()) -#endif - { - } - //--------------------------------------------------------------------- - DrillerRemoteSession::~DrillerRemoteSession() - { - } - //--------------------------------------------------------------------- - void DrillerRemoteSession::StartDrilling(const DrillerListType& drillers, const char* captureFile) - { - if (captureFile) - { - m_captureFile.Open(captureFile, AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY); - AZ_Warning("DrillerRemoteSession", m_captureFile.IsOpen(), "Failed to open %s. Driller data will not be saved.", captureFile); - } - -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - m_decompressor.StartDecompressor(); -#endif - BusConnect(static_cast(reinterpret_cast(this))); - EBUS_EVENT(DrillerNetworkConsoleCommandBus, StartRemoteDrillerSession, drillers, this); - } - //--------------------------------------------------------------------- - void DrillerRemoteSession::StopDrilling() - { - EBUS_EVENT(DrillerNetworkConsoleCommandBus, StopRemoteDrillerSession, static_cast(reinterpret_cast(this))); - BusDisconnect(); -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - if (m_decompressor.IsDecompressorStarted()) - { - m_decompressor.StopDecompressor(); - } -#endif - - m_captureFile.Close(); - } - //--------------------------------------------------------------------- - void DrillerRemoteSession::LoadCaptureData(const char* fileName) - { - m_captureFile.Open(fileName, AZ::IO::SystemFile::SF_OPEN_READ_ONLY); - AZ_Warning("DrillerRemoteSession", m_captureFile.IsOpen(), "Failed to open %s. No driller data could be loaded.", fileName); - if (m_captureFile.IsOpen()) - { -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - m_decompressor.StartDecompressor(); -#endif - AZ::IO::SystemFile::SizeType bytesRemaining = m_captureFile.Length(); - AZ::IO::SystemFile::SizeType maxReadChunkSize = 1024 * 1024; - AZStd::vector readBuffer; - readBuffer.resize_no_construct(static_cast(maxReadChunkSize)); - while (bytesRemaining > 0) - { - AZ::IO::SystemFile::SizeType bytesToRead = bytesRemaining < maxReadChunkSize ? bytesRemaining : maxReadChunkSize; - if (m_captureFile.Read(bytesToRead, readBuffer.data()) != bytesToRead) - { - AZ_Warning("DrillerRemoteSession", false, "Failed reading driller data. No more driller data can be read."); - break; - } -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - Decompress(readBuffer.data(), static_cast(bytesToRead)); - ProcessIncomingDrillerData(fileName, m_uncompressedMsgBuffer.data(), m_uncompressedMsgBuffer.size()); -#else - ProcessIncomingDrillerData(fileName, readBuffer.data(), readBuffer.size()); -#endif - bytesRemaining -= bytesToRead; - } -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - m_decompressor.StopDecompressor(); -#endif - m_captureFile.Close(); - } - } - //--------------------------------------------------------------------- - void DrillerRemoteSession::OnReceivedMsg(TmMsgPtr msg) - { - AZ_Assert(msg->GetCustomBlob(), "Missing driller frame data!"); - - if (msg->GetCustomBlobSize() == 0) - { - return; - } - - if (m_captureFile.IsOpen()) - { - if (m_captureFile.Write(msg->GetCustomBlob(), msg->GetCustomBlobSize()) != msg->GetCustomBlobSize()) - { - AZ_Warning("DrillerRemoteSession", false, "Failed writing capture data to %s, no more data will be written out.", m_captureFile.Name()); - m_captureFile.Close(); - } - } - -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - Decompress(msg->GetCustomBlob(), msg->GetCustomBlobSize()); - ProcessIncomingDrillerData(m_captureFile.Name(),m_uncompressedMsgBuffer.data(), m_uncompressedMsgBuffer.size()); -#else - ProcessIncomingDrillerData(m_captureFile.Name(),msg->GetCustomBlob(), msg->GetCustomBlobSize()); -#endif - } - //--------------------------------------------------------------------- - void DrillerRemoteSession::Decompress(const void* compressedBuffer, size_t compressedBufferSize) - { - m_uncompressedMsgBuffer.clear(); - if (m_uncompressedMsgBuffer.capacity() < compressedBufferSize * 10) - { - m_uncompressedMsgBuffer.reserve(compressedBufferSize * 10); - } -#if defined(ENABLE_COMPRESSION_FOR_REMOTE_DRILLER) - unsigned int compressedBytesRemaining = static_cast(compressedBufferSize); - unsigned int decompressedBytes = 0; - while (compressedBytesRemaining > 0) - { - unsigned int uncompressedBytes = c_decompressionBufferSize; - unsigned int bytesConsumed = m_decompressor.Decompress(reinterpret_cast(compressedBuffer) + decompressedBytes, compressedBytesRemaining, m_decompressionBuffer, uncompressedBytes); - decompressedBytes += bytesConsumed; - compressedBytesRemaining -= bytesConsumed; - m_uncompressedMsgBuffer.insert(m_uncompressedMsgBuffer.end(), &m_decompressionBuffer[0], &m_decompressionBuffer[uncompressedBytes]); - } -#else - m_uncompressedMsgBuffer.insert(m_uncompressedMsgBuffer.end(), &((char*)compressedBuffer)[0], &((char*)compressedBuffer)[compressedBufferSize]); -#endif - } - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- - // DrillerNetSessionStream - //--------------------------------------------------------------------- - /** - * Represents a driller session on the target machine. - * It is responsible for listening for driller events and forwarding - * them to the console machine. - */ - class DrillerNetSessionStream - : public AZ::Debug::DrillerOutputStream - , AZ::SystemTickBus::Handler - { - public: - AZ_CLASS_ALLOCATOR(DrillerNetSessionStream, AZ::OSAllocator, 0); - - DrillerNetSessionStream(AZ::u64 sessionId); - ~DrillerNetSessionStream(); - - //--------------------------------------------------------------------- - // DrillerOutputStream - //--------------------------------------------------------------------- - virtual void WriteBinary(const void* data, unsigned int dataSize); - virtual void OnEndOfFrame(); - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- - // AZ::SystemTickBus - //--------------------------------------------------------------------- - void OnSystemTick() override; - //--------------------------------------------------------------------- - - static const size_t c_defaultUncompressedBufferSize = 256 * 1024; - static const size_t c_defaultCompressedBufferSize = 32 * 1024; - static const size_t c_bufferCount = 2; - - AZ::Debug::DrillerSession* m_session; - AZ::u64 m_sessionId; - TargetInfo m_requestor; - size_t m_activeBuffer; - AZStd::vector m_uncompressedBuffer[c_bufferCount]; - AZStd::vector m_compressedBuffer[c_bufferCount]; - -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - // Compression - AZ::ZLib m_compressor; - AZStd::fixed_vector m_compressionBuffer; -#endif - - // String Pooling - AZ::Debug::DrillerDefaultStringPool m_stringPool; - - // TEMP Debug - //AZ::IO::SystemFile m_file; - }; - - DrillerNetSessionStream::DrillerNetSessionStream(AZ::u64 sessionId) - : m_session(NULL) - , m_sessionId(sessionId) - , m_activeBuffer(0) -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - , m_compressor(&AZ::AllocatorInstance::Get()) -#endif - { - for (size_t i = 0; i < c_bufferCount; ++i) - { - m_uncompressedBuffer[i].reserve(c_defaultUncompressedBufferSize); - m_compressedBuffer[i].reserve(c_defaultCompressedBufferSize); - } - -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - // Level 3 compression seems to give pretty good compression at decent speed. - // Speed is paramount for us because initial driller packets can be huge and - // we need to be able to compress the data within the driller report call - // without blocking for too long. - m_compressor.StartCompressor(3); -#endif - - SetStringPool(&m_stringPool); - - AZ::SystemTickBus::Handler::BusConnect(); - } - //--------------------------------------------------------------------- - DrillerNetSessionStream::~DrillerNetSessionStream() - { -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - m_compressor.StopCompressor(); -#endif - - // Debug - //m_file.Close(); - } - //--------------------------------------------------------------------- - void DrillerNetSessionStream::WriteBinary(const void* data, unsigned int dataSize) - { - size_t activeBuffer = m_activeBuffer; - - if (dataSize > 0) - { -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - // Only do the compression when the buffer is full so we don't run the compression all the time - if (m_uncompressedBuffer[activeBuffer].size() + dataSize > c_defaultUncompressedBufferSize) - { - // compress - unsigned int curDataSize = static_cast(m_uncompressedBuffer[activeBuffer].size()); - unsigned int remaining = curDataSize; - while (remaining > 0) - { - unsigned int processedBytes = curDataSize - remaining; - unsigned int compressedBytes = m_compressor.Compress(m_uncompressedBuffer[activeBuffer].data() + processedBytes, remaining, m_compressionBuffer.data(), static_cast(c_defaultCompressedBufferSize)); - if (compressedBytes > 0) - { - m_compressedBuffer[activeBuffer].insert(m_compressedBuffer[activeBuffer].end(), m_compressionBuffer.data(), m_compressionBuffer.data() + compressedBytes); - } - } - m_uncompressedBuffer[activeBuffer].clear(); - } - - m_uncompressedBuffer[activeBuffer].insert(m_uncompressedBuffer[activeBuffer].end(), reinterpret_cast(data), reinterpret_cast(data) + dataSize); -#else - // Since we are not compressing, transfer the input directly into our compressed buffer - m_compressedBuffer[activeBuffer].insert(m_compressedBuffer[activeBuffer].end(), reinterpret_cast(data), reinterpret_cast(data) + dataSize); -#endif - } - } - //--------------------------------------------------------------------- - void DrillerNetSessionStream::OnEndOfFrame() - { - size_t activeBuffer = m_activeBuffer; - -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - // Write whatever data has not yet been compressed and flush the compressor - unsigned int curDataSize = static_cast(m_uncompressedBuffer[activeBuffer].size()); - unsigned int remaining = curDataSize; - unsigned int compressedBytes = 0; - do - { - unsigned int processedBytes = curDataSize - remaining; - compressedBytes = m_compressor.Compress(m_uncompressedBuffer[activeBuffer].data() + processedBytes, remaining, m_compressionBuffer.data(), static_cast(c_defaultCompressedBufferSize), AZ::ZLib::FT_SYNC_FLUSH); - if (compressedBytes > 0) - { - m_compressedBuffer[activeBuffer].insert(m_compressedBuffer[activeBuffer].end(), m_compressionBuffer.data(), m_compressionBuffer.data() + compressedBytes); - } - } while (compressedBytes > 0 || remaining > 0); -#endif - - m_activeBuffer = (activeBuffer + 1) % 2; // switch buffers - } - //------------------------------------------------------------------------- - void DrillerNetSessionStream::OnSystemTick() - { - // The buffer index we want to send is the one we wrote to in the previous frame. - size_t bufferIndex = (m_activeBuffer + 1) % 2; - - if (m_compressedBuffer[bufferIndex].empty()) - { - return; - } - - TmMsg msg(m_sessionId); - - msg.AddCustomBlob(m_compressedBuffer[bufferIndex].data(), m_compressedBuffer[bufferIndex].size()); - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_requestor, msg); - - - // Debug - //if (!m_file.IsOpen()) - //{ - // AZStd::string filename = AZStd::string::format("localdrill_%llu", m_sessionId); - // m_file.Open(filename.c_str(), AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY | AZ::IO::SystemFile::SF_OPEN_CREATE); - //} - //m_file.Write(msg.GetCustomBlob(), msg.GetCustomBlobSize()); - - // Reset buffers - m_uncompressedBuffer[bufferIndex].clear(); - m_compressedBuffer[bufferIndex].clear(); - - // Buffers may grow during exceptional circumstances. Re-shrink them to their default sizes - // so we don't keep holding on to the memory. - m_uncompressedBuffer[bufferIndex].reserve(c_defaultUncompressedBufferSize); - m_compressedBuffer[bufferIndex].reserve(c_defaultCompressedBufferSize); - } - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- - // DrillerNetworkAgent - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::Init() - { - m_cbDrillerEnumRequest = TmMsgCallback(AZStd::bind(&DrillerNetworkAgentComponent::OnRequestDrillerEnum, this, AZStd::placeholders::_1)); - m_cbDrillerStartRequest = TmMsgCallback(AZStd::bind(&DrillerNetworkAgentComponent::OnRequestDrillerStart, this, AZStd::placeholders::_1)); - m_cbDrillerStopRequest = TmMsgCallback(AZStd::bind(&DrillerNetworkAgentComponent::OnRequestDrillerStop, this, AZStd::placeholders::_1)); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::Activate() - { - m_cbDrillerEnumRequest.BusConnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestDrillerEnum); - m_cbDrillerStartRequest.BusConnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStartSession); - m_cbDrillerStopRequest.BusConnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStopSession); - TargetManagerClient::Bus::Handler::BusConnect(); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::Deactivate() - { - TargetManagerClient::Bus::Handler::BusDisconnect(); - m_cbDrillerEnumRequest.BusDisconnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestDrillerEnum); - m_cbDrillerStartRequest.BusDisconnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStartSession); - m_cbDrillerStopRequest.BusDisconnect(NetworkDrillerSyncMsgId::NetDrillMsg_RequestStopSession); - - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - for (size_t i = 0; i < m_activeSessions.size(); ++i) - { - if (mgr) - { - mgr->Stop(m_activeSessions[i]->m_session); - } - delete m_activeSessions[i]; - } - m_activeSessions.clear(); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) - { - provided.push_back(AZ_CRC("DrillerNetworkAgentService", 0xcd2ab821)); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) - { - incompatible.push_back(AZ_CRC("DrillerNetworkAgentService", 0xcd2ab821)); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::Reflect(AZ::ReflectContext* context) - { - if (AZ::SerializeContext* serializeContext = azrtti_cast(context)) - { - serializeContext->Class() - ->Version(1) - ; - - if (AZ::EditContext* editContext = serializeContext->GetEditContext()) - { - editContext->Class( - "Driller Network Agent", "Runs on the machine being drilled and communicates with tools") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::Category, "Profiling") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) - ; - } - - ReflectNetDrillerClasses(context); - } - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::TargetLeftNetwork(TargetInfo info) - { - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - for (AZStd::vector::iterator it = m_activeSessions.begin(); it != m_activeSessions.end(); ) - { - if ((*it)->m_requestor.GetNetworkId() == info.GetNetworkId()) - { - if (mgr) - { - mgr->Stop((*it)->m_session); - } - delete *it; - it = m_activeSessions.erase(it); - } - else - { - ++it; - } - } - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::OnRequestDrillerEnum(TmMsgPtr msg) - { - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (!mgr) - { - return; - } - - TargetInfo sendTo; - EBUS_EVENT_RESULT(sendTo, TargetManager::Bus, GetTargetInfo, msg->GetSenderTargetId()); - NetDrillerEnumeration drillerEnum; - for (int i = 0; i < mgr->GetNumDrillers(); ++i) - { - AZ::Debug::Driller* driller = mgr->GetDriller(i); - AZ_Assert(driller, "DrillerManager returned a NULL driller. This is not legal!"); - drillerEnum.m_enumeration.push_back(); - drillerEnum.m_enumeration.back().m_id = driller->GetId(); - drillerEnum.m_enumeration.back().m_groupName = driller->GroupName(); - drillerEnum.m_enumeration.back().m_name = driller->GetName(); - drillerEnum.m_enumeration.back().m_description = driller->GetDescription(); - } - EBUS_EVENT(TargetManager::Bus, SendTmMessage, sendTo, drillerEnum); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::OnRequestDrillerStart(TmMsgPtr msg) - { - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (!mgr) - { - return; - } - - NetDrillerStartSessionRequest* request = azdynamic_cast(msg.get()); - AZ_Assert(request, "Not a NetDrillerStartSessionRequest msg!"); - AZ::Debug::DrillerManager::DrillerListType drillers; - for (size_t i = 0; i < request->m_drillerIds.size(); ++i) - { - AZ::Debug::DrillerManager::DrillerInfo di; - di.id = request->m_drillerIds[i]; - drillers.push_back(di); - } - DrillerNetSessionStream* session = aznew DrillerNetSessionStream(request->m_sessionId); - EBUS_EVENT_RESULT(session->m_requestor, TargetManager::Bus, GetTargetInfo, msg->GetSenderTargetId()); - m_activeSessions.push_back(session); - session->m_session = mgr->Start(*session, drillers); - } - //--------------------------------------------------------------------- - void DrillerNetworkAgentComponent::OnRequestDrillerStop(TmMsgPtr msg) - { - NetDrillerStopSessionRequest* request = azdynamic_cast(msg.get()); - for (AZStd::vector::iterator it = m_activeSessions.begin(); it != m_activeSessions.end(); ++it) - { - if ((*it)->m_sessionId == request->m_sessionId) - { - AZ::Debug::DrillerManager* mgr = NULL; - EBUS_EVENT_RESULT(mgr, AZ::ComponentApplicationBus, GetDrillerManager); - if (mgr) - { - mgr->Stop((*it)->m_session); - } - delete *it; - m_activeSessions.erase(it); - return; - } - } - } - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- - // DrillerRemoteConsole - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::Init() - { - m_cbDrillerEnum = TmMsgCallback(AZStd::bind(&DrillerNetworkConsoleComponent::OnReceivedDrillerEnum, this, AZStd::placeholders::_1)); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::Activate() - { - m_cbDrillerEnum.BusConnect(NetworkDrillerSyncMsgId::NetDrillMsg_DrillerEnum); - DrillerNetworkConsoleCommandBus::Handler::BusConnect(); - TargetManagerClient::Bus::Handler::BusConnect(); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::Deactivate() - { - TargetManagerClient::Bus::Handler::BusDisconnect(); - DrillerNetworkConsoleCommandBus::Handler::BusDisconnect(); - m_cbDrillerEnum.BusDisconnect(NetworkDrillerSyncMsgId::NetDrillMsg_DrillerEnum); - - for (size_t i = 0; i < m_activeSessions.size(); ++i) - { - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_curTarget, NetDrillerStopSessionRequest(static_cast(reinterpret_cast(m_activeSessions[i])))); - m_activeSessions[i]->OnDrillerConnectionLost(); - } - m_activeSessions.clear(); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided) - { - provided.push_back(AZ_CRC("DrillerNetworkConsoleService", 0x2286125d)); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible) - { - incompatible.push_back(AZ_CRC("DrillerNetworkConsoleService", 0x2286125d)); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(1) - ; - - if (AZ::EditContext* editContext = serialize->GetEditContext()) - { - editContext->Class( - "Driller Network Console", "Runs on the tool machine and is responsible for communications with the DrillerNetworkAgent") - ->ClassElement(AZ::Edit::ClassElements::EditorData, "") - ->Attribute(AZ::Edit::Attributes::Category, "Profiling") - ->Attribute(AZ::Edit::Attributes::AppearsInAddComponentMenu, AZ_CRC("System", 0xc94d118b)) - ; - } - - ReflectNetDrillerClasses(context); - } - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::EnumerateAvailableDrillers() - { - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_curTarget, TmMsg(NetworkDrillerSyncMsgId::NetDrillMsg_RequestDrillerEnum)); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::StartRemoteDrillerSession(const DrillerListType& drillers, DrillerRemoteSession* handler) - { - NetDrillerStartSessionRequest request; - request.m_drillerIds = drillers; - request.m_sessionId = static_cast(reinterpret_cast(handler)); - m_activeSessions.push_back(handler); - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_curTarget, request); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::StopRemoteDrillerSession(AZ::u64 sessionId) - { - for (size_t i = 0; i < m_activeSessions.size(); ++i) - { - if (sessionId == static_cast(reinterpret_cast(m_activeSessions[i]))) - { - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_curTarget, NetDrillerStopSessionRequest(sessionId)); - m_activeSessions[i] = m_activeSessions.back(); - m_activeSessions.pop_back(); - } - } - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::DesiredTargetConnected(bool connected) - { - if (connected) - { - EBUS_EVENT_RESULT(m_curTarget, TargetManager::Bus, GetDesiredTarget); - EBUS_EVENT(DrillerNetworkConsoleCommandBus, EnumerateAvailableDrillers); - } - else - { - for (size_t i = 0; i < m_activeSessions.size(); ++i) - { - m_activeSessions[i]->OnDrillerConnectionLost(); - } - m_activeSessions.clear(); - EBUS_EVENT(DrillerNetworkConsoleEventBus, OnReceivedDrillerEnumeration, DrillerInfoListType()); - } - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::DesiredTargetChanged(AZ::u32 newTargetID, AZ::u32 oldTargetID) - { - (void)oldTargetID; - (void)newTargetID; - EBUS_EVENT(DrillerNetworkConsoleEventBus, OnReceivedDrillerEnumeration, DrillerInfoListType()); - for (size_t i = 0; i < m_activeSessions.size(); ++i) - { - EBUS_EVENT(TargetManager::Bus, SendTmMessage, m_curTarget, NetDrillerStopSessionRequest(static_cast(reinterpret_cast(m_activeSessions[i])))); - m_activeSessions[i]->OnDrillerConnectionLost(); - } - m_activeSessions.clear(); - } - //--------------------------------------------------------------------- - void DrillerNetworkConsoleComponent::OnReceivedDrillerEnum(TmMsgPtr msg) - { - NetDrillerEnumeration* drillerEnum = azdynamic_cast(msg.get()); - AZ_Assert(drillerEnum, "No NetDrillerEnumeration message!"); - - EBUS_EVENT(DrillerNetworkConsoleEventBus, OnReceivedDrillerEnumeration, drillerEnum->m_enumeration); - } - //--------------------------------------------------------------------- - - //--------------------------------------------------------------------- - // ReflectNetDrillerClasses - //--------------------------------------------------------------------- - void ReflectNetDrillerClasses(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - // Assume no one else will register our classes. - if (serialize->FindClassData(DrillerInfo::RTTI_Type()) == nullptr) - { - serialize->Class() - ->Field("Id", &DrillerInfo::m_id) - ->Field("GroupName", &DrillerInfo::m_groupName) - ->Field("Name", &DrillerInfo::m_name) - ->Field("Description", &DrillerInfo::m_description); - serialize->Class() - ->Field("DrillerIds", &NetDrillerStartSessionRequest::m_drillerIds) - ->Field("SessionId", &NetDrillerStartSessionRequest::m_sessionId); - serialize->Class() - ->Field("SessionId", &NetDrillerStopSessionRequest::m_sessionId); - serialize->Class() - ->Field("Enumeration", &NetDrillerEnumeration::m_enumeration); - } - } - } - //--------------------------------------------------------------------- -} // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.h b/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.h deleted file mode 100644 index 669b308668..0000000000 --- a/Code/Framework/AzFramework/AzFramework/Driller/RemoteDrillerInterface.h +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef AZFRAMEWORK_REMOTE_DRILLER_INTERFACE_H -#define AZFRAMEWORK_REMOTE_DRILLER_INTERFACE_H - -#include -#include -#include -#include -#include -#include -#include -#include - -//#define ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - -namespace AZ -{ - struct ClassDataReflection; -} - -namespace AzFramework -{ - /** - * Represents a remote driller session on the tool machine. - * It is responsible for receiving and processing remote driller data. - * Driller clients should derive from this class and implement the virtual interfaces. - */ - class DrillerRemoteSession - : public TmMsgBus::Handler - { - public: - DrillerRemoteSession(); - ~DrillerRemoteSession(); - - // Called when new driller data arrives - virtual void ProcessIncomingDrillerData(const char* streamIdentifier, const void* data, size_t dataSize) = 0; - // Called when the connection to the driller is lost. The session should be deleted in response to this message - virtual void OnDrillerConnectionLost() = 0; - - // Start drilling the selected drillers as part of this session - void StartDrilling(const DrillerListType& drillers, const char* captureFile); - // Stop this drill session - void StopDrilling(); - - // Replay a previously captured driller session from file - void LoadCaptureData(const char* fileName); - - protected: - //--------------------------------------------------------------------- - // TmMsgBus - //--------------------------------------------------------------------- - virtual void OnReceivedMsg(TmMsgPtr msg); - //--------------------------------------------------------------------- - - void Decompress(const void* compressedBuffer, size_t compressedBufferSize); - - static const AZ::u32 c_decompressionBufferSize = 128 * 1024; - - AZStd::vector m_uncompressedMsgBuffer; -#ifdef ENABLE_COMPRESSION_FOR_REMOTE_DRILLER - AZ::ZLib m_decompressor; - char m_decompressionBuffer[c_decompressionBufferSize]; -#endif - AZ::IO::SystemFile m_captureFile; - }; - - /** - * Driller clients interested in receiving notification events from the - * network console should implement this interface. - */ - class DrillerNetworkConsoleEvents - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - typedef AZ::OSStdAllocator AllocatorType; - ////////////////////////////////////////////////////////////////////////// - - virtual ~DrillerNetworkConsoleEvents() {} - - // A list of available drillers has been received from the target machine. - virtual void OnReceivedDrillerEnumeration(const DrillerInfoListType& availableDrillers) = 0; - }; - typedef AZ::EBus DrillerNetworkConsoleEventBus; - - /** - * The network driller console implements this interface. - * Commands can be sent to the network console through this interface. - */ - class DrillerNetworkConsoleCommands - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // EBusTraits overrides - typedef AZ::OSStdAllocator AllocatorType; - - // there's only one driller console instance allowed - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ::EBusHandlerPolicy::Single; - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; - ////////////////////////////////////////////////////////////////////////// - - virtual ~DrillerNetworkConsoleCommands() {} - - // Request an enumeration of available drillers from the target machine - virtual void EnumerateAvailableDrillers() = 0; - // Start a drilling session. This function is normally called internally by DrillerRemoteSession - virtual void StartRemoteDrillerSession(const DrillerListType& drillers, DrillerRemoteSession* handler) = 0; - // Stop a drilling session. This function is normally called internally by DrillerRemoteSession - virtual void StopRemoteDrillerSession(AZ::u64 sessionId) = 0; - }; - typedef AZ::EBus DrillerNetworkConsoleCommandBus; - - class DrillerNetSessionStream; - - /** - * Runs on the machine being drilled and is responsible for communications - * with the DrillerNetworkConsole running on the tool side as well as - * creating DrillerNetSessionStreams for each driller session being started. - */ - class DrillerNetworkAgentComponent - : public AZ::Component - , public TargetManagerClient::Bus::Handler - { - public: - AZ_COMPONENT(DrillerNetworkAgentComponent, "{B587A74D-6190-4149-91CB-0EA69936BD59}") - - ////////////////////////////////////////////////////////////////////////// - // AZ::Component - virtual void Init(); - virtual void Activate(); - virtual void Deactivate(); - static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); - static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); - static void Reflect(AZ::ReflectContext* context); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // TargetManagerClient - virtual void TargetLeftNetwork(TargetInfo info); - ////////////////////////////////////////////////////////////////////////// - - protected: - ////////////////////////////////////////////////////////////////////////// - // TmMsg handlers - virtual void OnRequestDrillerEnum(TmMsgPtr msg); - virtual void OnRequestDrillerStart(TmMsgPtr msg); - virtual void OnRequestDrillerStop(TmMsgPtr msg); - ////////////////////////////////////////////////////////////////////////// - - TmMsgCallback m_cbDrillerEnumRequest; - TmMsgCallback m_cbDrillerStartRequest; - TmMsgCallback m_cbDrillerStopRequest; - - AZStd::vector m_activeSessions; - }; - - /** - * Runs on the tool machine and is responsible for communications with the - * DrillerNetworkAgent. - */ - class DrillerNetworkConsoleComponent - : public AZ::Component - , public DrillerNetworkConsoleCommandBus::Handler - , public TargetManagerClient::Bus::Handler - { - public: - AZ_COMPONENT(DrillerNetworkConsoleComponent, "{78ACADA4-F2C7-4320-8E97-59DD8B9BE33A}") - - ////////////////////////////////////////////////////////////////////////// - // AZ::Component - virtual void Init(); - virtual void Activate(); - virtual void Deactivate(); - static void GetProvidedServices(AZ::ComponentDescriptor::DependencyArrayType& provided); - static void GetIncompatibleServices(AZ::ComponentDescriptor::DependencyArrayType& incompatible); - static void Reflect(AZ::ReflectContext* context); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // DrillerNetworkConsoleCommandBus - virtual void EnumerateAvailableDrillers(); - virtual void StartRemoteDrillerSession(const DrillerListType& drillers, DrillerRemoteSession* handler); - virtual void StopRemoteDrillerSession(AZ::u64 sessionId); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // TargetManagerClient - virtual void DesiredTargetConnected(bool connected); - virtual void DesiredTargetChanged(AZ::u32 newTargetID, AZ::u32 oldTargetID); - ////////////////////////////////////////////////////////////////////////// - - protected: - ////////////////////////////////////////////////////////////////////////// - // TmMsg handlers - virtual void OnReceivedDrillerEnum(TmMsgPtr msg); - ////////////////////////////////////////////////////////////////////////// - - typedef AZStd::vector ActiveSessionListType; - ActiveSessionListType m_activeSessions; - TargetInfo m_curTarget; - TmMsgCallback m_cbDrillerEnum; - }; - - void ReflectNetDrillerClasses(AZ::ReflectContext* context); -} // namespace AzFramework - -#endif // AZFRAMEWORK_REMOTE_DRILLER_INTERFACE_H -#pragma once diff --git a/Code/Framework/AzFramework/AzFramework/Entity/EntityContextBus.h b/Code/Framework/AzFramework/AzFramework/Entity/EntityContextBus.h index 49cb8db609..124c8d8f50 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/EntityContextBus.h +++ b/Code/Framework/AzFramework/AzFramework/Entity/EntityContextBus.h @@ -16,11 +16,14 @@ #ifndef AZFRAMEWORK_ENTITYCONTEXTBUS_H #define AZFRAMEWORK_ENTITYCONTEXTBUS_H +#include #include #include #include #include +AZ_DECLARE_BUDGET(AzFramework); + namespace AZ { class Entity; diff --git a/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipService.h b/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipService.h index 7e33c29025..083d5b4785 100644 --- a/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipService.h +++ b/Code/Framework/AzFramework/AzFramework/Entity/EntityOwnershipService.h @@ -10,6 +10,7 @@ #include #include +#include #include #include @@ -18,6 +19,8 @@ namespace AZ class Entity; } +AZ_DECLARE_BUDGET(AzFramework); + namespace AzFramework { // Types diff --git a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp index 292cce29ec..4aa2e6c9e3 100644 --- a/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp +++ b/Code/Framework/AzFramework/AzFramework/Script/ScriptComponent.cpp @@ -33,6 +33,8 @@ extern "C" { # include } +AZ_DEFINE_BUDGET(Script); + namespace ScriptComponentCpp { template diff --git a/Code/Framework/AzFramework/AzFramework/TargetManagement/TargetManagementAPI.h b/Code/Framework/AzFramework/AzFramework/TargetManagement/TargetManagementAPI.h index 35e8b45859..6582e145cb 100644 --- a/Code/Framework/AzFramework/AzFramework/TargetManagement/TargetManagementAPI.h +++ b/Code/Framework/AzFramework/AzFramework/TargetManagement/TargetManagementAPI.h @@ -10,6 +10,7 @@ #define AZFRAMEWORK_TARGETMANAGEMENTAPI_H #include +#include #include #include #include @@ -21,6 +22,8 @@ #include #include +AZ_DECLARE_BUDGET(AzFramework); + namespace AZ { class ReflectContext; diff --git a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp index bfa9dfcf9e..520667d90c 100644 --- a/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp +++ b/Code/Framework/AzFramework/AzFramework/Visibility/EntityVisibilityBoundsUnionSystem.cpp @@ -12,6 +12,8 @@ #include #include +AZ_DECLARE_BUDGET(AzFramework); + namespace AzFramework { EntityVisibilityBoundsUnionSystem::EntityVisibilityBoundsUnionSystem() diff --git a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake index ecf0a2b4f0..87cf29ffec 100644 --- a/Code/Framework/AzFramework/AzFramework/azframework_files.cmake +++ b/Code/Framework/AzFramework/AzFramework/azframework_files.cmake @@ -123,11 +123,6 @@ set(FILES Entity/SliceGameEntityOwnershipServiceBus.h Entity/PrefabEntityOwnershipService.h Entity/PrefabEntityOwnershipService.cpp - Driller/RemoteDrillerInterface.cpp - Driller/RemoteDrillerInterface.h - Driller/DrillerConsoleAPI.h - Driller/DrillToFileComponent.h - Driller/DrillToFileComponent.cpp Components/ComponentAdapter.h Components/ComponentAdapter.inl Components/ComponentAdapterHelpers.h diff --git a/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp b/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp index 3750eb1420..b4d61d7ac1 100644 --- a/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp +++ b/Code/Framework/AzGameFramework/AzGameFramework/Application/GameApplication.cpp @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -37,12 +35,6 @@ namespace AzGameFramework void GameApplication::StartCommon(AZ::Entity* systemEntity) { AzFramework::Application::StartCommon(systemEntity); - - if (GetDrillerManager()) - { - GetDrillerManager()->Register(aznew GridMate::Debug::CarrierDriller()); - GetDrillerManager()->Register(aznew GridMate::Debug::ReplicaDriller()); - } } void GameApplication::MergeSettingsToRegistry(AZ::SettingsRegistryInterface& registry) @@ -92,10 +84,6 @@ namespace AzGameFramework components.emplace_back(azrtti_typeid()); #endif - // Note that this component is registered by AzFramework. - // It must be registered here instead of in the module so that existence of AzFrameworkModule is guaranteed. - components.emplace_back(azrtti_typeid()); - return components; } @@ -104,9 +92,6 @@ namespace AzGameFramework AzFramework::Application::CreateStaticModules(outModules); outModules.emplace_back(aznew AzGameFrameworkModule()); - - // have to let the metrics system know that it's ok to send back the name of the DrillerNetworkAgentComponent to Amazon as plain text, without hashing - EBUS_EVENT(AzFramework::MetricsPlainTextNameRegistrationBus, RegisterForNameSending, AZStd::vector{ azrtti_typeid() }); } void GameApplication::QueryApplicationType(AZ::ApplicationTypeQuery& appType) const diff --git a/Code/Framework/AzGameFramework/AzGameFramework/AzGameFrameworkModule.cpp b/Code/Framework/AzGameFramework/AzGameFramework/AzGameFrameworkModule.cpp index 80996a2e4a..e7da10568e 100644 --- a/Code/Framework/AzGameFramework/AzGameFramework/AzGameFrameworkModule.cpp +++ b/Code/Framework/AzGameFramework/AzGameFramework/AzGameFrameworkModule.cpp @@ -7,24 +7,15 @@ */ #include -// Component includes -#include -#include - namespace AzGameFramework { AzGameFrameworkModule::AzGameFrameworkModule() : AZ::Module() { - m_descriptors.insert(m_descriptors.end(), { - AzFramework::DrillToFileComponent::CreateDescriptor(), - }); } AZ::ComponentTypeList AzGameFrameworkModule::GetRequiredSystemComponents() const { - return AZ::ComponentTypeList{ - azrtti_typeid(), - }; + return {}; } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h index 9e5db5b5b7..d4707a3e8c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/API/ToolsApplicationAPI.h @@ -5,14 +5,10 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ - -#ifndef AZTOOLSFRAMEWORK_TOOLSAPPLICATIONAPI_H -#define AZTOOLSFRAMEWORK_TOOLSAPPLICATIONAPI_H - -#include - #pragma once +#include +#include #include #include #include @@ -1089,4 +1085,5 @@ namespace AzToolsFramework } } // namespace AzToolsFramework -#endif // AZTOOLSFRAMEWORK_TOOLSAPPLICATIONAPI_H +AZ_DECLARE_BUDGET(AzToolsFramework); + diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp index 2d687db00f..97f52e253b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AzToolsFrameworkModule.cpp @@ -52,6 +52,8 @@ #include #include +AZ_DEFINE_BUDGET(AzToolsFramework); + namespace AzToolsFramework { AzToolsFrameworkModule::AzToolsFrameworkModule() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp index 503cbc1d65..5b2638da1e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/LegacyFramework/Core/EditorFrameworkApplication.cpp @@ -35,10 +35,8 @@ #include #include #include -#include #include -#include #ifdef AZ_PLATFORM_WINDOWS #include "shlobj.h" @@ -485,8 +483,6 @@ namespace LegacyFramework void Application::CreateApplicationComponents() { EnsureComponentCreated(AzFramework::TargetManagementComponent::RTTI_Type()); - EnsureComponentCreated(AzFramework::DrillerNetworkConsoleComponent::RTTI_Type()); - EnsureComponentCreated(AzFramework::DrillerNetworkAgentComponent::RTTI_Type()); } void Application::CreateSystemComponents() @@ -507,8 +503,6 @@ namespace LegacyFramework ComponentApplication::RegisterCoreComponents(); RegisterComponentDescriptor(AzFramework::TargetManagementComponent::CreateDescriptor()); - RegisterComponentDescriptor(AzFramework::DrillerNetworkConsoleComponent::CreateDescriptor()); - RegisterComponentDescriptor(AzFramework::DrillerNetworkAgentComponent::CreateDescriptor()); RegisterComponentDescriptor(AzToolsFramework::Framework::CreateDescriptor()); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h index 415a87f984..9ab896ab9d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI.h @@ -5,7 +5,10 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ +#pragma once + #include +#include #include #include #include @@ -14,8 +17,6 @@ #include #include "PropertyEditorAPI_Internals.h" -#pragma once - class QWidget; class QCheckBox; class QLabel; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h index 8b53121776..ecd27baed4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/UI/PropertyEditor/PropertyEditorAPI_Internals.h @@ -25,6 +25,8 @@ class QColor; class QString; class QPoint; +AZ_DECLARE_BUDGET(AzToolsFramework); + namespace AzToolsFramework { namespace Components diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/Undo/UndoCacheInterface.h b/Code/Framework/AzToolsFramework/AzToolsFramework/Undo/UndoCacheInterface.h index 39b23bc449..ef3d6c191d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/Undo/UndoCacheInterface.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/Undo/UndoCacheInterface.h @@ -9,8 +9,11 @@ #pragma once #include +#include #include +AZ_DECLARE_BUDGET(AzToolsFramework); + namespace AzToolsFramework { namespace UndoSystem diff --git a/Code/Framework/AzToolsFramework/Tests/ComponentAddRemove.cpp b/Code/Framework/AzToolsFramework/Tests/ComponentAddRemove.cpp index 3225639fff..e15f4f3cfd 100644 --- a/Code/Framework/AzToolsFramework/Tests/ComponentAddRemove.cpp +++ b/Code/Framework/AzToolsFramework/Tests/ComponentAddRemove.cpp @@ -1117,7 +1117,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/GridMate/GridMate/GridMate.cpp b/Code/Framework/GridMate/GridMate/GridMate.cpp index 538dc6d853..356f7ad16b 100644 --- a/Code/Framework/GridMate/GridMate/GridMate.cpp +++ b/Code/Framework/GridMate/GridMate/GridMate.cpp @@ -6,6 +6,7 @@ * */ +#include #include #include @@ -14,6 +15,8 @@ #include #include +AZ_DEFINE_BUDGET(GridMate); + namespace GridMate { class GridMateImpl diff --git a/Code/Framework/GridMate/GridMate/Replica/ReplicaDefs.h b/Code/Framework/GridMate/GridMate/Replica/ReplicaDefs.h index 737b121d03..e2fee41228 100644 --- a/Code/Framework/GridMate/GridMate/Replica/ReplicaDefs.h +++ b/Code/Framework/GridMate/GridMate/Replica/ReplicaDefs.h @@ -5,11 +5,9 @@ * SPDX-License-Identifier: Apache-2.0 OR MIT * */ -#ifndef GM_REPLICADEFS_H -#define GM_REPLICADEFS_H - -/// \file ReplicaChunk.h +#pragma once +#include #include namespace GridMate @@ -80,4 +78,5 @@ namespace GridMate static const ZoneMask ZoneMask_All = (ZoneMask) - 1; } // namespace Gridmate -#endif // GM_REPLICADEFS_H +AZ_DECLARE_BUDGET(GridMate); + diff --git a/Code/Framework/GridMate/GridMate/Replica/Tasks/ReplicaMarshalTasks.cpp b/Code/Framework/GridMate/GridMate/Replica/Tasks/ReplicaMarshalTasks.cpp index f5e6e0f5a6..c1d6905e14 100644 --- a/Code/Framework/GridMate/GridMate/Replica/Tasks/ReplicaMarshalTasks.cpp +++ b/Code/Framework/GridMate/GridMate/Replica/Tasks/ReplicaMarshalTasks.cpp @@ -6,8 +6,6 @@ * */ -#include - #include #include #include diff --git a/Code/Framework/GridMate/Tests/gridmate_test_files.cmake b/Code/Framework/GridMate/Tests/gridmate_test_files.cmake index 7b2ae2e8ab..3ff67f8eda 100644 --- a/Code/Framework/GridMate/Tests/gridmate_test_files.cmake +++ b/Code/Framework/GridMate/Tests/gridmate_test_files.cmake @@ -8,7 +8,6 @@ set(FILES test_Main.cpp - TestProfiler.cpp Tests.h Session.cpp Serialize.cpp @@ -16,7 +15,6 @@ set(FILES ReplicaSmall.cpp ReplicaMedium.cpp ReplicaBehavior.cpp - Replica.cpp StreamSecureSocketDriverTests.cpp StreamSocketDriverTests.cpp CarrierStreamSocketDriverTests.cpp diff --git a/Code/Legacy/CryCommon/FrameProfiler.h b/Code/Legacy/CryCommon/FrameProfiler.h deleted file mode 100644 index ac6d3a52a1..0000000000 --- a/Code/Legacy/CryCommon/FrameProfiler.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - - -#pragma once - -#include - -#define SUBSYSTEM_DEFINES \ - X(PROFILE_ANY, "Any") \ - X(PROFILE_RENDERER, "Renderer") \ - X(PROFILE_3DENGINE, "3DEngine") \ - X(PROFILE_PARTICLE, "Particle") \ - X(PROFILE_AI, "AI") \ - X(PROFILE_ANIMATION, "Animation") \ - X(PROFILE_MOVIE, "Movie") \ - X(PROFILE_ENTITY, "Entity") \ - X(PROFILE_UI, "UI") \ - X(PROFILE_NETWORK, "Network") \ - X(PROFILE_PHYSICS, "Physics") \ - X(PROFILE_SCRIPT, "Script") \ - X(PROFILE_SCRIPT_CFUNC, "Script C Functions") \ - X(PROFILE_AUDIO, "Audio") \ - X(PROFILE_EDITOR, "Editor") \ - X(PROFILE_SYSTEM, "System") \ - X(PROFILE_ACTION, "Action") \ - X(PROFILE_GAME, "Game") \ - X(PROFILE_INPUT, "Input") \ - X(PROFILE_SYNC, "Sync") \ - X(PROFILE_NETWORK_TRAFFIC, "Network Traffic") \ - X(PROFILE_DEVICE, "Device") - -#define X(Subsystem, SubsystemName) Subsystem, -enum EProfiledSubsystem -{ - SUBSYSTEM_DEFINES - PROFILE_LAST_SUBSYSTEM -}; -#undef X - -#include - - - -#define FUNCTION_PROFILER_LEGACYONLY(pISystem, subsystem) - -#define FUNCTION_PROFILER(pISystem, subsystem) - -#define FUNCTION_PROFILER_FAST(pISystem, subsystem, bProfileEnabled) - -#define FUNCTION_PROFILER_ALWAYS(pISystem, subsystem) - -#define FRAME_PROFILER_LEGACYONLY(szProfilerName, pISystem, subsystem) - -#define FRAME_PROFILER(szProfilerName, pISystem, subsystem) - -#define FRAME_PROFILER_FAST(szProfilerName, pISystem, subsystem, bProfileEnabled) - -#define FUNCTION_PROFILER_SYS(subsystem) - -#define STALL_PROFILER(cause) - diff --git a/Code/Legacy/CryCommon/ISystem.h b/Code/Legacy/CryCommon/ISystem.h index 74153eb39b..3c13ac04d8 100644 --- a/Code/Legacy/CryCommon/ISystem.h +++ b/Code/Legacy/CryCommon/ISystem.h @@ -1654,11 +1654,4 @@ inline void CryLogAlways(const char* format, ...) } #endif // EXCLUDE_NORMAL_LOG - -////////////////////////////////////////////////////////////////////////// -// Additional headers. -////////////////////////////////////////////////////////////////////////// -#include - #endif // CRYINCLUDE_CRYCOMMON_ISYSTEM_H - diff --git a/Code/Legacy/CryCommon/crycommon_files.cmake b/Code/Legacy/CryCommon/crycommon_files.cmake index ba11de0215..8b8df7856e 100644 --- a/Code/Legacy/CryCommon/crycommon_files.cmake +++ b/Code/Legacy/CryCommon/crycommon_files.cmake @@ -87,7 +87,6 @@ set(FILES CrySystemBus.h CryTypeInfo.h CryVersion.h - FrameProfiler.h HeapAllocator.h LegacyAllocator.cpp LegacyAllocator.h diff --git a/Code/Legacy/CrySystem/LocalizedStringManager.cpp b/Code/Legacy/CrySystem/LocalizedStringManager.cpp index db77eda3e8..8b09667f13 100644 --- a/Code/Legacy/CrySystem/LocalizedStringManager.cpp +++ b/Code/Legacy/CrySystem/LocalizedStringManager.cpp @@ -1899,7 +1899,6 @@ static void LogDecompTimer(__int64 nTotalTicks, __int64 nDecompTicks, __int64 nA AZStd::string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const SLanguage* pLanguage) const { - FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled); if ((flags & IS_COMPRESSED) != 0) { #if defined(LOG_DECOMP_TIMES) diff --git a/Code/Legacy/CrySystem/Log.cpp b/Code/Legacy/CrySystem/Log.cpp index be2816c890..b671748920 100644 --- a/Code/Legacy/CrySystem/Log.cpp +++ b/Code/Legacy/CrySystem/Log.cpp @@ -396,7 +396,6 @@ void CLog::LogV(const ELogType type, [[maybe_unused]]int flags, const char* szFo } } - FUNCTION_PROFILER(GetISystem(), PROFILE_SYSTEM); LOADING_TIME_PROFILE_SECTION(GetISystem()); bool bfile = false, bconsole = false; @@ -1445,8 +1444,6 @@ void CLog::RemoveCallback(ILogCallback* pCallback) ////////////////////////////////////////////////////////////////////////// void CLog::Update() { - FUNCTION_PROFILER_FAST(m_pSystem, PROFILE_SYSTEM, g_bProfilerEnabled); - if (CryGetCurrentThreadId() == m_nMainThreadId) { if (!m_threadSafeMsgQueue.empty()) diff --git a/Code/Legacy/CrySystem/System.cpp b/Code/Legacy/CrySystem/System.cpp index d848160b3e..8c950e900c 100644 --- a/Code/Legacy/CrySystem/System.cpp +++ b/Code/Legacy/CrySystem/System.cpp @@ -22,6 +22,8 @@ #include #include #include +#include +#include #include #include #include @@ -659,8 +661,6 @@ ISystem* CSystem::GetCrySystem() ////////////////////////////////////////////////////////////////////////// void CSystem::SleepIfNeeded() { - FUNCTION_PROFILER_FAST(this, PROFILE_SYSTEM, g_bProfilerEnabled); - ITimer* const pTimer = gEnv->pTimer; static bool firstCall = true; @@ -738,7 +738,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) _mm_setcsr(_mm_getcsr() & ~0x280 | (g_cvars.sys_float_exceptions > 0 ? 0 : 0x280)); #endif //WIN32 - FUNCTION_PROFILER_LEGACYONLY(GetISystem(), PROFILE_SYSTEM); AZ_TRACE_METHOD(); m_nUpdateCounter++; @@ -832,8 +831,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) //limit frame rate if vsync is turned off //for consoles this is done inside renderthread to be vsync dependent { - FRAME_PROFILER_LEGACYONLY("FRAME_CAP", gEnv->pSystem, PROFILE_SYSTEM); - AZ_TRACE_METHOD_NAME("FrameLimiter"); static ICVar* pSysMaxFPS = NULL; static ICVar* pVSync = NULL; @@ -882,7 +879,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) //update console system if (m_env.pConsole) { - FRAME_PROFILER("SysUpdate:Console", this, PROFILE_SYSTEM); m_env.pConsole->Update(); } @@ -898,7 +894,6 @@ bool CSystem::UpdatePreTickBus(int updateFlags, int nPauseMode) // Run movie system pre-update if (!bNoUpdate) { - FRAME_PROFILER("SysUpdate:UpdateMovieSystem", this, PROFILE_SYSTEM); UpdateMovieSystem(updateFlags, fMovieFrameTime, true); } @@ -914,7 +909,6 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/) if (!m_bNoUpdate) { const float fMovieFrameTime = m_Time.GetFrameTime(ITimer::ETIMER_UI); - FRAME_PROFILER("SysUpdate:UpdateMovieSystem", this, PROFILE_SYSTEM); UpdateMovieSystem(updateFlags, fMovieFrameTime, false); } @@ -922,7 +916,6 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/) // Update sound system if (!m_bNoUpdate) { - FRAME_PROFILER("SysUpdate:UpdateAudioSystems", this, PROFILE_SYSTEM); UpdateAudioSystems(); } @@ -949,10 +942,7 @@ bool CSystem::UpdatePostTickBus(int updateFlags, int /*nPauseMode*/) m_updateTimes.push_back(std::make_pair(cur_time, updateTime)); } - { - FRAME_PROFILER("SysUpdate - SystemEventDispatcher::Update", this, PROFILE_SYSTEM); - m_pSystemEventDispatcher->Update(); - } + m_pSystemEventDispatcher->Update(); if (!gEnv->IsEditing() && m_eRuntimeState == ESYSTEM_EVENT_LEVEL_GAMEPLAY_START) { @@ -973,8 +963,6 @@ bool CSystem::UpdateLoadtime() void CSystem::UpdateAudioSystems() { - AZ_TRACE_METHOD(); - FRAME_PROFILER_LEGACYONLY("SysUpdate:Audio", this, PROFILE_SYSTEM); Audio::AudioSystemRequestBus::Broadcast(&Audio::AudioSystemRequestBus::Events::ExternalUpdate); } diff --git a/Code/Legacy/CrySystem/SystemEventDispatcher.cpp b/Code/Legacy/CrySystem/SystemEventDispatcher.cpp index 525bf1a005..8e4e36b453 100644 --- a/Code/Legacy/CrySystem/SystemEventDispatcher.cpp +++ b/Code/Legacy/CrySystem/SystemEventDispatcher.cpp @@ -9,6 +9,7 @@ #include "CrySystem_precompiled.h" #include "SystemEventDispatcher.h" +#include CSystemEventDispatcher::CSystemEventDispatcher() : m_listeners(0) diff --git a/Code/Legacy/CrySystem/SystemInit.cpp b/Code/Legacy/CrySystem/SystemInit.cpp index b5a6265493..ebd3d91a3d 100644 --- a/Code/Legacy/CrySystem/SystemInit.cpp +++ b/Code/Legacy/CrySystem/SystemInit.cpp @@ -97,7 +97,6 @@ #include #include #include -#include #if defined(ANDROID) #include @@ -1696,46 +1695,6 @@ void CmdSetAwsLogLevel(IConsoleCmdArgs* pArgs) } } -void CmdDrillToFile(IConsoleCmdArgs* pArgs) -{ - if (azstricmp(pArgs->GetArg(0), "DrillerStop") == 0) - { - EBUS_EVENT(AzFramework::DrillerConsoleCommandBus, StopDrillerSession, AZ::Crc32("DefaultDrillerSession")); - } - else - { - if (pArgs->GetArgCount() > 1) - { - AZ::Debug::DrillerManager::DrillerListType drillersToEnable; - for (int iArg = 1; iArg < pArgs->GetArgCount(); ++iArg) - { - if (azstricmp(pArgs->GetArg(iArg), "Replica") == 0) - { - drillersToEnable.push_back(); - drillersToEnable.back().id = AZ::Crc32("ReplicaDriller"); - } - else if (azstricmp(pArgs->GetArg(iArg), "Carrier") == 0) - { - drillersToEnable.push_back(); - drillersToEnable.back().id = AZ::Crc32("CarrierDriller"); - } - else - { - CryLogAlways("Driller %s not supported.", pArgs->GetArg(iArg)); - } - } - EBUS_EVENT(AzFramework::DrillerConsoleCommandBus, StartDrillerSession, drillersToEnable, AZ::Crc32("DefaultDrillerSession")); - } - else - { - CryLogAlways("Syntax: DrillerStart [Driller1] [Driller2] [...]"); - CryLogAlways("Supported Drillers:"); - CryLogAlways(" Carrier"); - CryLogAlways(" Replica"); - } - } -} - ////////////////////////////////////////////////////////////////////////// void CSystem::CreateSystemVars() { @@ -2114,9 +2073,6 @@ void CSystem::CreateSystemVars() // By default it is now enabled. Modify system.cfg or game.cfg to disable it REGISTER_INT("sys_enableCanvasEditor", 1, VF_NULL, "Enables the UI Canvas Editor"); - REGISTER_COMMAND_DEV_ONLY("DrillerStart", CmdDrillToFile, VF_DEV_ONLY, "Start a driller capture."); - REGISTER_COMMAND_DEV_ONLY("DrillerStop", CmdDrillToFile, VF_DEV_ONLY, "Stop a driller capture."); - REGISTER_COMMAND("sys_SetLogLevel", CmdSetAwsLogLevel, 0, "Set AWS log level [0 - 6]."); } diff --git a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp index 7cdb62d45a..01c7340919 100644 --- a/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp +++ b/Code/Legacy/CrySystem/ViewSystem/ViewSystem.cpp @@ -172,8 +172,6 @@ CViewSystem::~CViewSystem() //------------------------------------------------------------------------ void CViewSystem::Update(float frameTime) { - FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION); - if (gEnv->IsDedicated()) { return; diff --git a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp index f9b779a2d7..0887b17682 100644 --- a/Code/Tools/AssetBundler/source/utils/applicationManager.cpp +++ b/Code/Tools/AssetBundler/source/utils/applicationManager.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -169,7 +168,6 @@ namespace AssetBundler if (*iter == azrtti_typeid() || *iter == azrtti_typeid() || *iter == azrtti_typeid() || - *iter == azrtti_typeid() || *iter == azrtti_typeid()) { // Asset Bundler does not require the above components to be active diff --git a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp index adcdfd3083..3bf75e2d9b 100644 --- a/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp +++ b/Code/Tools/SceneAPI/SceneCore/Tests/Containers/SceneBehaviorTests.cpp @@ -371,7 +371,6 @@ namespace AZ::SceneAPI::Containers MOCK_CONST_METHOD0(GetAppRoot, const char*()); MOCK_CONST_METHOD0(GetEngineRoot, const char*()); MOCK_CONST_METHOD0(GetExecutableFolder, const char* ()); - MOCK_METHOD0(GetDrillerManager, AZ::Debug::DrillerManager* ()); MOCK_CONST_METHOD1(QueryApplicationType, void(AZ::ApplicationTypeQuery&)); }; diff --git a/Code/Tools/Standalone/CMakeLists.txt b/Code/Tools/Standalone/CMakeLists.txt index a8242022a8..78047dd6cf 100644 --- a/Code/Tools/Standalone/CMakeLists.txt +++ b/Code/Tools/Standalone/CMakeLists.txt @@ -38,34 +38,3 @@ ly_add_target( PRIVATE STANDALONETOOLS_ENABLE_LUA_IDE ) - -ly_add_target( - NAME Profiler APPLICATION - NAMESPACE AZ - AUTOMOC - AUTOUIC - AUTORCC - FILES_CMAKE - standalone_tools_files.cmake - profiler_files.cmake - Platform/${PAL_PLATFORM_NAME}/profiler_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake - INCLUDE_DIRECTORIES - PRIVATE - . - Source/Editor - Source/Driller - Source/Driller/Carrier - Source/Driller/Profiler - Source/Driller/IO - BUILD_DEPENDENCIES - PRIVATE - Legacy::CryCommon - AZ::AzCore - AZ::AzFramework - AZ::AzToolsFramework - AZ::GridMate - ${additional_dependencies} - COMPILE_DEFINITIONS - PRIVATE - STANDALONETOOLS_ENABLE_PROFILER -) diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.cpp deleted file mode 100644 index 3152862d80..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.cpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "AnnotationHeaderView.hxx" -#include "AnnotationsDataView.hxx" -#include "Annotations.hxx" -#include - -namespace Driller -{ - static const int k_contractedSize = 20; - static const int k_textWidth = 153; - - AnnotationHeaderView::AnnotationHeaderView(AnnotationsProvider* ptrAnnotations, QWidget* parent, Qt::WindowFlags flags) - : QWidget(parent, flags) - , m_ptrAnnotations(ptrAnnotations) - { - setupUi(this); - - m_State.m_EndFrame = -1; - m_State.m_FramesInView = 10; - m_State.m_FrameOffset = 0; - - annotationDataView->RegisterAnnotationHeaderView(this, m_ptrAnnotations); - annotationDataView->setAutoFillBackground(true); - - connect(configureAnnotations, SIGNAL(pressed()), this, SIGNAL(OnOptionsClick())); - connect(annotationDataView, SIGNAL(InformOfMouseOverAnnotation(const Annotation&)), this, SIGNAL(InformOfMouseOverAnnotation(const Annotation&))); - connect(annotationDataView, SIGNAL(InformOfClickAnnotation(const Annotation&)), this, SIGNAL(InformOfClickAnnotation(const Annotation&))); - connect(m_ptrAnnotations, SIGNAL(AnnotationDataInvalidated()), this, SLOT(RefreshView())); - - annotationDataView->update(); - - QSize size = annotationDataView->size(); - int nextHeight = size.height(); - - (void)nextHeight; - } - - QSize AnnotationHeaderView::sizeHint() const - { - return QSize(0, k_contractedSize); - } - - - AnnotationHeaderView::~AnnotationHeaderView() - { - } - - void AnnotationHeaderView::RefreshView() - { - annotationDataView->update(); - } - - void AnnotationHeaderView::SetEndFrame(FrameNumberType frameNum) - { - QSize size = annotationDataView->size(); - int nextHeight = size.height(); - - (void)nextHeight; - - m_State.m_EndFrame = frameNum; - annotationDataView->update(); - } - - void AnnotationHeaderView::SetSliderOffset(FrameNumberType frameNum) - { - m_State.m_FrameOffset = frameNum; - annotationDataView->update(); - } - - void AnnotationHeaderView::SetDataPointsInView(int count) - { - m_State.m_FramesInView = count; - annotationDataView->update(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.hxx deleted file mode 100644 index 41f40b93ce..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.hxx +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef ANNOTATION_HEADER_VIEW_HXX -#define ANNOTATION_HEADER_VIEW_HXX - -#if !defined(Q_MOC_RUN) -#include -#include - -#include - -#include -#include -#include -#endif - - -namespace Driller -{ - class AnnotationsProvider; - class AnnotationsDataView; - class Annotation; - - /** The annotation header view runs along the top of the channels, and shows annotation blips that can be hovered over. - * this gives nice hit boxes for clicking that are not a sliver thick. - */ - - class AnnotationHeaderView : public QWidget, private Ui::AnnotationHeaderView - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(AnnotationHeaderView,AZ::SystemAllocator,0); - AnnotationHeaderView(AnnotationsProvider* ptrAnnotations, QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~AnnotationHeaderView(void); - - struct HeaderViewState - { - int m_EndFrame; - int m_FramesInView; - int m_FrameOffset; - }; - - const HeaderViewState& GetState() { return m_State; } - - void SetDataPointsInView( int count ); - void SetEndFrame( FrameNumberType frame ); - void SetSliderOffset( FrameNumberType frame ); - -signals: - void OnOptionsClick(); - void InformOfMouseOverAnnotation(const Annotation& annotation); - void InformOfClickAnnotation(const Annotation& annotation); - public slots: - void RefreshView(); - - private: - HeaderViewState m_State; - - AnnotationsProvider *m_ptrAnnotations; - - virtual QSize sizeHint() const; - - }; - -} - - -#endif // ANNOTATION_HEADER_VIEW_HXX diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.ui b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.ui deleted file mode 100644 index a8f10135e8..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationHeaderView.ui +++ /dev/null @@ -1,178 +0,0 @@ - - - AnnotationHeaderView - - - - 0 - 0 - 1023 - 38 - - - - - 0 - 0 - - - - Form - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - - 0 - - - 0 - - - 3 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 8 - - - 0 - - - 8 - - - 3 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Configure which messages are annotated on the display - - - Qt::LeftToRight - - - Configure Annotations - - - - :/driller/settings_icon:/driller/settings_icon - - - - - - - - - - - 0 - 0 - - - - true - - - - - - - - - - - Driller::AnnotationsDataView - QWidget -
Source/Driller/Annotations/AnnotationsDataView.hxx
- 1 -
-
- - - - -
diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.cpp deleted file mode 100644 index c59a956670..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "Annotations.hxx" -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -namespace Driller -{ - // stores the settings that are saved into the file and transported from user to user to accompany drill files. - // as always, this is just a dumb container and does not need encapsulation - class AnnotationWorkspaceSettings - : public AZ::UserSettings - { - public: - AZ_RTTI(AnnotationWorkspaceSettings, "{431EFFCF-C3C5-4BB3-8246-E452E11D4FF8}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(AnnotationWorkspaceSettings, AZ::SystemAllocator, 0); - - ChannelContainer m_ActiveAnnotationChannels; - ChannelCRCContainer m_ActiveAnnotationChannelCRCs; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(2) - ->Field("m_ActiveAnnotationChannels", &AnnotationWorkspaceSettings::m_ActiveAnnotationChannels) - ->Field("m_ActiveAnnotationChannelCRCs", &AnnotationWorkspaceSettings::m_ActiveAnnotationChannelCRCs); - } - } - }; - - // stores the data that goes with the user preferences, even without a workspace file - // mainly gui stuff... - // as always, this is just a dumb container and does not need encapsulation - class AnnotationUserSettings - : public AZ::UserSettings - { - public: - AZ_RTTI(AnnotationUserSettings, "{D3584846-0574-4B63-9693-4F3265CDE16D}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(AnnotationUserSettings, AZ::SystemAllocator, 0); - - ChannelContainer m_KnownAnnotationChannels; // keeps track of all annotation channels ever seen - AZStd::unordered_map m_customizedColors; - - AZ::u32 GetRGBAColorForChannel(AZ::u32 channelNameCRC) - { - auto found = m_customizedColors.find(channelNameCRC); - if (found != m_customizedColors.end()) - { - return found->second; - } - - AZ::u32 num_different_colors = 7; - QColor col; - float sat = .9f; - float val = .9f; - col.setHsvF((float)(channelNameCRC % num_different_colors) / (float(num_different_colors)), sat, val); - QRgb rgbColor = col.rgba(); - return rgbColor; - } - - void SetRGBAColorForChannel(AZ::u32 channelNameCRC, AZ::u32 rgbaColor) - { - m_customizedColors[channelNameCRC] = rgbaColor; - } - - void ResetColorForChannel(AZ::u32 channelNameCRC) - { - m_customizedColors.erase(channelNameCRC); - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(1) - ->Field("m_KnownAnnotationChannels", &AnnotationUserSettings::m_KnownAnnotationChannels) - ->Field("m_customizedColors", &AnnotationUserSettings::m_customizedColors); - } - } - }; - - void AnnotationsProvider::Reflect(AZ::ReflectContext* context) - { - AnnotationWorkspaceSettings::Reflect(context); - AnnotationUserSettings::Reflect(context); - } - - Annotation::Annotation() - { - m_ChannelCRC = 0; - m_eventIndex = 0; - m_frameIndex = 0; - } - - Annotation::Annotation(AZ::s64 eventID, FrameNumberType frame, const char* text, const char* channel) - { - m_eventIndex = eventID; - m_frameIndex = frame; - m_text = text; - m_channel = channel; - m_ChannelCRC = AZ::Crc32(m_channel.c_str()); - } - - Annotation::Annotation(const Annotation& other) - { - *this = other; - } - - Annotation::Annotation(Annotation&& other) - { - *this = AZStd::move(other); - } - - Annotation& Annotation::operator=(Annotation&& other) - { - if (this != &other) - { - m_eventIndex = other.m_eventIndex; - m_frameIndex = other.m_frameIndex; - m_text = AZStd::move(other.m_text); - m_channel = AZStd::move(other.m_channel); - m_ChannelCRC = other.m_ChannelCRC; - } - return *this; - } - - Annotation& Annotation::operator=(const Annotation& other) - { - if (this != &other) - { - m_eventIndex = other.m_eventIndex; - m_frameIndex = other.m_frameIndex; - m_text = other.m_text; - m_channel = other.m_channel; - m_ChannelCRC = other.m_ChannelCRC; - } - return *this; - } - - AnnotationsProvider::AnnotationsProvider(QObject* pParent) - : QObject(pParent) - { - m_bVectorDirty = false; - - /// load user settings and workspace settings from usersettings component to persist state - - m_ptrUserSettings = AZ::UserSettings::CreateFind(AZ_CRC("ANNOT_USERSETTINGS", 0x3ddaa4f1), AZ::UserSettings::CT_GLOBAL); - m_ptrWorkspaceSettings = AZ::UserSettings::CreateFind(AZ_CRC("ANNOT_WORKSPACESETTINGS", 0xf7ca8dd3), AZ::UserSettings::CT_GLOBAL); - } - - AnnotationsProvider::~AnnotationsProvider() - { - AZ::UserSettings::Release(m_ptrUserSettings); - AZ::UserSettings::Release(m_ptrWorkspaceSettings); - } - - - void AnnotationsProvider::LoadSettingsFromWorkspace(WorkspaceSettingsProvider* ptrProvider) - { - AnnotationWorkspaceSettings* rawPtr = ptrProvider->FindSetting(AZ_CRC("ANNOTATIONWORKSPACE", 0x28319f66)); - if (rawPtr) - { - m_ptrWorkspaceSettings->m_ActiveAnnotationChannels = rawPtr->m_ActiveAnnotationChannels; - m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs = rawPtr->m_ActiveAnnotationChannelCRCs; - - // aggregate missing channels: - for (auto it = m_ptrWorkspaceSettings->m_ActiveAnnotationChannels.begin(); it != m_ptrWorkspaceSettings->m_ActiveAnnotationChannels.end(); ++it) - { - NotifyOfChannelExistence(it->c_str()); - } - } - } - - void AnnotationsProvider::SaveSettingsToWorkspace(WorkspaceSettingsProvider* ptrProvider) - { - AnnotationWorkspaceSettings* rawPtr = ptrProvider->CreateSetting(AZ_CRC("ANNOTATIONWORKSPACE", 0x28319f66)); - rawPtr->m_ActiveAnnotationChannels = m_ptrWorkspaceSettings->m_ActiveAnnotationChannels; - rawPtr->m_ActiveAnnotationChannelCRCs = m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs; - } - - // returns the end of the vector (ie, the invalid iterator) - AnnotationsProvider::ConstAnnotationIterator AnnotationsProvider::GetEnd() const - { - AZ_Assert(!m_bVectorDirty, "You may not interrogate the annotations provider before it is finalized"); - - return m_currentAnnotations.end(); - } - - // returns iterator to the first annotation thats on the frame given (or the end iterator) - AnnotationsProvider::ConstAnnotationIterator AnnotationsProvider::GetFirstAnnotationForFrame(FrameNumberType frameIndex) const - { - AZ_Assert(!m_bVectorDirty, "You may not interrogate the annotations provider before it is finalized"); - - // do we have annotations for that framE? - FrameIndexToCurrentMap::const_iterator it = m_frameToIndex.find(frameIndex); - if (it == m_frameToIndex.end()) - { - return GetEnd(); - } - - return m_currentAnnotations.begin() + it->second; - } - - // returns iterator to the first annotation that is foer that event # (or the end iterator) - AnnotationsProvider::ConstAnnotationIterator AnnotationsProvider::GetAnnotationForEvent(EventNumberType eventIndex) const - { - AZ_Assert(!m_bVectorDirty, "You may not interrogate the annotations provider before it is finalized"); - - // do we have annotations for that event index? - EventIndexToCurrentMap::const_iterator it = m_eventToIndex.find(eventIndex); - if (it == m_eventToIndex.end()) - { - return GetEnd(); - } - - return m_currentAnnotations.begin() + it->second; - } - - // note:: claims ownership of the data in annotation. - void AnnotationsProvider::AddAnnotation(Annotation&& target) - { - if (m_eventToIndex.find(target.GetEventIndex()) != m_eventToIndex.end()) - { - return; - } - - // can we do this quickly and easily? - if ( - (!m_bVectorDirty) && // if we're not already going to need to sort, and... - ( - (m_currentAnnotations.empty()) || // we either have no annotations or... - (m_currentAnnotations.back().GetEventIndex() < target.GetEventIndex()) // the fresh annotation belongs at the end anyway and we will not need to re-sort. - ) - ) - { - // we're adding annotations onto the end, so we will not have to sort, we can just accumulate the data. - - m_eventToIndex[target.GetEventIndex()] = m_currentAnnotations.size(); - - // if its the first annotation for this frame, we can also add it: - if (m_frameToIndex.find(target.GetFrameIndex()) == m_frameToIndex.end()) - { - m_frameToIndex[target.GetFrameIndex()] = m_currentAnnotations.size(); - } - - m_currentAnnotations.push_back(target); - } - else - { - // we're adding annotations out of order, we have to re-sort: - m_currentAnnotations.push_back(target); - m_bVectorDirty = true; - } - } - - - // called by the main controller to sort and build the map cache. - void AnnotationsProvider::Finalize() - { - /* - // temp: add some fake annots - AddAnnotation(Annotation(5, 10, "Test annotation", "tracker")); - AddAnnotation(Annotation(15, 110, "Test annotation2", "tracker1")); - AddAnnotation(Annotation(25, 210, "Test annotatio3n", "tracker2")); - AddAnnotation(Annotation(35, 310, "Test annotation4", "tracker3")); - */ - - if (!m_bVectorDirty) - { - emit AnnotationDataInvalidated(); - - return; - } - - m_frameToIndex.clear(); - m_eventToIndex.clear(); - - // sort them so they are in order from beginning to end: - AZStd::sort( - m_currentAnnotations.begin(), - m_currentAnnotations.end(), - [](const Annotation& a, const Annotation& b) -> bool - { - return a.GetEventIndex() < b.GetEventIndex(); - } - ); - - // now build the lookup tables: - FrameNumberType lastFrameIndex = -1; - for (AZStd::size_t idx = 0, endIdx = m_currentAnnotations.size(); idx < endIdx; ++idx) - { - const Annotation& current = m_currentAnnotations[idx]; - m_eventToIndex[current.GetEventIndex()] = idx; - if (lastFrameIndex != current.GetFrameIndex()) - { - m_frameToIndex[current.GetFrameIndex()] = idx; - lastFrameIndex = current.GetFrameIndex(); - } - } - - emit AnnotationDataInvalidated(); - - m_bVectorDirty = false; - } - - const ChannelContainer& AnnotationsProvider::GetAllKnownChannels() const - { - return m_ptrUserSettings->m_KnownAnnotationChannels; - } - - void AnnotationsProvider::GetCurrentlyEnabledChannelCRCs(ChannelCRCContainer& target) const - { - target.insert(m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.begin(), m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.end()); - } - - // let us know that a channel exists: - void AnnotationsProvider::NotifyOfChannelExistence(const char* name) - { - if (m_ptrUserSettings->m_KnownAnnotationChannels.insert(name).second) - { - emit KnownAnnotationsChanged(); - } - } - - void AnnotationsProvider::SetChannelEnabled(const char* channelName, bool enabled) - { - if (enabled) - { - if (m_ptrWorkspaceSettings->m_ActiveAnnotationChannels.insert(channelName).second) - { - m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.insert(AZ::Crc32(channelName)); - NotifyOfChannelExistence(channelName); - emit SelectedAnnotationsChanged(); - } - } - else - { - AZ::u32 channelCRC = AZ::Crc32(channelName); - if (IsChannelEnabled(channelCRC)) - { - m_ptrWorkspaceSettings->m_ActiveAnnotationChannels.erase(channelName); - m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.erase(channelCRC); - emit SelectedAnnotationsChanged(); - } - } - } - - QColor AnnotationsProvider::GetColorForChannel(AZ::u32 channelNameCRC) const - { - QRgb rgbaValue = m_ptrUserSettings->GetRGBAColorForChannel(channelNameCRC); - return QColor(rgbaValue); - } - - void AnnotationsProvider::SetColorForChannel(AZ::u32 channelNameCRC, QColor newColor) - { - QRgb rgbaValue = newColor.rgba(); - m_ptrUserSettings->SetRGBAColorForChannel(channelNameCRC, rgbaValue); - - if (IsChannelEnabled(channelNameCRC)) - { - // update displays - emit SelectedAnnotationsChanged(); - } - } - - void AnnotationsProvider::ResetColorForChannel(AZ::u32 channelNameCRC) - { - m_ptrUserSettings->ResetColorForChannel(channelNameCRC); - } - - bool AnnotationsProvider::IsChannelEnabled(AZ::u32 channelNameCRC) const - { - return (m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.find(channelNameCRC) != m_ptrWorkspaceSettings->m_ActiveAnnotationChannelCRCs.end()); - } - - void AnnotationsProvider::Clear() - { - m_frameToIndex.clear(); - m_eventToIndex.clear(); - m_currentAnnotations.clear(); - m_bVectorDirty = false; - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.hxx deleted file mode 100644 index d87e8d61e4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/Annotations.hxx +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_ANNOTATIONS_H -#define DRILLER_ANNOTATIONS_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include -#include -#include - -#include -#endif - -#pragma once - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - // ------------------------------------------------------------------------------------------------------------ - // Annotation - // represents one annotation returned or fed into the annotations interface. - class Annotation - { - public: - AZ_CLASS_ALLOCATOR(Annotation, AZ::SystemAllocator, 0); - Annotation(); - Annotation(AZ::s64 eventID, FrameNumberType frame, const char* text, const char* channel); - Annotation(const Annotation& other); - Annotation(Annotation&& other); - Annotation& operator=(Annotation&& other); - Annotation& operator=(const Annotation& other); - - AZ::s64 GetEventIndex() const { return m_eventIndex; } - FrameNumberType GetFrameIndex() const { return m_frameIndex; } - const AZStd::string& GetText() const { return m_text; } - const AZStd::string& GetChannel() const { return m_channel; } - const AZ::u32 GetChannelCRC() const { return m_ChannelCRC; } - - private: - AZ::s64 m_eventIndex; - FrameNumberType m_frameIndex; - AZStd::string m_text; - AZStd::string m_channel; - AZ::u32 m_ChannelCRC; - }; - - // ------------------------------------------------------------------------------------------------------------ - // AnnotationsProviderInterface - // a class which provides annotation information to the parts of the system that care about annotations. - // other parts of the system that want to know what annotations occur where will be given a pointer to this guy - // and they will ask him what they need to know. - // PLEASE NOTE: This is essentially a live cache of what's currently in the view range and is for rendering only. - // its essentially destroyed and recreated every frame. - - class AnnotationWorkspaceSettings; - class AnnotationUserSettings; - class WorkspaceSettingsProvider; - - // contains a set of channel names - typedef AZStd::unordered_set ChannelContainer; - typedef AZStd::unordered_set ChannelCRCContainer; - - class AnnotationsProvider - : public QObject - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(AnnotationsProvider, AZ::SystemAllocator, 0); - - typedef AZStd::vector AnnotationContainer; - typedef AnnotationContainer::const_iterator ConstAnnotationIterator; - - // graph renderers need to know what color to draw annotations, and what annotations exist given a particular event or frame: - ConstAnnotationIterator GetEnd() const; // returns the end of the vector (ie, the invalid iterator) - ConstAnnotationIterator GetFirstAnnotationForFrame(FrameNumberType frameIndex) const; // returns iterator to the first annotation thats on the frame given (or the end iterator) - ConstAnnotationIterator GetAnnotationForEvent(EventNumberType eventIndex) const; // returns iterator to the first annotation that is for that event # (or the end iterator) - - // claims ownership of the given annotation, via r-value ref. This is used during populate. - void AddAnnotation(Annotation&& target); - - // configure a channel - void ConfigureChannel(const char* channel, QColor color); - - AnnotationsProvider(QObject* pParent = NULL); - ~AnnotationsProvider(); - - // called by the main controller to sort and build the map cache. - void Finalize(); - void Clear(); - static void Reflect(AZ::ReflectContext* context); - - // --- channel management --- - const ChannelContainer& GetAllKnownChannels() const; - void GetCurrentlyEnabledChannelCRCs(ChannelCRCContainer& target) const; - void NotifyOfChannelExistence(const char* name); - void SetChannelEnabled(const char* channelName, bool enabled); - bool IsChannelEnabled(AZ::u32 channelNameCRC) const; - QColor GetColorForChannel(AZ::u32 channelNameCRC) const; // each channel has a color, this is configured externally. - void SetColorForChannel(AZ::u32 channelNameCRC, QColor newColor); // each channel has a color, this is configured externally. - void ResetColorForChannel(AZ::u32 channelNameCRC); // each channel has a color, this is configured externally. - - void LoadSettingsFromWorkspace(WorkspaceSettingsProvider* ptrProvider); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider* ptrProvider); - signals: - void KnownAnnotationsChanged(); - void SelectedAnnotationsChanged(); - void AnnotationDataInvalidated(); - - protected: - AnnotationContainer m_currentAnnotations; - typedef AZStd::unordered_map EventIndexToCurrentMap; // maps from event index to index in our vector. - typedef AZStd::unordered_map FrameIndexToCurrentMap; // maps from frame index to index in our vector. - EventIndexToCurrentMap m_eventToIndex; - FrameIndexToCurrentMap m_frameToIndex; - - // housekeeping - bool m_bVectorDirty; - - AZStd::intrusive_ptr m_ptrWorkspaceSettings; // loaded from workspace and user settings. // crc(somethingelse) - AZStd::intrusive_ptr m_ptrUserSettings; // loaded only from user settings / CRC(whatever) - }; -} - -#endif//DRILLER_ANNOTATIONS_H diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.cpp deleted file mode 100644 index a928abd564..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "AnnotationsDataView.hxx" -#include "AnnotationHeaderView.hxx" -#include "Annotations.hxx" - -#include -#include -#include -#include - -namespace Driller -{ - static const float adv_arrow_width = 8.0f; - - AnnotationsDataView::AnnotationsDataView(QWidget* parent) - : QWidget(parent) - , m_ptrHeaderView(nullptr) - , m_ptrAnnotations(nullptr) - { - setAttribute(Qt::WA_OpaquePaintEvent, true); - setMouseTracking(true); - } - - AnnotationsDataView::~AnnotationsDataView() - { - } - - void AnnotationsDataView::RegisterAnnotationHeaderView(AnnotationHeaderView* header, AnnotationsProvider* annotations) - { - m_ptrHeaderView = header; - m_ptrAnnotations = annotations; - } - - int AnnotationsDataView::PositionToFrame(const QPoint& pt) - { - QRect wrect = rect(); - - int frame = m_ptrHeaderView->GetState().m_FrameOffset + m_ptrHeaderView->GetState().m_FramesInView - 1; - frame = frame <= m_ptrHeaderView->GetState().m_EndFrame ? frame : m_ptrHeaderView->GetState().m_EndFrame; - - int rOffset = wrect.width() - pt.x(); - int rCell = (int)((float)rOffset / GetBarWidth()); - int retFrame = frame - rCell; - - //AZ_TracePrintf("Driller","Click Frame Raw Input = %d\n", retFrame); - - return retFrame; - } - - float AnnotationsDataView::GetBarWidth() - { - return ((float)(rect().width()) / (float)(m_ptrHeaderView->GetState().m_FramesInView)); - } - - void AnnotationsDataView::paintEvent(QPaintEvent* event) - { - (void)event; - - m_ClickableAreas.clear(); - - QPen pen; - pen.setWidth(1); - QBrush brush; - brush.setStyle(Qt::SolidPattern); - pen.setBrush(brush); - - QPainter painter(this); - painter.setRenderHint(QPainter::Antialiasing, true); - painter.setRenderHint(QPainter::TextAntialiasing, true); - - painter.setPen(pen); - painter.fillRect(rect(), Qt::black); - - int frame = m_ptrHeaderView->GetState().m_FrameOffset + m_ptrHeaderView->GetState().m_FramesInView - 1; - frame = frame <= m_ptrHeaderView->GetState().m_EndFrame ? frame : m_ptrHeaderView->GetState().m_EndFrame; - - QRect wrect = rect(); - - float barWidth = GetBarWidth(); - int barWidthHalf = (int)(barWidth / 2.0f); - - QPen fatPen(QColor(255, 255, 255, 255)); - fatPen.setWidth(2); - fatPen.setCapStyle(Qt::FlatCap); - - if (m_ptrHeaderView->GetState().m_EndFrame) - { - float rightEdgeOfBar = (float)wrect.right(); - float leftEdgeOfBar = rightEdgeOfBar - barWidth; - - while (frame >= 0 && rightEdgeOfBar >= wrect.left()) - { - int actualLeftEdge = (int)floorf(leftEdgeOfBar); - - float center = (float)(actualLeftEdge + barWidthHalf) + 0.5f; - - // annotations? - AnnotationsProvider::ConstAnnotationIterator it = m_ptrAnnotations->GetFirstAnnotationForFrame(frame); - AnnotationsProvider::ConstAnnotationIterator endIt = m_ptrAnnotations->GetEnd(); - - while ((it != endIt) && (it->GetFrameIndex() == frame)) - { - QPainterPath newPath; - QPolygonF newPolygon; - newPolygon << QPointF(center - adv_arrow_width, 1.0f) << QPointF(center, wrect.height() - 1.0f) << QPointF(center + adv_arrow_width, 1.0f); - newPath.addPolygon(newPolygon); - newPath.closeSubpath(); - - if (m_eventsToHighlight.find(it->GetEventIndex()) != m_eventsToHighlight.end()) - { - painter.setPen(fatPen); - painter.setBrush(m_ptrAnnotations->GetColorForChannel(it->GetChannelCRC())); - } - else - { - painter.setPen(QColor(0, 0, 0, 0)); - painter.setBrush(m_ptrAnnotations->GetColorForChannel(it->GetChannelCRC())); - } - painter.drawPath(newPath); - m_ClickableAreas[it->GetEventIndex()] = newPath; - ++it; - } - - --frame; - rightEdgeOfBar -= barWidth; - leftEdgeOfBar -= barWidth; - } - } - } - - void AnnotationsDataView::mouseMoveEvent(QMouseEvent* event) - { - AZStd::unordered_set newEventsToHighlight; - - for (auto it = m_ClickableAreas.begin(); it != m_ClickableAreas.end(); ++it) - { - if (it->second.contains(event->pos())) - { - auto annot = m_ptrAnnotations->GetAnnotationForEvent(it->first); - if (annot != m_ptrAnnotations->GetEnd()) - { - newEventsToHighlight.insert(annot->GetEventIndex()); - emit InformOfMouseOverAnnotation(*annot); - } - } - } - - bool doUpdate = false; - // did our highlight change? - for (auto it = newEventsToHighlight.begin(); it != newEventsToHighlight.end(); ++it) - { - if (m_eventsToHighlight.find(*it) == m_eventsToHighlight.end()) - { - doUpdate = true; - break; - } - } - - // did our highlight change? - if (!doUpdate) - { - for (auto it = m_eventsToHighlight.begin(); it != m_eventsToHighlight.end(); ++it) - { - if (newEventsToHighlight.find(*it) == newEventsToHighlight.end()) - { - doUpdate = true; - break; - } - } - } - - if (doUpdate) - { - newEventsToHighlight.swap(m_eventsToHighlight); - update(); - } - - // find the first annotation within a margin: - event->ignore(); - } - - void AnnotationsDataView::mousePressEvent(QMouseEvent* event) - { - for (auto it = m_ClickableAreas.begin(); it != m_ClickableAreas.end(); ++it) - { - if (it->second.contains(event->pos())) - { - auto annot = m_ptrAnnotations->GetAnnotationForEvent(it->first); - if (annot != m_ptrAnnotations->GetEnd()) - { - emit InformOfClickAnnotation(*annot); - } - } - } - event->ignore(); - } - - void AnnotationsDataView::mouseReleaseEvent(QMouseEvent* event) - { - event->ignore(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.hxx deleted file mode 100644 index d6da50e0c0..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView.hxx +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef ANNOTATIONS_DATA_VIEW -#define ANNOTATIONS_DATA_VIEW - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include -#endif - -namespace Driller -{ - class AnnotationsProvider; - class Annotation; - class AnnotationHeaderView; - /** Annotations Data View just shows the annotations that are available in a horizontal strip with indicators for easy clickability. - */ - - class AnnotationsDataView : public QWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(AnnotationsDataView, AZ::SystemAllocator, 0); - AnnotationsDataView(QWidget* parent = nullptr); - virtual ~AnnotationsDataView(); - - void RegisterAnnotationHeaderView(AnnotationHeaderView* header, AnnotationsProvider* annotations); - - int PositionToFrame( const QPoint &pt ); - - float GetBarWidth(); - - virtual void paintEvent( QPaintEvent *event ); - virtual void mouseMoveEvent( QMouseEvent *event ); - virtual void mousePressEvent( QMouseEvent *event ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - -signals: - void InformOfMouseOverAnnotation(const Annotation& annotation); - void InformOfClickAnnotation(const Annotation& annotation); - private: - typedef AZStd::unordered_map EventIndexToClickablePath; - EventIndexToClickablePath m_ClickableAreas; - AZStd::unordered_set m_eventsToHighlight; - - AnnotationsProvider *m_ptrAnnotations; - AnnotationHeaderView *m_ptrHeaderView; - }; -} - -#endif // ANNOTATIONS_DATA_VIEW diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.cpp deleted file mode 100644 index b107e6be23..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.cpp +++ /dev/null @@ -1,250 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "AnnotationsDataView_Events.hxx" -#include "AnnotationsHeaderView_Events.hxx" -#include "Annotations.hxx" -#include - -#include -#include -#include -#include - -namespace Driller -{ - static const float adv_events_arrow_width = 8.0f; - - AnnotationsDataView_Events::AnnotationsDataView_Events(AnnotationHeaderView_Events* header, AnnotationsProvider* annotations) - : QWidget(header) - , m_ptrHeaderView(header) - , m_ptrAnnotations(annotations) - , m_ptrAxis(NULL) - { - setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - setFixedHeight(18); - setAutoFillBackground(false); - setAttribute(Qt::WA_OpaquePaintEvent, true); - setMouseTracking(true); - m_CurrentFrameNumber = 0; - } - - void AnnotationsDataView_Events::AttachToAxis(Charts::Axis* pAxis) - { - if (m_ptrAxis) - { - disconnect(m_ptrAxis, SIGNAL(destroyed(QObject*)), this, SLOT(OnAxisDestroyed())); - disconnect(m_ptrAxis, SIGNAL(Invalidated()), this, SLOT(OnAxisInvalidated())); - } - - m_ptrAxis = pAxis; - if (pAxis) - { - connect(m_ptrAxis, SIGNAL(destroyed(QObject*)), this, SLOT(OnAxisDestroyed())); - connect(m_ptrAxis, SIGNAL(Invalidated()), this, SLOT(OnAxisInvalidated())); - } - } - - void AnnotationsDataView_Events::OnAxisDestroyed() - { - m_ptrAxis = NULL; - update(); - } - - void AnnotationsDataView_Events::OnAxisInvalidated() - { - update(); - } - - AnnotationsDataView_Events::~AnnotationsDataView_Events() - { - } - - void AnnotationsDataView_Events::paintEvent(QPaintEvent* event) - { - (void)event; - - m_ClickableAreas.clear(); - - // scan for annotations - - - - // fill with black - QPainter painter(this); - painter.fillRect(rect(), Qt::black); - - if (!m_ptrAxis) - { - return; - } - - if (!m_ptrAxis->GetValid()) - { - return; - } - - QRectF drawRange = rect(); - // adjust for inset: - - drawRange.adjust(2.0f, 0.0f, -4.0f, 0.0f); - float leftEdge = (float)drawRange.left(); - float drawRangeWidth = (float)drawRange.width(); - - AZ::s64 eventIndexStart = (AZ::s64)m_ptrAxis->GetWindowMin(); - AZ::s64 eventIndexEnd = (AZ::s64)m_ptrAxis->GetWindowMax() + 1; - float eventIndexRange = ((float)m_ptrAxis->GetWindowMax() - (float)m_ptrAxis->GetWindowMin()); // this is the domain range - - - if (eventIndexRange <= 0.0f) - { - return; - } - - float oneEventWidthInPixels = drawRangeWidth / eventIndexRange; - float halfEventWidth = oneEventWidthInPixels * 0.5f; - - // find the first event within that range: - QPen fatPen(QColor(255, 255, 255, 255)); - fatPen.setWidth(2); - fatPen.setCapStyle(Qt::FlatCap); - - AnnotationsProvider::ConstAnnotationIterator it = m_ptrAnnotations->GetFirstAnnotationForFrame(m_CurrentFrameNumber); - AnnotationsProvider::ConstAnnotationIterator endIt = m_ptrAnnotations->GetEnd(); - - // now keep going until we hit the end of the range: - while (it != endIt) - { - if (it->GetEventIndex() >= eventIndexEnd) - { - break; - } - - if (it->GetEventIndex() < eventIndexStart) - { - ++it; - continue; // we're within the zoom - } - - // transform that event ID into the window domain: - - - float eventRatio = ((float)it->GetEventIndex() - m_ptrAxis->GetWindowMin()) / eventIndexRange; - - float center = floorf(leftEdge + (drawRangeWidth * eventRatio)); - - center += (float)drawRange.left(); - center += halfEventWidth; - - QPainterPath newPath; - QPolygonF newPolygon; - newPolygon << QPointF(center - adv_events_arrow_width, 1.0f) << QPointF(center, drawRange.height() - 1.0f) << QPointF(center + adv_events_arrow_width, 1.0f); - newPath.addPolygon(newPolygon); - newPath.closeSubpath(); - - if (m_eventsToHighlight.find(it->GetEventIndex()) != m_eventsToHighlight.end()) - { - painter.setPen(fatPen); - painter.setBrush(m_ptrAnnotations->GetColorForChannel(it->GetChannelCRC())); - } - else - { - painter.setPen(QColor(0, 0, 0, 0)); - painter.setBrush(m_ptrAnnotations->GetColorForChannel(it->GetChannelCRC())); - } - painter.drawPath(newPath); - m_ClickableAreas[it->GetEventIndex()] = newPath; - ++it; - } - } - - void AnnotationsDataView_Events::mouseMoveEvent(QMouseEvent* event) - { - AZStd::unordered_set newEventsToHighlight; - - for (auto it = m_ClickableAreas.begin(); it != m_ClickableAreas.end(); ++it) - { - if (it->second.contains(event->pos())) - { - auto annot = m_ptrAnnotations->GetAnnotationForEvent(it->first); - if (annot != m_ptrAnnotations->GetEnd()) - { - newEventsToHighlight.insert(annot->GetEventIndex()); - emit InformOfMouseOverAnnotation(*annot); - } - } - } - - bool doUpdate = false; - // did our highlight change? - for (auto it = newEventsToHighlight.begin(); it != newEventsToHighlight.end(); ++it) - { - if (m_eventsToHighlight.find(*it) == m_eventsToHighlight.end()) - { - doUpdate = true; - break; - } - } - - // did our highlight change? - if (!doUpdate) - { - for (auto it = m_eventsToHighlight.begin(); it != m_eventsToHighlight.end(); ++it) - { - if (newEventsToHighlight.find(*it) == newEventsToHighlight.end()) - { - doUpdate = true; - break; - } - } - } - - if (doUpdate) - { - newEventsToHighlight.swap(m_eventsToHighlight); - update(); - } - - // find the first annotation within a margin: - event->ignore(); - } - - void AnnotationsDataView_Events::mousePressEvent(QMouseEvent* event) - { - for (auto it = m_ClickableAreas.begin(); it != m_ClickableAreas.end(); ++it) - { - if (it->second.contains(event->pos())) - { - auto annot = m_ptrAnnotations->GetAnnotationForEvent(it->first); - if (annot != m_ptrAnnotations->GetEnd()) - { - emit InformOfClickAnnotation(*annot); - } - } - } - event->ignore(); - } - - - void AnnotationsDataView_Events::mouseReleaseEvent(QMouseEvent* event) - { - event->ignore(); - } - - void AnnotationsDataView_Events::OnScrubberFrameUpdate(FrameNumberType newFramenumber) - { - if (newFramenumber != m_CurrentFrameNumber) - { - m_CurrentFrameNumber = newFramenumber; - // we don't update here because we wait for the new range to be set - //update(); - } - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.hxx deleted file mode 100644 index 4a9c8a7810..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsDataView_Events.hxx +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef ANNOTATIONS_DATA_VIEW_EVENTS_HXX -#define ANNOTATIONS_DATA_VIEW_EVENTS_HXX - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include - -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Charts -{ - class Axis; -} - -namespace Driller -{ - class AnnotationsProvider; - class Annotation; - class AnnotationHeaderView_Events; - /** Annotations Data View just shows the annotations that are available in a horizontal strip with indicators for easy clickability. - * This flavor of the view is supposed to operate on individual events instead of individual frames and is supposed to sit above the event driller track - * But it can actually work on any track thats willing to provide it with an axis. - */ - - class AnnotationsDataView_Events : public QWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(AnnotationsDataView_Events, AZ::SystemAllocator, 0); - AnnotationsDataView_Events( AnnotationHeaderView_Events* header, AnnotationsProvider *annotations ); - virtual ~AnnotationsDataView_Events(); - - void AttachToAxis(Charts::Axis *pAxis); - - virtual void paintEvent( QPaintEvent *event ); - virtual void mouseMoveEvent( QMouseEvent *event ); - virtual void mousePressEvent( QMouseEvent *event ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - - signals: - void InformOfMouseOverAnnotation(const Annotation& annotation); - void InformOfClickAnnotation(const Annotation& annotation); - private: - typedef AZStd::unordered_map EventIndexToClickablePath; - - EventIndexToClickablePath m_ClickableAreas; - AZStd::unordered_set m_eventsToHighlight; - QPainter *m_Painter; - Charts::Axis *m_ptrAxis; - - AnnotationsProvider *m_ptrAnnotations; - AnnotationHeaderView_Events *m_ptrHeaderView; - FrameNumberType m_CurrentFrameNumber; - - const Annotation* GetNearestAnnotationToMousePoint(QPoint pos) const; - - public slots: - void OnAxisInvalidated(); - void OnAxisDestroyed(); - void OnScrubberFrameUpdate(FrameNumberType newFrameNumber); - }; -} - -#endif // ANNOTATIONS_DATA_VIEW diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.cpp deleted file mode 100644 index f8db607b51..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "AnnotationsHeaderView_Events.hxx" -#include "AnnotationsDataView_Events.hxx" -#include "Annotations.hxx" -#include - -namespace Driller -{ - static const int k_eventContractedSize = 18; - - AnnotationHeaderView_Events::AnnotationHeaderView_Events(QWidget* parent, Qt::WindowFlags flags) - : QWidget(parent, flags) - , m_ptrAnnotations(NULL) - { - this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - this->setFixedHeight(k_eventContractedSize); - this->setAutoFillBackground(true); - - QHBoxLayout* mainLayout = new QHBoxLayout(this); - this->setLayout(mainLayout); - - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setSpacing(0); - } - - void AnnotationHeaderView_Events::OnScrubberFrameUpdate(FrameNumberType newFrame) - { - if (m_ptrDataView) - { - m_ptrDataView->OnScrubberFrameUpdate(newFrame); - } - } - - QSize AnnotationHeaderView_Events::sizeHint() const - { - return QSize(0, k_eventContractedSize); - } - - void AnnotationHeaderView_Events::ControllerSizeChanged(QSize newSize) - { - (void)newSize; - } - - AnnotationHeaderView_Events::~AnnotationHeaderView_Events() - { - } - - void AnnotationHeaderView_Events::AttachToAxis(AnnotationsProvider* ptrAnnotations, Charts::Axis* target) - { - m_ptrAnnotations = ptrAnnotations; - m_ptrDataView = aznew AnnotationsDataView_Events(this, ptrAnnotations); - - connect(m_ptrDataView, SIGNAL(InformOfMouseOverAnnotation(const Annotation&)), this, SIGNAL(InformOfMouseOverAnnotation(const Annotation&))); - connect(m_ptrDataView, SIGNAL(InformOfClickAnnotation(const Annotation&)), this, SIGNAL(InformOfClickAnnotation(const Annotation&))); - connect(m_ptrAnnotations, SIGNAL(AnnotationDataInvalidated()), this, SLOT(RefreshView())); - - layout()->addWidget(m_ptrDataView); - m_ptrDataView->AttachToAxis(target); - } - - void AnnotationHeaderView_Events::RefreshView() - { - m_ptrDataView->update(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.hxx deleted file mode 100644 index 98eb6246d6..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/AnnotationsHeaderView_Events.hxx +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef ANNOTATION_HEADER_VIEW_EVENTS_HXX -#define ANNOTATION_HEADER_VIEW_EVENTS_HXX - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Charts -{ - class Axis; -} - -namespace Driller -{ - class AnnotationsProvider; - class AnnotationsDataView_Events; - class Annotation; - - /** This version of the annotations header view sits above the per-frame events widget (near the bottom of hte main view). - * Its job is to show annotations that happen within a single frame (on an event-by-event basis!) - * It can actually work on any track thats willing to provide it with an axis. - */ - - class AnnotationHeaderView_Events : public QWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(AnnotationHeaderView_Events,AZ::SystemAllocator,0); - AnnotationHeaderView_Events(QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~AnnotationHeaderView_Events(void); - - void AttachToAxis(AnnotationsProvider* ptrAnnotations, Charts::Axis *target); -signals: - void InformOfMouseOverAnnotation(const Annotation& annotation); - void InformOfClickAnnotation(const Annotation& annotation); - -public slots: - void RefreshView(); - void ControllerSizeChanged(QSize newSize); - void OnScrubberFrameUpdate(FrameNumberType newFrame); - private: - AnnotationsProvider *m_ptrAnnotations; - AnnotationsDataView_Events *m_ptrDataView; - - virtual QSize sizeHint() const; - - }; - -} - - -#endif // ANNOTATION_HEADER_VIEW_HXX diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsDialog.ui b/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsDialog.ui deleted file mode 100644 index 185f7b9eba..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsDialog.ui +++ /dev/null @@ -1,151 +0,0 @@ - - - configureAnnotationsDialog - - - - 0 - 0 - 446 - 168 - - - - Configure Annotations - - - true - - - false - - - - 2 - - - 4 - - - 4 - - - 4 - - - 4 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Display Annotations From the Selected Features - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 5 - 0 - - - - - - - - - 0 - 0 - - - - - 200 - 0 - - - - - 16777215 - 16777215 - - - - Search Annotations - - - - - - - - - - false - - - true - - - false - - - false - - - true - - - 60 - - - true - - - true - - - false - - - 30 - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.cpp b/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.cpp deleted file mode 100644 index b66ffa1047..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.cpp +++ /dev/null @@ -1,248 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include "ConfigureAnnotationsWindow.hxx" -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace Driller -{ - ////////////////////////////// - // ConfigureAnnotationsModel - ////////////////////////////// - int ConfigureAnnotationsModel::rowCount(const QModelIndex& index) const - { - if (index == QModelIndex()) - { - return (int)m_cache.size(); - } - return 0; - } - - int ConfigureAnnotationsModel::columnCount(const QModelIndex& index) const - { - (void)index; - return 1; - } - - Qt::ItemFlags ConfigureAnnotationsModel::flags(const QModelIndex& index) const - { - if (index == QModelIndex()) - { - return Qt::ItemFlags(); - } - - if (index.column() == 0) - { - return Qt::ItemIsUserCheckable | Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable; - } - - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; - } - - bool ConfigureAnnotationsModel::setData(const QModelIndex& index, const QVariant& value, int role) - { - if (role == Qt::CheckStateRole) - { - Qt::CheckState newState = (Qt::CheckState)value.toInt(); - if (index.column() == 0) - { - if (index.row() < (int)m_cache.size()) - { - Qt::CheckState oldEnabled = m_ptrProvider->IsChannelEnabled(AZ::Crc32(m_cache[index.row()].toUtf8().data())) ? Qt::Checked : Qt::Unchecked; - - if (newState != oldEnabled) - { - m_ptrProvider->SetChannelEnabled(m_cache[index.row()].toUtf8().data(), newState == Qt::Checked ? true : false); - return true; - } - } - } - } - else if (role == AzToolsFramework::ColorPickerDelegate::COLOR_PICKER_ROLE) - { - QColor newColor = qvariant_cast(value); - AZ::u32 crcOfChannel = AZ::Crc32(m_cache[index.row()].toUtf8().data()); - m_ptrProvider->SetColorForChannel(crcOfChannel, newColor); - m_cachedColorIcons[index.row()] = CreatePixmapForColor(newColor); - } - return false; - } - - QVariant ConfigureAnnotationsModel::data(const QModelIndex& index, int role) const - { - if (index == QModelIndex()) - { - return QVariant(); - } - - if (index.column() == 0) - { - switch (role) - { - case Qt::CheckStateRole: - { - AZ::u32 crcvalue = AZ::Crc32(m_cache[index.row()].toUtf8().data()); - return QVariant(m_ptrProvider->IsChannelEnabled(crcvalue) ? QVariant(Qt::Checked) : QVariant(Qt::Unchecked)); - } - case Qt::DecorationRole: - { - return m_cachedColorIcons[index.row()]; - } - case Qt::DisplayRole: - { - return m_cache[index.row()]; - } - case AzToolsFramework::ColorPickerDelegate::COLOR_PICKER_ROLE: - { - AZ::u32 crcvalue = AZ::Crc32(m_cache[index.row()].toUtf8().data()); - QColor channelColor = m_ptrProvider->GetColorForChannel(crcvalue); - return QVariant(channelColor); - } - } - } - - return QVariant(); - } - - QVariant ConfigureAnnotationsModel::headerData (int section, Qt::Orientation orientation, int role) const - { - (void)orientation; - - if (role == Qt::DisplayRole) - { - switch (section) - { - case 0: - return QVariant(tr("Annotation Type")); - break; - } - - return QVariant(); - } - else if (role == Qt::TextAlignmentRole) - { - if (section == 0) - { - return QVariant(Qt::AlignVCenter | Qt::AlignLeft); - } - } - - return QVariant(); - } - - QPixmap ConfigureAnnotationsModel::CreatePixmapForColor(QColor color) - { - QPixmap pixmap(16, 16); - { - QPainter painter(&pixmap); - painter.fillRect(0, 0, 16, 16, Qt::black); - painter.fillRect(1, 1, 15, 15, color); - } - return pixmap; - } - - - void ConfigureAnnotationsModel::Recache() - { - beginResetModel(); - m_cache.clear(); - m_cachedColorIcons.clear(); - AZStd::for_each(m_ptrProvider->GetAllKnownChannels().begin(), m_ptrProvider->GetAllKnownChannels().end(), - [this](const AZStd::string& value) - { - m_cache.push_back(QString::fromUtf8(value.c_str())); - QColor channelColor = m_ptrProvider->GetColorForChannel(AZ::Crc32(value.c_str())); - - m_cachedColorIcons.push_back(CreatePixmapForColor(channelColor)); - }); - endResetModel(); - } - - ConfigureAnnotationsModel::ConfigureAnnotationsModel(AnnotationsProvider* ptrProvider, QObject* pParent) - : QAbstractTableModel(pParent) - { - m_ptrProvider = ptrProvider; - connect(ptrProvider, &AnnotationsProvider::KnownAnnotationsChanged, this, &ConfigureAnnotationsModel::Recache); - Recache(); - } - - ConfigureAnnotationsModel::~ConfigureAnnotationsModel() - { - } - - /////////////////////////////// - // ConfigureAnnotationsWindow - /////////////////////////////// - - ConfigureAnnotationsWindow::ConfigureAnnotationsWindow(QWidget* pParent /* = NULL */) - : QDialog(pParent) - , m_proxyModel(nullptr) - { - m_ptrLoadedUI = azcreate(Ui::configureAnnotationsDialog, ()); - m_ptrLoadedUI->setupUi(this); - } - - ConfigureAnnotationsWindow::~ConfigureAnnotationsWindow() - { - AZStd::intrusive_ptr pState = AZ::UserSettings::CreateFind(AZ_CRC("CONFIGURE ANNOTATIONS WINDOW", 0x581c6568), AZ::UserSettings::CT_GLOBAL); - if (pState) - { - pState->CaptureGeometry(this); - } - - azdestroy(m_ptrLoadedUI); - } - - void ConfigureAnnotationsWindow::Initialize(AnnotationsProvider* ptrProvider) - { - m_ptrProvider = ptrProvider; - m_ptrModel = aznew ConfigureAnnotationsModel(ptrProvider, this); - - m_proxyModel = new QSortFilterProxyModel(this); - m_proxyModel->setDynamicSortFilter(false); - m_proxyModel->setFilterCaseSensitivity(Qt::CaseInsensitive); - m_proxyModel->setSortCaseSensitivity(Qt::CaseInsensitive); - m_proxyModel->setSourceModel(m_ptrModel); - - m_ptrLoadedUI->statusTable->setSelectionBehavior(QAbstractItemView::SelectRows); - m_ptrLoadedUI->statusTable->setModel(m_proxyModel); - m_ptrLoadedUI->statusTable->setItemDelegate(aznew AzToolsFramework::ColorPickerDelegate(this)); - m_ptrLoadedUI->statusTable->horizontalHeader()->setSortIndicator(0, Qt::AscendingOrder); - - connect(m_ptrLoadedUI->searchField, SIGNAL(textChanged(const QString&)), this, SLOT(OnFilterChanged(const QString&))); - - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(AZ_CRC("CONFIGURE ANNOTATIONS WINDOW", 0x581c6568), AZ::UserSettings::CT_GLOBAL); - - if (windowState) - { - windowState->RestoreGeometry(this); - } - } - - void ConfigureAnnotationsWindow::OnFilterChanged(const QString& filter) - { - m_proxyModel->setFilterFixedString(filter); - } - - void ConfigureAnnotationsWindow::closeEvent (QCloseEvent* e) - { - e->accept(); - deleteLater(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.hxx b/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.hxx deleted file mode 100644 index 7c9c91203f..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Annotations/ConfigureAnnotationsWindow.hxx +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CONFIGURE_ANNOTATIONS_WINDOW_H -#define CONFIGURE_ANNOTATIONS_WINDOW_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#endif - -class QSortFilterProxyModel; - -namespace Ui -{ - class configureAnnotationsDialog; -} - -namespace Driller -{ - class AnnotationsProvider; - class ConfigureAnnotationsModel; - - class ConfigureAnnotationsWindow : public QDialog - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(ConfigureAnnotationsWindow, AZ::SystemAllocator, 0); - - ConfigureAnnotationsWindow(QWidget *pParent = NULL); - virtual ~ConfigureAnnotationsWindow(); - - void Initialize(AnnotationsProvider* ptrProvider); - - public slots: - void OnFilterChanged(const QString&); - - protected: - Ui::configureAnnotationsDialog* m_ptrLoadedUI; - QSortFilterProxyModel* m_proxyModel; - ConfigureAnnotationsModel* m_ptrModel; - AnnotationsProvider* m_ptrProvider; - virtual void closeEvent ( QCloseEvent * e ); - }; - - - class ConfigureAnnotationsModel : public QAbstractTableModel - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(ConfigureAnnotationsModel, AZ::SystemAllocator, 0); - - //////////////////////////////////////////////////////////////////////////////////////////////// - // QAbstractTableModel - int rowCount(const QModelIndex& index = QModelIndex()) const override; - int columnCount(const QModelIndex& index = QModelIndex()) const override; - Qt::ItemFlags flags(const QModelIndex &index) const override; - - QVariant data(const QModelIndex& index, int role) const override; - bool setData(const QModelIndex &index, const QVariant &value, int role) override; - QVariant headerData ( int section, Qt::Orientation orientation, int role ) const override; - //////////////////////////////////////////////////////////////////////////////////////////////// - - ConfigureAnnotationsModel(AnnotationsProvider* ptrProvider, QObject *pParent = NULL); - - virtual ~ConfigureAnnotationsModel(); - - private: - AnnotationsProvider* m_ptrProvider; - AZStd::vector m_cache; - AZStd::vector m_cachedColorIcons; - - QPixmap CreatePixmapForColor(QColor color); - - private slots: - void Recache(); - }; - - -} - -#endif //CONFIGURE_ANNOTATIONS_WINDOW_H diff --git a/Code/Tools/Standalone/Source/Driller/AreaChart.cpp b/Code/Tools/Standalone/Source/Driller/AreaChart.cpp deleted file mode 100644 index a0eccc7d45..0000000000 --- a/Code/Tools/Standalone/Source/Driller/AreaChart.cpp +++ /dev/null @@ -1,636 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include -#include - -#include - -#include -#include - -#include -#include -#include - -namespace AreaChart -{ - /////////////// - // LineSeries - /////////////// - - LineSeries::LineSeries(AreaChart* owner, size_t seriesId, const QString& name, const QColor& color, size_t seriesSize) - : m_owner(owner) - , m_seriesId(seriesId) - , m_name(name) - , m_color(color) - , m_highlighted(false) - , m_enabled(true) - , m_hasData(false) - { - if (seriesSize > 0) - { - m_linePoints.reserve(seriesSize); - } - } - - LineSeries::~LineSeries() - { - } - - size_t LineSeries::GetSeriesId() const - { - return m_seriesId; - } - - void LineSeries::AddPoint(const LinePoint& linePoint) - { - // Handle simple case first - if (m_linePoints.empty() || m_linePoints.back().m_position < linePoint.m_position) - { - m_hasData |= linePoint.m_value > 0; - m_linePoints.push_back(linePoint); - } - else - { - // TODO: Handle the case of out of order insertion - AZ_Error("LineSeries",false,"Trying to add series point out of order. Unsupported behavior"); - } - } - - void LineSeries::Reset() - { - m_linePoints.clear(); - } - - bool LineSeries::IsHighlighted() const - { - return m_highlighted; - } - - bool LineSeries::IsEnabled() const - { - return m_enabled && m_hasData; - } - - const QColor& LineSeries::GetColor() const - { - return m_color; - } - - void LineSeries::ResetPainterPath() - { - // Kind of silly that QPainterPath doesn't have a clear. - m_painterPath = QPainterPath(); - } - - QPainterPath& LineSeries::GetPainterPath() - { - return m_painterPath; - } - - const QPainterPath& LineSeries::GetPainterPath() const - { - return m_painterPath; - } - - ////////////// - // AreaChart - ////////////// - - const size_t AreaChart::k_invalidSeriesId = static_cast(-1); - - AreaChart::AreaChart(QWidget* parent) - : QWidget(parent) - , m_inspectionSeries(k_invalidSeriesId) - , m_sizingDirty(true) - , m_regenGraph(true) - , m_axisMin(0) - , m_horizontalAxis(nullptr) - , m_verticalAxis(nullptr) - , m_insetTop(16) - , m_insetBottom(24) - , m_insetLeft(56) - , m_insetRight(16) - , m_widgetBackground(32,32,32,255) - , m_graphBackground(Qt::black) - { - setStyleSheet(QString("QToolTip { border: 1px solid white; padding: 1px; background: black; color: white; }")); - - m_axisMax = m_axisMin; - } - - AreaChart::~AreaChart() - { - delete m_horizontalAxis; - delete m_verticalAxis; - } - - bool AreaChart::IsMouseInspectionEnabled() const - { - return hasMouseTracking(); - } - - void AreaChart::EnableMouseInspection(bool enabled) - { - setMouseTracking(enabled); - } - - void AreaChart::SetMinimumValueRange(unsigned int value) - { - m_axisMin = value; - - m_axisMax = m_axisMin; - - for (auto& sizingPair : m_maxSizing) - { - if (sizingPair.second > m_axisMax) - { - m_axisMax = sizingPair.second; - } - } - - m_regenGraph = true; - update(); - } - - void AreaChart::ResetChart() - { - m_axisMax = m_axisMin; - m_maxSizing.clear(); - m_lineSeries.clear(); - m_markers.clear(); - - m_sizingDirty = true; - m_regenGraph = true; - - update(); - } - - void AreaChart::ConfigureVerticalAxis(QString label, unsigned int minimumHeight) - { - SetMinimumValueRange(minimumHeight); - - if (m_verticalAxis == nullptr) - { - m_verticalAxis = aznew Charts::Axis(); - } - - if (m_verticalAxis) - { - m_verticalAxis->SetLabel(label); - m_verticalAxis->SetAxisRange(0.0f, static_cast(m_axisMax)); - } - } - - void AreaChart::ConfigureHorizontalAxis(QString label, int minimum, int maximum) - { - if (m_horizontalAxis == nullptr) - { - m_horizontalAxis = aznew Charts::Axis(); - } - - if (m_horizontalAxis) - { - m_horizontalAxis->SetLabel(label); - m_horizontalAxis->SetAxisRange(static_cast(minimum), static_cast(maximum)); - } - } - - void AreaChart::ResetSeries(AZ::u32 seriesId) - { - if (!IsValidSeriesId(seriesId)) - { - return; - } - - m_lineSeries[seriesId].Reset(); - } - - size_t AreaChart::CreateSeries(const QString& name, const QColor& color, size_t size) - { - size_t seriesKey = m_lineSeries.size(); - AZ_Error("AreaChart", seriesKey != k_invalidSeriesId,"Trying to use invalid key for series Id. Too many Area Series created."); - - if (size <= 0) - { - size = m_maxSizing.size(); - } - - m_lineSeries.emplace_back(this, seriesKey, name, color, size); - - return seriesKey; - } - - void AreaChart::AddPoint(size_t seriesId, int position, unsigned int value) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - LinePoint linePoint(position,value); - AddPoint(seriesId,linePoint); - } - - void AreaChart::AddPoint(size_t seriesId, const LinePoint& linePoint) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - if (!IsValidSeriesId(seriesId)) - { - AZ_Error("AreaChart", false, "Invalid SeriesId given."); - return; - } - - LineSeries& lineSeries = m_lineSeries[seriesId]; - - lineSeries.AddPoint(linePoint); - - auto sizingIter = m_maxSizing.find(linePoint.m_position); - - if (sizingIter != m_maxSizing.end()) - { - sizingIter->second += linePoint.m_value; - - if (sizingIter->second > m_axisMax) - { - m_axisMax = sizingIter->second; - } - } - else - { - m_maxSizing[linePoint.m_position] = linePoint.m_value; - - if (linePoint.m_value > m_axisMax) - { - m_axisMax = linePoint.m_value; - } - } - - m_regenGraph = true; - update(); - } - - void AreaChart::SetSeriesHighlight(size_t seriesId, bool highlighted) - { - if (IsValidSeriesId(seriesId)) - { - LineSeries& lineSeries = m_lineSeries[seriesId]; - - lineSeries.m_highlighted = highlighted; - - update(); - } - } - - void AreaChart::SetSeriesEnabled(size_t seriesId, bool enabled) - { - if (IsValidSeriesId(seriesId)) - { - LineSeries& lineSeries = m_lineSeries[seriesId]; - - lineSeries.m_enabled = enabled; - - // Need to regen our graph data here, since we've removed one from the listing - m_regenGraph = true; - update(); - } - } - - void AreaChart::AddMarker(Charts::AxisType axis, int position, const QColor& color) - { - m_markers.emplace_back(axis, position, color); - } - - void AreaChart::mouseMoveEvent(QMouseEvent* mouseEvent) - { - if (IsMouseInspectionEnabled()) - { - QPoint mousePos = mouseEvent->pos(); - size_t hoveredArea = k_invalidSeriesId; - - if (m_graphRect.contains(mousePos) && m_hitAreas.size() > 0) - { - int offset = mousePos.x() - m_graphRect.left(); - - size_t counter = static_cast(static_cast(offset) / (static_cast(m_graphRect.width())/m_hitAreas.size())); - - bool escape = false; - - // Need to handle the areas right at the edge of the polygons - for (int i = -1; i <= 1; ++i) - { - if ((counter + i) >= m_hitAreas.size()) - { - continue; - } - - const AZStd::vector& hitAreas = m_hitAreas[counter + i]; - - for (const HitArea& hitArea : hitAreas) - { - QPolygon polygon = hitArea.m_polygon; - - if (hitArea.m_polygon.containsPoint(mousePos,Qt::OddEvenFill)) - { - hoveredArea = hitArea.m_seriesId; - escape = true; - break; - } - } - - if (escape) - { - break; - } - } - } - - if (hoveredArea != m_inspectionSeries) - { - m_inspectionSeries = hoveredArea; - update(); - - // Signal out which series we are inspecting - emit InspectedSeries(m_inspectionSeries); - } - } - } - - void AreaChart::leaveEvent(QEvent* event) - { - (void)event; - - if (m_inspectionSeries != k_invalidSeriesId) - { - m_inspectionSeries = k_invalidSeriesId; - update(); - - // Signal out which series we are inspecting - emit InspectedSeries(m_inspectionSeries); - } - - if (m_clicked) - { - m_clicked = false; - } - } - - void AreaChart::mousePressEvent(QMouseEvent* mouseEvent) - { - if (IsMouseInspectionEnabled()) - { - m_clicked = true; - m_mouseDownPoint = mouseEvent->pos(); - } - } - - void AreaChart::mouseReleaseEvent(QMouseEvent* mouseEvent) - { - if (IsMouseInspectionEnabled() && m_clicked) - { - QPoint upPoint = mouseEvent->pos(); - - // Want it to be roughly the same spot. - if ((m_mouseDownPoint - upPoint).manhattanLength() < 20) - { - int closestValue = 0; - if (m_horizontalAxis && m_graphRect.width() > 0) - { - float ratio = static_cast(upPoint.x() - m_graphRect.left()) / static_cast(m_graphRect.width()); - closestValue = static_cast(m_horizontalAxis->GetRangeMin()) + static_cast((m_horizontalAxis->GetRange() * ratio) + 0.5f); - } - - emit SelectedSeries(m_inspectionSeries, closestValue); - } - } - } - - void AreaChart::resizeEvent(QResizeEvent* event) - { - (void)event; - - m_sizingDirty = true; - update(); - } - - void AreaChart::paintEvent(QPaintEvent* event) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - (void)event; - - if (m_sizingDirty) - { - m_sizingDirty = false; - m_regenGraph = true; - - QPoint topLeft(rect().left() + m_insetLeft, rect().top() + m_insetTop); - QPoint bottomRight(rect().right() - m_insetRight, rect().bottom() - m_insetBottom); - - m_graphRect = QRect(topLeft,bottomRight); - } - - if (m_regenGraph) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - m_regenGraph = false; - - if (m_verticalAxis) - { - m_verticalAxis->SetAxisRange(0.0f, static_cast(m_axisMax)); - } - - m_hitAreas.clear(); - m_hitAreas.reserve(m_maxSizing.size()); - m_hitAreas.resize(m_maxSizing.size()); - - // Running tally of samples that we need to keep track of to manipulate our way through - AZStd::vector runningTotal(m_maxSizing.size(), 0); - - for (LineSeries& lineSeries : m_lineSeries) - { - unsigned int counter = 0; - - // Would have to special case out the single data point sample - if (lineSeries.IsEnabled() && lineSeries.m_linePoints.size() > 1) - { - unsigned int currentValue = lineSeries.m_linePoints[counter].m_value; - - unsigned int bottomLeft = runningTotal[counter]; - unsigned int topLeft = bottomLeft + currentValue; - - runningTotal[counter] = topLeft; - ++counter; - - lineSeries.ResetPainterPath(); - QPainterPath& painterPath = lineSeries.GetPainterPath(); - - AZ_Assert(runningTotal.size() == lineSeries.m_linePoints.size(), "Mismatched/missing sample values given to AreaChart"); - for (; counter < lineSeries.m_linePoints.size(); ++counter) - { - currentValue = lineSeries.m_linePoints[counter].m_value; - - unsigned int bottomRight = runningTotal[counter]; - unsigned int topRight = bottomRight + currentValue; - - runningTotal[counter] = topRight; - - QPolygon polygon; - polygon.append(ConvertToGraphPoint(counter - 1, bottomLeft)); - polygon.append(ConvertToGraphPoint(counter - 1, topLeft)); - polygon.append(ConvertToGraphPoint(counter, topRight)); - polygon.append(ConvertToGraphPoint(counter, bottomRight)); - - painterPath.addPolygon(polygon); - - m_hitAreas[counter].emplace_back(polygon, lineSeries.GetSeriesId()); - - bottomLeft = bottomRight; - topLeft = topRight; - } - } - } - } - - { - QPen pen; - QBrush brush; - QPainter p(this); - - p.fillRect(rect(),m_widgetBackground); - p.fillRect(m_graphRect, m_graphBackground); - - QRect widgetBounds = rect(); - - if (m_horizontalAxis) - { - m_horizontalAxis->PaintAxis(Charts::AxisType::Horizontal, &p, widgetBounds, m_graphRect, nullptr); - } - - if (m_verticalAxis) - { - m_verticalAxis->PaintAxis(Charts::AxisType::Vertical, &p, widgetBounds, m_graphRect, nullptr); - } - - p.setClipRect(m_graphRect.left(), m_graphRect.top() - 1, m_graphRect.width() + 2, m_graphRect.height() + 2); - - brush.setStyle(Qt::SolidPattern); - - pen.setStyle(Qt::SolidLine); - pen.setWidth(2); - - for (LineSeries& lineSeries : m_lineSeries) - { - if (!lineSeries.IsEnabled()) - { - continue; - } - - brush.setColor(lineSeries.GetColor()); - p.fillPath(lineSeries.GetPainterPath(), brush); - - if (lineSeries.IsHighlighted() - || lineSeries.GetSeriesId() == m_inspectionSeries) - { - // Then highlight it - pen.setColor(Qt::white); - p.setPen(pen); - - p.drawPath(lineSeries.GetPainterPath()); - } - } - - brush.setStyle(Qt::SolidPattern); - - pen.setStyle(Qt::SolidLine); - pen.setColor( m_graphBackground ); - pen.setWidth(2); - - p.setPen(pen); - - for (GraphMarker& marker : m_markers) - { - brush.setColor(marker.m_color); - switch (marker.m_axis) - { - case Charts::AxisType::Horizontal: - { - static const int k_barWidth = 4; - static const int k_halfWidth = k_barWidth / 2; - - if (!AZ::IsClose(m_horizontalAxis->GetRange(),0.0f,0.01f) ) - { - float minRange = m_horizontalAxis->GetRangeMin(); - - float ratio = (marker.m_position - minRange) / m_horizontalAxis->GetRange(); - ratio = AZStd::GetMin(1.0f, ratio); - - QPoint startPoint; - startPoint.setX(m_graphRect.left() + static_cast(m_graphRect.width() * ratio) - k_halfWidth); - startPoint.setY(m_graphRect.top()); - - p.fillRect(startPoint.x(), startPoint.y(), k_barWidth, m_graphRect.height(), brush); - p.drawRect(startPoint.x(), startPoint.y() + 1, k_barWidth, m_graphRect.height() - 1); - } - break; - } - case Charts::AxisType::Vertical: - { - QPoint startPoint = ConvertToGraphPoint(0, static_cast(marker.m_position)); - startPoint.setX(m_graphRect.right()); - - p.fillRect(startPoint.x(), startPoint.y(), m_graphRect.width(), 2, brush); - p.drawRect(startPoint.x(), startPoint.y(), m_graphRect.width(), 2); - break; - } - default: - AZ_Error("Standalone Tools", false, "Unknown axis type given to marker."); - }; - } - } - } - - Charts::Axis* AreaChart::GetAxis(Charts::AxisType axisType) - { - switch (axisType) - { - case Charts::AxisType::Horizontal: - return m_horizontalAxis; - case Charts::AxisType::Vertical: - return m_verticalAxis; - default: - AZ_Error("AreaChart", false, "Unknown AxisType."); - return nullptr; - } - } - - bool AreaChart::IsValidSeriesId(size_t seriesId) const - { - return seriesId < m_lineSeries.size(); - } - - QPoint AreaChart::ConvertToGraphPoint(int index, unsigned int value) - { - QPoint graphPoint(m_graphRect.bottomLeft()); - - int maxSizes = static_cast(m_maxSizing.size()); - - if (m_horizontalAxis) - { - maxSizes = AZStd::GetMax(maxSizes, static_cast(m_horizontalAxis->GetRange())); - } - - if (maxSizes >= 2) - { - // -1, since the index is 0 based. - graphPoint.setX(m_graphRect.left() + static_cast(m_graphRect.width() * (static_cast(index) / static_cast(maxSizes - 1)))); - } - - if (m_axisMax > 0) - { - graphPoint.setY(m_graphRect.bottom() - static_cast(m_graphRect.height() * (static_cast(value) / static_cast(m_axisMax)))); - } - - return graphPoint; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/AreaChart.hxx b/Code/Tools/Standalone/Source/Driller/AreaChart.hxx deleted file mode 100644 index 6e41734d07..0000000000 --- a/Code/Tools/Standalone/Source/Driller/AreaChart.hxx +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once -#ifndef PROFILER_AREACHART_H -#define PROFILER_AREACHART_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include -#include - -#include -#endif - -namespace Charts -{ - class Axis; -} - -namespace AreaChart -{ - class AreaChart; - - struct LinePoint - { - public: - LinePoint(int position, unsigned int value) - : m_position(position) - , m_value(value) - { - } - - int m_position; - unsigned int m_value; - }; - - class LineSeries - { - private: - friend class AreaChart; - - typedef AZStd::vector< LinePoint > LinePoints; - - public: - LineSeries(AreaChart* owner, size_t seriesId, const QString& name, const QColor& color, size_t seriesSize = 0); - ~LineSeries(); - - size_t GetSeriesId() const; - void AddPoint(const LinePoint& linePoint); - void Reset(); - - bool IsHighlighted() const; - bool IsEnabled() const; - - const QColor& GetColor() const; - - void ResetPainterPath(); - - QPainterPath& GetPainterPath(); - const QPainterPath& GetPainterPath() const; - - private: - - AreaChart* m_owner; - LinePoints m_linePoints; - - size_t m_seriesId; - QString m_name; - QColor m_color; - - QPainterPath m_painterPath; - bool m_highlighted; - bool m_enabled; - bool m_hasData; - }; - - class AreaChart - : public QWidget - { - Q_OBJECT - Q_PROPERTY(int insetTop MEMBER m_insetTop) - Q_PROPERTY(int insetBottom MEMBER m_insetBottom) - Q_PROPERTY(int insetLeft MEMBER m_insetLeft) - Q_PROPERTY(int insetRight MEMBER m_insetRight) - Q_PROPERTY(QColor widgetBackground MEMBER m_widgetBackground) - Q_PROPERTY(QColor graphBackground MEMBER m_graphBackground) - - struct HitArea - { - HitArea(const QPolygon& polygon, size_t seriesId) - : m_polygon(polygon) - , m_seriesId(seriesId) - { - } - - QPolygon m_polygon; - size_t m_seriesId; - }; - - struct GraphMarker - { - GraphMarker(Charts::AxisType axis, int position, const QColor& color) - : m_axis(axis) - , m_position(position) - , m_color(color) - { - } - - Charts::AxisType m_axis; - int m_position; - QColor m_color; - }; - - public: - static const size_t k_invalidSeriesId; - - AreaChart(QWidget* parent = nullptr); - ~AreaChart(); - - bool IsMouseInspectionEnabled() const; - void EnableMouseInspection(bool enabled); - - void ResetChart(); - - void ConfigureVerticalAxis(QString label, unsigned int minimumHeight = -1); - void ConfigureHorizontalAxis(QString label, int minimum, int maximum); - - size_t CreateSeries(const QString& name, const QColor& color, size_t size = 0); - void ResetSeries(AZ::u32); - - // Methods of adding points - void AddPoint(size_t seriesId, int position, unsigned int value); - void AddPoint(size_t seriesId, const LinePoint& linePoint); - - // Methods of manipulating series - void SetSeriesHighlight(size_t seriesId, bool highlighted); - void SetSeriesEnabled(size_t seriesId, bool enabled); - - // Methods of adding markers - void AddMarker(Charts::AxisType axis, int position, const QColor& color); - - public slots: - - signals: - void InspectedSeries(size_t seriesId); - void SelectedSeries(size_t seriesId, int position); - - protected: - - // Mouse Inspection - void mouseMoveEvent(QMouseEvent* mouseEvent) override; - void leaveEvent(QEvent* mouseEvent) override; - - // Mouse clicks - void mousePressEvent(QMouseEvent* mouseEvent) override; - void mouseReleaseEvent(QMouseEvent* mouseEvent) override; - - void resizeEvent(QResizeEvent* resizeEvent) override; - void paintEvent(QPaintEvent* paintEvent) override; - - private: - - void SetMinimumValueRange(unsigned int value); - Charts::Axis* GetAxis(Charts::AxisType axisType); - - bool IsValidSeriesId(size_t seriesId) const; - - QPoint ConvertToGraphPoint(int index, unsigned int value); - - AZStd::vector< GraphMarker > m_markers; - AZStd::vector< LineSeries > m_lineSeries; - - AZStd::unordered_map m_maxSizing; - - size_t m_inspectionSeries; - - size_t m_mouseOverArea; - AZStd::vector< AZStd::vector > m_hitAreas; - - bool m_clicked; - QPoint m_mouseDownPoint; - - QRect m_graphRect; - bool m_sizingDirty; - bool m_regenGraph; - - unsigned int m_axisMin; - unsigned int m_axisMax; - - Charts::Axis* m_horizontalAxis; - Charts::Axis* m_verticalAxis; - - // Styling - int m_insetTop; - int m_insetBottom; - int m_insetLeft; - int m_insetRight; - QColor m_widgetBackground; - QColor m_graphBackground; - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Axis.cpp b/Code/Tools/Standalone/Source/Driller/Axis.cpp deleted file mode 100644 index 6c55f668da..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Axis.cpp +++ /dev/null @@ -1,648 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -#include "Axis.hxx" - -namespace Charts -{ - ////////////////////////////////////////////////////////////////////////// - Axis::Axis(QObject* pParent) - : QObject(pParent) - , m_lockRange(true) - , m_lockZoom(true) - , m_lockRight(false) - , m_autoWindow(true) - , m_rangeMin(0) - , m_rangeMax(0) - , m_windowMax(0) - , m_windowMin(0) - , m_rangeMaxInitialized(false) - , m_rangeMinInitialized(false) - {} - Axis::~Axis() - { - } - - bool Axis::GetValid() const - { - return ((m_rangeMinInitialized) && (m_rangeMaxInitialized) && (m_rangeMin < m_rangeMax) && (m_windowMin < m_windowMax)); - } - - void Axis::Clear() - { - bool wasValid = GetValid(); - - m_rangeMinInitialized = false; - m_rangeMaxInitialized = false; - m_rangeMax = m_rangeMin = m_windowMax = m_windowMin = 0.0f; - - if (wasValid) - { - emit Invalidated(); - } - } - - void Axis::SetAxisRange(float minimum, float maximum) - { - float oldRangeMin = m_rangeMin; - float oldRangeMax = m_rangeMax; - float oldWindowMin = m_windowMin; - float oldWindowMax = m_windowMax; - - bool wasValid = GetValid(); - - if (m_lockRight) - { - m_windowMin += maximum - m_rangeMax; - m_windowMax = m_rangeMax; - } - m_rangeMin = minimum; - m_rangeMax = maximum; - - if (m_autoWindow && !m_lockRight) - { - m_windowMin = m_rangeMin; - m_windowMax = m_rangeMax; - } - - m_rangeMinInitialized = true; - m_rangeMaxInitialized = true; - - if ((oldRangeMax != m_rangeMax) || - (oldRangeMin != m_rangeMin) || - (oldWindowMin != m_windowMin) || - (oldWindowMax != m_windowMax) || - (wasValid != GetValid())) - { - emit Invalidated(); - } - } - - void Axis::AddAxisRange(float value) - { - bool updateValues = false; - float minRange = m_rangeMin; - float maxRange = m_rangeMax; - - if ((value < m_rangeMin) || !m_rangeMinInitialized) - { - updateValues = true; - minRange = value; - } - - if ((m_rangeMax < value) || !m_rangeMaxInitialized) - { - updateValues = true; - maxRange = value; - } - - if (updateValues) - { - SetAxisRange(minRange, maxRange); - } - } - - void Axis::SetRangeMax(float rangemax) - { - SetAxisRange(m_rangeMin, rangemax); - } - - void Axis::SetRangeMin(float rangemin) - { - SetAxisRange(rangemin, m_rangeMax); - } - - void Axis::UpdateWindowRange(float delta) - { - if (delta != 0.0f) - { - m_windowMax += delta; - m_windowMin += delta; - if (m_windowMax > m_rangeMax) - { - delta = m_windowMax - m_rangeMax; - m_windowMax -= delta; - m_windowMin -= delta; - } - - if (m_windowMin < m_rangeMin) - { - delta = m_rangeMin - m_windowMin; - m_windowMax += delta; - m_windowMin += delta; - } - - emit Invalidated(); - } - } - - void Axis::SetViewFull() - { - float oldWindowMin = m_windowMin; - float oldWindowMax = m_windowMax; - - m_autoWindow = true; - m_windowMin = m_rangeMin; - m_windowMax = m_rangeMax; - - if ( - (oldWindowMin != m_windowMin) || - (oldWindowMax != m_windowMax) - ) - { - emit Invalidated(); - } - } - - void Axis::SetLabel(QString newLabel) - { - if (m_label != newLabel) - { - m_label = newLabel; - emit Invalidated(); - } - } - - bool Axis::GetLockedRight() const - { - return m_lockRight; - } - - bool Axis::GetLockedRange() const - { - return m_lockRange; - } - - bool Axis::GetLockedZoom() const - { - return m_lockZoom; - } - - void Axis::SetLockedRange(bool newValue) - { - m_lockRange = newValue; - } - - void Axis::SetLockedZoom(bool newValue) - { - m_lockZoom = newValue; - } - - void Axis::SetLockedRight(bool newValue) - { - m_lockRight = newValue; - } - - void Axis::SetAutoWindow(bool autoWindow) - { - m_autoWindow = autoWindow; - } - - bool Axis::GetAutoWindow() const - { - return m_autoWindow; - } - - QString Axis::GetLabel() const - { - return m_label; - } - - float Axis::GetWindowMin() const - { - return m_windowMin; - } - - float Axis::GetWindowMax() const - { - return m_windowMax; - } - - float Axis::GetRangeMin() const - { - return m_rangeMin; - } - - float Axis::GetRangeMax() const - { - return m_rangeMax; - } - - void Axis::SetWindowMin(float newValue) - { - if (m_windowMin != newValue) - { - m_windowMin = newValue; - emit Invalidated(); - } - } - - void Axis::SetWindowMax(float newValue) - { - if (m_windowMax != newValue) - { - m_windowMax = newValue; - emit Invalidated(); - } - } - - float Axis::GetWindowRange() const - { - if (!GetValid()) - { - return 1.0f; - } - return m_windowMax - m_windowMin; - } - - float Axis::GetRange() const - { - if (!GetValid()) - { - return 1.0f; - } - return m_rangeMax - m_rangeMin; - } - - // focuspoint is a number from 0 to 1 that indicates how far along that axis the focal point is - // for example on a horizontal axis, 0 is the start, or GetwindowMin(), and 1 is the end, GetWindowMaX() - - void Axis::Drag(float delta) - { - if (!GetValid()) - { - return; - } - - if (GetLockedRange()) - { - return; - } - - UpdateWindowRange(delta); - } - - void Axis::ZoomToRange(float windowMin, float windowMax, bool clamp) - { - if (!GetValid()) - { - return; - } - - float oldmin = m_windowMin; - float oldmax = m_windowMax; - m_windowMin = windowMin; - m_windowMax = windowMax; - - if (clamp) - { - if (m_windowMin < m_rangeMin) - { - m_windowMin = m_rangeMin; - } - - if (m_windowMax > m_rangeMax) - { - m_windowMax = m_rangeMax; - } - } - - if ((m_windowMin != oldmin) || (m_windowMax != oldmax)) - { - emit Invalidated(); - } - } - - void Axis::Zoom(float ratio, float steps, float zoomLimit) - { - if (!GetValid()) - { - return; - } - - if (GetLockedRight()) - { - ratio = 1.0f; - } - if (!GetLockedZoom()) - { - SetAutoWindow(false); - - float testMin = GetWindowMin(); - float testMax = GetWindowMax(); - - testMin -= float(GetWindowRange()) * 0.05f * ratio * -steps; - testMax += float(GetWindowRange()) * 0.05f * (1.0f - ratio) * -steps; - - if ((testMax - testMin) > 0.0f) - { - if (testMax > GetRangeMax()) - { - float offset = GetRangeMax() - testMax; - testMax += offset; - testMin += offset; - } - if (testMin < GetRangeMin()) - { - float offset = testMin - GetRangeMin(); - testMax -= offset; - testMin -= offset; - } - if (testMax - testMin >= zoomLimit) - { - SetWindowMin(testMin); - SetWindowMax(testMax); - } - if ((testMax - testMin) > (GetRangeMax() - GetRangeMin())) - { - SetViewFull(); - } - } - } - } - - // given a width of a view in pixels, subdivide it and return a vector of domain units that - // satisfy a human outlook on domain values: - float Axis::ComputeAxisDivisions(float pixelWidth, AZStd::vector& domainPointsOut, float minPixels, float maxPixels, bool allowFractions) - { - if (!GetValid()) - { - return 1.0f; - } - - float divisor = 1.0f; - float windowRange = GetWindowRange(); - - // compute the divisor - float currentDivisionWidthInPixels = pixelWidth / (windowRange / divisor); - while (currentDivisionWidthInPixels > maxPixels) - { - // drop it down by 0.5 then by 0.1 - divisor /= 2.0f; - currentDivisionWidthInPixels = pixelWidth / (windowRange / divisor); - if (currentDivisionWidthInPixels <= maxPixels) - { - break; - } - - divisor *= 0.2f; // 0.5f * 0.2f = 0.1 - currentDivisionWidthInPixels = pixelWidth / (windowRange / divisor); - } - // the min pixels is an absolute requirement to prevent text from overlapping - // which is why we apply that constraint LAST. - // so for example, if window shows 100 units, and divisor is 2.0, then that would yield 50 pieces. - // 50 pieces over the span of 1000 pixels is 1000 / 50, 20 pixels each; - // 100 pieces would be (num pieces / pixel space to draw in) pixels - while (currentDivisionWidthInPixels < minPixels) - { - // the division width is too small, there are too many pieces. Make fewer pieces by choosing a larger - // divisor - // drop it down by 0.5 then by 0.1 - divisor *= 5.0f; - currentDivisionWidthInPixels = pixelWidth / (windowRange / divisor); - if (currentDivisionWidthInPixels >= minPixels) - { - break; - } - - divisor *= 2.0f; - currentDivisionWidthInPixels = pixelWidth / (windowRange / divisor); - } - - if ((divisor < 1.0f) && (!allowFractions)) - { - divisor = 1.0f; - } - - - // now lay out the domain starting with the first unit of that number: - float startingUnit = floorf(m_windowMin / divisor) * divisor; - - // to retain precision we are going to try to do the math around the origin. - startingUnit -= m_windowMin; - AZStd::size_t maximumAllowedUnitsBeforeSomethingTerribleHasOccurred = (AZStd::size_t)(pixelWidth / 4.0f); - - // so for example if we've decided that the divisor is 10 units, and the window min is 12.5, then it will go to 1.25, chop off the .25, and go back to 10 - while (startingUnit <= windowRange) - { - if (startingUnit >= 0.0f) - { - domainPointsOut.push_back(startingUnit + m_windowMin); - } - startingUnit += divisor; - - if (domainPointsOut.size() > maximumAllowedUnitsBeforeSomethingTerribleHasOccurred) - { - break; // you can put a break point here, but it usually means that we've lost enough precision. Change your axis range or numbering scheme! - } - } - - return divisor; - } - void Axis::PaintAxis(AxisType axisType, QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter) - { - switch (axisType) - { - case AxisType::Horizontal: - PaintAsHorizontalAxis(painter, widgetBounds, graphBounds, formatter); - break; - case AxisType::Vertical: - PaintAsVerticalAxis(painter, widgetBounds, graphBounds, formatter); - break; - default: - break; - } - } - - void Axis::PaintAsVerticalAxis(QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter) - { - (void)widgetBounds; - - const QColor axisBrush = QColor(255, 255, 0, 255); - const QColor axisPen = QColor(0, 255, 255, 255); - const QColor dottedColor(64, 64, 64, 255); - const QColor solidColor(0, 255, 255, 255); - - QBrush brush; - QPen pen; - - brush.setColor(axisBrush); - pen.setColor(axisPen); - painter->setPen(pen); - - QFont currentFont = painter->font(); - currentFont.setPointSize(currentFont.pointSize() - 1); - painter->setFont(currentFont); - - int w = painter->fontMetrics().horizontalAdvance(GetLabel()); - int h = painter->fontMetrics().height(); - - int centerHeight = graphBounds.top() + (graphBounds.height() / 2); - - DrawRotatedText(GetLabel(), painter, 270, h, centerHeight + w / 2, 1.25f); - - currentFont.setPointSize(currentFont.pointSize() + 1); - painter->setFont(currentFont); - - QPoint startPoint = graphBounds.topLeft(); - QPoint endPoint = graphBounds.bottomLeft(); - - int height = endPoint.y() - startPoint.y(); - int fontH = painter->fontMetrics().height(); - - if (height == 0) - { - height = 1; - } - - AZStd::vector divisions; - divisions.reserve(10); - - float divisionSize = ComputeAxisDivisions(static_cast(height), divisions, fontH * 2.0f, fontH * 2.0f); - - QPen dottedPen; - dottedPen.setStyle(Qt::DotLine); - dottedPen.setColor(dottedColor); - - QBrush solidBrush; - QPen solidPen; - solidPen.setStyle(Qt::SolidLine); - solidPen.setColor(solidColor); - solidPen.setWidth(1); - - float fullRange = fabs(GetWindowRange()); - - for (float division : divisions) - { - float ratio = static_cast(division - GetWindowMin()) / fullRange; - - QPoint lineStart; - lineStart.setX(endPoint.x()); - lineStart.setY(endPoint.y() - static_cast(height*ratio)); - - QPoint lineEnd(static_cast(lineStart.x() + graphBounds.width()), lineStart.y()); - - painter->setPen(dottedPen); - painter->drawLine(lineStart, lineEnd); - - QString text; - - if (formatter) - { - text = formatter->convertAxisValueToText(Charts::AxisType::Vertical, division, divisions.front(), divisions.back(), divisionSize); - } - else - { - text = QString("%1").arg((AZ::s64)division); - } - - int textW = painter->fontMetrics().horizontalAdvance(text); - painter->setPen(solidPen); - painter->drawText(lineStart.x() - textW - 2, (int)lineStart.y() + fontH / 2, text); - } - } - - void Axis::PaintAsHorizontalAxis(QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter) - { - const QColor axisBrush = QColor(255, 255, 0, 255); - const QColor axisPen = QColor(0, 255, 255, 255); - const QColor dottedColor(64, 64, 64,255); - const QColor solidColor(0, 255, 255, 255); - - QBrush brush; - QPen pen; - - brush.setColor(axisBrush); - pen.setColor(axisPen); - painter->setPen(pen); - - QFont currentFont = painter->font(); - currentFont.setPointSize(currentFont.pointSize() - 1); - painter->setFont(currentFont); - - painter->drawText(0, 0, widgetBounds.width(), widgetBounds.height(), Qt::AlignHCenter | Qt::AlignBottom, GetLabel()); - - currentFont.setPointSize(currentFont.pointSize() + 1); - painter->setFont(currentFont); - - QPoint startPoint = graphBounds.bottomLeft(); - QPoint endPoint = graphBounds.bottomRight(); - int width = endPoint.x() - startPoint.x(); - - if (width == 0) - { - width = 1; - } - - float textSpaceRequired = (float)painter->fontMetrics().horizontalAdvance("9,999,999.99"); - - int fontH = painter->fontMetrics().height(); - - AZStd::vector divisions; - divisions.reserve(10); - - float divisionSize = ComputeAxisDivisions(static_cast(width), divisions, textSpaceRequired, textSpaceRequired); - - QPen dottedPen; - dottedPen.setStyle(Qt::DotLine); - dottedPen.setColor(dottedColor); - - QBrush solidBrush; - QPen solidPen; - solidPen.setStyle(Qt::SolidLine); - solidPen.setColor(solidColor); - solidPen.setWidth(1); - - float fullRange = fabs(GetWindowRange()); - - for (float division : divisions) - { - float ratio = float(division - GetWindowMin()) / fullRange; - - QPoint lineStart; - lineStart.setX(startPoint.x() + static_cast(width*ratio)); - lineStart.setY(startPoint.y()); - - QPoint lineEnd(lineStart.x(), static_cast(startPoint.y() - graphBounds.height())); - - painter->setPen(dottedPen); - painter->drawLine(lineStart, lineEnd); - - QString text; - - if (formatter) - { - text = formatter->convertAxisValueToText(Charts::AxisType::Horizontal, division, divisions.front(), divisions.back(), divisionSize); - } - else - { - text = QString("%1").arg((AZ::s64)division); - } - - int textW = painter->fontMetrics().horizontalAdvance(text); - - painter->setPen(solidPen); - painter->drawText(lineStart.x() - textW / 2, startPoint.y() + fontH, text); - } - } - - void Axis::DrawRotatedText(QString text, QPainter *painter, float degrees, int x, int y, float scale) - { - painter->save(); - painter->translate(x, y); - painter->scale(scale, scale); - painter->rotate(degrees); - painter->drawText(0, 0, text); - painter->restore(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Axis.hxx b/Code/Tools/Standalone/Source/Driller/Axis.hxx deleted file mode 100644 index a9231307b7..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Axis.hxx +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CHART_AXIS_H -#define CHART_AXIS_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include -#include -#endif - -class QPainter; - -#pragma once - -namespace Charts -{ - // the Axis represents one axis on a chart. its float-based - // it contains information about window range and domain range. - class Axis : public QObject - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(Axis,AZ::SystemAllocator,0); - Axis(QObject* pParent = NULL); - ~Axis(); // not virtual - - public: - bool GetValid() const; - bool GetAutoWindow() const; - QString GetLabel() const; - float GetWindowMin() const; - float GetWindowMax() const; - float GetRangeMin() const; - float GetRangeMax() const; - float GetWindowRange() const; - float GetRange() const; - bool GetLockedZoom() const; - bool GetLockedRange() const; - bool GetLockedRight() const; - void Zoom(float focusPoint, float steps, float zoomLimit ); - void ZoomToRange(float windowMin, float windowMax, bool clamp); - - void PaintAxis(AxisType axisType, QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter); - - float ComputeAxisDivisions(float pixelWidth, AZStd::vector& domainPointsOut, float minPixels, float maxPixels, bool allowFractions = true); - -signals: - void Invalidated(); // something has happened which should cause anyone using this axis to update themselves. - -public slots: - void SetAxisRange( float minimum, float maximum ); - void AddAxisRange( float value ); - void SetViewFull(); - void SetLabel(QString newLabel); - void SetLockedRight(bool lockRight); - void SetLockedRange(bool locked); // cannot pan - void SetLockedZoom(bool locked); // cannot zoom. - void Clear(); - void SetAutoWindow( bool autoWindow ); - void SetWindowMin(float newValue); - void SetWindowMax(float newValue); - void UpdateWindowRange(float delta); - void SetRangeMax(float rangemax); - void SetRangeMin(float rangemin); - void Drag(float delta); - - private: - - void PaintAsVerticalAxis(QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter); - void PaintAsHorizontalAxis(QPainter* painter, const QRect& widgetBounds, const QRect& graphBounds, QAbstractAxisFormatter* formatter); - void DrawRotatedText(QString text, QPainter *painter, float degrees, int x, int y, float scale); - - QString m_label; - float m_rangeMin; - float m_rangeMax; - float m_windowMin; - float m_windowMax; - bool m_lockZoom; // zoom is always to the range - bool m_lockRange; // you may only pan - bool m_lockRight; - bool m_autoWindow; - bool m_rangeMinInitialized; - bool m_rangeMaxInitialized; // these are false until you init them, and the axis is invalid until such a time. - }; -} - - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/CSVExportSettings.h b/Code/Tools/Standalone/Source/Driller/CSVExportSettings.h deleted file mode 100644 index c7fc45d25d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CSVExportSettings.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_CSVEXPORTSETTINGS_H -#define DRILLER_CSVEXPORTSETTINGS_H - -#include -#include - -#pragma once - -namespace Driller -{ - class CSVExportSettings - { - public: - AZ_CLASS_ALLOCATOR(CSVExportSettings, AZ::SystemAllocator, 0); - - CSVExportSettings() - : m_shouldExportColumnDescriptor(true) - { - } - - virtual ~CSVExportSettings() - { - } - - void SetShouldExportColumnDescriptors(bool shouldExport) - { - m_shouldExportColumnDescriptor = shouldExport; - } - - bool ShouldExportColumnDescriptors() const - { - return m_shouldExportColumnDescriptor; - } - - private: - bool m_shouldExportColumnDescriptor; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.cpp deleted file mode 100644 index 6e943ae2c0..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.cpp +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -#include "CarrierDataAggregator.hxx" -#include -#include "CarrierDataEvents.h" -#include "CarrierDataView.hxx" - -namespace Driller -{ - ///////////////////////////// - // CarrierCSVExportSettings - ///////////////////////////// - CarrierExportSettings::CarrierExportSettings() - { - m_columnDescriptors = - { - {ExportField::Data_Sent, "Data Sent(Bytes)"}, - {ExportField::Data_Received, "Data Received(Bytes)"}, - {ExportField::Data_Resent, "Data Resent(Bytes)"}, - {ExportField::Data_Acked, "Data Acked(Bytes)"}, - {ExportField::Packets_Sent, "Packets Sent"}, - {ExportField::Packets_Received, "Packets Received"}, - {ExportField::Packets_Lost, "Packets Lost"}, - {ExportField::Packets_Acked, "Packets Acked"}, - {ExportField::Packet_RTT, "Packet Round Trip Time"}, - {ExportField::Packet_Loss, "Packet Loss(%)"}, - {ExportField::Effective_Data_Sent, "Effective Data Sent(Bytes)"}, - {ExportField::Effective_Data_Received, "Effective Data Received(Bytes)"}, - {ExportField::Effective_Data_Resent, "Effective Data Resent(Bytes)"}, - {ExportField::Effective_Data_Acked, "Effective Data Acked(Bytes)"}, - {ExportField::Effective_Packets_Sent, "Effective Packets Sent"}, - {ExportField::Effective_Packets_Received, "Effective Packets Received"}, - {ExportField::Effective_Packets_Lost, "Effective Packets Lost"}, - {ExportField::Effective_Packets_Acked, "Effective Packets Acked"}, - {ExportField::Effective_Packet_RTT, "Effective Packet Round Trip Time"}, - {ExportField::Effective_Packet_Loss, "Effective Packet Loss(%)"} - }; - - m_exportOrdering = - { - ExportField::Data_Sent, - ExportField::Effective_Data_Sent, - ExportField::Data_Received, - ExportField::Effective_Data_Received, - ExportField::Data_Resent, - ExportField::Effective_Data_Resent, - ExportField::Data_Acked, - ExportField::Effective_Data_Acked, - ExportField::Packets_Sent, - ExportField::Effective_Packets_Sent, - ExportField::Packets_Received, - ExportField::Effective_Packets_Received, - ExportField::Packets_Lost, - ExportField::Effective_Packets_Lost, - ExportField::Packets_Acked, - ExportField::Effective_Packets_Acked, - ExportField::Packet_RTT, - ExportField::Effective_Packet_RTT, - ExportField::Packet_Loss, - ExportField::Effective_Packet_Loss - }; - - for (const AZStd::pair< ExportField, AZStd::string >& item : m_columnDescriptors) - { - m_stringToExportEnum[item.second] = item.first; - } - } - - void CarrierExportSettings::GetExportItems(QStringList& items) const - { - for (const AZStd::pair< CarrierExportField, AZStd::string>& item : m_columnDescriptors) - { - items.push_back(QString(item.second.c_str())); - } - } - - void CarrierExportSettings::GetActiveExportItems(QStringList& items) const - { - for (CarrierExportField currentField : m_exportOrdering) - { - if (currentField != CarrierExportField::UNKNOWN) - { - items.push_back(QString(FindColumnDescriptor(currentField).c_str())); - } - } - } - - void CarrierExportSettings::UpdateExportOrdering(const QStringList& activeItems) - { - m_exportOrdering.clear(); - - for (const QString& activeItem : activeItems) - { - ExportField field = FindExportFieldFromDescriptor(activeItem.toStdString().c_str()); - - AZ_Assert(field != ExportField::UNKNOWN, "Unknown descriptor %s", activeItem.toStdString().c_str()); - if (field != ExportField::UNKNOWN) - { - m_exportOrdering.push_back(field); - } - } - } - - const AZStd::vector< CarrierExportField >& CarrierExportSettings::GetExportOrder() const - { - return m_exportOrdering; - } - - const AZStd::string& CarrierExportSettings::FindColumnDescriptor(ExportField exportField) const - { - static const AZStd::string emptyDescriptor; - - AZStd::unordered_map::const_iterator descriptorIter = m_columnDescriptors.find(exportField); - - if (descriptorIter == m_columnDescriptors.end()) - { - AZ_Assert(false, "Unknown column descriptor in Carrier CSV Export"); - return emptyDescriptor; - } - else - { - return descriptorIter->second; - } - } - - CarrierExportField CarrierExportSettings::FindExportFieldFromDescriptor(const char* columnDescriptor) const - { - AZStd::unordered_map::const_iterator exportIter = m_stringToExportEnum.find(columnDescriptor); - - ExportField retVal = ExportField::UNKNOWN; - - if (exportIter != m_stringToExportEnum.end()) - { - retVal = exportIter->second; - } - - return retVal; - } - - ////////////////////////// - // CarrierDataAggregator - ////////////////////////// - float CarrierDataAggregator::GetTValueAtFrame(FrameNumberType frame, AZ::s64 maxValue) - { - float valueAtFrame = 0.0f; - - size_t numEventsAtFrame = NumOfEventsAtFrame(frame); - for (EventNumberType i = m_frameToEventIndex[frame]; i < static_cast(m_frameToEventIndex[frame] + numEventsAtFrame); i++) - { - CarrierDataEvent* event = static_cast(m_events[i]); - // Consider the aggregation a sum of all data send and received (i.e. total bandwidth used). - valueAtFrame += event->mLastSecond.mDataSend + event->mLastSecond.mDataReceived; - } - - if (valueAtFrame >= maxValue) - { - return 1.0f; - } - - if (valueAtFrame == 0.0f) - { - return -1.0f; - } - - float tValue = (valueAtFrame / (maxValue * 2)) - 1.0f; - return tValue; - } - - CarrierDataAggregator::CarrierDataAggregator(int identity) - : Aggregator(identity) - , m_parser(this) - { - } - - CustomizeCSVExportWidget* CarrierDataAggregator::CreateCSVExportCustomizationWidget() - { - return aznew GenericCustomizeCSVExportWidget(m_csvExportSettings); - } - - float CarrierDataAggregator::ValueAtFrame(FrameNumberType frame) - { - return GetTValueAtFrame(frame, (1024 * 20)); - } - - QColor CarrierDataAggregator::GetColor() const - { - return QColor(255, 0, 0); - } - - QString CarrierDataAggregator::GetName() const - { - return QString("Carrier"); - } - - QString CarrierDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString CarrierDataAggregator::GetDescription() const - { - return QString("GridMate Carrier Data"); - } - - QString CarrierDataAggregator::GetToolTip() const - { - return QString("Information about overall bandwidth usage"); - } - - AZ::Uuid CarrierDataAggregator::GetID() const - { - return AZ::Uuid("{927B208C-28E8-4BE7-BF4E-629D98F7097F}"); - } - - QWidget* CarrierDataAggregator::DrillDownRequest(FrameNumberType frame) - { - (void)frame; - - // Always provide a full view of the driller data. - FrameNumberType lastFrame = static_cast(m_frameToEventIndex.size() - 1); - - // This pointer is cleaned up by qt when the window is closed. - return aznew CarrierDataView(0, lastFrame, this); - } - - void CarrierDataAggregator::OptionsRequest() - { - } - - void CarrierDataAggregator::ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) - { - CarrierExportSettings* carrierExportSettings = static_cast(exportSettings); - const AZStd::vector< CarrierExportField >& exportOrdering = carrierExportSettings->GetExportOrder(); - - bool addComma = false; - - for (CarrierExportField currentField : exportOrdering) - { - if (addComma) - { - file.Write(",", 1); - } - - const AZStd::string& columnDescriptor = carrierExportSettings->FindColumnDescriptor(currentField); - file.Write(columnDescriptor.c_str(), columnDescriptor.size()); - addComma = true; - } - - file.Write("\n", 1); - } - - void CarrierDataAggregator::ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) - { - const CarrierDataEvent* carrierEvent = static_cast(drillerEvent); - - CarrierExportSettings* carrierExportSettings = static_cast(exportSettings); - - const AZStd::vector< CarrierExportField >& exportOrdering = carrierExportSettings->GetExportOrder(); - bool addComma = false; - - AZStd::string number; - - for (CarrierExportField currentField : exportOrdering) - { - if (addComma) - { - file.Write(",", 1); - } - - switch (currentField) - { - case CarrierExportField::Data_Sent: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mDataSend); - break; - } - case CarrierExportField::Data_Received: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mDataReceived); - break; - } - case CarrierExportField::Data_Resent: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mDataResent); - break; - } - case CarrierExportField::Data_Acked: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mDataAcked); - break; - } - case CarrierExportField::Packets_Sent: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mPacketSend); - break; - } - case CarrierExportField::Packets_Received: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mPacketReceived); - break; - } - case CarrierExportField::Packets_Lost: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mPacketLost); - break; - } - case CarrierExportField::Packets_Acked: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mPacketAcked); - break; - } - case CarrierExportField::Packet_RTT: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mRTT); - break; - } - case CarrierExportField::Packet_Loss: - { - AZStd::to_string(number, carrierEvent->mLastSecond.mPacketLoss); - break; - } - case CarrierExportField::Effective_Data_Sent: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mDataSend); - break; - } - case CarrierExportField::Effective_Data_Received: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mDataReceived); - break; - } - case CarrierExportField::Effective_Data_Resent: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mDataResent); - break; - } - case CarrierExportField::Effective_Data_Acked: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mDataAcked); - break; - } - case CarrierExportField::Effective_Packets_Sent: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mPacketSend); - break; - } - case CarrierExportField::Effective_Packets_Received: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mPacketReceived); - break; - } - case CarrierExportField::Effective_Packets_Lost: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mPacketLost); - break; - } - case CarrierExportField::Effective_Packets_Acked: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mPacketAcked); - break; - } - case CarrierExportField::Effective_Packet_RTT: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mRTT); - break; - } - case CarrierExportField::Effective_Packet_Loss: - { - AZStd::to_string(number, carrierEvent->mEffectiveLastSecond.mPacketLoss); - break; - } - default: - AZ_Assert(false, "Unknown CarrierExportField"); - break; - } - - file.Write(number.c_str(), number.size()); - addComma = true; - } - - file.Write("\n", 1); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.hxx deleted file mode 100644 index 9981148135..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataAggregator.hxx +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_CARRIER_DATAAGGREGATOR_H -#define DRILLER_CARRIER_DATAAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "CarrierDataParser.h" - -#include "Source/Driller/GenericCustomizeCSVExportWidget.hxx" -#endif - -namespace Driller -{ - struct CarrierData; -} - -namespace Driller -{ - class CarrierDataView; - - class CarrierExportSettings - : public GenericCSVExportSettings - { - public: - enum class ExportField - { - Data_Sent, - Data_Received, - Data_Resent, - Data_Acked, - Packets_Sent, - Packets_Received, - Packets_Lost, - Packets_Acked, - Packet_RTT, - Packet_Loss, - Effective_Data_Sent, - Effective_Data_Received, - Effective_Data_Resent, - Effective_Data_Acked, - Effective_Packets_Sent, - Effective_Packets_Received, - Effective_Packets_Lost, - Effective_Packets_Acked, - Effective_Packet_RTT, - Effective_Packet_Loss, - - UNKNOWN - }; - - private: - AZStd::unordered_map m_columnDescriptors; - AZStd::unordered_map m_stringToExportEnum; - AZStd::vector< ExportField > m_exportOrdering; - - public: - AZ_CLASS_ALLOCATOR(CarrierExportSettings, AZ::SystemAllocator, 0); - - CarrierExportSettings(); - - void GetExportItems(QStringList& items) const override; - void GetActiveExportItems(QStringList& items) const override; - - const AZStd::vector< ExportField >& GetExportOrder() const; - const AZStd::string& FindColumnDescriptor(ExportField exportField) const; - - protected: - void UpdateExportOrdering(const QStringList& activeItems) override; - - private: - ExportField FindExportFieldFromDescriptor(const char* descriptor) const; - }; - - typedef CarrierExportSettings::ExportField CarrierExportField; - - class CarrierDataAggregator : public Aggregator - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(CarrierDataAggregator, AZ::SystemAllocator, 0); - - CarrierDataAggregator(int identity = 0); - - static AZ::u32 DrillerId() { return AZ_CRC("CarrierDriller"); } - - // Driller::Aggregator. - AZ::u32 GetDrillerId() const override - { - return DrillerId(); - } - - static const char* ChannelName() { return "GridMate"; } - - AZ::Crc32 GetChannelId() const override - { - return AZ::Crc32(ChannelName()); - } - - - AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() override - { - return &m_parser; - } - - bool CanExportToCSV() const override - { - return true; - } - - CustomizeCSVExportWidget* CreateCSVExportCustomizationWidget() override; - - // Driller::Aggregator. - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) override {} - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*) override {} - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*) override {} - - public slots: - // Driller::Aggregator. - float ValueAtFrame(FrameNumberType frame) override; - QColor GetColor() const override; - QString GetName() const override; - QString GetChannelName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - void OptionsRequest() override; - - protected: - void ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) override; - void ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) override; - - private: - - // Aggregate all data events in a particular frame and return a normalized - // value in the range [-1,1] based on the min/max range [0,maxValue]. - float GetTValueAtFrame(FrameNumberType frame, AZ::s64 maxValue); - - CarrierExportSettings m_csvExportSettings; - - // A parser that will parse carrier driller XML data and add events back - // into this aggregator. - CarrierDataParser m_parser; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataEvents.h b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataEvents.h deleted file mode 100644 index 3947d593c8..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataEvents.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_CARRIER_DATAEVENTS_H -#define DRILLER_CARRIER_DATAEVENTS_H - -#include -#include -#include -#include "Source/Driller/DrillerEvent.h" - -namespace Driller -{ - namespace Carrier - { - enum CarrierEventType - { - CET_INFO = 1 - }; - } - - struct CarrierData - { - AZ::s32 mDataSend; //< Data sent (bytes). - AZ::s32 mDataReceived; //< Data received (bytes). - AZ::s32 mDataResent; //< Data resent (bytes). - AZ::s32 mDataAcked; //< Data acknowledged (bytes). - AZ::s32 mPacketSend; //< Number of packets sent. - AZ::s32 mPacketReceived; //< Number of packets received. - AZ::s32 mPacketLost; //< Number of packets lost. - AZ::s32 mPacketAcked; //< Number of packets acknowledged. - float mRTT; //< Round-trip time. - float mPacketLoss; //< Packet loss percentage. - }; - - class CarrierDataEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(CarrierDataEvent, AZ::SystemAllocator, 0); - - CarrierDataEvent() - : DrillerEvent(Carrier::CET_INFO) - , mID("") - { - }; - - virtual void StepForward(Aggregator* data) { (void)data; }; - virtual void StepBackward(Aggregator* data) { (void)data; }; - - AZStd::string mID; - CarrierData mLastSecond; - CarrierData mEffectiveLastSecond; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.cpp deleted file mode 100644 index 1595487994..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.cpp +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "CarrierDataEvents.h" -#include "CarrierDataAggregator.hxx" -#include "CarrierDataParser.h" - -namespace Driller -{ - CarrierDataParser::CarrierDataParser(CarrierDataAggregator* m_aggregator) - : DrillerHandlerParser(false) - , m_currentType(CDT_NONE) - , m_aggregator(m_aggregator) - { - } - - CarrierDataParser::~CarrierDataParser() - { - } - - AZ::Debug::DrillerHandlerParser* CarrierDataParser::OnEnterTag(AZ::u32 tagName) - { - // Start of a new event. - if (tagName == AZ_CRC("Statistics")) - { - m_currentType = CDT_STATISTICS; - m_aggregator->AddEvent(aznew CarrierDataEvent); - return this; - } - else if (tagName == AZ_CRC("LastSecond")) - { - m_currentType = CDT_LAST_SECOND; - return this; - } - else if (tagName == AZ_CRC("EffectiveLastSecond")) - { - m_currentType = CDT_EFFECTIVE_LAST_SECOND; - return this; - } - else - { - return nullptr; - } - } - - void CarrierDataParser::OnExitTag(AZ::Debug::DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)handler; - - if (tagName == AZ_CRC("LastSecond") || tagName == AZ_CRC("EffectiveLastSecond")) - { - m_currentType = CDT_NONE; - } - } - - void CarrierDataParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - // Ignore unsupported tags. - if (m_currentType == CDT_NONE) - { - return; - } - - CarrierDataEvent* event = static_cast(m_aggregator->GetEvents().back()); - - if (m_currentType == CDT_STATISTICS) - { - dataNode.Read(event->mID); - return; - } - - CarrierData* eventData = nullptr; - switch (m_currentType) - { - case CDT_LAST_SECOND: - eventData = &event->mLastSecond; - break; - case CDT_EFFECTIVE_LAST_SECOND: - eventData = &event->mEffectiveLastSecond; - break; - default: - return; - } - - if (dataNode.m_name == AZ_CRC("DataSend")) - { - dataNode.Read(eventData->mDataSend); - } - else if (dataNode.m_name == AZ_CRC("DataReceived")) - { - dataNode.Read(eventData->mDataReceived); - } - else if (dataNode.m_name == AZ_CRC("DataResent")) - { - dataNode.Read(eventData->mDataResent); - } - else if (dataNode.m_name == AZ_CRC("DataAcked")) - { - dataNode.Read(eventData->mDataAcked); - } - else if (dataNode.m_name == AZ_CRC("PacketSend")) - { - dataNode.Read(eventData->mPacketSend); - } - else if (dataNode.m_name == AZ_CRC("PacketReceived")) - { - dataNode.Read(eventData->mPacketReceived); - } - else if (dataNode.m_name == AZ_CRC("PacketLost")) - { - dataNode.Read(eventData->mPacketLost); - } - else if (dataNode.m_name == AZ_CRC("PacketAcked")) - { - dataNode.Read(eventData->mPacketAcked); - } - else if (dataNode.m_name == AZ_CRC("PacketLoss")) - { - dataNode.Read(eventData->mPacketLoss); - } - else if (dataNode.m_name == AZ_CRC("rtt")) - { - dataNode.Read(eventData->mRTT); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.h b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.h deleted file mode 100644 index 069065e03e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataParser.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_CARRIER_DATAPARSER_H -#define DRILLER_CARRIER_DATAPARSER_H - -#include -#include "CarrierDataEvents.h" - -namespace Driller -{ - class CarrierDataAggregator; - - enum CarrierDataType - { - CDT_NONE, - CDT_STATISTICS, - CDT_LAST_SECOND, - CDT_EFFECTIVE_LAST_SECOND - }; - - class CarrierDataParser - : public AZ::Debug::DrillerHandlerParser - { - public: - // The parser will add events to a CarrierDataAggregator instance. - CarrierDataParser(CarrierDataAggregator* m_aggregator); - virtual ~CarrierDataParser(); - - // AZ::Debug::DrillerHandlerParser: Callbacks for entering, leaving and finding data - // while parsing the driller XML data. - AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName) override; - void OnExitTag(AZ::Debug::DrillerHandlerParser* handler, AZ::u32 tagName) override; - void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) override; - - private: - // The current tag type while parsing the driller XML data. - CarrierDataType m_currentType; - - // The aggregator where events are added as a result of parsing the XML data. - CarrierDataAggregator* m_aggregator; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.cpp b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.cpp deleted file mode 100644 index f7d456522a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include "CarrierDataEvents.h" -#include "CarrierDataAggregator.hxx" -#include "CarrierDataView.hxx" -#include "CarrierOperationTelemetryEvent.h" - -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -#include -#include -#include - -namespace Driller -{ - static AZ::s64 GetLargestDataValue(const CarrierDataView::DataPointList& dataPointList) - { - AZ::s64 maxDataValue = 0; - for (auto dataPoint = dataPointList.begin(); dataPoint != dataPointList.end(); dataPoint++) - { - if (dataPoint->second > maxDataValue) - { - maxDataValue = static_cast(dataPoint->second); - } - } - return maxDataValue; - } - - static void BuildEventList(const CarrierDataAggregator* aggr, - FrameNumberType startFrame, - FrameNumberType endFrame, - AZStd::vector& eventIdxList) - { - eventIdxList.clear(); - for (FrameNumberType frame = startFrame; frame <= endFrame; frame++) - { - size_t numEvents = aggr->NumOfEventsAtFrame(frame); - if (numEvents == 0) - { - continue; - } - - EventNumberType firstEventIdx = aggr->GetFirstIndexAtFrame(frame); - for (EventNumberType eventIdx = firstEventIdx; eventIdx < static_cast(firstEventIdx + numEvents); eventIdx++) - { - eventIdxList.push_back(eventIdx); - } - } - } - - static void GetEventIds(const CarrierDataAggregator* aggr, - FrameNumberType startFrame, - FrameNumberType endFrameIdx, - AZStd::set& ids) - { - ids.clear(); - for (FrameNumberType frameId = startFrame; frameId <= endFrameIdx; frameId++) - { - size_t numEvents = aggr->NumOfEventsAtFrame(frameId); - EventNumberType firstEventIndex = aggr->GetFirstIndexAtFrame(frameId); - for (EventNumberType eventIndex = firstEventIndex; eventIndex < static_cast(firstEventIndex + numEvents); eventIndex++) - { - CarrierDataEvent* event = static_cast(aggr->GetEvents()[eventIndex]); - ids.insert(event->mID); - } - } - } - - CarrierDataView::CarrierDataView(FrameNumberType startFrame, FrameNumberType endFrame, const CarrierDataAggregator* aggregator) - : QDialog() - , mStartFrame(0) - , mEndFrame(0) - , m_lifespanTelemetry("CarrierDataView") - { - // Create a window defined in CarrierDataView.ui. - m_gui = azcreate(Ui::CarrierDataView, ()); - m_gui->setupUi(this); - - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); - - mStartFrame = startFrame; - mEndFrame = endFrame; - mAggregator = aggregator; - - // Prepare the dialog. - show(); - raise(); - activateWindow(); - setFocus(); - - setWindowTitle(aggregator->GetDialogTitle()); - - // Find all unique ids and add them to the drop down box. - AZStd::set ids; - GetEventIds(aggregator, startFrame, endFrame, ids); - - for (auto id = ids.begin(); id != ids.end(); id++) - { - m_gui->Filter->addItem((*id).c_str()); - } - - QObject::connect(m_gui->Filter, SIGNAL(currentIndexChanged(int)), this, SLOT(OnCurrentFilterChanged())); - - // Update the charts based on the current filter. - OnCurrentFilterChanged(); - } - - CarrierDataView::~CarrierDataView() - { - azdestroy(m_gui); - } - - void CarrierDataView::OnCurrentFilterChanged() - { - AZStd::string currentId = AZStd::string(m_gui->Filter->currentText().toUtf8().constData()); - SetupAllCharts(currentId, mAggregator, mStartFrame, mEndFrame); - - CarrierOperationTelemetryEvent filterChanged; - filterChanged.SetAttribute("IPFilterChanged", ""); - filterChanged.Log(); - } - - void CarrierDataView::SetupAllCharts(AZStd::string id, - const CarrierDataAggregator* aggr, - FrameNumberType startFrame, - FrameNumberType endFrame) - { - AZStd::vector eventIdxList; - BuildEventList(aggr, startFrame, endFrame, eventIdxList); - - DataPointList send; - DataPointList recv; - DataPointList effectiveSend; - DataPointList effectiveRecv; - DataPointList pktSend; - DataPointList pktRecv; - DataPointList rtt; - DataPointList loss; - - EventNumberType eventIndex = 0; - for (auto eventItr = eventIdxList.begin(); eventItr != eventIdxList.end(); eventItr++) - { - EventNumberType realEventIndex = *eventItr; - CarrierDataEvent* event = static_cast(aggr->GetEvents()[realEventIndex]); - - if (event->mID.compare(id) != 0) - { - continue; - } - - // Total bytes sent and received. - send.push_back(DataPoint(eventIndex, static_cast(event->mLastSecond.mDataSend))); - recv.push_back(DataPoint(eventIndex, static_cast(event->mLastSecond.mDataReceived))); - // Effective bytes sent and received ( - effectiveSend.push_back(DataPoint(eventIndex, static_cast(event->mEffectiveLastSecond.mDataSend))); - effectiveRecv.push_back(DataPoint(eventIndex, static_cast(event->mEffectiveLastSecond.mDataReceived))); - // Total packets send and received. - pktSend.push_back(DataPoint(eventIndex, static_cast(event->mLastSecond.mPacketSend))); - pktRecv.push_back(DataPoint(eventIndex, static_cast(event->mLastSecond.mPacketReceived))); - // RTT - rtt.push_back(DataPoint(eventIndex, event->mLastSecond.mRTT)); - // Loss - loss.push_back(DataPoint(eventIndex, event->mLastSecond.mPacketLoss)); - - eventIndex++; - } - - SetupDualBytesChart(m_gui->sendRecvDataStrip, send, recv); - SetupDualBytesChart(m_gui->effectiveSendRecvDataStrip, effectiveSend, effectiveRecv); - SetupDualPacketChart(m_gui->packetSendRecvDataStrip, pktSend, pktRecv); - SetupTimeChart(m_gui->rttDataStrip, rtt); - } - - void CarrierDataView::SetupDualBytesChart(StripChart::DataStrip* chart, const DataPointList& bytes0, const DataPointList& bytes1) - { - chart->Reset(); - AZ::s64 maxSend = GetLargestDataValue(bytes0); - AZ::s64 maxRecv = GetLargestDataValue(bytes1); - chart->AddAxis("Seconds", 0.0f, static_cast(bytes0.size() > bytes1.size() ? bytes0.size() : bytes1.size()), false); - chart->AddAxis("Bytes/second", 0.0f, (maxSend > maxRecv ? maxSend : maxRecv) * 1.2f, false); - - int sendChannel = chart->AddChannel("Bytes0"); - int recvChannel = chart->AddChannel("Bytes1"); - chart->SetChannelColor(sendChannel, QColor(0, 255, 0)); - chart->SetChannelStyle(sendChannel, StripChart::Channel::STYLE_CONNECTED_LINE); - chart->SetChannelColor(recvChannel, QColor(255, 0, 0)); - chart->SetChannelStyle(recvChannel, StripChart::Channel::STYLE_CONNECTED_LINE); - - for (auto dataPoint = bytes0.begin(); dataPoint != bytes0.end(); dataPoint++) - { - chart->AddData(sendChannel, 0, static_cast(dataPoint->first), dataPoint->second); - } - - for (auto dataPoint = bytes1.begin(); dataPoint != bytes1.end(); dataPoint++) - { - chart->AddData(recvChannel, 0, static_cast(dataPoint->first), dataPoint->second); - } - } - - void CarrierDataView::SetupDualPacketChart(StripChart::DataStrip* chart, const DataPointList& packets0, const DataPointList& packets1) - { - chart->Reset(); - AZ::s64 maxSend = GetLargestDataValue(packets0); - AZ::s64 maxRecv = GetLargestDataValue(packets1); - chart->AddAxis("Seconds", 0.0f, static_cast(packets0.size() > packets1.size() ? packets0.size() : packets1.size()), false); - chart->AddAxis("Packets/second", 0.0f, (maxSend > maxRecv ? maxSend : maxRecv) * 1.2f, false); - - int sendChannel = chart->AddChannel("Bytes0"); - int recvChannel = chart->AddChannel("Bytes1"); - chart->SetChannelColor(sendChannel, QColor(0, 255, 0)); - chart->SetChannelStyle(sendChannel, StripChart::Channel::STYLE_CONNECTED_LINE); - chart->SetChannelColor(recvChannel, QColor(255, 0, 0)); - chart->SetChannelStyle(recvChannel, StripChart::Channel::STYLE_CONNECTED_LINE); - - for (auto dataPoint = packets0.begin(); dataPoint != packets0.end(); dataPoint++) - { - chart->AddData(sendChannel, 0, static_cast(dataPoint->first), dataPoint->second); - } - - for (auto dataPoint = packets1.begin(); dataPoint != packets1.end(); dataPoint++) - { - chart->AddData(recvChannel, 0, static_cast(dataPoint->first), dataPoint->second); - } - } - - void CarrierDataView::SetupTimeChart(StripChart::DataStrip* chart, const DataPointList& time) - { - chart->Reset(); - - AZ::s64 maxRTT = GetLargestDataValue(time); - chart->AddAxis("Seconds", 0.0f, static_cast(time.size()), false); - chart->AddAxis("Milliseconds", 0.0f, maxRTT * 1.2f); - - int channel = chart->AddChannel("RTT"); - chart->SetChannelColor(channel, QColor(255, 0, 255)); - chart->SetChannelStyle(channel, StripChart::Channel::STYLE_CONNECTED_LINE); - - for (auto dataPoint = time.begin(); dataPoint != time.end(); dataPoint++) - { - chart->AddData(channel, 0, static_cast(dataPoint->first), dataPoint->second); - } - } - - void CarrierDataView::SetupPercentageChart(StripChart::DataStrip* chart, const DataPointList& percentage) - { - chart->Reset(); - - chart->AddAxis("Seconds", 0.0f, static_cast(percentage.size()), false); - chart->AddAxis("Percentage", 0.0f, 100.0f); - - int channel = chart->AddChannel("Loss"); - chart->SetChannelColor(channel, QColor(255, 255, 255)); - chart->SetChannelStyle(channel, StripChart::Channel::STYLE_CONNECTED_LINE); - - for (auto dataPoint = percentage.begin(); dataPoint != percentage.end(); dataPoint++) - { - chart->AddData(channel, 0, static_cast(dataPoint->first), dataPoint->second); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.hxx b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.hxx deleted file mode 100644 index 114954a15a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.hxx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CARRIER_DATAVIEW_H -#define CARRIER_DATAVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Ui -{ - class CarrierDataView; -} - -namespace Driller -{ - class CarrierDataAggregator; - - class CarrierDataView - : public QDialog - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(CarrierDataView, AZ::SystemAllocator, 0); - CarrierDataView(FrameNumberType startFrame, FrameNumberType endFrame, const CarrierDataAggregator* aggr); - virtual ~CarrierDataView(); - - // A data point is made up of a x and y value (first and second respectively) - // which can be plotted onto a XY chart. - typedef AZStd::pair DataPoint; - typedef AZStd::vector DataPointList; - - public slots: - void OnCurrentFilterChanged(); - - private: - void SetupAllCharts(AZStd::string id, - const CarrierDataAggregator* aggr, - FrameNumberType startFrame, - FrameNumberType endFrame); - - void SetupDualBytesChart(StripChart::DataStrip* chart, const DataPointList& bytes0, const DataPointList& bytes1); - void SetupDualPacketChart(StripChart::DataStrip* chart, const DataPointList& packets1, const DataPointList& packets2); - void SetupTimeChart(StripChart::DataStrip* chart, const DataPointList& time); - void SetupPercentageChart(StripChart::DataStrip* chart, const DataPointList& percentage); - - const CarrierDataAggregator* mAggregator; - FrameNumberType mStartFrame, mEndFrame; - - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - - // A QT widget defined in CarrierDataView.ui and compiled into ui_CarrierDataView.hpp. - Ui::CarrierDataView* m_gui; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.ui b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.ui deleted file mode 100644 index 915744e1a7..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierDataView.ui +++ /dev/null @@ -1,327 +0,0 @@ - - - CarrierDataView - - - - 0 - 0 - 1000 - 825 - - - - Carrier Data View - - - - - - - - - 0 - 32 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - - - - - - - - 0 - 1 - - - - - 0 - 128 - - - - - - 70 - 20 - 111 - 20 - - - - - 10 - 75 - true - - - - false - - - QLabel { color : rgb(0, 255, 0); } - - - Total Send - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 70 - 40 - 111 - 20 - - - - - 10 - 75 - true - - - - QLabel { color : rgb(255, 0, 0); } - - - Total Received - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 0 - 1 - - - - - 0 - 128 - - - - - - 70 - 20 - 141 - 20 - - - - - 10 - 75 - true - - - - false - - - QLabel { color : rgb(0, 255, 0); } - - - User Data Send - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 70 - 40 - 141 - 20 - - - - - 10 - 75 - true - - - - QLabel { color : rgb(255, 0, 0); } - - - User Data Received - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 0 - 1 - - - - - 0 - 128 - - - - - - 70 - 20 - 141 - 20 - - - - - 10 - 75 - true - - - - false - - - QLabel { color : rgb(0, 255, 0); } - - - Packets Send - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - 70 - 40 - 141 - 20 - - - - - 10 - 75 - true - - - - QLabel { color : rgb(255, 0, 0); } - - - Packets Received - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - 0 - 1 - - - - - 0 - 128 - - - - - - 70 - 20 - 181 - 20 - - - - - 10 - 75 - true - - - - false - - - QLabel { color : rgb(255, 0, 255); } - - - Return Trip Time (Latency) - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - - - - - StripChart::DataStrip - QWidget -
../StripChart.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierOperationTelemetryEvent.h b/Code/Tools/Standalone/Source/Driller/Carrier/CarrierOperationTelemetryEvent.h deleted file mode 100644 index d4c7d004ef..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Carrier/CarrierOperationTelemetryEvent.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef DRILLER_CARRIER_CARRIEROPERATIONTELEMETRYEVENT_H -#define DRILLER_CARRIER_CARRIEROPERATIONTELEMETRYEVENT_H - -#include "Source/Telemetry/TelemetryEvent.h" - -namespace Driller -{ - class CarrierOperationTelemetryEvent - : public Telemetry::TelemetryEvent - { - public: - CarrierOperationTelemetryEvent() - : Telemetry::TelemetryEvent("CarrierDataViewOperation") - { - } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.cpp b/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.cpp deleted file mode 100644 index 95fb586500..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.cpp +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "Source/Driller/ChannelConfigurationDialog.hxx" -#include - -namespace Driller -{ - ChannelConfigurationDialog::ChannelConfigurationDialog(QWidget* parent) - : QDialog(parent) - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint); - - QMargins margins(0, 0, 0, 0); - setContentsMargins(margins); - } - - ChannelConfigurationDialog::~ChannelConfigurationDialog() - { - emit DialogClosed(this); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.hxx b/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.hxx deleted file mode 100644 index 1baf205077..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationDialog.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once -#ifndef PROFILER_CHANNELCONFIGURATIONDIALOG_H -#define PROFILER_CHANNELCONFIGURATIONDIALOG_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#endif - -namespace Driller -{ - class ChannelConfigurationDialog - : public QDialog - { - Q_OBJECT; - - public: - AZ_CLASS_ALLOCATOR(ChannelConfigurationDialog,AZ::SystemAllocator,0); - - ChannelConfigurationDialog(QWidget* parent = nullptr); - ~ChannelConfigurationDialog(); - - signals: - - void DialogClosed(QDialog* dialog); - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.cpp b/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.cpp deleted file mode 100644 index 689b87f2b2..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include -#include - -namespace Driller -{ - /////////////////////////////// - // ChannelConfigurationWidget - /////////////////////////////// - - ChannelConfigurationWidget::ChannelConfigurationWidget(QWidget* parent) - : QWidget(parent) - { - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.hxx b/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.hxx deleted file mode 100644 index 3f64e1b52c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelConfigurationWidget.hxx +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once -#ifndef PROFILER_CHANNELCONFIGURATIONWIDGET_H -#define PROFILER_CHANNELCONFIGURATIONWIDGET_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#endif - -namespace Driller -{ - class ChannelConfigurationWidget - : public QWidget - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(ChannelConfigurationWidget, AZ::SystemAllocator,0); - - ChannelConfigurationWidget(QWidget* parent = nullptr); - ~ChannelConfigurationWidget() = default; - - public slots: - signals: - void ConfigurationChanged(); - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/ChannelControl.cpp b/Code/Tools/Standalone/Source/Driller/ChannelControl.cpp deleted file mode 100644 index a98f93be98..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelControl.cpp +++ /dev/null @@ -1,484 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ChannelControl.hxx" -#include - -#include "Annotations/Annotations.hxx" -#include "ChannelDataView.hxx" -#include "ChannelProfilerWidget.hxx" -#include "DrillerAggregator.hxx" -#include "DrillerMainWindowMessages.h" -#include "Source/Driller/ChannelConfigurationDialog.hxx" -#include "Source/Driller/ChannelConfigurationWidget.hxx" -#include "Source/Driller/CollapsiblePanel.hxx" -#include "Source/Driller/CustomizeCSVExportWidget.hxx" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -namespace Driller -{ - ChannelControl::ChannelControl(const char* channelName, AnnotationsProvider* ptrAnnotations, QWidget* parent, Qt::WindowFlags flags) - : QWidget(parent, flags) - , m_isSetup(false) - , m_captureMode(CaptureMode::Unknown) - , m_channelId(channelName) - , m_configurationDialog(nullptr) - { - setupUi(this); - - m_State.m_EndFrame = -1; - m_State.m_FramesInView = 10; // magic numbers (this matches the default drop-down menu option) - m_State.m_ContractedHeight = false; - m_State.m_ScrubberFrame = 0; - m_State.m_FrameOffset = 0; - m_State.m_LoopBegin = 0; - m_State.m_LoopEnd = 0; - - this->channelName->setText(channelName ? channelName : "Channel Name Here"); - - channelDataView->RegisterToChannel(this, ptrAnnotations); - channelDataView->setAutoFillBackground(true); - - configChannel->setVisible(false); - - connect(channelDataView, SIGNAL(InformOfMouseClick(Qt::MouseButton, FrameNumberType, FrameNumberType, int)), SIGNAL(InformOfMouseClick(Qt::MouseButton, FrameNumberType, FrameNumberType, int))); - connect(channelDataView, SIGNAL(InformOfMouseMove(FrameNumberType, FrameNumberType, int)), SIGNAL(InformOfMouseMove(FrameNumberType, FrameNumberType, int))); - connect(channelDataView, SIGNAL(InformOfMouseRelease(Qt::MouseButton, FrameNumberType, FrameNumberType, int)), SIGNAL(InformOfMouseRelease(Qt::MouseButton, FrameNumberType, FrameNumberType, int))); - connect(channelDataView, SIGNAL(InformOfMouseWheel(FrameNumberType, int, FrameNumberType, int)), SIGNAL(InformOfMouseWheel(FrameNumberType, int, FrameNumberType, int))); - connect(configChannel, SIGNAL(clicked()), SLOT(OnConfigureChannel())); - - ConfigureUI(); - } - - ChannelControl::~ChannelControl() - { - if (m_configurationDialog) - { - m_configurationDialog->close(); - } - m_configurationDialog = nullptr; - - QList::iterator iter = m_OpenDrills.begin(); - while (iter != m_OpenDrills.end()) - { - delete *iter; - ++iter; - } - m_OpenDrills.clear(); - } - - bool ChannelControl::IsInCaptureMode(CaptureMode captureMode) const - { - return m_captureMode == captureMode; - } - - void ChannelControl::SetCaptureMode(CaptureMode captureMode) - { - if (captureMode != m_captureMode) - { - m_captureMode = captureMode; - - ConfigureUI(); - - emit OnCaptureModeChanged(m_captureMode); - } - } - - void ChannelControl::OnContractedToggled(bool toggleState) - { - (void)toggleState; - - // We're going to want to contract this eventually. So keeping the function - // to avoid unwiring all of the other methods, while we transition - /* - m_Contracted->setChecked(toggleState); - - if (toggleState) // MINIMIZED - { - m_State.m_ContractedHeight = true; - m_Info->hide(); - setFixedHeight(k_contractedSize); - QIcon eyecon(":/general/expand"); - m_Contracted->setIcon(eyecon); - } - else // NORMAL - { - m_State.m_ContractedHeight = false; - m_Info->show(); - this->setFixedHeight(k_expandedSize); - QIcon eyecon(":/general/contract"); - m_Contracted->setIcon(eyecon); - } - emit ExpandedContracted(); - */ - } - - void ChannelControl::OnSuccessfulDrillDown(QWidget* drillerWidget) - { - if (drillerWidget) - { - connect(drillerWidget, SIGNAL(destroyed(QObject*)), this, SLOT(OnDrillDestroyed(QObject*))); - m_OpenDrills.push_back(drillerWidget); - } - } - - void ChannelControl::OnDrillDestroyed(QObject* drill) - { - QWidget* qw = qobject_cast(drill); - m_OpenDrills.removeOne(qw); - } - - void ChannelControl::OnShowCommand() - { - //todo: phughes consider auto-hide toggle to control this behavior - - //QList::iterator ptiter = m_OpenDrillsPositions.begin(); - //QList::iterator iter = m_OpenDrills.begin(); - //while (iter != m_OpenDrills.end()) - //{ - // (*iter)->show(); - // (*iter)->move(*ptiter); - // ++iter; - // ++ptiter; - //} - } - - void ChannelControl::OnHideCommand() - { - //todo: phughes consider auto-hide toggle to control this behavior - - //m_OpenDrillsPositions.clear(); - //QList::iterator iter = m_OpenDrills.begin(); - //while (iter != m_OpenDrills.end()) - //{ - // if (*iter) - // { - // m_OpenDrillsPositions.push_back((*iter)->pos()); - // (*iter)->hide(); - // } - // ++iter; - //} - } - - bool ChannelControl::IsSetup() const - { - return m_isSetup; - } - - void ChannelControl::SignalSetup() - { - m_isSetup = true; - - ConfigureUI(); - } - - bool ChannelControl::IsActive() const - { - bool isActive = false; - - for (ChannelProfilerWidget* profiler : m_profilerWidgets) - { - if (profiler->IsActive()) - { - isActive = true; - break; - } - } - - return isActive; - } - - const AZStd::list< ChannelProfilerWidget* >& ChannelControl::GetProfilers() const - { - return m_profilerWidgets; - } - - ChannelProfilerWidget* ChannelControl::GetMainProfiler() const - { - ChannelProfilerWidget* retVal = nullptr; - - for (ChannelProfilerWidget* profiler : m_profilerWidgets) - { - if (profiler->IsActive()) - { - retVal = profiler; - break; - } - } - - return retVal; - } - - ChannelProfilerWidget* ChannelControl::AddAggregator(Aggregator* aggregator) - { - ChannelProfilerWidget* retVal = nullptr; - - for (ChannelProfilerWidget* profiler : m_profilerWidgets) - { - if (profiler->GetID() == aggregator->GetID()) - { - AZ_Warning("ChannelControl", false, "Trying to register two aggregators with the same ID"); - retVal = profiler; - break; - } - } - - if (retVal == nullptr) - { - retVal = aznew ChannelProfilerWidget(this, aggregator); - - if (retVal != nullptr) - { - ConnectProfilerWidget(retVal); - - profilerLayout->addWidget(retVal); - m_profilerWidgets.push_back(retVal); - - aggregator->AnnotateChannelView(channelDataView); - - if (aggregator->HasConfigurations()) - { - configChannel->setVisible(true); - } - - connect(aggregator, SIGNAL(NormalizedRangeChanged()), SLOT(OnNormalizedRangeChanged())); - } - } - - return retVal; - } - - bool ChannelControl::RemoveAggregator(Aggregator* aggregator) - { - bool removed = false; - - for (auto profilerIter = m_profilerWidgets.begin(); - profilerIter != m_profilerWidgets.end(); - ++profilerIter) - { - if ((*profilerIter)->GetID() == aggregator->GetID()) - { - removed = true; - m_profilerWidgets.erase(profilerIter); - break; - } - } - - AZ_Warning("ChannelControl", removed, "Trying to remove aggregator from the wrong Channel Control"); - return removed; - } - - void ChannelControl::SetAllProfilersEnabled(bool enabled) - { - for (ChannelProfilerWidget* profiler : m_profilerWidgets) - { - profiler->SetIsActive(enabled); - } - } - - AZ::Crc32 ChannelControl::GetChannelId() const - { - return m_channelId; - } - - void ChannelControl::SetEndFrame(FrameNumberType endFrame) - { - channelDataView->DirtyGraphData(); - m_State.m_EndFrame = endFrame; - channelDataView->update(); - } - - void ChannelControl::SetSliderOffset(FrameNumberType frameOffset) - { - channelDataView->DirtyGraphData(); - m_State.m_FrameOffset = frameOffset; - //AZ_TracePrintf("Driller"," SetSliderOffset %d = %d - %d\n", m_State.m_FrameOffset, m_State.m_EndFrame, frame); - channelDataView->update(); - } - - void ChannelControl::SetLoopBegin(FrameNumberType frameNum) - { - if (m_State.m_LoopBegin != frameNum) - { - m_State.m_LoopBegin = frameNum; - - FrameNumberType lastFrame = m_State.m_FrameOffset + m_State.m_FramesInView - 1; - - if (frameNum < m_State.m_FrameOffset) - { - emit RequestScrollToFrame(frameNum); - } - else if (frameNum > lastFrame) - { - emit RequestScrollToFrame(m_State.m_FrameOffset + (frameNum - lastFrame)); - } - - channelDataView->update(); - } - } - void ChannelControl::SetLoopEnd(FrameNumberType frameNum) - { - if (m_State.m_LoopEnd != frameNum) - { - m_State.m_LoopEnd = frameNum; - - FrameNumberType lastFrame = m_State.m_FrameOffset + m_State.m_FramesInView - 1; - - if (frameNum < m_State.m_FrameOffset) - { - emit RequestScrollToFrame(frameNum); - } - else if (frameNum > lastFrame) - { - emit RequestScrollToFrame(m_State.m_FrameOffset + (frameNum - lastFrame)); - } - - channelDataView->update(); - } - } - - void ChannelControl::SetScrubberFrame(FrameNumberType frameNum) - { - if (m_State.m_ScrubberFrame != frameNum) - { - m_State.m_ScrubberFrame = frameNum; - - FrameNumberType lastFrame = m_State.m_FrameOffset + m_State.m_FramesInView - 1; - - if (frameNum < m_State.m_FrameOffset) - { - emit RequestScrollToFrame(frameNum); - } - else if (frameNum > lastFrame) - { - emit RequestScrollToFrame(m_State.m_FrameOffset + (frameNum - lastFrame)); - } - - channelDataView->update(); - } - } - - void ChannelControl::SetDataPointsInView(FrameNumberType count) - { - m_State.m_FramesInView = count; - channelDataView->DirtyGraphData(); - channelDataView->update(); - } - - void ChannelControl::OnRefreshView() - { - channelDataView->update(); - } - - void ChannelControl::OnActivationChanged(ChannelProfilerWidget* profilerWidget, bool activated) - { - if (activated) - { - profilerWidget->GetAggregator()->AnnotateChannelView(channelDataView); - } - else - { - profilerWidget->GetAggregator()->RemoveChannelAnnotation(channelDataView); - } - - channelDataView->DirtyGraphData(); - channelDataView->update(); - } - - void ChannelControl::OnConfigureChannel() - { - if (m_configurationDialog == nullptr) - { - m_configurationDialog = aznew ChannelConfigurationDialog(); - QVBoxLayout* layout = new QVBoxLayout(); - - QMargins contentMargins(3,5,3,5); - layout->setContentsMargins(contentMargins); - layout->setSpacing(5); - - for (ChannelProfilerWidget* profilerWidget : m_profilerWidgets) - { - if (profilerWidget->IsActive()) - { - ChannelConfigurationWidget* configurationWidget = profilerWidget->CreateConfigurationWidget(); - - if (configurationWidget) - { - connect(configurationWidget, SIGNAL(ConfigurationChanged()), SLOT(OnConfigurationChanged())); - layout->addWidget(configurationWidget); - } - } - } - - m_configurationDialog->setLayout(layout); - m_configurationDialog->show(); - m_configurationDialog->setFocus(); - - connect(m_configurationDialog, SIGNAL(DialogClosed(QDialog*)), SLOT(OnDialogClosed(QDialog*))); - - m_configurationDialog->setWindowTitle(QString("%1's Channel Configurations.").arg(channelName->text())); - } - - if (m_configurationDialog->isMinimized()) - { - m_configurationDialog->showNormal(); - } - - m_configurationDialog->raise(); - m_configurationDialog->activateWindow(); - } - - void ChannelControl::OnDialogClosed(QDialog* dialog) - { - if (m_configurationDialog == dialog) - { - m_configurationDialog = nullptr; - } - } - - void ChannelControl::OnConfigurationChanged() - { - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - for (ChannelProfilerWidget* profilerWidget : m_profilerWidgets) - { - profilerWidget->GetAggregator()->OnConfigurationChanged(); - } - - // Force the channel data view to regrab all of the aggregator data. - channelDataView->RefreshGraphData(); - } - } - - void ChannelControl::OnNormalizedRangeChanged() - { - // Only want to allow this while we are inspecting. - // Otherwise just too much noise with the incoming data. - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - channelDataView->RefreshGraphData(); - } - } - - void ChannelControl::ConnectProfilerWidget(ChannelProfilerWidget* profilerWidget) - { - connect(this, SIGNAL(OnCaptureModeChanged(CaptureMode)), profilerWidget, SLOT(SetCaptureMode(CaptureMode))); - - connect(profilerWidget, SIGNAL(OnActivationChanged(ChannelProfilerWidget*, bool)), this, SLOT(OnActivationChanged(ChannelProfilerWidget*, bool))); - - profilerWidget->SetCaptureMode(m_captureMode); - } - - void ChannelControl::ConfigureUI() - { - if (IsSetup()) - { - configChannel->setEnabled(!IsInCaptureMode(CaptureMode::Capturing)); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChannelControl.hxx b/Code/Tools/Standalone/Source/Driller/ChannelControl.hxx deleted file mode 100644 index 4da56bd5f4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelControl.hxx +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CHANNEL_CONTROL_H -#define CHANNEL_CONTROL_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include - -#include "DrillerNetworkMessages.h" - -#include "Source/Driller/DrillerDataTypes.h" - -// Generated Files -#include -#endif - -namespace Driller -{ - class AnnotationsProvider; - class ChannelConfigurationDialog; - - /* - Channel Control intermediates between one data Aggregator, the application's main window, and the renderer. - This maintains state used by the renderer and passes changes both up and down via signal/slot. - */ - - class ChannelControl - : public QWidget - , private Ui::ChannelControl - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(ChannelControl,AZ::SystemAllocator,0); - ChannelControl( const char* channelName, AnnotationsProvider* ptrAnnotations, QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~ChannelControl(void); - - struct - { - FrameNumberType m_EndFrame; - FrameNumberType m_FramesInView; - int m_ContractedHeight; - FrameNumberType m_ScrubberFrame; - FrameNumberType m_FrameOffset; - FrameNumberType m_LoopBegin; - FrameNumberType m_LoopEnd; - } m_State; - - bool m_isLive; - - QList m_OpenDrills; - QList m_OpenDrillsPositions; - - bool IsSetup() const; - void SignalSetup(); - - bool IsActive() const; - const AZStd::list< ChannelProfilerWidget* >& GetProfilers() const; - - // Temporary solution, since eventually we'll want to display all of the information - // we have at once. For now, since we can only have one. Get a "main" window. - ChannelProfilerWidget* GetMainProfiler() const; - ChannelProfilerWidget* AddAggregator(Aggregator* aggregator); - bool RemoveAggregator(Aggregator* aggregator); - - void SetAllProfilersEnabled(bool enabled); - AZ::Crc32 GetChannelId() const; - - void SetDataPointsInView( FrameNumberType count ); - void SetEndFrame( FrameNumberType frame ); - void SetSliderOffset( FrameNumberType frame ); - void SetLoopBegin( FrameNumberType frame ); - void SetLoopEnd( FrameNumberType frame ); - - bool IsInCaptureMode(CaptureMode captureMode) const; - - public slots: - void SetCaptureMode(CaptureMode captureMode); - void OnContractedToggled( bool toggleState ); - void OnSuccessfulDrillDown(QWidget* drillerWidget); - void SetScrubberFrame( FrameNumberType frame ); - void OnDrillDestroyed(QObject *drill); - void OnShowCommand(); - void OnHideCommand(); - void OnRefreshView(); - void OnActivationChanged(ChannelProfilerWidget*,bool activated); - void OnConfigureChannel(); - void OnDialogClosed(QDialog* dialog); - - void OnConfigurationChanged(); - void OnNormalizedRangeChanged(); - - signals: - - void OnCaptureModeChanged(CaptureMode captureMode); - void RequestScrollToFrame( FrameNumberType frame ); - void InformOfMouseClick(Qt::MouseButton button, FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseMove( FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseRelease(Qt::MouseButton button, FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseWheel( FrameNumberType frame, int wheelAmount, FrameNumberType range, int modifiers ); - QWidget* DrillDownRequest(FrameNumberType atFrame); - void OptionsRequest(); - void ExpandedContracted(); - - void AddConfigurationWidgets(QLayout* configurationLayout); - - QString GetInspectionFileName() const; - - private: - - void ConnectProfilerWidget(ChannelProfilerWidget* profilerWidget); - void ConfigureUI(); - - bool m_isSetup; - - CaptureMode m_captureMode; - AZ::Crc32 m_channelId; - AZStd::list< ChannelProfilerWidget* > m_profilerWidgets; - - ChannelConfigurationDialog* m_configurationDialog; - }; -} - - -#endif // CHANNEL_CONTROL_H diff --git a/Code/Tools/Standalone/Source/Driller/ChannelControl.ui b/Code/Tools/Standalone/Source/Driller/ChannelControl.ui deleted file mode 100644 index 165e00e64b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelControl.ui +++ /dev/null @@ -1,218 +0,0 @@ - - - ChannelControl - - - - 0 - 0 - 1023 - 74 - - - - - 0 - 0 - - - - Form - - - true - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 250 - 0 - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 3 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 5 - - - 0 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 14 - - - - - - - - - - - - 0 - 0 - - - - ... - - - - :/driller/settings_icon:/driller/settings_icon - - - - - - - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 5 - - - 0 - - - 0 - - - 0 - - - - - 5 - - - 5 - - - 0 - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - Driller::ChannelDataView - QWidget -
Source/Driller/ChannelDataView.hxx
- 1 -
-
- - - - -
diff --git a/Code/Tools/Standalone/Source/Driller/ChannelDataView.cpp b/Code/Tools/Standalone/Source/Driller/ChannelDataView.cpp deleted file mode 100644 index 27922f47a3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelDataView.cpp +++ /dev/null @@ -1,875 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -#include "ChannelDataView.hxx" -#include - -#include "ChannelControl.hxx" -#include "ChannelProfilerWidget.hxx" -#include "DrillerAggregator.hxx" -#include "Annotations/Annotations.hxx" - -#include -#include -#include -#include -#include - -namespace Driller -{ - static const int k_contractedSize = 28; - static const int k_expandedSize = 64; - static const int k_textWidth = 128; - - static const int k_barHeight = 5; - - //////////////////////// - // AggregatorDataPoint - //////////////////////// - AggregatorDataPoint::AggregatorDataPoint() - : m_isActive(true) - , m_isShowingOverlay(false) - , m_shouldOutline(false) - { - } - - AggregatorDataPoint::AggregatorDataPoint(QRect rectangle, ChannelProfilerWidget* profilerWidget) - : m_visualBlock(rectangle) - , m_isActive(true) - , m_isShowingOverlay(false) - , m_shouldOutline(false) - - { - m_combinedProfilers.insert(profilerWidget); - } - - void AggregatorDataPoint::Draw(QPainter& painter, int leftEdge, float barWidth) - { - QColor drawColor; - QColor outlineColor; - - m_isActive = false; - - for (ChannelProfilerWidget* currentProfiler : m_combinedProfilers) - { - if (currentProfiler->IsActive()) - { - if (m_isActive) - { - drawColor = QColor(255, 255, 255); - outlineColor = QColor(255, 255, 0); - break; - } - else - { - m_isActive = true; - drawColor = currentProfiler->GetAggregator()->GetColor(); - - // right now this should never be used. If it eventually is used, we'll probably - // want to add a flow to the aggregators to pass along this color. For now - // some silly wrapping to do something noticeable. - outlineColor = QColor((drawColor.red() + 100) % 255, (drawColor.green() + 100) % 255, (drawColor.blue() + 100) % 255); - } - } - } - - if (m_isActive) - { - const int upAmount = static_cast(ceilf(k_barHeight * 0.5f)); - - int centerHeight = m_visualBlock.center().y(); - int topEdge = static_cast(centerHeight - upAmount); - - if (m_shouldOutline) - { - static const int k_outlineSize = 1; - - painter.fillRect( - leftEdge, - topEdge, - static_cast(barWidth), - k_barHeight, - outlineColor); - - painter.fillRect( - leftEdge + k_outlineSize, - (int)topEdge + k_outlineSize, - (int)barWidth - (2 * k_outlineSize), // overdraw on dense data > 1 event per pixel, optimize later - k_barHeight - (2 * k_outlineSize), - drawColor); - } - else - { - painter.fillRect( - leftEdge, - topEdge, - static_cast(barWidth), - k_barHeight, - drawColor); - } - } - } - - bool AggregatorDataPoint::IntersectsDataPoint(const AggregatorDataPoint& dataPoint) - { - return m_visualBlock.intersects(dataPoint.m_visualBlock); - } - - bool AggregatorDataPoint::ContainsPoint(const QPoint& point) - { - // Don't want to collide if we aren't visible. - if (m_isActive) - { - // Our Visual block's horizontal information is only valid when it is created. - // After that we lazily update information, so the only valid information that the block maintins is the vertical. - // So we're going to rely on the DataView to manage the horizontal collision, and we'll manage the vertical. - return (m_visualBlock.bottom() > point.y() && m_visualBlock.top() <= point.y()); - } - else - { - return false; - } - } - - void AggregatorDataPoint::AddAggregatorDataPoint(const AggregatorDataPoint& dataPoint) - { - m_drawColor = QColor(255, 255, 255); - - // dataPointBottomRight - QPoint dpBR = dataPoint.m_visualBlock.bottomRight(); - - // dataPointTopLeft - QPoint dpTL = dataPoint.m_visualBlock.topLeft(); - - // visualBlockBottomRight - QPoint vbBR = m_visualBlock.bottomRight(); - - // visualBlockTopLeft - QPoint vbTL = m_visualBlock.topLeft(); - - QPoint bottomRight(AZStd::GetMax(dpBR.x(), vbBR.x()), AZStd::GetMax(dpBR.y(), vbBR.y())); - QPoint topLeft(AZStd::GetMin(dpTL.x(), vbTL.x()), AZStd::GetMin(dpTL.y(), vbTL.y())); - - m_visualBlock = QRect(topLeft, bottomRight); - - m_combinedProfilers.insert(dataPoint.m_combinedProfilers.begin(), dataPoint.m_combinedProfilers.end()); - } - - bool AggregatorDataPoint::SetOverlayEnabled(bool enabled) - { - if (m_isShowingOverlay != enabled) - { - m_isShowingOverlay = enabled; - - if (m_isShowingOverlay) - { - int activeProfilers = 0; - QString toolTip = "Multiple Profiler(s)"; - - for (ChannelProfilerWidget* channelProfiler : m_combinedProfilers) - { - if (channelProfiler->IsActive()) - { - ++activeProfilers; - toolTip.append(QString("
- %1").arg(channelProfiler->GetName())); - } - } - - if (activeProfilers >= 2) - { - m_shouldOutline = true; - - // Since QToolTip::HideText doesn't seem to actually do anything, I'm trying to show - // a second tool tip while the first one is being displayed. However, - // if I use the same string for the tool tip, it doesn't actually update the position. - // But since the cursor has moved away from the original postion, it begins the countdown - // timer to hide the tool tip. Meaning, the new tool tip I was trying to generate hides. - // Going to alternatingly append a space to the end to force it to be different to - // avoid this nonsense. - { - static bool k_dumbToolTipHack = false; - if (k_dumbToolTipHack) - { - toolTip.append(" "); - } - - k_dumbToolTipHack = !k_dumbToolTipHack; - } - - QToolTip::showText(QCursor::pos(), toolTip); - } - else - { - m_shouldOutline = false; - } - } - else - { - m_shouldOutline = false; - QToolTip::hideText(); - } - - return true; - } - - return false; - } - - ///////////////// - // BudgetMarker - ///////////////// - - BudgetMarker::BudgetMarker(float value, QColor& drawColor) - : m_value(value) - , m_drawColor(drawColor) - { - } - - BudgetMarker::~BudgetMarker() - { - } - - float BudgetMarker::GetValue() const - { - return m_value; - } - - const QColor& BudgetMarker::GetColor() const - { - return m_drawColor; - } - - //////////////////// - // ChannelDataView - //////////////////// - ChannelDataView::ChannelDataView(QWidget* parent) - : QWidget(parent) - , m_Channel(nullptr) - , m_ptrAnnotations(nullptr) - , m_minFrame(-1) - , m_maxFrame(-1) - , m_highlightedFrame(-1) - , m_lastFrame(0) - , m_xOffset(0) - , m_initializeDrag(false) - , m_dragInitialized(false) - , m_shouldIgnorePoint(false) - , m_mouseGrabbed(false) - , m_dirtyGraph(true) - { - setAutoFillBackground(true); - setAttribute(Qt::WA_OpaquePaintEvent, true); - - setMouseTracking(true); - } - - ChannelDataView::~ChannelDataView() - { - } - - void ChannelDataView::RegisterToChannel(ChannelControl* channel, AnnotationsProvider* annotations) - { - m_Channel = channel; - m_ptrAnnotations = annotations; - } - - int ChannelDataView::FrameToPosition(FrameNumberType frameNumber) - { - int localOffset = 0; - FrameNumberType frameDifference = 0; - - if (frameNumber < m_Channel->m_State.m_FrameOffset) - { - frameDifference = frameNumber - m_Channel->m_State.m_FrameOffset; - } - else if (frameNumber >= (m_Channel->m_State.m_FrameOffset + (m_Channel->m_State.m_FramesInView - 1))) - { - frameDifference = frameNumber - (m_Channel->m_State.m_FrameOffset + (m_Channel->m_State.m_FramesInView - 1)); - localOffset = rect().width(); - } - - localOffset += static_cast(GetBarWidth() * frameDifference); - - return mapToGlobal(QPoint(localOffset, 0)).x(); - } - - FrameNumberType ChannelDataView::PositionToFrame(const QPoint& pt) - { - QRect wrect = rect(); - - FrameNumberType frame = m_Channel->m_State.m_FrameOffset + m_Channel->m_State.m_FramesInView - 1; - frame = frame <= m_Channel->m_State.m_EndFrame ? frame : m_Channel->m_State.m_EndFrame; - - float pct = (float)pt.x() / (float)wrect.width(); - FrameNumberType rCell = m_Channel->m_State.m_FramesInView - 1 - (int)((float)m_Channel->m_State.m_FramesInView * pct); - FrameNumberType retFrame = frame - rCell; - - return retFrame; - } - - FrameNumberType ChannelDataView::FramesPerPixel() - { - FrameNumberType range = PositionToFrame(QPoint(0, 0)) - PositionToFrame(QPoint(1, 0)); - return(range > 0 ? range : 1); - } - - float ChannelDataView::GetBarWidth() - { - return ((float)(rect().width()) / (float)(m_Channel->m_State.m_FramesInView)); - } - - void ChannelDataView::paintEvent(QPaintEvent* event) - { - (void)event; - - if (m_dirtyGraph) - { - m_dirtyGraph = false; - RecalculateGraphedPoints(); - } - - QPen pen; - pen.setWidth(1); - QBrush brush; - brush.setStyle(Qt::SolidPattern); - pen.setBrush(brush); - - QPainter painter(this); - - painter.setPen(pen); - painter.fillRect(rect(), Qt::black); - - FrameNumberType frame = m_Channel->m_State.m_FrameOffset + m_Channel->m_State.m_FramesInView - 1; - frame = frame <= m_Channel->m_State.m_EndFrame ? frame : m_Channel->m_State.m_EndFrame; - - QRect wrect = rect(); - - float barWidth = GetBarWidth(); - int barWidthHalf = (int)(barWidth / 2.0f); - float drawBarWidth = ((barWidth - 1.0f) < 1.0f ? 1.0f : (barWidth - 1.0f)); - - if (m_Channel->IsActive()) - { - // PLAYBACK LOOP MARKERS - if (m_Channel->m_State.m_LoopBegin >= frame - m_Channel->m_State.m_FramesInView) - { - float l = rect().right() - barWidth / 2.0f - 1 - barWidth * (frame - m_Channel->m_State.m_LoopBegin); - painter.fillRect((int)l, 0, 2, rect().height(), QColor(255, 255, 0, 255)); - } - if (m_Channel->m_State.m_LoopEnd >= frame - m_Channel->m_State.m_FramesInView) - { - float l = rect().right() - barWidth / 2.0f - 1 - barWidth * (frame - m_Channel->m_State.m_LoopEnd); - painter.fillRect((int)l, 0, 2, rect().height(), QColor(255, 255, 0, 255)); - } - } - - brush.setStyle(Qt::Dense2Pattern); - brush.setColor(Qt::red); - int wrectHeight = wrect.height() / (m_Channel->m_State.m_ContractedHeight ? 2 : 1); - - if (m_Channel->IsActive() && m_Channel->m_State.m_EndFrame) - { - // SCRUBBER - if (m_Channel->m_State.m_ScrubberFrame >= frame - m_Channel->m_State.m_FramesInView) - { - float l = rect().right()-GetBarWidth()/2.0f - 1 - GetBarWidth() * (frame - m_Channel->m_State.m_ScrubberFrame); - painter.fillRect( (int)l, 0, 2, rect().height(), brush ); - } - - float rightEdgeOfBar = (float)wrect.right(); - float leftEdgeOfBar = rightEdgeOfBar - barWidth; - - AZStd::list< ChannelProfilerWidget* > activeProfilers; - - for (ChannelProfilerWidget* profiler : m_Channel->GetProfilers()) - { - if (profiler->IsActive()) - { - activeProfilers.push_back(profiler); - } - } - - while (frame >= 0 && rightEdgeOfBar >= wrect.left()) - { - int actualLeftEdge = (int)floorf(leftEdgeOfBar); - - // Graph out precomputed points. - DataPointList& dataPointList = m_graphedPoints[frame]; - - for (AggregatorDataPoint& dataPoint : dataPointList) - { - dataPoint.Draw(painter, actualLeftEdge, drawBarWidth); - } - - // annotations? - AnnotationsProvider::ConstAnnotationIterator it = m_ptrAnnotations->GetFirstAnnotationForFrame(frame); - AnnotationsProvider::ConstAnnotationIterator endIt = m_ptrAnnotations->GetEnd(); - - if (it != endIt) - { - painter.fillRect(actualLeftEdge + barWidthHalf, 0, 1, wrectHeight, m_ptrAnnotations->GetColorForChannel(it->GetChannelCRC())); - //++it; - } - - --frame; - rightEdgeOfBar -= barWidth; - leftEdgeOfBar -= barWidth; - } - - // Styling the budget markers. - // Mildly ugly, but not a lot of pixels to work with - // to make it look better. - pen = QPen(Qt::black); - pen.setWidth(1); - - painter.setPen(pen); - brush.setStyle(Qt::BrushStyle::SolidPattern); - - // Budget Markers - for (BudgetMarkerMap::value_type& mapPair : m_budgetMarkers) - { - BudgetMarker& budgetMarker = mapPair.second; - - QColor drawColor = budgetMarker.GetColor(); - - QRect sizeRect = rect(); - int x = rect().left(); - float normalizedValue = ((budgetMarker.GetValue() + 1.0f) / 2.0f); - int y = static_cast(rect().bottom() - (rect().height() * normalizedValue)); - int width = rect().width(); - int height = 4; - brush.setColor(drawColor); - - // Want to make sure we always draw the entire box. - if (y > rect().bottom() - height) - { - y = rect().bottom() - height; - } - - painter.fillRect( - x, - y, - width, - height, - brush); - - painter.drawRect( - x, - y, - width, - height); - } - } - } - - void ChannelDataView::mouseMoveEvent(QMouseEvent* event) - { - if (m_Channel->IsInCaptureMode(CaptureMode::Capturing)) - { - return; - } - - if (m_Channel->IsActive()) - { - if (m_mouseGrabbed) - { - if (m_shouldIgnorePoint && event->globalPos() == m_centerPoint) - { - m_shouldIgnorePoint = false; - return; - } - - QPoint mousePoint = event->globalPos(); - int mouseDelta = (mousePoint.x() - m_centerPoint.x()); - - if (m_initializeDrag) - { - m_initializeDrag = false; - m_dragInitialized = true; - - QApplication::setOverrideCursor(QCursor(Qt::BlankCursor)); - - QRect screenGeometry = QApplication::primaryScreen()->geometry(); - m_centerPoint = screenGeometry.center(); - - mouseDelta = (mousePoint.x() - mapToGlobal(m_simulatedPoint).x()); - } - - m_simulatedPoint.setX(m_simulatedPoint.x() + mouseDelta); - - QPoint framePoint = m_simulatedPoint; - framePoint.setX(framePoint.x() + m_xOffset); - - FrameNumberType frame = PositionToFrame(framePoint); - FrameNumberType framesPerPixel = FramesPerPixel(); - - // raw frame, sanitized by the controller - emit InformOfMouseMove(frame, framesPerPixel, event->modifiers()); - event->ignore(); - - QRect boundingRect = rect(); - - m_shouldIgnorePoint = true; - QCursor::setPos(m_centerPoint); - m_xOffset += mouseDelta; - - if (!boundingRect.contains(m_simulatedPoint)) - { - m_simulatedPoint.setX(AZ::GetClamp(m_simulatedPoint.x(), boundingRect.left(), boundingRect.right())); - } - else - { - m_xOffset = 0; - } - - if (m_lastFrame != frame) - { - m_lastFrame = frame; - - if (framesPerPixel == 1) - { - int barWidth = static_cast(ceilf(GetBarWidth())); - m_xOffset %= barWidth; - } - else - { - m_xOffset = 0; - } - } - - // Can't scroll beyond the minimum frame. - if (m_lastFrame == 0 && m_xOffset < 0) - { - m_xOffset = 0; - } - // Can't scroll beyond the maximum frame. - else if (m_lastFrame == m_Channel->m_State.m_EndFrame && m_xOffset > 0) - { - m_xOffset = 0; - } - } - // If we aren't dragging, we need to deal with highlighting - else - { - QPoint pos = event->localPos().toPoint(); - - // This guy expects relative position to parent. Not local space. - FrameNumberType frameNumber = PositionToFrame(event->pos()); - - FramePointMapping::iterator dataPointIter = m_graphedPoints.find(frameNumber); - - if (dataPointIter != m_graphedPoints.end()) - { - if (frameNumber != m_highlightedFrame) - { - RemoveHighlight(); - } - - bool needsUpdate = false; - - DataPointList& dataPointList = dataPointIter->second; - AggregatorDataPoint* overlayPoint = nullptr; - - for (AggregatorDataPoint& dataPoint : dataPointList) - { - if (dataPoint.ContainsPoint(pos)) - { - m_highlightedFrame = frameNumber; - overlayPoint = &dataPoint; - } - else if (dataPoint.SetOverlayEnabled(false)) - { - needsUpdate = true; - } - } - - if (overlayPoint) - { - if (overlayPoint->SetOverlayEnabled(true)) - { - needsUpdate = true; - } - } - else - { - m_highlightedFrame = -1; - } - - if (needsUpdate) - { - update(); - } - } - else - { - RemoveHighlight(); - } - } - } - } - - void ChannelDataView::mousePressEvent(QMouseEvent* event) - { - if (!m_Channel->IsInCaptureMode(CaptureMode::Capturing) && m_Channel->IsActive()) - { - emit InformOfMouseClick(event->button(), PositionToFrame(event->pos()), FramesPerPixel(), event->modifiers()); - event->ignore(); - - // Only want to perform dragging actions on left clicks. - if (event->button() == Qt::LeftButton) - { - grabMouse(); - - m_initializeDrag = true; - m_simulatedPoint = event->pos(); - - m_mouseGrabbed = true; - m_xOffset = 0; - - m_lastFrame = m_Channel->m_State.m_ScrubberFrame; - } - } - } - - void ChannelDataView::mouseReleaseEvent(QMouseEvent* event) - { - if (!m_Channel->IsInCaptureMode(CaptureMode::Capturing) && m_Channel->IsActive()) - { - if (m_mouseGrabbed) - { - FrameNumberType frame = PositionToFrame(m_simulatedPoint); - emit InformOfMouseRelease(event->button(), frame, FramesPerPixel(), event->modifiers()); - event->ignore(); - - m_mouseGrabbed = false; - - if (m_dragInitialized) - { - m_shouldIgnorePoint = true; - - QCursor::setPos(mapToGlobal(m_simulatedPoint)); - QApplication::restoreOverrideCursor(); - } - - releaseMouse(); - } - } - } - - void ChannelDataView::wheelEvent(QWheelEvent* event) - { - if (event->angleDelta().y() == 0) - { - event->accept(); - return; - } - - emit InformOfMouseWheel(PositionToFrame(event->position().toPoint()), event->angleDelta().y(), FramesPerPixel(), event->modifiers()); - event->ignore(); - } - - void ChannelDataView::leaveEvent(QEvent* event) - { - (void)event; - RemoveHighlight(); - } - - void ChannelDataView::DirtyGraphData() - { - m_dirtyGraph = true; - } - - void ChannelDataView::RefreshGraphData() - { - for (ChannelProfilerWidget* profilerWidget : m_Channel->GetProfilers()) - { - profilerWidget->GetAggregator()->AnnotateChannelView(this); - } - - m_graphedPoints.clear(); - DirtyGraphData(); - update(); - } - - BudgetMarkerTicket ChannelDataView::AddBudgetMarker(float value, QColor color) - { - ++m_budgetMarkerCounter; - - if (m_budgetMarkerCounter == 0 || m_budgetMarkers.find(m_budgetMarkerCounter) != m_budgetMarkers.end()) - { - BudgetMarkerTicket startTicket = m_budgetMarkerCounter; - - do - { - ++m_budgetMarkerCounter; - } while ((m_budgetMarkerCounter == 0 || m_budgetMarkers.find(m_budgetMarkerCounter) != m_budgetMarkers.end()) && m_budgetMarkerCounter != startTicket); - - AZ_Assert(m_budgetMarkers.find(m_budgetMarkerCounter) == m_budgetMarkers.end(),"Ran out of tickets inside of budget marker creation."); - } - - m_budgetMarkers.insert(BudgetMarkerMap::value_type(m_budgetMarkerCounter, BudgetMarker(value, color))); - return m_budgetMarkerCounter; - } - - void ChannelDataView::RemoveBudgetMarker(BudgetMarkerTicket ticket) - { - m_budgetMarkers.erase(ticket); - } - - void ChannelDataView::resizeEvent(QResizeEvent* newSize) - { - QWidget::resizeEvent(newSize); - - // Graph data relies on the size of the graph, so we need to update it whenever we resize. - DirtyGraphData(); - } - - void ChannelDataView::RecalculateGraphedPoints() - { - FrameNumberType frame = m_Channel->m_State.m_FrameOffset + m_Channel->m_State.m_FramesInView - 1; - frame = AZ::GetMin(frame, m_Channel->m_State.m_EndFrame); - - QRect wrect = rect(); - int wrectHeight = wrect.height() / (m_Channel->m_State.m_ContractedHeight ? 2 : 1); - - float barWidth = GetBarWidth(); - - if (m_Channel->m_State.m_EndFrame) - { - float vRange = (float)(wrectHeight - k_barHeight); - float half = vRange / 2.0f; - - float rectBarWidth = (barWidth < 1.0f ? 1.0f : barWidth); - - float rightEdgeOfBar = (float)wrect.right(); - float leftEdgeOfBar = rightEdgeOfBar - barWidth; - - FrameNumberType newMax = frame; - - while (frame >= 0 && rightEdgeOfBar >= wrect.left()) - { - // If the frame is a new frame we need to parse it's data. - if (m_graphedPoints.find(frame) == m_graphedPoints.end()) - { - int actualLeftEdge = (int)floorf(leftEdgeOfBar); - int actualWidth = (int)floorf(rectBarWidth - 1.0f); - - if (actualWidth < 1) - { - actualWidth = 1; - } - - AZStd::list dataPoints; - - for (ChannelProfilerWidget* currentProfiler : m_Channel->GetProfilers()) - { - float vaf = currentProfiler->GetAggregator()->ValueAtFrame(frame); - int topOfBar = (int)(half - (vaf * half)); - - QRect drawRect(actualLeftEdge, topOfBar, actualWidth, k_barHeight); - - dataPoints.emplace_back(drawRect, currentProfiler); - } - - while (!dataPoints.empty()) - { - AggregatorDataPoint currentPoint = dataPoints.front(); - dataPoints.pop_front(); - - bool intersected = false; - AZStd::list::iterator aggregatorIter = dataPoints.begin(); - - do - { - intersected = false; - aggregatorIter = dataPoints.begin(); - - while (aggregatorIter != dataPoints.end()) - { - if (currentPoint.IntersectsDataPoint((*aggregatorIter))) - { - intersected = true; - currentPoint.AddAggregatorDataPoint((*aggregatorIter)); - aggregatorIter = dataPoints.erase(aggregatorIter); - } - else - { - ++aggregatorIter; - } - } - } while (intersected); - - m_graphedPoints[frame].push_back(currentPoint); - } - } - - --frame; - rightEdgeOfBar -= barWidth; - leftEdgeOfBar -= barWidth; - } - - FrameNumberType newMin = AZ::GetMax(0, frame + 1); - - if (m_minFrame >= 0) - { - while (m_minFrame < newMin) - { - m_graphedPoints.erase(m_minFrame); - ++m_minFrame; - } - } - - m_minFrame = newMin; - - if (m_maxFrame >= 0) - { - while (m_maxFrame >= 0 && m_maxFrame > newMax) - { - m_graphedPoints.erase(m_maxFrame); - --m_maxFrame; - } - } - - m_maxFrame = newMax; - } - else - { - m_minFrame = -1; - m_maxFrame = -1; - m_graphedPoints.clear(); - } - } - - void ChannelDataView::RemoveHighlight() - { - if (m_highlightedFrame >= 0) - { - FramePointMapping::iterator dataPointIter = m_graphedPoints.find(m_highlightedFrame); - - if (dataPointIter != m_graphedPoints.end()) - { - bool needsUpdate = false; - DataPointList& dataPointList = dataPointIter->second; - - for (AggregatorDataPoint& dataPoint : dataPointList) - { - needsUpdate = dataPoint.SetOverlayEnabled(false) || needsUpdate; - } - - if (needsUpdate) - { - update(); - } - } - - m_highlightedFrame = -1; - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChannelDataView.hxx b/Code/Tools/Standalone/Source/Driller/ChannelDataView.hxx deleted file mode 100644 index b12f9c021e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelDataView.hxx +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CHANNEL_DATA_VIEW_H -#define CHANNEL_DATA_VIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include - -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Driller -{ - class AnnotationsProvider; - class ChannelControl; - class ChannelDataView; - class ChannelProfilerWidget; - class Aggregator; - - class AggregatorDataPoint - { - public: - AggregatorDataPoint(); - AggregatorDataPoint(QRect rectangle,ChannelProfilerWidget* profiler); - - void Draw(QPainter& painter, int leftEdge, float barWidth); - bool ContainsPoint(const QPoint& point); - - bool IntersectsDataPoint(const AggregatorDataPoint& dataPoint); - void AddAggregatorDataPoint(const AggregatorDataPoint& dataPoint); - - bool SetOverlayEnabled(bool enabled); - - private: - - bool m_isActive; - bool m_isShowingOverlay; - bool m_shouldOutline; - QColor m_drawColor; - QRect m_visualBlock; - - AZStd::unordered_set< ChannelProfilerWidget* > m_combinedProfilers; - }; - - class BudgetMarker - { - public: - BudgetMarker(float value, QColor& drawColor); - ~BudgetMarker(); - - float GetValue() const; - const QColor& GetColor() const; - - private: - - float m_value; - QColor m_drawColor; - }; - - typedef unsigned int BudgetMarkerTicket; - - /* - Channel Data View handles all rendering of the scrolling data graph. - To do this it caches pointer access to its owning Channel - and pulls state information directly from there. - - Mouse events are passed upwards to its owning Channel via signal/slot. - */ - - class ChannelDataView : public QWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(ChannelDataView, AZ::SystemAllocator, 0); - ChannelDataView( QWidget* parent = nullptr ); - - virtual ~ChannelDataView(); - - void RegisterToChannel(ChannelControl* channel, AnnotationsProvider* annotations); - - QPainter *m_Painter; - ChannelControl *m_Channel; - AnnotationsProvider *m_ptrAnnotations; - - int FrameToPosition(FrameNumberType frameNumber); - FrameNumberType PositionToFrame( const QPoint &pt ); - FrameNumberType FramesPerPixel(); - - float GetBarWidth(); - - virtual void paintEvent( QPaintEvent *event ); - virtual void mouseMoveEvent( QMouseEvent *event ); - virtual void mousePressEvent( QMouseEvent *event ); - virtual void mouseReleaseEvent( QMouseEvent *event ); - virtual void wheelEvent(QWheelEvent *event); - virtual void leaveEvent( QEvent* event ); - - void DirtyGraphData(); - void RefreshGraphData(); - - BudgetMarkerTicket AddBudgetMarker(float value, QColor color); - void RemoveBudgetMarker(BudgetMarkerTicket ticket); - -signals: - void InformOfMouseClick(Qt::MouseButton button, FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseMove( FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseRelease(Qt::MouseButton button, FrameNumberType frame, FrameNumberType range, int modifiers ); - void InformOfMouseWheel( FrameNumberType frame, int wheelAmount, FrameNumberType range, int modifiers ); - - protected: - void resizeEvent(QResizeEvent* event) override; - - private: - - void RecalculateGraphedPoints(); - void RemoveHighlight(); - - typedef AZStd::list< AggregatorDataPoint > DataPointList; - typedef AZStd::unordered_map FramePointMapping; - - typedef AZStd::unordered_map BudgetMarkerMap; - - BudgetMarkerTicket m_budgetMarkerCounter; - BudgetMarkerMap m_budgetMarkers; - - FramePointMapping m_graphedPoints; - AZStd::list< ChannelProfilerWidget* > m_profilerWidgets; - - FrameNumberType m_minFrame; - FrameNumberType m_maxFrame; - FrameNumberType m_highlightedFrame; - - FrameNumberType m_lastFrame; - int m_xOffset; - - bool m_initializeDrag; - bool m_dragInitialized; - - bool m_shouldIgnorePoint; - - QPoint m_simulatedPoint; - QPoint m_centerPoint; - - bool m_mouseGrabbed; - bool m_dirtyGraph; - }; - -} - - -#endif // CHANNEL_DATA_VIEW_H diff --git a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.cpp b/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.cpp deleted file mode 100644 index b596fa023a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "Source/Driller/ChannelProfilerWidget.hxx" -#include - -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/ChannelControl.hxx" -#include "Source/Driller/CollapsiblePanel.hxx" -#include "Source/Driller/CustomizeCSVExportWidget.hxx" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -#include -#include -#include - -namespace Driller -{ - void ColorizeIcon(QIcon& icon, const char* iconPath, Aggregator* aggregator) - { - QImage alphaImage(iconPath); - alphaImage = alphaImage.convertToFormat(QImage::Format_ARGB32_Premultiplied); - - QImage colorizedImage(alphaImage.width(), alphaImage.height(), QImage::Format_ARGB32_Premultiplied); - - QColor color = aggregator->GetColor(); - color.setAlphaF(1.0f); - - QPainter painter; - painter.begin(&colorizedImage); - painter.setCompositionMode(QPainter::CompositionMode_Source); - painter.fillRect(colorizedImage.rect(), color); - painter.end(); - - colorizedImage.setAlphaChannel(alphaImage); - - icon.addPixmap(QPixmap::fromImage(colorizedImage)); - } - - ChannelProfilerWidget::ChannelProfilerWidget(ChannelControl* channelControl, Aggregator* aggregator) - : QWidget(channelControl) - , m_channelControl(channelControl) - , m_drilledWidget(nullptr) - , m_aggregator(aggregator) - , m_captureMode(CaptureMode::Unknown) - , m_isActive(true) - , m_activeIcon() - , m_inactiveIcon() - { - setupUi(this); - - connect(this, SIGNAL(DrillDownRequest(FrameNumberType)), m_aggregator, SLOT(DrillDownRequest(FrameNumberType))); - connect(this, SIGNAL(ExportToCSVRequest(const char*, CSVExportSettings*)), m_aggregator, SLOT(ExportToCSVRequest(const char*, CSVExportSettings*))); - - connect(m_aggregator, SIGNAL(GetInspectionFileName()), m_channelControl, SIGNAL(GetInspectionFileName())); - - connect(profilerName, SIGNAL(clicked()), this, SLOT(OnActivationToggled())); - connect(enableChannel, SIGNAL(clicked()), this, SLOT(OnActivationToggled())); - //connect(channelOptions,SIGNAL(clicked()),this, SLOT(OnConfigureChannel())); - connect(drillDown, SIGNAL(clicked()), this, SLOT(OnDrillDown())); - connect(exportData, SIGNAL(clicked()), this, SLOT(OnExportToCSV())); - - ColorizeIcon(m_activeIcon, ":/driller/active_color_swatch", aggregator); - ColorizeIcon(m_inactiveIcon, ":/driller/inactive_color_swatch", aggregator); - - profilerName->setToolTip(aggregator->GetToolTip()); - profilerName->setText(GetName()); - - UpdateActivationIcon(); - ConfigureUI(); - } - - ChannelProfilerWidget::~ChannelProfilerWidget() - { - } - - Aggregator* ChannelProfilerWidget::GetAggregator() const - { - return m_aggregator; - } - - bool ChannelProfilerWidget::IsActive() const - { - return m_isActive; - } - - void ChannelProfilerWidget::SetIsActive(bool isActive) - { - if (m_isActive != isActive) - { - m_isActive = isActive; - UpdateActivationIcon(); - - if (m_aggregator && m_captureMode == Driller::CaptureMode::Configuration) - { - m_aggregator->EnableCapture(isActive); - } - - emit OnActivationChanged(this, m_isActive); - } - } - - QString ChannelProfilerWidget::GetName() const - { - return (m_aggregator ? m_aggregator->GetName() : "Unknown Profiler"); - } - - AZ::Uuid ChannelProfilerWidget::GetID() - { - return (m_aggregator ? m_aggregator->GetID() : AZ::Uuid::CreateNull()); - } - - ChannelConfigurationWidget* ChannelProfilerWidget::CreateConfigurationWidget() - { - ChannelConfigurationWidget* configurationWidget = nullptr; - - if (m_aggregator) - { - configurationWidget = m_aggregator->CreateConfigurationWidget(); - } - - return configurationWidget; - } - - void ChannelProfilerWidget::OnActivationToggled() - { - SetIsActive(!IsActive()); - } - - void ChannelProfilerWidget::SetCaptureMode(CaptureMode captureMode) - { - if (m_captureMode != captureMode) - { - m_captureMode = captureMode; - - ConfigureUI(); - } - } - - void ChannelProfilerWidget::OnDrillDown() - { - if (m_channelControl && IsInCaptureMode(CaptureMode::Inspecting)) - { - char traceStr[AZ::Uuid::MaxStringBuffer]; - m_aggregator->GetID().ToString(traceStr, AZ_ARRAY_SIZE(traceStr)); - AZ_TracePrintf("Driller", "Drill Down ID = %s\n", traceStr); - - if (m_drilledWidget == nullptr) - { - m_drilledWidget = emit DrillDownRequest(m_channelControl->m_State.m_ScrubberFrame); - if (m_drilledWidget) - { - connect(m_drilledWidget, SIGNAL(destroyed(QObject*)), this, SLOT(OnDrillDestroyed(QObject*))); - emit OnSuccessfulDrillDown(m_drilledWidget); - } - } - else - { - if (m_drilledWidget->isMinimized()) - { - m_drilledWidget->showNormal(); - } - - m_drilledWidget->raise(); - m_drilledWidget->activateWindow(); - } - } - } - - void ChannelProfilerWidget::OnDrillDestroyed(QObject* widget) - { - if (widget == m_drilledWidget) - { - m_drilledWidget = nullptr; - } - } - - void ChannelProfilerWidget::OnExportToCSV() - { - DrillerOperationTelemetryEvent exportToCSVEvent; - exportToCSVEvent.SetAttribute("ExportToCSV", m_aggregator->GetName().toStdString().c_str()); - exportToCSVEvent.Log(); - - char traceStr[AZ::Uuid::MaxStringBuffer]; - m_aggregator->GetID().ToString(traceStr, AZ_ARRAY_SIZE(traceStr)); - AZ_TracePrintf("Driller", "Export Request for ID = %s\n", traceStr); - - QFileDialog fileDialog; - - CustomizeCSVExportWidget* customizeWidget = m_aggregator->CreateCSVExportCustomizationWidget(); - - // Always use the Qt dialog for consistency - fileDialog.setOption(QFileDialog::DontUseNativeDialog, true); - fileDialog.setAcceptMode(QFileDialog::AcceptSave); - fileDialog.setWindowTitle(QString("Export %1 To CSV").arg(m_aggregator->GetName())); - fileDialog.setNameFilter("CSV (*.csv)"); - fileDialog.setDefaultSuffix("csv"); - - if (customizeWidget) - { - CollapsiblePanel* collapsiblePanel = aznew CollapsiblePanel(&fileDialog); - - collapsiblePanel->SetTitle("Customize"); - collapsiblePanel->SetContent(customizeWidget); - - // I don't know why the decided to use a GridLayout here instead of nested layouts. But whatever. - QGridLayout* gridLayout = static_cast(fileDialog.layout()); - int numRows = gridLayout->rowCount(); - - gridLayout->addWidget(collapsiblePanel, numRows, 0, 1, gridLayout->columnCount()); - } - - QString fileName; - if (fileDialog.exec()) - { - QStringList fileList = fileDialog.selectedFiles(); - - for (const QString& file : fileList) - { - if (!file.isEmpty()) - { - fileName = file; - break; - } - } - } - - if (!fileName.isEmpty()) - { - CSVExportSettings* exportSettings = nullptr; - - if (customizeWidget) - { - customizeWidget->FinalizeSettings(); - exportSettings = customizeWidget->GetExportSettings(); - } - - emit ExportToCSVRequest(fileName.toStdString().c_str(), exportSettings); - } - } - - bool ChannelProfilerWidget::AllowCSVExport() const - { - return (m_aggregator ? m_aggregator->CanExportToCSV() : false); - } - - void ChannelProfilerWidget::UpdateActivationIcon() - { - if (IsActive()) - { - enableChannel->setIcon(m_activeIcon); - } - else - { - enableChannel->setIcon(m_inactiveIcon); - } - } - - bool ChannelProfilerWidget::IsInCaptureMode(CaptureMode captureMode) const - { - return m_captureMode == captureMode; - } - - void ChannelProfilerWidget::ConfigureUI() - { - switch (m_captureMode) - { - case CaptureMode::Configuration: - enableChannel->setEnabled(true); - drillDown->setVisible(false); - exportData->setVisible(false); - break; - case CaptureMode::Capturing: - enableChannel->setEnabled(false); - drillDown->setVisible(false); - exportData->setVisible(false); - break; - case CaptureMode::Inspecting: - enableChannel->setEnabled(true); - drillDown->setVisible(true); - exportData->setVisible(AllowCSVExport()); - exportData->setEnabled(AllowCSVExport()); - break; - default: - break; - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.hxx b/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.hxx deleted file mode 100644 index 307a3084df..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.hxx +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#ifndef DRILLER_CHANNELPROFILERWIDGET_H -#define DRILLER_CHANNELPROFILERWIDGET_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include - -#include "Source/Driller/DrillerDataTypes.h" - -// Generated Files -#include -#endif - -namespace Driller -{ - class Aggregator; - class ChannelControl; - class CSVExportSettings; - class ChannelConfigurationWidget; - - class ChannelProfilerWidget - : public QWidget - , private Ui::ChannelProfilerWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(ChannelProfilerWidget, AZ::SystemAllocator,0); - - ChannelProfilerWidget(ChannelControl* channelControl, Aggregator* aggregator); - virtual ~ChannelProfilerWidget(); - - Aggregator* GetAggregator() const; - - bool IsActive() const; - void SetIsActive(bool isActive); - - QString GetName() const; - AZ::Uuid GetID(); - - ChannelConfigurationWidget* CreateConfigurationWidget(); - - public slots: - void OnActivationToggled(); - void SetCaptureMode(CaptureMode mode); - - void OnDrillDown(); - void OnDrillDestroyed(QObject* drill); - - void OnExportToCSV(); - - signals: - void OnActivationChanged(ChannelProfilerWidget*,bool activated); - - QWidget* DrillDownRequest(FrameNumberType atFrame); - void ExportToCSVRequest(const char* filename, CSVExportSettings* customizeWidget); - - void OnSuccessfulDrillDown(QWidget* widget); - - private: - - bool AllowCSVExport() const; - void UpdateActivationIcon(); - - bool IsInCaptureMode(CaptureMode captureMode) const; - void ConfigureUI(); - - ChannelControl* m_channelControl; - QWidget* m_drilledWidget; - Aggregator* m_aggregator; - - CaptureMode m_captureMode; - bool m_isActive; - - QImage m_inactiveImage; - QImage m_activeImage; - QIcon m_activeIcon; - QIcon m_inactiveIcon; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.ui b/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.ui deleted file mode 100644 index 67e117a20d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChannelProfilerWidget.ui +++ /dev/null @@ -1,150 +0,0 @@ - - - ChannelProfilerWidget - - - - 0 - 0 - 374 - 28 - - - - ChannelProfilerWidget - - - - 3 - - - 9 - - - 0 - - - 0 - - - 0 - - - - - Toggle this Profiler On/Off - - - - - - - 12 - 12 - - - - - - - - - 13 - - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - 0 - - - 0 - - - 4 - - - 0 - - - - - Save to CSV - - - ... - - - - :/driller/export_button_enabled - :/driller/export_button_disabled - :/driller/export_button_disabled:/driller/export_button_enabled - - - - 20 - 20 - - - - - - - - Detailed Profiling Information - - - ... - - - - :/driller/drill_down_enabled - :/driller/drill_down_disabled - :/driller/drill_down_disabled:/driller/drill_down_enabled - - - - 20 - 20 - - - - - - - - - - - - AzToolsFramework::ClickableLabel - QLabel -
AzToolsFramework/UI/UICore/ClickableLabel.hxx
-
-
- - - - -
diff --git a/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.cpp b/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.cpp deleted file mode 100644 index 33c1dc66d4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ChartNumberFormats.h" - -namespace DrillerCharts -{ - QString FriendlyFormat(AZ::s64 n) - { - QString str; - - str = QString("%L1").arg(n); - - //if (n < 0) - //{ - // str = "-"; - //} - - //AZ::s64 b = n / 1000000000l; - //n %= 1000000000l; - - //AZ::s64 m = n / 1000000l; - //n %= 1000000l; - - //AZ::s64 k = n / 1000l; - //n %= 1000l; - - //if (b) - //{ - // str += QString("%0b").arg(abs(b)); - //} - //if (m) - //{ - // str += QString("%0m").arg(abs(m)); - //} - //if (k) - //{ - // str += QString("%0k").arg(abs(k)); - //} - //if (n) - //{ - // str += QString("%0").arg(abs(n)); - //} - - return str; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.h b/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.h deleted file mode 100644 index 6c20f1dfda..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChartNumberFormats.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef CHARTNUMBERFORMATS_H -#define CHARTNUMBERFORMATS_H - -#include -#include - -#pragma once - -namespace DrillerCharts -{ - QString FriendlyFormat(AZ::s64 n); -} - -#endif //CHARTNUMBERFORMATS_H diff --git a/Code/Tools/Standalone/Source/Driller/ChartTypes.cpp b/Code/Tools/Standalone/Source/Driller/ChartTypes.cpp deleted file mode 100644 index 3a01b80c41..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChartTypes.cpp +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "Source/Driller/ChartTypes.hxx" -#include - -namespace Charts -{ - QAbstractAxisFormatter::QAbstractAxisFormatter(QObject* parent) - : QObject(parent) - { - } -} diff --git a/Code/Tools/Standalone/Source/Driller/ChartTypes.hxx b/Code/Tools/Standalone/Source/Driller/ChartTypes.hxx deleted file mode 100644 index 897df65ff3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/ChartTypes.hxx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once -#ifndef PROFILER_CHARTTYPES_H -#define PROFILER_CHARTTYPES_H - -#if !defined(Q_MOC_RUN) -#include -#endif - -namespace Charts -{ - enum class AxisType - { - Horizontal, - Vertical - }; - - // Plug this guy into the chart if you wish to custom format axes - class QAbstractAxisFormatter : public QObject - { - Q_OBJECT - public: - QAbstractAxisFormatter(QObject *pParent); - - /** convertAxisValueToText - * Expects you to return a QString with the value for the axis. - * value : value it wants the label for. - * minDisplayedValue : what value is at the bottom of the axis in the display - * maxDisplayedValue : what value is at the top of this axis in the display - * divisionSize : what each tickmark is, in domain units. - * So for example, if the axis is from 938 to 2114 and its got a tickmark every 250, and it wants to know what you'd like it to draw for 1250 - * then you'll get Value = 1250, minDisplayedValue = 1000, maxDisplayedValue = 2000, divisionSize = 250. - */ - virtual QString convertAxisValueToText(AxisType axisType, float value, float minDisplayedValue, float maxDisplayedValue, float divisionSize) = 0; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.cpp b/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.cpp deleted file mode 100644 index 9ef3779849..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "CollapsiblePanel.hxx" -#include -#include - -namespace Driller -{ - CollapsiblePanel::CollapsiblePanel(QWidget* parent) - : QWidget(parent) - , m_isCollapsed(false) - , m_content(nullptr) - , m_gui(nullptr) - { - m_gui = azcreate(Ui::CollapsiblePanel, ()); - m_gui->setupUi(this); - - // Default to collapsed, need to initialize the variable to true to trigger the delta. - SetCollapsed(true); - - QObject::connect(m_gui->stateIcon, SIGNAL(clicked()), this, SLOT(OnClicked())); - } - - CollapsiblePanel::~CollapsiblePanel() - { - azdestroy(m_gui); - m_gui = nullptr; - } - - void CollapsiblePanel::SetTitle(const QString& title) - { - m_gui->description->setText(title); - } - - void CollapsiblePanel::SetContent(QWidget* content) - { - if (m_content) - { - m_gui->contentLayout->removeWidget(content); - m_content = nullptr; - } - - m_content = content; - - if (m_content) - { - m_gui->contentLayout->addWidget(m_content); - } - } - - void CollapsiblePanel::SetCollapsed(bool collapsed) - { - if (m_isCollapsed != collapsed) - { - m_isCollapsed = collapsed; - - m_gui->groupBox->setVisible(!m_isCollapsed); - - if (m_isCollapsed) - { - m_gui->stateIcon->setArrowType(Qt::RightArrow); - emit Collapsed(); - } - else - { - m_gui->stateIcon->setArrowType(Qt::DownArrow); - emit Expanded(); - } - } - } - - bool CollapsiblePanel::IsCollapsed() const - { - return m_isCollapsed; - } - - void CollapsiblePanel::OnClicked() - { - SetCollapsed(!m_isCollapsed); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.hxx b/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.hxx deleted file mode 100644 index df207b9247..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_COLLAPSIBLEPANEL_H -#define DRILLER_COLLAPSIBLEPANEL_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#pragma once - -#include -#endif - -namespace Ui -{ - class CollapsiblePanel; -} - -namespace Driller -{ - class CollapsiblePanel - : public QWidget - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(CollapsiblePanel, AZ::SystemAllocator, 0); - - CollapsiblePanel(QWidget* parent = nullptr); - ~CollapsiblePanel(); - - void SetTitle(const QString& title); - void SetContent(QWidget* content); - - void SetCollapsed(bool collapsed); - bool IsCollapsed() const; - - public slots: - void OnClicked(); - - signals: - void Collapsed(); - void Expanded(); - - private: - - bool m_isCollapsed; - - QWidget* m_content; - Ui::CollapsiblePanel* m_gui; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.ui b/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.ui deleted file mode 100644 index 83f057ee94..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CollapsiblePanel.ui +++ /dev/null @@ -1,125 +0,0 @@ - - - CollapsiblePanel - - - - 0 - 0 - 591 - 421 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 5 - - - 0 - - - 0 - - - 0 - - - - - ... - - - - - - - - 10 - - - - Panel Name ggggMMMWWWW - - - - - - - - - - - 0 - 0 - - - - - - - - 0 - - - 10 - - - 0 - - - 0 - - - 0 - - - - - 0 - - - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.cpp b/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.cpp deleted file mode 100644 index 72130b5300..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include - -#include "CombinedEventsControl.hxx" -#include - -#include "Annotations/AnnotationsHeaderView_Events.hxx" -#include "Axis.hxx" -#include "CollapsiblePanel.hxx" -#include "ChannelDataView.hxx" -#include "DrillerAggregator.hxx" -#include "DrillerEvent.h" -#include "DrillerMainWindowMessages.h" - -#include - -using namespace Racetrack; - -namespace Driller -{ - static const int k_raceTrackMinSize = 50; - static const int k_eventTrackSize = 20; - - CombinedEventsControl::CombinedEventsControl(QWidget* parent, Qt::WindowFlags flags) - : QDockWidget(parent, flags) - { - m_ScrubberIndex = 0; - - m_FirstIndex = 0; - m_LastIndex = 0; - - QWidget* nullBar = new QWidget(); - setTitleBarWidget(nullBar); - - setFeatures(QDockWidget::NoDockWidgetFeatures); - setAllowedAreas(Qt::BottomDockWidgetArea); - - m_collapsiblePanel = new CollapsiblePanel(this); - this->setWidget(m_collapsiblePanel); - - m_Contents = new QWidget(this); - m_Contents->setGeometry(0, 22, 542, 34); - m_Contents->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum); - QVBoxLayout* layout = new QVBoxLayout(); - - layout->setMargin(0); - layout->setSpacing(2); - - m_Contents->setLayout(layout); - m_collapsiblePanel->SetContent(m_Contents); - m_collapsiblePanel->SetTitle("Detailed Event View"); - - m_EventTrack = aznew CEQDataTrack(this); - m_EventTrack->SetupAxis("", 0.0f, 1.0f, false); - m_EventTrack->SetMarkerColor(Qt::darkMagenta); - m_EventTrack->setMinimumHeight(k_raceTrackMinSize); - - m_annotationHeaderView = aznew AnnotationHeaderView_Events(this); - - m_Contents->layout()->addWidget(m_annotationHeaderView); - m_Contents->layout()->addWidget(m_EventTrack); - - m_EventTrack->installEventFilter(this); - - connect(m_EventTrack, SIGNAL(EventRequestEventFocus(Driller::EventNumberType)), this, SLOT(OnEventTrackRequestEventFocus(Driller::EventNumberType))); - } - - void CombinedEventsControl::SetIdentity(int identity) - { - m_identity = identity; - DrillerEventWindowMessages::Handler::BusConnect(m_identity); - } - - bool CombinedEventsControl::eventFilter(QObject* obj, QEvent* event) - { - if (event->type() == QEvent::Resize) - { - if (obj == m_EventTrack) - { - QRect eventTrackGeometry = m_EventTrack->geometry(); - QSize actualSize = QSize(eventTrackGeometry.x(), eventTrackGeometry.height()); - emit InfoAreaGeometryChanged(actualSize); - } - } - - // hand it to the owner - return QObject::eventFilter(obj, event); - } - - Charts::Axis* CombinedEventsControl::GetAxis() const - { - return m_EventTrack->GetAxis(); - } - - - CombinedEventsControl::~CombinedEventsControl() - { - DrillerEventWindowMessages::Handler::BusDisconnect(m_identity); - - if (m_EventTrack) - { - delete m_EventTrack; - } - } - - void CombinedEventsControl::ClearAggregatorList() - { - m_Aggregators.clear(); - m_EventTrack->Clear(); - m_EventTrack->setMinimumHeight(k_raceTrackMinSize); - - m_ScrubberIndex = 0; - m_FirstIndex = 0; - m_LastIndex = 0; - } - - void CombinedEventsControl::AddAggregatorList(DrillerNetworkMessages::AggregatorList& theList) - { - // m_EventStrip clear all existing channels and the channel axis - m_EventTrack->Clear(); - for (DrillerNetworkMessages::AggregatorList::iterator iter = theList.begin(); iter != theList.end(); ++iter) - { - m_Aggregators.push_back(*iter); - - int channelID = m_EventTrack->AddChannel((*iter)->GetName()); - m_EventTrack->SetChannelColor(channelID, (*iter)->GetColor()); - } - - m_EventTrack->setMinimumHeight(k_raceTrackMinSize + static_cast(m_Aggregators.size()) * k_eventTrackSize); - } - void CombinedEventsControl::AddAggregator(Aggregator& theAggregator) - { - m_Aggregators.push_back(&theAggregator); - - int channelID = m_EventTrack->AddChannel(theAggregator.GetName()); - m_EventTrack->SetChannelColor(channelID, theAggregator.GetColor()); - - m_EventTrack->setMinimumHeight(k_raceTrackMinSize + static_cast(m_Aggregators.size()) * k_eventTrackSize); - } - - void CombinedEventsControl::SetAnnotationsProvider(AnnotationsProvider* ptrAnnotations) - { - m_annotationHeaderView->AttachToAxis(ptrAnnotations, GetAxis()); - } - - void CombinedEventsControl::SetEndFrame(FrameNumberType /*frame*/) - { - m_EventTrack->update(); - } - - void CombinedEventsControl::SetSliderOffset(FrameNumberType /*frame*/) - { - } - - void CombinedEventsControl::MouseClickInformed(int newValue) - { - emit InformOfMouseClick(newValue, 1, 0); - } - - void CombinedEventsControl::MouseMoveInformed(int newValue) - { - emit InformOfMouseMove(newValue, 1, 0); - } - - void CombinedEventsControl::OnEventScrubberboxChanged(int newValue) - { - emit EventRequestEventFocus(static_cast(newValue)); - } - - void CombinedEventsControl::SetScrubberFrame(FrameNumberType frame) - { - m_EventTrack->GetAxis()->Clear(); - - int temp_m_FirstIndex = 0x7fffffff; - int temp_m_LastIndex = 0; - - AZ::s64 highestCount = 0; - int channelIdx = 0; - for (AZStd::list::iterator iter = m_Aggregators.begin(); iter != m_Aggregators.end(); ++iter, ++channelIdx) - { - m_EventTrack->ClearData(channelIdx); - - size_t numEvents = (*iter)->NumOfEventsAtFrame(frame); - - if (numEvents) - { - highestCount += numEvents; - EventNumberType eventIndexOffset = (*iter)->GetFirstIndexAtFrame(frame); - - for (EventNumberType eventIndex = 0; eventIndex < static_cast(numEvents); ++eventIndex) - { - DrillerEvent* dep = (*iter)->GetEvents()[ eventIndex + eventIndexOffset ]; - AZ::s64 geid = dep->GetGlobalEventId(); - - temp_m_FirstIndex = (int)geid < temp_m_FirstIndex ? (int)geid : temp_m_FirstIndex; - temp_m_LastIndex = (int)geid > temp_m_LastIndex ? (int)geid : temp_m_LastIndex; - - //AZ_TracePrintf("LUA","First %d Last %d\n",temp_m_FirstIndex, temp_m_LastIndex); - - m_EventTrack->AddData(channelIdx, (float)geid, (float)channelIdx); - } - } - } - - m_FirstIndex = temp_m_FirstIndex; - m_LastIndex = temp_m_LastIndex; - - m_EventTrack->GetAxis()->SetAxisRange((float)m_FirstIndex, (float)m_LastIndex); - m_EventTrack->GetAxis()->SetViewFull(); - SanitizeScrubberIndex(); - emit EventRequestEventFocus(m_ScrubberIndex); - } - - void CombinedEventsControl::OnEventTrackRequestEventFocus(Driller::EventNumberType eventIndex) - { - emit EventRequestEventFocus(eventIndex); - } - - ////////////////////////////////////////////////////////////////////////// - // Event Window Messages - void CombinedEventsControl::EventFocusChanged(EventNumberType eventIdx) - { - m_ScrubberIndex = eventIdx; - SanitizeScrubberIndex(); - m_EventTrack->SetMarkerPosition((float)m_ScrubberIndex); - } - - void CombinedEventsControl::SanitizeScrubberIndex() - { - m_ScrubberIndex = m_ScrubberIndex < m_FirstIndex ? m_FirstIndex : m_ScrubberIndex; - m_ScrubberIndex = m_ScrubberIndex > m_LastIndex ? m_LastIndex : m_ScrubberIndex; - } - - - ////////////////////////////////////////////////////////////////////////// - CEQDataTrack::CEQDataTrack(QWidget* parent, Qt::WindowFlags flags) - : DataRacetrack(parent, flags) - { - m_InsetT = 4; - m_InsetB = 12; - SetZeroBasedAxisNumbering(true); - setAutoFillBackground(false); - setAttribute(Qt::WA_OpaquePaintEvent, true); - } - CEQDataTrack::~CEQDataTrack() - { - } -} diff --git a/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.hxx b/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.hxx deleted file mode 100644 index 3882d81356..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CombinedEventsControl.hxx +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef COMBINEDEVENTS_CONTROL_H -#define COMBINEDEVENTS_CONTROL_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#include - -#include "DrillerNetworkMessages.h" -#include "DrillerMainWindowMessages.h" -#include "RacetrackChart.hxx" -#include "Annotations/AnnotationsHeaderView_Events.hxx" -#endif - -namespace Charts -{ - class Axis; -} - -namespace Driller -{ - class Aggregator; - class CEQDataTrack; - class CollapsiblePanel; - class AnnotationsProvider; - - /* - Channel Control intermediates between one data Aggregator, the application's main window, and the renderer. - This maintains state used by the renderer and passes changes both up and down via signal/slot. - */ - - class CombinedEventsControl - : public QDockWidget - , public Driller::DrillerEventWindowMessages::Bus::Handler - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(CombinedEventsControl,AZ::SystemAllocator,0); - CombinedEventsControl( QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~CombinedEventsControl(void); - - void SetIdentity(int identity); - - void ClearAggregatorList(); - void AddAggregatorList(DrillerNetworkMessages::AggregatorList &theList); - void AddAggregator(Aggregator &theAggregator); - - void SetAnnotationsProvider(AnnotationsProvider* ptrAnnotations); - - AZStd::listm_Aggregators; - - int m_identity; - EventNumberType m_ScrubberIndex; - void SanitizeScrubberIndex(); - - QWidget *m_Contents; - - CollapsiblePanel* m_collapsiblePanel; - - AnnotationHeaderView_Events* m_annotationHeaderView; - CEQDataTrack* m_EventTrack; - - int m_FirstIndex; - int m_LastIndex; - int m_IndexCount; - - void SetActive( int active ); - void SetEndFrame( FrameNumberType frame ); - void SetSliderOffset( FrameNumberType frame ); - - Charts::Axis* GetAxis() const; - - virtual void EventFocusChanged(EventNumberType eventIdx); - - protected: - bool eventFilter(QObject *obj, QEvent *event); - - public slots: - void MouseClickInformed( int newValue ); - void MouseMoveInformed( int newValue ); - void OnEventScrubberboxChanged( int newValue ); - void SetScrubberFrame( FrameNumberType frame ); - void OnEventTrackRequestEventFocus(Driller::EventNumberType); - - signals: - void InformOfMouseClick( int newValue, int range, int modifiers ); - void InformOfMouseMove( int newValue, int range, int modifiers ); - void InfoAreaGeometryChanged ( QSize newSize); - void EventRequestEventFocus(EventNumberType); - }; - - class CEQDataTrack - : public Racetrack::DataRacetrack - { - Q_OBJECT; - public: - - AZ_CLASS_ALLOCATOR(CEQDataTrack,AZ::SystemAllocator,0); - CEQDataTrack( QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~CEQDataTrack(void); - }; - -} - - -#endif // COMBINEDEVENTS_CONTROL_H diff --git a/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.cpp b/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.cpp deleted file mode 100644 index 16650d0852..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "Source/Driller/CustomizeCSVExportWidget.hxx" -#include - -#include "Source/Driller/CSVExportSettings.h" - -namespace Driller -{ - ///////////////////////////// - // CustomizeCSVExportWidget - ///////////////////////////// - - CustomizeCSVExportWidget::CustomizeCSVExportWidget(CSVExportSettings& exportSettings, QWidget* parent) - : QWidget(parent) - , m_exportSettings(exportSettings) - { - } - - CustomizeCSVExportWidget::~CustomizeCSVExportWidget() - { - } - - CSVExportSettings* CustomizeCSVExportWidget::GetExportSettings() const - { - return (&m_exportSettings); - } - - void CustomizeCSVExportWidget::OnShouldExportStateDescriptorChecked(int state) - { - m_exportSettings.SetShouldExportColumnDescriptors(state == Qt::Checked); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.hxx b/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.hxx deleted file mode 100644 index 75ea714fcd..0000000000 --- a/Code/Tools/Standalone/Source/Driller/CustomizeCSVExportWidget.hxx +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_CUSTOMIZECSVEXPORTWIDGET_H -#define DRILLER_CUSTOMIZECSVEXPORTWIDGET_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#pragma once - -#include -#endif - -namespace Driller -{ - class CSVExportSettings; - - class CustomizeCSVExportWidget : public QWidget - { - Q_OBJECT - public: - CustomizeCSVExportWidget(CSVExportSettings& customSettings, QWidget* parent); - virtual ~CustomizeCSVExportWidget(); - - virtual void FinalizeSettings() = 0; - CSVExportSettings* GetExportSettings() const; - - public slots: - void OnShouldExportStateDescriptorChecked(int); - - protected: - CSVExportSettings& m_exportSettings; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.cpp b/Code/Tools/Standalone/Source/Driller/DoubleListSelector.cpp deleted file mode 100644 index d352719e22..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DoubleListSelector.hxx" -#include -#include - -namespace Driller -{ - /////////////////////// - // DoubleListSelector - /////////////////////// - - DoubleListSelector::DoubleListSelector(QWidget* parent) - : QWidget(parent) - , m_gui(new Ui::DoubleListSelector()) - { - m_gui->setupUi(this); - - m_gui->activateButton->setAutoDefault(false); - m_gui->deactivateButton->setAutoDefault(false); - - QObject::connect(m_gui->activateButton, SIGNAL(clicked()), this, SLOT(activateSelected())); - QObject::connect(m_gui->deactivateButton, SIGNAL(clicked()), this, SLOT(deactivateSelected())); - } - - DoubleListSelector::~DoubleListSelector() - { - delete m_gui; - } - - void DoubleListSelector::setItemList(const QStringList& items, bool maintainActiveList) - { - if (maintainActiveList) - { - m_gui->inactiveList->clearItems(); - - const QStringList& activeItems = m_gui->activeList->getAllItems(); - - QStringList newActiveItems; - QStringList inactiveItems; - - for (const QString& currentItem : items) - { - if (activeItems.contains(currentItem)) - { - newActiveItems.push_back(currentItem); - } - else - { - inactiveItems.push_back(currentItem); - } - } - - m_gui->activeList->clearItems(); - - m_gui->inactiveList->addItems(inactiveItems); - m_gui->activeList->addItems(newActiveItems); - - emit ActiveItemsChanged(); - } - else - { - m_gui->inactiveList->clearItems(); - m_gui->inactiveList->addItems(items); - m_gui->activeList->clearItems(); - } - } - - void DoubleListSelector::setActiveItems(const QStringList& items) - { - QStringList inactiveItems = m_gui->inactiveList->getAllItems(); - const QStringList& activeItems = m_gui->activeList->getAllItems(); - - inactiveItems.append(activeItems); - - m_gui->inactiveList->clearItems(); - m_gui->activeList->clearItems(); - - for (const QString& currentItem : items) - { - QStringList::iterator itemIter = inactiveItems.begin(); - - while (itemIter != inactiveItems.end()) - { - if ((*itemIter).compare(currentItem) == 0) - { - inactiveItems.erase(itemIter); - break; - } - - ++itemIter; - } - } - - m_gui->inactiveList->addItems(inactiveItems); - m_gui->activeList->addItems(items); - - emit ActiveItemsChanged(); - } - - const QStringList& DoubleListSelector::getActiveItems() const - { - return m_gui->activeList->getAllItems(); - } - - void DoubleListSelector::setActiveTitle(const QString& title) - { - m_gui->activeGroupBox->setTitle(title); - } - - void DoubleListSelector::setInactiveTitle(const QString& title) - { - m_gui->inactiveGroupBox->setTitle(title); - } - - void DoubleListSelector::activateSelected() - { - QStringList activateItems; - - m_gui->inactiveList->getSelectedItems(activateItems); - m_gui->inactiveList->removeSelected(); - - m_gui->activeList->addItems(activateItems); - - emit ActiveItemsChanged(); - } - - void DoubleListSelector::deactivateSelected() - { - QStringList activateItems; - - m_gui->activeList->getSelectedItems(activateItems); - m_gui->activeList->removeSelected(); - - m_gui->inactiveList->addItems(activateItems); - - emit ActiveItemsChanged(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.hxx b/Code/Tools/Standalone/Source/Driller/DoubleListSelector.hxx deleted file mode 100644 index ce733868e9..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.hxx +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef AZTOOLSFRAMEWORK_UI_UICORE_DOUBLELISTSELECTOR_H -#define AZTOOLSFRAMEWORK_UI_UICORE_DOUBLELISTSELECTOR_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#pragma once - -#include -#endif - -namespace Ui -{ - class DoubleListSelector; -} - -namespace Driller -{ - class DoubleListSelector - : public QWidget - { - Q_OBJECT - - public: - AZ_CLASS_ALLOCATOR(DoubleListSelector, AZ::SystemAllocator,0); - - explicit DoubleListSelector(QWidget* parent = nullptr); - ~DoubleListSelector(); - - void setItemList(const QStringList& items, bool maintainActiveList = true); - void setActiveItems(const QStringList& items); - - const QStringList& getActiveItems() const; - - void setActiveTitle(const QString& title); - void setInactiveTitle(const QString& title); - - public slots: - void activateSelected(); - void deactivateSelected(); - - signals: - void ActiveItemsChanged(); - - private: - - Ui::DoubleListSelector* m_gui; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.ui b/Code/Tools/Standalone/Source/Driller/DoubleListSelector.ui deleted file mode 100644 index c7d4d74483..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DoubleListSelector.ui +++ /dev/null @@ -1,174 +0,0 @@ - - - DoubleListSelector - - - - 0 - 0 - 527 - 449 - - - - Form - - - - - - - 0 - 0 - - - - Inactive - - - - - - - - - - - - - 50 - 0 - - - - - 75 - 16777215 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Vertical - - - - 50 - 40 - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - >> - - - false - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - << - - - false - - - - - - - Qt::Vertical - - - - 50 - 40 - - - - - - - - - - - - 0 - 0 - - - - Active - - - - - - - - - - - - - Driller::FilteredListView - QWidget -
Source/Driller/FilteredListView.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/DrillerAggregator.cpp b/Code/Tools/Standalone/Source/Driller/DrillerAggregator.cpp deleted file mode 100644 index bd88e8afbb..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerAggregator.cpp +++ /dev/null @@ -1,223 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerAggregator.hxx" -#include - -#include "DrillerEvent.h" - -#include -#include -#include - -#include "Source/Driller/CSVExportSettings.h" - -#include - -namespace Driller -{ - class AggregatorSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(AggregatorSavedState, "{9AAB69CE-8061-4CB6-8387-DB60FD8DBB75}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(AggregatorSavedState, AZ::SystemAllocator, 0); - AggregatorSavedState() {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(1) - ; - } - } - }; - - ////////////////////////////////////////////////////////////////////////// - Aggregator::Aggregator(int identity) - : QObject() - , m_identity(identity) - , m_currentEvent(Driller::kInvalidEventIndex) - , m_isCaptureEnabled(true) - { - DrillerMainWindowMessages::Handler::BusConnect(m_identity); - DrillerWorkspaceWindowMessages::Handler::BusConnect(m_identity); - - // subclassed aggregators should work with settingsDocument at this point - // to retrieve state - } - Aggregator::~Aggregator() - { - // subclassed aggregators should work with settingsDocument at this point - // to store the current state so it can be retrieved when constructed again - - DrillerWorkspaceWindowMessages::Handler::BusDisconnect(m_identity); - DrillerMainWindowMessages::Handler::BusDisconnect(m_identity); - - for (EventListType::iterator it = m_events.begin(); it != m_events.end(); ++it) - { - delete *it; - } - } - - void Aggregator::Reset() - { - for (EventListType::iterator it = m_events.begin(); it != m_events.end(); ++it) - { - delete *it; - } - - m_events.clear(); - m_frameToEventIndex.clear(); - m_currentEvent = kInvalidEventIndex; - } - bool Aggregator::IsValid() - { - return m_events.size() > 0; - } - - void Aggregator::AddNewFrame() - { - m_frameToEventIndex.push_back(m_events.size()); - } - - bool Aggregator::DataAtFrame(FrameNumberType frame) - { - return NumOfEventsAtFrame(frame) > 0; - } - - void Aggregator::ExportToCSVRequest(const char* filename, CSVExportSettings* exportSettings) - { - AZ::IO::SystemFile exportFile; - - if (exportFile.Open(filename, AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY)) - { - if (exportSettings == nullptr || exportSettings->ShouldExportColumnDescriptors()) - { - ExportColumnDescriptorToCSV(exportFile, exportSettings); - } - - for (DrillerEvent* drillerEvent : m_events) - { - ExportEventToCSV(exportFile, drillerEvent, exportSettings); - } - - exportFile.Close(); - } - else - { - QMessageBox::critical(nullptr, "Error Opening File", QString("Could not open file %1").arg(filename), QMessageBox::Ok); - } - } - - size_t Aggregator::NumOfEventsAtFrame(FrameNumberType frame) const - { - size_t numFrames = m_frameToEventIndex.size(); - if (numFrames == 1) - { - return m_events.size(); - } - - if (frame == numFrames - 1) - { - return m_events.size() - m_frameToEventIndex[frame]; // last frame - } - - if (numFrames >= 2) - { - EventNumberType ftei1 = m_frameToEventIndex[frame + 1]; - EventNumberType ftei0 = m_frameToEventIndex[frame]; - size_t fte = (ftei1 - ftei0); - return fte; - } - - return 0; - } - - QString Aggregator::GetDialogTitle() const - { - return QString("%1 - %2").arg(GetName()).arg(GetInspectionFileName()); - } - - void Aggregator::FrameChanged(FrameNumberType frame) - { - size_t numFrames = m_frameToEventIndex.size(); - if (numFrames) - { - EventNumberType targetEventIndex; - - if (frame == numFrames - 1) - { - targetEventIndex = m_events.size() - 1; - } - else - { - targetEventIndex = m_frameToEventIndex[frame + 1]; - - // the current targetEventIndex belongs to the next frame "frame+1" minus 1 - --targetEventIndex; - } - - EventChanged(targetEventIndex); - } - } - - void Aggregator::EventChanged(EventNumberType eventIndex) - { - if (eventIndex == m_currentEvent) - { - return; - } - - // TODO: If we are at the end and we click at the start, we can start from the START as it's a known state - if (eventIndex > m_currentEvent) - { - // forward (m_currentEvent has already been executed so start currentEvent+1) - for (EventNumberType i = m_currentEvent + 1; i <= eventIndex; ++i) - { - m_events[i]->StepForward(this); - } - } - else if (eventIndex < m_currentEvent) - { - // backward (current event has executed so revert it - for (EventNumberType i = m_currentEvent; i > eventIndex; --i) - { - m_events[i]->StepBackward(this); - } - } - - m_currentEvent = eventIndex; - emit OnDataCurrentEventChanged(); - } - - void Aggregator::ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) - { - (void)file; - (void)exportSettings; - } - - void Aggregator::ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) - { - (void)file; - (void)drillerEvent; - (void)exportSettings; - } - - void Aggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - AggregatorSavedState::Reflect(context); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/DrillerAggregator.hxx b/Code/Tools/Standalone/Source/Driller/DrillerAggregator.hxx deleted file mode 100644 index cf370a4571..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerAggregator.hxx +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLERAGGREGATOR_H -#define DRILLER_DRILLERAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include "DrillerMainWindowMessages.h" -#include "DrillerDataTypes.h" - -#include -#include -#endif - -namespace AZ -{ - namespace IO - { - class SystemFile; - } - class ReflectContext; -} - -namespace Driller -{ - class DrillerEvent; - class AnnotationsProvider; - class CSVExportSettings; - class CustomizeCSVExportWidget; - - class ChannelDataView; - class ChannelConfigurationWidget; - - /* - Aggregator is a pure virtual data source that packages its data - into easily digestible, single frame chunks for external consumption. - It is a pull, not a push, source. - - Separately, aggregators are responsible for handling their own Options and Drill Down displays. - */ - - class Aggregator - : public QObject - , public Driller::DrillerMainWindowMessages::Bus::Handler - , public Driller::DrillerWorkspaceWindowMessages::Bus::Handler - { - Q_OBJECT; - public: - typedef AZStd::vector EventListType; - typedef AZStd::vector FrameToEventIndexType; - - Aggregator(int identity); - virtual ~Aggregator(); - // MainWindow Bus Commands - - virtual AZ::Crc32 GetChannelId() const { return 0; } - virtual AZ::u32 GetDrillerId() const { return 0; } - virtual AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() { return nullptr; } - virtual void EnableCapture(bool enabled) { m_isCaptureEnabled = enabled; } - bool IsCaptureEnabled() const { return m_isCaptureEnabled; } - int GetIdentity() const { return m_identity; } - - virtual bool CanExportToCSV() const { return false; } - virtual CustomizeCSVExportWidget* CreateCSVExportCustomizationWidget() { return nullptr; } - - virtual bool HasConfigurations() const { return false; } - virtual ChannelConfigurationWidget* CreateConfigurationWidget() { return nullptr; } - virtual void OnConfigurationChanged() { } - - virtual void AnnotateChannelView(ChannelDataView* dataView) { (void)dataView; } - virtual void RemoveChannelAnnotation(ChannelDataView* dataView) { (void)dataView; } - - /// reset for another data run - virtual void Reset(); - virtual bool IsValid(); - - /// Make a game frame. - virtual void AddNewFrame(); - /// Adds new event. We can have many events (or none) for each game frame. - void AddEvent(DrillerEvent* event) { m_events.push_back(event); emit OnDataAddEvent();} - void FinalizeEvent() { emit OnEventFinalized(m_events.back()); } - EventListType& GetEvents() { return m_events; } - const EventListType& GetEvents() const { return m_events; } - size_t NumOfEventsAtFrame(FrameNumberType frame) const; - EventNumberType GetCurrentEvent() const { return m_currentEvent; } - - EventNumberType GetFirstIndexAtFrame(FrameNumberType frame ) const { return m_frameToEventIndex[frame]; } - - size_t GetFrameCount() const { return m_frameToEventIndex.size(); } - - // ----- annotation functionality ---- - - // emit all annotations that match the provider's filter, given the start and end frame: - virtual void EmitAllAnnotationsForFrameRange( FrameNumberType startFrameInclusive, FrameNumberType endFrameInclusive , AnnotationsProvider* ptrProvider) { (void)startFrameInclusive; (void)endFrameInclusive; (void)ptrProvider; } - - // emit all channels that you are aware of existing within that frame range (You may emit duplicate channels, they will be ignored) - virtual void EmitAnnotationChannelsForFrameRange( FrameNumberType startFrameInclusive, FrameNumberType endFrameInclusive , AnnotationsProvider* ptrProvider) { (void)startFrameInclusive; (void)endFrameInclusive; (void)ptrProvider; } - - QString GetDialogTitle() const; - - signals: - - void NormalizedRangeChanged(); - - void OnDataCurrentEventChanged(); - void OnDataAddEvent(); - void OnEventFinalized(DrillerEvent* event); - - QString GetInspectionFileName() const; - - public slots: - // Queries - virtual bool DataAtFrame(FrameNumberType frame ); - virtual float ValueAtFrame(FrameNumberType frame ) = 0; - virtual QColor GetColor() const = 0; - virtual QString GetChannelName() const = 0; - virtual QString GetName() const = 0; - virtual QString GetDescription() const = 0; - virtual QString GetToolTip() const = 0; - virtual QString GetDrillDownIcon() { return ":/general/callstack"; } - virtual AZ::Uuid GetID() const = 0; - virtual QWidget* DrillDownRequest(FrameNumberType atFrame) = 0; - virtual void OptionsRequest() = 0; - - void ExportToCSVRequest(const char* filename, CSVExportSettings* exportSettings); - - protected: - Aggregator(const Aggregator&) = delete; - virtual void FrameChanged(FrameNumberType frame); - virtual void EventChanged(EventNumberType eventIndex); - - virtual void ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings); - virtual void ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings); - - EventNumberType m_currentEvent; ///< Current event points last executed event - EventListType m_events; - FrameToEventIndexType m_frameToEventIndex; - bool m_isCaptureEnabled; - int m_identity; - - public: - static void Reflect(AZ::ReflectContext* context); - }; -} - -#endif //DRILLER_DRILLERAGGREGATOR_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerAggregatorOptions.hxx b/Code/Tools/Standalone/Source/Driller/DrillerAggregatorOptions.hxx deleted file mode 100644 index 966f0fbcd6..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerAggregatorOptions.hxx +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLERAGGREGATOR_OPTIONS_H -#define DRILLER_DRILLERAGGREGATOR_OPTIONS_H - -#include "QtGui/qcolor.h" - -namespace Driller -{ - class Aggregator; - - class AggregatorOptions - { - public: - - AggregatorOptions( Aggregator *owner ) - : m_Owner(owner) - { - } - virtual ~AggregatorOptions() - { - } - - Aggregator *m_Owner; - }; -} - -#endif //DRILLER_DRILLERAGGREGATOR_OPTIONS_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.cpp b/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.cpp deleted file mode 100644 index 7f39136649..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.cpp +++ /dev/null @@ -1,1952 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerCaptureWindow.hxx" -#include - -#include "DrillerMainWindowMessages.h" -#include "DrillerAggregator.hxx" -#include "ChannelControl.hxx" -#include "ChannelProfilerWidget.hxx" -#include "CombinedEventsControl.hxx" -#include "DrillerDataContainer.h" -#include "DrillerMainWindow.hxx" -#include "DrillerOperationTelemetryEvent.h" -#include "Workspaces/Workspace.h" - -#include -#include - -#include -#include -#include -#include - -#include "QtGui/QPalette" -#include "Annotations/AnnotationHeaderView.hxx" -#include "Annotations/ConfigureAnnotationsWindow.hxx" - -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -void initSharedResources() -{ - Q_INIT_RESOURCE(sharedResources); -} - -namespace -{ - const char* drillerDebugName = "Driller"; - const char* drillerInfoName = "Driller"; - const char* baseTempFileName = "drillercapture.drl"; -} - -namespace Driller -{ - class DrillerCaptureWindowSavedState - : public AzToolsFramework::MainWindowSavedState - { - public: - AZ_RTTI(DrillerCaptureWindowSavedState, "{19721873-2FB0-4B5B-BCFC-C774FEC7687A}", AzToolsFramework::MainWindowSavedState); - AZ_CLASS_ALLOCATOR(DrillerCaptureWindowSavedState, AZ::SystemAllocator, 0); - - AZStd::list m_ChannelIDs; - int m_fpsValue; - FrameNumberType m_scrubberCurrentFrame; - EventNumberType m_scrubberCurrentEvent; - FrameNumberType m_playbackLoopBegin; - FrameNumberType m_playbackLoopEnd; - AZStd::string m_priorSaveFolder; - - DrillerCaptureWindowSavedState() - : m_fpsValue(60) - , m_scrubberCurrentFrame(0) - , m_scrubberCurrentEvent(0) - , m_playbackLoopBegin(0) - , m_playbackLoopEnd(0) - {} - - void Init(const QByteArray& windowState, const QByteArray& windowGeom) - { - AzToolsFramework::MainWindowSavedState::Init(windowState, windowGeom); - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_ChannelIDs", &DrillerCaptureWindowSavedState::m_ChannelIDs) - ->Field("m_fpsValue", &DrillerCaptureWindowSavedState::m_fpsValue) - ->Field("m_scrubberCurrentFrame", &DrillerCaptureWindowSavedState::m_scrubberCurrentFrame) - ->Field("m_scrubberCurrentEvent", &DrillerCaptureWindowSavedState::m_scrubberCurrentEvent) - ->Field("m_playbackLoopBegin", &DrillerCaptureWindowSavedState::m_playbackLoopBegin) - ->Field("m_playbackLoopEnd", &DrillerCaptureWindowSavedState::m_playbackLoopEnd) - ->Field("m_priorSaveFolder", &DrillerCaptureWindowSavedState::m_priorSaveFolder) - ->Version(8); - } - } - }; - - // WORKSPACES are files loaded and stored independent of the global application - // designed to be used for DRL data specific view settings and to pass around - class DrillerCaptureWindowWorkspace - : public AZ::UserSettings - { - public: - AZ_RTTI(DrillerCaptureWindowWorkspace, "{EB67D4B6-41F5-4CED-85F1-E98586036BC6}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(DrillerCaptureWindowWorkspace, AZ::SystemAllocator, 0); - - DrillerCaptureWindowWorkspace() {} - - AZStd::list m_ChannelIDs; - AZStd::string m_matchingDataFileName; - FrameNumberType m_scrubberCurrentFrame; - FrameNumberType m_frameRangeBegin; - FrameNumberType m_frameRangeEnd; - FrameNumberType m_visibleFrames; - int m_sliderPosition; - EventNumberType m_scrubberCurrentEvent; - - FrameNumberType m_playbackLoopBegin; - FrameNumberType m_playbackLoopEnd; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_ChannelIDs", &DrillerCaptureWindowWorkspace::m_ChannelIDs) - ->Field("m_matchingDataFileName", &DrillerCaptureWindowWorkspace::m_matchingDataFileName) - ->Field("m_scrubberCurrentFrame", &DrillerCaptureWindowWorkspace::m_scrubberCurrentFrame) - ->Field("m_frameRangeBegin", &DrillerCaptureWindowWorkspace::m_frameRangeBegin) - ->Field("m_frameRangeEnd", &DrillerCaptureWindowWorkspace::m_frameRangeEnd) - ->Field("m_visibleFrames", &DrillerCaptureWindowWorkspace::m_visibleFrames) - ->Field("m_playbackLoopBegin", &DrillerCaptureWindowWorkspace::m_playbackLoopBegin) - ->Field("m_playbackLoopEnd", &DrillerCaptureWindowWorkspace::m_playbackLoopEnd) - ->Field("m_sliderPosition", &DrillerCaptureWindowWorkspace::m_sliderPosition) - ->Field("m_scrubberCurrentEvent", &DrillerCaptureWindowWorkspace::m_scrubberCurrentEvent) - ->Version(6); - } - } - }; -} - -namespace Driller -{ - extern AZ::Uuid ContextID; - - const int DrillerCaptureWindow::s_availableFrameQuantities[] = { 30, 60, 120, 240, 480, 960, 0 }; - - ////////////////////////////////////////////////////////////////////////// - //DrillerCaptureWindow - DrillerCaptureWindow::DrillerCaptureWindow(CaptureMode captureMode, int identity, QWidget* parent, Qt::WindowFlags flags) - : QDockWidget(parent, flags) - , m_captureMode(captureMode) - , m_identity(identity) - , m_windowStateCRC(0) - { - initSharedResources(); - - AZStd::string windowStateStr = AZStd::string::format("DRILLER CAPTURE WINDOW STATE %i", m_identity); - m_windowStateCRC = AZ::Crc32(windowStateStr.c_str()); - - m_captureIsDirty = false; - - m_playbackIsActive = false; - m_draggingPlaybackLoopBegin = false; - m_draggingPlaybackLoopEnd = false; - m_draggingAnything = false; - m_manipulatingScrollBar = false; - m_frameRangeEnd = 0; - m_frameRangeBegin = 0; - m_ptrConfigureAnnotationsWindow = NULL; - m_isLoadingFile = false; - m_TargetConnected = false; - m_captureIsDirty = false; - m_bForceNextScrub = true; - m_captureId = 0; - - m_gui = azcreate(Ui::DrillerCaptureWindow, ()); - m_gui->setupUi(this); - - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - setFeatures(QDockWidget::DockWidgetClosable); - } - - m_gui->combinedEventsWidget->SetIdentity(m_identity); - - // Removing the title bar, since it's meaningless for us. - setTitleBarWidget(new QWidget()); - - connect(m_gui->playButton, SIGNAL(toggled(bool)), this, SLOT(OnPlayToggled(bool))); - - if (IsInLiveMode()) - { - connect(m_gui->captureButton, SIGNAL(toggled(bool)), this, SLOT(OnCaptureToggled(bool))); - } - else - { - m_gui->captureButton->setDisabled(true); - } - - connect(m_gui->frameScrubberBox, SIGNAL(valueChanged(int)), this, SLOT(OnFrameScrubberboxChanged(int))); - connect(m_gui->controlScrollBar, SIGNAL(sliderPressed()), this, SLOT(OnSliderPressed())); - connect(m_gui->controlScrollBar, SIGNAL(sliderMoved(int)), this, SLOT(OnNewSliderValue(int))); - connect(m_gui->controlScrollBar, SIGNAL(valueChanged(int)), this, SLOT(OnNewSliderValue(int))); - - QMenu* quantMenu = new QMenu(this); - - QSignalMapper* ptrMapper = new QSignalMapper(this); - int numQuantsAvailable = sizeof(s_availableFrameQuantities) / sizeof(int); - for (int idx = 0; idx < numQuantsAvailable; ++idx) - { - int thisQuant = s_availableFrameQuantities[idx]; - - QString label = thisQuant ? tr("%1 frames").arg(s_availableFrameQuantities[idx]) : tr("All frames"); - - // connect to mapper: - QAction* act = new QAction(label, this); - connect(act, SIGNAL(triggered()), ptrMapper, SLOT(map())); - ptrMapper->setMapping(act, thisQuant); - quantMenu->addAction(act); - } - connect(ptrMapper, SIGNAL(mapped(int)), this, SLOT(OnQuantMenuFinal(int))); - - m_gui->quantityButton->setText("120 frames"); - m_gui->quantityButton->setMenu(quantMenu); - - m_gui->scrollArea->setBackgroundRole(QPalette::Dark); - DrillerNetworkMessages::Handler::BusConnect(m_identity); - - m_visibleFrames = 120; - - QString tmpCapturePath = PrepTempFile(baseTempFileName); - m_data = aznew DrillerDataContainer(m_identity, tmpCapturePath.toUtf8().data()); - - connect(this, SIGNAL(ScrubberFrameUpdate(FrameNumberType)), m_gui->combinedEventsWidget, SLOT(SetScrubberFrame(FrameNumberType))); - - m_ptrAnnotationsHeaderView = aznew AnnotationHeaderView(&m_AnnotationProvider, this); - m_gui->channelLayout->addWidget(m_ptrAnnotationsHeaderView); - - connect(m_ptrAnnotationsHeaderView, SIGNAL(OnOptionsClick()), this, SLOT(OnAnnotationOptionsClick())); - connect(m_ptrAnnotationsHeaderView, SIGNAL(InformOfMouseOverAnnotation(const Annotation&)), this, SLOT(InformOfMouseOverAnnotation(const Annotation&))); - connect(m_ptrAnnotationsHeaderView, SIGNAL(InformOfClickAnnotation(const Annotation&)), this, SLOT(InformOfClickAnnotation(const Annotation&))); - connect(&m_AnnotationProvider, SIGNAL(SelectedAnnotationsChanged()), this, SLOT(OnSelectedAnnotationChannelsChanged())); - - // button state maintenance courtesy of the TargetManagerClient bus message(s) we handle - m_gui->captureButton->setEnabled(false); - - if (IsInLiveMode()) - { - AzFramework::TargetManagerClient::Bus::Handler::BusConnect(); - } - - StateReset(); - - m_gui->combinedEventsWidget->SetAnnotationsProvider(&m_AnnotationProvider); - - connect(m_gui->combinedEventsWidget->m_annotationHeaderView, SIGNAL(InformOfMouseOverAnnotation(const Annotation&)), this, SLOT(InformOfMouseOverAnnotation(const Annotation&))); - connect(m_gui->combinedEventsWidget->m_annotationHeaderView, SIGNAL(InformOfClickAnnotation(const Annotation&)), this, SLOT(InformOfClickAnnotation(const Annotation&))); - connect(this, SIGNAL(ScrubberFrameUpdate(FrameNumberType)), m_gui->combinedEventsWidget->m_annotationHeaderView, SLOT(OnScrubberFrameUpdate(FrameNumberType))); - connect(m_gui->actionClose, SIGNAL(triggered()), this, SLOT(OnCloseFile())); - - connect(m_gui->combinedEventsWidget, SIGNAL(EventRequestEventFocus(EventNumberType)), this, SLOT(EventRequestEventFocus(EventNumberType))); - - UpdateLiveControls(); - emit CaptureWindowSetToLive(IsInLiveMode()); - - RestoreWindowState(); - QTimer::singleShot(0, this, SLOT(OnUpdateScrollSize())); - - DrillerCaptureWindowRequestBus::Handler::BusConnect(m_identity); - } - - DrillerCaptureWindow::~DrillerCaptureWindow(void) - { - DrillerCaptureWindowRequestBus::Handler::BusDisconnect(m_identity); - DrillerNetworkMessages::Handler::BusDisconnect(m_identity); - AzFramework::TargetManagerClient::Bus::Handler::BusDisconnect(); - - delete m_data; - azdestroy(m_gui); - } - - bool DrillerCaptureWindow::event(QEvent* evt) - { - if (evt->type() == QEvent::WindowActivate) - { - emit CaptureWindowSetToLive(static_cast(IsInLiveMode())); - } - - // parent class - return QDockWidget::event(evt); - } - - ////////////////////////////////////////////////////////////////////////// - // internal workings - void DrillerCaptureWindow::StateReset() - { - if (m_visibleFrames == m_frameRangeEnd - m_frameRangeBegin + 1) - { - // full range was visible. - OnQuantMenuFinal(120); - } - - OnPlayToggled(false); - SetPlaybackLoopBegin(0); - SetPlaybackLoopEnd(0); - SetFrameRangeBegin(0); - SetFrameRangeEnd(0); - SetScrubberFrame(0); - m_bForceNextScrub = true; - - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->SetEndFrame(0); - } - - m_ptrAnnotationsHeaderView->SetEndFrame(0); - } - - void DrillerCaptureWindow::UpdateLiveControls() - { - bool isViewingStoredData = IsInCaptureMode(CaptureMode::Inspecting); - - // these overlapping frames must be both hidden and then one made visible - // otherwise the containing window is forced wide enough to support both - // which overrides previous sizes and leaves a ton of dead space behind - m_gui->targetFrame->setVisible(!isViewingStoredData); - - m_gui->playButton->setVisible(isViewingStoredData); - m_gui->frameFPS->setVisible(isViewingStoredData); - m_gui->frameScrubberBox->setEnabled(isViewingStoredData); - - // For now, we're not sure if we want to keep this, or expand on it - // going ahead. So for now we'll just hide it. - m_gui->combinedEventsWidget->setVisible(false); - - if (IsInCaptureMode(CaptureMode::Configuration)) - { - m_gui->frame->setVisible(false); - m_gui->quantityButton->setVisible(false); - } - else - { - m_gui->frame->setVisible(true); - m_gui->quantityButton->setVisible(true); - } - - emit CaptureWindowSetToLive(!isViewingStoredData); - } - - void DrillerCaptureWindow::SetCaptureMode(CaptureMode captureMode) - { - if (m_captureMode != captureMode) - { - m_captureMode = captureMode; - emit OnCaptureModeChange(m_captureMode); - } - } - - void DrillerCaptureWindow::ResetCaptureControls() - { - // Reset the state of the UI Controls - m_currentDataFilename = ""; - SetCaptureMode(CaptureMode::Configuration); - OnCloseFile(); - m_data->CloseCaptureData(); - m_data->CreateAggregators(); - UpdateLiveControls(); - } - - bool DrillerCaptureWindow::IsInLiveMode() const - { - return IsInCaptureMode(CaptureMode::Capturing) || IsInCaptureMode(CaptureMode::Configuration); - } - - bool DrillerCaptureWindow::IsInCaptureMode(CaptureMode captureMode) const - { - return m_captureMode == captureMode; - } - - void DrillerCaptureWindow::ClearExistingChannels() - { - ClearChannelDisplay(true); - } - - void DrillerCaptureWindow::ClearChannelDisplay(bool withDeletion) - { - if (withDeletion) - { - m_gui->combinedEventsWidget->ClearAggregatorList(); - - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - m_gui->channelLayout->removeWidget(*iter); - delete *iter; - } - m_channels.clear(); - } - else - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - m_gui->channelLayout->removeWidget(*iter); - } - } - - // layouts take one message process to update their sizes, we need to queue a refresh of our scroll area at the end of the event queue - // so that the sizeHint() will be correct. - QTimer::singleShot(0, this, SLOT(OnUpdateScrollSize())); - } - - void DrillerCaptureWindow::SortChannels() - { - SortedChannels temp; - - // two passes, first pushes active channels and second pushes the remaining inactive channels - // this maintains the relative order of the list within categories to avoid surprises - for (ChannelControl* channelControl : m_channels) - { - if (channelControl->IsActive()) - { - temp.push_back(channelControl); - } - } - - for (ChannelControl* channelControl : m_channels) - { - if (!channelControl->IsActive()) - { - channelControl->OnContractedToggled(false); - temp.push_back(channelControl); - } - } - - m_channels.clear(); - m_channels = temp; - temp.clear(); - } - - void DrillerCaptureWindow::PopulateChannelDisplay() - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - m_gui->channelLayout->addWidget(*iter); - (*iter)->SetDataPointsInView(m_visibleFrames); - } - // layouts take one message process to update their sizes, we need to queue a refresh of our scroll area at the end of the event queue - // so that the sizeHint() will be correct. - QTimer::singleShot(0, this, SLOT(OnUpdateScrollSize())); - } - - void DrillerCaptureWindow::OnUpdateScrollSize() - { - // this just tells the scroll area to tell its layout that it has a new sizehint - m_gui->scrollArea->updateGeometry(); - } - - ChannelControl* DrillerCaptureWindow::FindChannelControl(Aggregator* aggregator) - { - ChannelControl* retVal = nullptr; - - QString channelName = aggregator->GetChannelName(); - AZ::Crc32 groupCRC = AZ::Crc32(channelName.toStdString().c_str()); - - for (ChannelControl* channelControl : m_channels) - { - if (groupCRC == channelControl->GetChannelId()) - { - retVal = channelControl; - break; - } - } - - if (retVal == nullptr) - { - retVal = aznew ChannelControl(channelName.toStdString().c_str(), &m_AnnotationProvider); - - if (retVal) - { - m_channels.push_back(retVal); - } - } - - return retVal; - } - - void DrillerCaptureWindow::AddChannelDisplay(ChannelControl* cc) - { - m_gui->channelLayout->addWidget(cc); - - // layouts take one message process to update their sizes, we need to queue a refresh of our scroll area at the end of the event queue - // so that the sizeHint() will be correct. - QTimer::singleShot(0, this, SLOT(OnUpdateScrollSize())); - } - - ////////////////////////////////////////////////////////////////////////// - // Driller Network Messages - void DrillerCaptureWindow::ConnectedToNetwork() - { - if (m_isLoadingFile) - { - return; - } - - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - return; - } - - StateReset(); - } - - void DrillerCaptureWindow::ConnectChannelControl(ChannelControl* dc) - { - if (!dc->IsSetup()) - { - connect(dc, SIGNAL(GetInspectionFileName()), this, SLOT(GetOpenFileName())); - connect(dc, SIGNAL(RequestScrollToFrame(FrameNumberType)), this, SLOT(HandleScrollToFrameRequest(FrameNumberType))); - connect(dc, SIGNAL(InformOfMouseClick(Qt::MouseButton, FrameNumberType, FrameNumberType, int)), this, SLOT(OnChannelControlMouseDown(Qt::MouseButton, FrameNumberType, FrameNumberType, int))); - connect(dc, SIGNAL(InformOfMouseMove(FrameNumberType, FrameNumberType, int)), this, SLOT(OnChannelControlMouseMove(FrameNumberType, FrameNumberType, int))); - connect(dc, SIGNAL(InformOfMouseRelease(Qt::MouseButton, FrameNumberType, FrameNumberType, int)), this, SLOT(OnChannelControlMouseUp(Qt::MouseButton, FrameNumberType, FrameNumberType, int))); - connect(dc, SIGNAL(InformOfMouseWheel(FrameNumberType, int, FrameNumberType, int)), this, SLOT(OnChannelControlMouseWheel(FrameNumberType, int, FrameNumberType, int))); - connect(dc, SIGNAL(ExpandedContracted()), this, SLOT(OnUpdateScrollSize())); - - connect(this, SIGNAL(ScrubberFrameUpdate(FrameNumberType)), dc, SLOT(SetScrubberFrame(FrameNumberType))); - connect(this, SIGNAL(ShowYourself()), dc, SLOT(OnShowCommand())); - connect(this, SIGNAL(HideYourself()), dc, SLOT(OnHideCommand())); - connect(this, SIGNAL(OnCaptureModeChange(CaptureMode)), dc, SLOT(SetCaptureMode(CaptureMode))); - - dc->SetCaptureMode(m_captureMode); - - dc->SignalSetup(); - } - } - - // target that you're connected to knows what aggregators are ready. - void DrillerCaptureWindow::NewAggregatorsAvailable() - { - if (m_isLoadingFile) - { - return; - } - - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - return; - } - - // otherwise, make em, if we're live. - m_data->CreateAggregators(); - } - - // incoming driller bus message - void DrillerCaptureWindow::NewAggregatorList(AggregatorList& theList) - { - ClearExistingChannels(); - - if (theList.size()) - { - for (AggregatorList::iterator iter = theList.begin(); iter != theList.end(); ++iter) - { - ChannelControl* channelControl = FindChannelControl((*iter)); - ConnectChannelControl(channelControl); - - ChannelProfilerWidget* profilerWidget = channelControl->AddAggregator((*iter)); - - if (profilerWidget) - { - // defaults to active - // restore previous inactive state if GUIDs match - bool wasInactive = (m_inactiveChannels.find(profilerWidget->GetID()) != m_inactiveChannels.end()); - profilerWidget->SetIsActive(!wasInactive); - } - } - - PopulateChannelDisplay(); - - m_gui->combinedEventsWidget->AddAggregatorList(theList); - m_gui->captureButton->setEnabled(true); - } - } - - void DrillerCaptureWindow::AddAggregator(Aggregator& theAggregator) - { - ChannelControl* channelControl = FindChannelControl(&theAggregator); - - if (!channelControl->IsSetup()) - { - ConnectChannelControl(channelControl); - AddChannelDisplay(channelControl); - } - - ChannelProfilerWidget* profilerWidget = channelControl->AddAggregator(&theAggregator); - - if (profilerWidget) - { - // defaults to active - // restore previous inactive state if GUIDs match - int wasInactive = (m_inactiveChannels.find(profilerWidget->GetID()) != m_inactiveChannels.end()); - profilerWidget->SetIsActive(!wasInactive); - } - - m_gui->captureButton->setEnabled(true); - m_gui->combinedEventsWidget->AddAggregator(theAggregator); - } - - void DrillerCaptureWindow::DiscardAggregators() - { - ClearExistingChannels(); - m_gui->captureButton->setEnabled(false); - } - - // incoming driller bus message - void DrillerCaptureWindow::DisconnectedFromNetwork() - { - //todo: phughes message the user or something - } - - void DrillerCaptureWindow::UpdateEndFrameInControls() - { - if (!m_isLoadingFile) - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->SetEndFrame(m_frameRangeEnd); - } - m_ptrAnnotationsHeaderView->SetEndFrame(m_frameRangeEnd); - } - } - - QString DrillerCaptureWindow::GetOpenFileName() const - { - AZ_Error("DrillerCaptureWindow", IsInCaptureMode(CaptureMode::Inspecting), "Trying to get file name in non-inspected case"); - return m_currentDataFilename; - } - - // incoming driller bus message - void DrillerCaptureWindow::EndFrame(FrameNumberType frame) - { - // if we're loading a file then we do not scrub these live: - SetFrameRangeEnd(frame); - UpdateEndFrameInControls(); - } - - // incoming driller bus message - void DrillerCaptureWindow::ScrubberFrame(FrameNumberType frame) - { - emit ScrubberFrameUpdate(frame); - m_gui->frameScrubberBox->setValue(static_cast(frame)); - } - - ////////////////////////////////////////////////////////////////////////// - // Data Viewer Request Messages - void DrillerCaptureWindow::EventRequestEventFocus(EventNumberType eventIdx) - { - m_scrubberCurrentEvent = eventIdx; - - EBUS_EVENT_ID(m_identity, Driller::DrillerEventWindowMessages::Bus, EventFocusChanged, eventIdx); - } - - void DrillerCaptureWindow::SetScrubberEvent(EventNumberType eventIdx) - { - EventRequestEventFocus(eventIdx); - } - - ////////////////////////////////////////////////////////////////////////// - // GUI Messages - void DrillerCaptureWindow::OnCaptureToggled(bool toggleState) - { - DrillerOperationTelemetryEvent captureEvent; - - if (toggleState) - { - captureEvent.SetAttribute("StartDataCapture", ""); - captureEvent.SetMetric("CaptureId", m_captureId); - - QString activeChannels; - - bool appendComma = false; - - for (ChannelControl* channel : m_channels) - { - const AZStd::list< ChannelProfilerWidget* >& profilers = channel->GetProfilers(); - - for (ChannelProfilerWidget* profiler : profilers) - { - if (profiler->IsActive()) - { - if (appendComma) - { - activeChannels.append(","); - } - - appendComma = true; - activeChannels.append(profiler->GetName()); - } - } - } - - captureEvent.SetAttribute("ActiveChannels", activeChannels.toStdString().c_str()); - - AZ_TracePrintf(drillerInfoName, "Capture ON, starting a new data session\n"); - OnPlayToggled(false); - m_gui->captureButton->setText(tr("Stop Capture")); - m_gui->captureButton->setToolTip(tr("Stop Capturing Driller Data")); - StateReset(); - - SetCaptureMode(CaptureMode::Capturing); - - m_AnnotationProvider.Clear(); - - ClearChannelDisplay(false); - SortChannels(); - PopulateChannelDisplay(); - - if (m_data) - { - m_data->StartDrilling(); - } - - SetCaptureDirty(true); - UpdateLiveControls(); - } - else - { - captureEvent.SetAttribute("StopDataCapture", ""); - captureEvent.SetMetric("CaptureId", m_captureId); - - ++m_captureId; - - AZ_TracePrintf(drillerInfoName, "Capture OFF, freezing data for analysis\n"); - m_gui->captureButton->setText(tr("Capture")); - m_gui->captureButton->setToolTip(tr("Begin Capturing Driller Data")); - - bool wascapturing = IsInCaptureMode(CaptureMode::Capturing); - - CaptureMode::Inspecting; - emit OnCaptureModeChange(m_captureMode); - - if (m_data) - { - m_data->StopDrilling(); - } - - if (wascapturing) - { - OnSaveDrillerFile(); - ScrubberToEnd(); - SetFrameRangeEnd(0); - // counting on the OnSave to recognize the TMP file from the capture and copy appropriately - // and setting it to our currently active data file - } - } - - captureEvent.Log(); - - update(); - } - - void DrillerCaptureWindow::SetCaptureDirty(bool isDirty) - { - m_captureIsDirty = isDirty; - } - - void DrillerCaptureWindow::OnMenuCloseCurrentWindow() - { - AZ_TracePrintf(drillerDebugName, "Close requested\n"); - - OnCaptureToggled(false); - OnCloseFile(); - - EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, RequestMainWindowClose, ContextID); - } - - void DrillerCaptureWindow::OnOpen() - { - AZ_TracePrintf(drillerDebugName, "Open requested\n"); - - this->show(); - emit ShowYourself(); - } - - void DrillerCaptureWindow::OnClose() - { - OnCloseFile(); - } - - void DrillerCaptureWindow::OnCloseFile() - { - SaveWindowState(); - - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - AZ_TracePrintf(drillerDebugName, "Close requested of file\n"); - m_data->CloseCaptureData(); - this->close(); - deleteLater(); - } - } - - void DrillerCaptureWindow::OnContractAllChannels() - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->OnContractedToggled(true); - } - } - - void DrillerCaptureWindow::OnExpandAllChannels() - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->OnContractedToggled(false); - } - } - - void DrillerCaptureWindow::OnDisableAllChannels() - { - for (ChannelControl* channelControl : m_channels) - { - channelControl->SetAllProfilersEnabled(false); - } - } - void DrillerCaptureWindow::OnEnableAllChannels() - { - for (ChannelControl* channelControl : m_channels) - { - channelControl->SetAllProfilersEnabled(true); - } - } - - void DrillerCaptureWindow::OnToBegin() - { - ScrubberToBegin(); - m_gui->controlScrollBar->setValue(m_frameRangeBegin); - } - - void DrillerCaptureWindow::OnToEnd() - { - // set the scroll view to scroll to the end: - ScrubberToEnd(); - } - - void DrillerCaptureWindow::OnPlayToggled(bool toggleState) - { - if (toggleState) - { - m_gui->playButton->setText(tr("Stop")); - m_gui->playButton->setToolTip(tr("Stop recorded session playback")); - m_playbackIsActive = true; - OnCaptureToggled(false); - int msec = 1000 / m_gui->fpsBox->value(); - QTimer::singleShot(msec, this, SLOT(PlaybackTick())); - } - else - { - m_gui->playButton->setText(tr("Play")); - m_gui->playButton->setToolTip(tr("Playback recorded session")); - m_gui->playButton->blockSignals(true); - m_gui->playButton->setChecked(false); - m_gui->playButton->blockSignals(false); - m_playbackIsActive = false; - } - } - - void DrillerCaptureWindow::PlaybackTick() - { - if (m_playbackIsActive) - { - if (m_scrubberCurrentFrame >= m_playbackLoopEnd) - { - SetScrubberFrame(m_playbackLoopBegin); - } - else if (m_scrubberCurrentFrame < m_playbackLoopBegin) - { - SetScrubberFrame(m_playbackLoopBegin); - } - else - { - SetScrubberFrame(m_scrubberCurrentFrame + 1); - } - - FocusScrollbar(m_scrubberCurrentFrame - (m_visibleFrames / 2)); - - int msec = 1000 / m_gui->fpsBox->value(); - QTimer::singleShot(msec, this, SLOT(PlaybackTick())); - } - } - - void DrillerCaptureWindow::OnSliderPressed() - { - if (m_playbackIsActive) - { - OnPlayToggled(false); - } - } - - void DrillerCaptureWindow::OnNewSliderValue(int newValue) - { - if (!m_manipulatingScrollBar && m_playbackIsActive) - { - OnPlayToggled(false); - } - - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->SetSliderOffset(newValue); - } - - m_ptrAnnotationsHeaderView->SetSliderOffset(newValue); - } - - void DrillerCaptureWindow::OnFrameScrubberboxChanged(int newValue) - { - SetScrubberFrame(newValue); - } - - void DrillerCaptureWindow::OnQuantMenuFinal(int range) - { - FrameNumberType frameRange = static_cast(range); - - if (frameRange <= 1) - { - frameRange = m_frameRangeEnd - m_frameRangeBegin + 1; - } - m_visibleFrames = frameRange; - - m_gui->quantityButton->setText(QString("%1 frames").arg(frameRange)); - - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->SetDataPointsInView(frameRange); - } - m_ptrAnnotationsHeaderView->SetDataPointsInView(frameRange); - } - - void DrillerCaptureWindow::FocusScrollbar(FrameNumberType focusFrame) - { - m_manipulatingScrollBar = true; - - // range of motion for the scrollbar covers the off-window area, not the total - FrameNumberType range = m_frameRangeEnd - m_visibleFrames + 1; - range = range >= m_frameRangeBegin ? range : m_frameRangeBegin; - - m_gui->controlScrollBar->setRange(m_frameRangeBegin, range); - - FrameNumberType curVal = focusFrame < 0 ? 0 : focusFrame; - curVal = focusFrame > range ? range : focusFrame; - m_gui->controlScrollBar->setValue(curVal); - - m_manipulatingScrollBar = false; - } - - ////////////////////////////////////////////////////////////////////////// - // State Control and Maintenance - void DrillerCaptureWindow::ScrubberToBegin() - { - SetScrubberFrame(GetFrameRangeBegin()); - } - - void DrillerCaptureWindow::ScrubberToEnd() - { - SetScrubberFrame(GetFrameRangeEnd()); - } - - void DrillerCaptureWindow::HandleScrollToFrameRequest(FrameNumberType frame) - { - FocusScrollbar(frame); - } - - void DrillerCaptureWindow::OnChannelControlMouseDown(Qt::MouseButton whichButton, FrameNumberType frame, FrameNumberType range, int modifiers) - { - // If we aren't inspecting data, we don't to mess around with anything. - if (!IsInCaptureMode(CaptureMode::Inspecting)) - { - return; - } - - if (modifiers & Qt::AltModifier) - { - if (whichButton == Qt::LeftButton) - { - SetPlaybackLoopBegin(frame); - } - if (whichButton == Qt::RightButton) - { - SetPlaybackLoopEnd(frame); - } - return; - } - - // Don't want to fight the user for control, relinquish our manipulation once they start doing stuff. - if (m_playbackIsActive) - { - OnPlayToggled(false); - } - - // we grab with the left button, pan with the right. - if (whichButton == Qt::LeftButton) - { - m_draggingAnything = true; - - if (abs(frame - m_playbackLoopBegin) <= range) - { - m_draggingPlaybackLoopBegin = true; - m_draggingPlaybackLoopEnd = false; - } - else if (abs(frame - m_playbackLoopEnd) <= range) - { - m_draggingPlaybackLoopBegin = false; - m_draggingPlaybackLoopEnd = true; - } - else - { - m_draggingPlaybackLoopBegin = false; - m_draggingPlaybackLoopEnd = false; - - SetScrubberFrame(frame); - } - } - } - - void DrillerCaptureWindow::OnChannelControlMouseMove(FrameNumberType frame, FrameNumberType range, int modifiers) - { - (void)range; - (void)modifiers; - - //ShowDrillerChannelTip(frame); - - if (m_draggingAnything) - { - if (m_draggingPlaybackLoopBegin) - { - SetPlaybackLoopBegin(frame); - } - else if (m_draggingPlaybackLoopEnd) - { - SetPlaybackLoopEnd(frame); - } - else - { - SetScrubberFrame(frame); - } - } - } - - void DrillerCaptureWindow::OnChannelControlMouseUp(Qt::MouseButton whichButton, FrameNumberType frame, FrameNumberType range, int modifiers) - { - (void)range; - (void)modifiers; - (void)frame; - - if (whichButton == Qt::LeftButton) - { - m_draggingAnything = false; - } - } - - void DrillerCaptureWindow::OnChannelControlMouseWheel(FrameNumberType frame, int wheelAmount, FrameNumberType range, int modifiers) - { - (void)range; - (void)modifiers; - - FrameNumberType currentVisibleFrames = m_visibleFrames; - bool zoomingIn = wheelAmount > 0; - if (zoomingIn) - { - // zooming in: - // find the next step DOWN from where we are and set our quant zoom to that - // since its from zoomed all the way in to out. The last element is assumed the special one. - - if (currentVisibleFrames == s_availableFrameQuantities[0]) - { - return; - } - - // before we zoom in, where is the given frame within our scroll area? - int leftSideOfScreen = m_gui->controlScrollBar->value(); - float fraction = (float)(frame - leftSideOfScreen) / (float)m_visibleFrames; - - int numQuantsAvailable = sizeof(s_availableFrameQuantities) / sizeof(int); - int quantChosen = -1; - for (int quantIndex = numQuantsAvailable - 2; quantIndex >= 0; --quantIndex) - { - if (currentVisibleFrames > s_availableFrameQuantities[quantIndex]) - { - quantChosen = s_availableFrameQuantities[quantIndex]; - break; - } - } - - if (quantChosen != -1) - { - OnQuantMenuFinal(quantChosen); - - // we want to focus the scrollbar at the same fraction as before - FocusScrollbar(frame - (int)((float)m_visibleFrames * fraction)); - } - } - else - { - // zooming out: - // find the next step DOWN from where we are and set our quant zoom to that - // since its from zoomed all the way in to out. The last element is assumed the special one. - - FrameNumberType fullRange = m_frameRangeEnd - m_frameRangeBegin + 1; - - if (currentVisibleFrames == fullRange) - { - return; - } - - int leftSideOfScreen = m_gui->controlScrollBar->value(); - float fraction = (float)(frame - leftSideOfScreen) / (float)m_visibleFrames; - - int numQuantsAvailable = sizeof(s_availableFrameQuantities) / sizeof(int); - - int quantChosen = -1; - for (int quantIndex = 0; quantIndex < numQuantsAvailable - 1; ++quantIndex) - { - if (currentVisibleFrames < s_availableFrameQuantities[quantIndex]) - { - quantChosen = s_availableFrameQuantities[quantIndex]; - break; - } - } - - if (quantChosen != -1) - { - OnQuantMenuFinal(quantChosen); - FocusScrollbar(frame - (int)((float)m_visibleFrames * fraction)); - } - } - } - - void DrillerCaptureWindow::SetScrubberFrame(FrameNumberType frame) - { - if ((!m_bForceNextScrub) && (frame == m_scrubberCurrentFrame)) - { - return; - } - - m_bForceNextScrub = false; - - m_scrubberCurrentFrame = frame >= m_frameRangeBegin ? frame : m_frameRangeBegin; - m_scrubberCurrentFrame = m_scrubberCurrentFrame <= m_frameRangeEnd ? m_scrubberCurrentFrame : m_frameRangeEnd; - - UpdateFrameScrubberbox(); - - ScrubberFrame(m_scrubberCurrentFrame); - - EBUS_EVENT_ID(m_identity, Driller::DrillerMainWindowMessages::Bus, FrameChanged, m_scrubberCurrentFrame); - m_AnnotationProvider.Finalize(); - } - - void DrillerCaptureWindow::SetPlaybackLoopBegin(FrameNumberType frame) - { - m_playbackLoopBegin = frame >= m_frameRangeBegin ? frame : m_frameRangeBegin; - m_playbackLoopBegin = m_playbackLoopBegin <= m_frameRangeEnd ? m_playbackLoopBegin : m_frameRangeEnd; - - m_playbackLoopEnd = m_playbackLoopEnd >= m_playbackLoopBegin ? m_playbackLoopEnd : m_playbackLoopBegin; - m_playbackLoopEnd = m_playbackLoopEnd <= m_frameRangeEnd ? m_playbackLoopEnd : m_frameRangeEnd; - - EBUS_EVENT_ID(m_identity, Driller::DrillerMainWindowMessages::Bus, PlaybackLoopBeginChanged, m_playbackLoopBegin); - - UpdatePlaybackLoopPoints(); - } - - void DrillerCaptureWindow::SetPlaybackLoopEnd(FrameNumberType frame) - { - m_playbackLoopEnd = frame >= m_frameRangeBegin ? frame : m_frameRangeBegin; - m_playbackLoopEnd = m_playbackLoopEnd <= m_frameRangeEnd ? m_playbackLoopEnd : m_frameRangeEnd; - - m_playbackLoopBegin = m_playbackLoopBegin >= m_playbackLoopEnd ? m_playbackLoopEnd : m_playbackLoopBegin; - m_playbackLoopBegin = m_playbackLoopBegin >= m_frameRangeBegin ? m_playbackLoopBegin : m_frameRangeBegin; - - EBUS_EVENT_ID(m_identity, Driller::DrillerMainWindowMessages::Bus, PlaybackLoopEndChanged, m_playbackLoopEnd); - - UpdatePlaybackLoopPoints(); - } - - void DrillerCaptureWindow::UpdatePlaybackLoopPoints() - { - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - (*iter)->SetLoopBegin(m_playbackLoopBegin); - (*iter)->SetLoopEnd(m_playbackLoopEnd); - } - } - - void DrillerCaptureWindow::SetFrameRangeBegin(FrameNumberType frame) - { - m_frameRangeBegin = frame; - - SetPlaybackLoopBegin(m_playbackLoopBegin); - SetPlaybackLoopEnd(m_playbackLoopEnd); - SetScrubberFrame(m_scrubberCurrentFrame); - UpdateFrameScrubberbox(); - UpdateScrollbar(); - } - - void DrillerCaptureWindow::SetFrameRangeEnd(FrameNumberType frame) - { - // if the scrubber/loop is on the last frame we always advance it to the new end - bool setScrubberToo = m_scrubberCurrentFrame == m_frameRangeEnd; - bool setEndloopToo = m_playbackLoopEnd == m_frameRangeEnd; - - FrameNumberType range = m_frameRangeEnd - m_visibleFrames + 1; - range = range >= m_frameRangeBegin ? range : m_frameRangeBegin; - - FrameNumberType priorFrameRangeEnd = m_frameRangeEnd; - - int diff = static_cast(frame - m_frameRangeEnd); - m_frameRangeEnd = frame; - - if (priorFrameRangeEnd < m_frameRangeEnd) - { - for (ChannelControl* channelControl : m_channels) - { - for (ChannelProfilerWidget* channelProfiler : channelControl->GetProfilers()) - { - Aggregator* aggregator = channelProfiler->GetAggregator(); - if (aggregator != nullptr) - { - aggregator->EmitAnnotationChannelsForFrameRange(priorFrameRangeEnd, m_frameRangeEnd, &m_AnnotationProvider); - aggregator->EmitAllAnnotationsForFrameRange(priorFrameRangeEnd, m_frameRangeEnd, &m_AnnotationProvider); - } - } - } - } - - if (!m_isLoadingFile) - { - SetScrubberFrame(setScrubberToo ? m_frameRangeEnd : m_scrubberCurrentFrame); - - SetPlaybackLoopBegin(m_playbackLoopBegin); - SetPlaybackLoopEnd(setEndloopToo ? m_frameRangeEnd : m_playbackLoopEnd); - UpdateFrameScrubberbox(); - UpdateScrollbar(diff); - } - } - - void DrillerCaptureWindow::UpdateFrameScrubberbox() - { - m_gui->frameScrubberBox->setRange(m_frameRangeBegin, m_frameRangeEnd); - m_gui->frameScrubberBox->setValue(m_scrubberCurrentFrame); - } - - void DrillerCaptureWindow::UpdateScrollbar(int diff) - { - int curVal = m_gui->controlScrollBar->value(); - - // range of motion for the scrollbar covers the off-window area, not the total - FrameNumberType range = m_frameRangeEnd - m_visibleFrames + 1; - range = range >= m_frameRangeBegin ? range : m_frameRangeBegin; - - m_gui->controlScrollBar->setRange(m_frameRangeBegin, range); - if (m_gui->controlScrollBar->value() >= range - 1) - { - m_gui->controlScrollBar->setValue(static_cast(range)); - } - else if (diff) - { - m_gui->controlScrollBar->setValue(static_cast(curVal)); - } - } - - ////////////////////////////////////////////////////////////////////////// - // when the Editor Main window is requested to close, it is not destroyed. - ////////////////////////////////////////////////////////////////////////// - // Qt Events - void DrillerCaptureWindow::closeEvent(QCloseEvent* event) - { - OnCloseFile(); - event->ignore(); - } - - void DrillerCaptureWindow::showEvent(QShowEvent* /*event*/) - { - emit ShowYourself(); - } - void DrillerCaptureWindow::hideEvent(QHideEvent* /*event*/) - { - emit HideYourself(); - } - - bool DrillerCaptureWindow::OnGetPermissionToShutDown() - { - OnCaptureToggled(false); - - bool willShutDown = true; - - ClearChannelDisplay(true); - - AZ_TracePrintf(drillerDebugName, " willShutDown == %d\n", (int)willShutDown); - return willShutDown; - } - - void DrillerCaptureWindow::ScrubToFrameRequest(FrameNumberType frame) - { - if (m_playbackIsActive) - { - OnPlayToggled(false); - } - - SetScrubberFrame(frame); - } - - void DrillerCaptureWindow::SaveWindowState() - { - m_inactiveChannels.clear(); - - for (auto iter = m_channels.begin(); iter != m_channels.end(); ++iter) - { - const AZStd::list< ChannelProfilerWidget*>& profilers = (*iter)->GetProfilers(); - - for (ChannelProfilerWidget* profiler : profilers) - { - if (!profiler->IsActive()) - { - m_inactiveChannels.insert(profiler->GetID()); - } - } - } - - // build state and store it. - auto newState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - //newState->Init(saveState(), saveGeometry()); - newState->m_ChannelIDs.clear(); - for (AZStd::set::iterator iter = m_inactiveChannels.begin(); iter != m_inactiveChannels.end(); ++iter) - { - newState->m_ChannelIDs.push_back(*iter); - } - - newState->m_fpsValue = m_gui->fpsBox->value(); - - newState->m_scrubberCurrentFrame = m_scrubberCurrentFrame; - newState->m_playbackLoopBegin = m_playbackLoopBegin; - newState->m_playbackLoopEnd = m_playbackLoopEnd; - newState->m_scrubberCurrentEvent = m_scrubberCurrentEvent; - } - - void DrillerCaptureWindow::RestoreWindowState() // call this after you have rebuilt everything. - { - // load the state from our state block: - auto savedState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (savedState) - { - QByteArray geomData((const char*)savedState->m_windowGeometry.data(), (int)savedState->m_windowGeometry.size()); - QByteArray stateData((const char*)savedState->GetWindowState().data(), (int)savedState->GetWindowState().size()); - - restoreGeometry(geomData); - if (this->isMaximized()) - { - this->showNormal(); - this->showMaximized(); - } - //restoreState(stateData); - - m_inactiveChannels.clear(); - for (auto iter = savedState->m_ChannelIDs.begin(); iter != savedState->m_ChannelIDs.end(); ++iter) - { - m_inactiveChannels.insert(*iter); - } - - m_gui->fpsBox->setValue(savedState->m_fpsValue); - - SetScrubberFrame(savedState->m_scrubberCurrentFrame); - SetPlaybackLoopBegin(savedState->m_playbackLoopBegin); - SetPlaybackLoopEnd(savedState->m_playbackLoopEnd); - SetScrubberEvent(savedState->m_scrubberCurrentEvent); - } - else - { - // default state! - } - } - - void DrillerCaptureWindow::OnOpenDrillerFile() - { - auto paths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); - QString capturePath; - if (paths.isEmpty()) - { - paths = QStandardPaths::standardLocations(QStandardPaths::TempLocation); - } - if (!paths.isEmpty()) - { - capturePath = paths.first(); - } - - QString fileName = QFileDialog::getOpenFileName(this, "Open Driller File", capturePath, "Driller Files (*.drl)"); - if (!fileName.isNull()) - { - OnOpenDrillerFile(fileName); - } - } - - void DrillerCaptureWindow::OnOpenDrillerFile(QString fileName) - { - if (m_data) - { - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - m_AnnotationProvider.Clear(); - - SetCaptureDirty(false); - m_currentDataFilename = fileName; - - m_isLoadingFile = true; - m_data->LoadCaptureData(fileName.toUtf8().data()); - m_isLoadingFile = false; - - SetCaptureMode(CaptureMode::Inspecting); - - m_bForceNextScrub = true; - EndFrame(m_frameRangeEnd); - SetPlaybackLoopBegin(0); - SetPlaybackLoopEnd(m_frameRangeEnd); - - OnQuantMenuFinal(m_visibleFrames); - - UpdateLiveControls(); - m_bForceNextScrub = true; - - ScrubberToEnd(); - QApplication::restoreOverrideCursor(); - } - } - - void DrillerCaptureWindow::OnOpenDrillerFileForWorkspace(QString fileName, QString workspaceFileName) - { - if (m_data) - { - QString successFileName; - - // does a file local to our given Workspace DRW exist? It gets preference on load. - QString localFileName(workspaceFileName.left(workspaceFileName.size() - 3) + "drl"); - if (AZ::IO::SystemFile::Exists(localFileName.toUtf8().data())) - { - successFileName = localFileName; - } - // does the workspace's suggested file exist? - else if (AZ::IO::SystemFile::Exists(fileName.toUtf8().data())) - { - successFileName = fileName; - } - // fall through to prompting the user for a DRL to use - else - { - QString userFileName = QFileDialog::getOpenFileName(this, "Find Driller File", localFileName, "Driller Files (*.drl)"); - if (!userFileName.isNull()) - { - successFileName = userFileName; - } - } - - if (!successFileName.isEmpty() && !successFileName.isNull()) - { - SetCaptureDirty(false); - m_currentDataFilename = successFileName; - - m_isLoadingFile = true; - m_data->LoadCaptureData(m_currentDataFilename.toUtf8().data()); - m_isLoadingFile = false; - - SetCaptureMode(CaptureMode::Inspecting); - - m_bForceNextScrub = true; - EndFrame(m_frameRangeEnd); - - OnQuantMenuFinal(m_visibleFrames); - m_bForceNextScrub = true; - ScrubberToEnd(); - UpdateLiveControls(); - } - } - } - - void DrillerCaptureWindow::RepopulateAnnotations() - { - // re-query all the annotations now that you have your settings. - m_AnnotationProvider.Clear(); - - if (m_frameRangeEnd != 0) - { - for (ChannelControl* channelControl : m_channels) - { - for (ChannelProfilerWidget* profiler : channelControl->GetProfilers()) - { - Aggregator* aggregator = profiler->GetAggregator(); - - if (aggregator != nullptr) - { - aggregator->EmitAnnotationChannelsForFrameRange(0, m_frameRangeEnd, &m_AnnotationProvider); - aggregator->EmitAllAnnotationsForFrameRange(0, m_frameRangeEnd, &m_AnnotationProvider); - } - } - } - } - m_AnnotationProvider.Finalize(); - } - - void DrillerCaptureWindow::OnOpenWorkspaceFile(QString workspaceFileName, bool openDrillerFileAlso) - { - OnCaptureToggled(false); - - if (m_data) - { - m_AnnotationProvider.Clear(); - // 1: spawn a new local settings object using the DRW - if (!AZ::IO::SystemFile::Exists(workspaceFileName.toUtf8().data())) - { - QMessageBox::warning(this, tr("File not found"), tr("Unable to find the specified file '%1'").arg(workspaceFileName), QMessageBox::Ok, QMessageBox::Ok); - return; - } - - WorkspaceSettingsProvider* provider = WorkspaceSettingsProvider::CreateFromFile(workspaceFileName.toUtf8().data()); - if (!provider) - { - QMessageBox::warning(this, tr("Corrupted file?"), tr("Unable to parse the specified file '%1'").arg(workspaceFileName), QMessageBox::Ok, QMessageBox::Ok); - return; - } - - // 2: extract therefrom the associated DRL file - AZStd::string windowStateStr = AZStd::string::format("DRILLER CAPTURE WINDOW WORKSPACE"); - AZ::u32 workspaceCRC = AZ::Crc32(windowStateStr.c_str()); - - DrillerCaptureWindowWorkspace* workspace = provider->FindSetting(workspaceCRC); - if (!workspace) - { - QMessageBox::warning(this, tr("Corrupted file?"), tr("Specified file '%1' does not appear to contain a workspace.").arg(workspaceFileName), QMessageBox::Ok, QMessageBox::Ok); - return; - } - - m_inactiveChannels.clear(); - for (auto iter = workspace->m_ChannelIDs.begin(); iter != workspace->m_ChannelIDs.end(); ++iter) - { - m_inactiveChannels.insert(*iter); - } - - // 3: load that data, which in turn clears and re-instantiates all needed aggregators - // other side effects include changing the current filename and replacing any current data loaded - if (openDrillerFileAlso) - { - m_isLoadingFile = true; - OnOpenDrillerFileForWorkspace(QString(workspace->m_matchingDataFileName.c_str()), workspaceFileName); - m_isLoadingFile = false; - } - - SetCaptureMode(CaptureMode::Inspecting); - - // 4: extract from the DRW any settings that I have saved there - // 5: synchronous EBUS message that informs all the aggregators that new settings are available - EBUS_EVENT_ID(m_identity, Driller::DrillerWorkspaceWindowMessages::Bus, ApplySettingsFromWorkspace, provider); - m_AnnotationProvider.LoadSettingsFromWorkspace(provider); - - // 6: aggregators are responsible for checking if any of their data dialogs are required, and open them - - EBUS_EVENT_ID(m_identity, Driller::DrillerWorkspaceWindowMessages::Bus, ActivateWorkspaceSettings, provider); - - // 7: main window itself should load its settings, which will include the current scrubber frame - m_scrubberCurrentFrame = 0; - m_scrubberCurrentEvent = 0; - m_playbackLoopBegin = 0; - m_playbackLoopEnd = 0; - - SetFrameRangeBegin(workspace->m_frameRangeBegin); - SetFrameRangeEnd(workspace->m_frameRangeEnd); - m_bForceNextScrub = true; - SetScrubberFrame(workspace->m_scrubberCurrentFrame); - SetPlaybackLoopBegin(workspace->m_playbackLoopBegin); - SetPlaybackLoopEnd(workspace->m_playbackLoopEnd); - OnQuantMenuFinal(workspace->m_visibleFrames); - m_gui->controlScrollBar->setSliderPosition(workspace->m_sliderPosition); - - SetScrubberEvent(workspace->m_scrubberCurrentEvent); - - // 8: close the local settings DRW - delete provider; - - RepopulateAnnotations(); - } - } - - void DrillerCaptureWindow::OnApplyWorkspaceFile(QString fileName) - { - if (!fileName.isNull()) - { - if (m_data) - { - OnOpenWorkspaceFile(fileName, false); - } - } - } - - void DrillerCaptureWindow::OnSaveWorkspaceFile(QString fileName, bool automated) - { - if (!fileName.isNull()) - { - if (m_data) - { - // 1: spawn a new local settings object using the DRW - WorkspaceSettingsProvider provider; - - // 2: push my own settings into the DRW - // plus logic to copy/rename tmp DRL files - AZStd::string windowStateStr = AZStd::string::format("DRILLER CAPTURE WINDOW WORKSPACE"); - AZ::u32 workspaceCRC = AZ::Crc32(windowStateStr.c_str()); - - DrillerCaptureWindowWorkspace* workspace = provider.CreateSetting(workspaceCRC); - if (!automated) - { - m_currentDataFilename = PrepDataFileForSaving(m_currentDataFilename, fileName); - } - workspace->m_matchingDataFileName = m_currentDataFilename.toUtf8().data(); - - m_inactiveChannels.clear(); - for (ChannelControl* channelControl : m_channels) - { - for (ChannelProfilerWidget* profilerWidget : channelControl->GetProfilers()) - { - if (!profilerWidget->IsActive()) - { - m_inactiveChannels.insert(profilerWidget->GetID()); - } - } - } - - workspace->m_ChannelIDs.clear(); - for (AZStd::set::iterator iter = m_inactiveChannels.begin(); iter != m_inactiveChannels.end(); ++iter) - { - workspace->m_ChannelIDs.push_back(*iter); - } - workspace->m_scrubberCurrentFrame = m_scrubberCurrentFrame; - workspace->m_frameRangeBegin = m_frameRangeBegin; - workspace->m_frameRangeEnd = m_frameRangeEnd; - workspace->m_visibleFrames = m_visibleFrames; - workspace->m_scrubberCurrentEvent = m_scrubberCurrentEvent; - - workspace->m_playbackLoopBegin = m_playbackLoopBegin; - workspace->m_playbackLoopEnd = m_playbackLoopEnd; - workspace->m_sliderPosition = m_gui->controlScrollBar->sliderPosition(); - - // 3: synchronous EBUS message that informs all the aggregators to push their own settings into the DRW - // 4: aggregators are responsible for dealing with their display view dialogs internally - EBUS_EVENT_ID(m_identity, Driller::DrillerWorkspaceWindowMessages::Bus, SaveSettingsToWorkspace, &provider); - m_AnnotationProvider.SaveSettingsToWorkspace(&provider); - - if (!provider.WriteToFile(fileName.toUtf8().data())) - { - SetCaptureDirty(true); - QMessageBox::warning(this, tr("Could not save workspace"), tr("Unable to write data to the specified file '%1'").arg(fileName), QMessageBox::Ok, QMessageBox::Ok); - } - else - { - SetCaptureDirty(false); - } - UpdateLiveControls(); - } - } - } - - void DrillerCaptureWindow::OnSaveDrillerFile() - { - if (m_frameRangeEnd <= 0) - { - if (m_identity == 0) - { - ResetCaptureControls(); - } - return; - } - - QString saveCapturePath; - QString tempWorkspaceName; - - auto newState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (!newState->m_priorSaveFolder.empty()) - { - saveCapturePath = newState->m_priorSaveFolder.data(); - } - else - { - auto paths = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); - - if (paths.isEmpty()) - { - paths = QStandardPaths::standardLocations(QStandardPaths::TempLocation); - } - - if (!paths.isEmpty()) - { - saveCapturePath = paths.first(); - } - } - - bool success = false; - - while (!success) - { - QString sourcename = m_tmpCaptureFilename; - - if (!m_currentDataFilename.isEmpty()) - { - sourcename = m_currentDataFilename; - } - - QString fileName = QFileDialog::getSaveFileName(this, "Save Driller File As...", saveCapturePath, "Driller Files (*.drl)"); - if (!fileName.isNull()) - { - SetCaptureDirty(false); - if (sourcename == fileName) - { - QMessageBox::warning(this, tr("Unable to save"), tr("You can't save a data file over itself ( '%1' to '%2' )").arg(sourcename).arg(fileName)); - } - else - { - (void)QFile::remove(fileName); - success = QFile::copy(sourcename, fileName); - if (success) - { - m_currentDataFilename = fileName; - - { - QTemporaryFile f; - f.setAutoRemove(false); - if (f.open()) - { - tempWorkspaceName = f.fileName(); - } - } - if (!tempWorkspaceName.isEmpty()) - { - OnSaveWorkspaceFile(tempWorkspaceName, true); - } - - ResetCaptureControls(); - - EBUS_EVENT(Driller::DrillerDataViewMessages::Bus, EventRequestOpenWorkspace, tempWorkspaceName.toUtf8().data()); - auto deleteResult = QFile::remove(tempWorkspaceName); - if (!deleteResult) - { - QMessageBox::warning(this, tr("Can't delete temp file"), tr("File = ( %1 )").arg(tempWorkspaceName)); - } - - return; - } - else - { - QMessageBox::warning(this, tr("Unable to save"), tr("Could not copy '%1' to '%2'").arg(sourcename).arg(fileName)); - } - } - } - - if (fileName.isNull() || m_identity == 0) // close this window if no file named OR this is a LIVE channel - { - ResetCaptureControls(); - return; - } - } - } - - QString DrillerCaptureWindow::PrepDataFileForSaving(QString filename, QString workspaceName) - { - // is this a TMP file? - QString tempPath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - if (filename.contains(tempPath, Qt::CaseInsensitive)) - { - // yes := rename to match workspace - QString newFilename(workspaceName.left(workspaceName.size() - 3) + "drl"); - // and then copy - QFile::copy(filename, newFilename); - m_currentDataFilename = newFilename; - UpdateLiveControls(); - return newFilename; - } - - return filename; - } - - QString DrillerCaptureWindow::PrepTempFile(QString filename) - { - QString tmpCapturePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - tmpCapturePath = QDir(tmpCapturePath).absoluteFilePath(filename); - m_tmpCaptureFilename = tmpCapturePath; - m_currentDataFilename = m_tmpCaptureFilename; - return tmpCapturePath; - } - - void DrillerCaptureWindow::OnAnnotationOptionsClick() - { - // show the annotations configure window: - if (m_ptrConfigureAnnotationsWindow) - { - m_ptrConfigureAnnotationsWindow->raise(); - } - else - { - m_ptrConfigureAnnotationsWindow = aznew ConfigureAnnotationsWindow(this); - m_ptrConfigureAnnotationsWindow->Initialize(&m_AnnotationProvider); - connect(m_ptrConfigureAnnotationsWindow, SIGNAL(destroyed(QObject*)), this, SLOT(OnAnnotationsDialogDestroyed())); - m_ptrConfigureAnnotationsWindow->show(); - } - } - - void DrillerCaptureWindow::OnSelectedAnnotationChannelsChanged() - { - // rebuild the annotations. - RepopulateAnnotations(); - // update the views. - } - - - void DrillerCaptureWindow::OnAnnotationsDialogDestroyed() - { - m_ptrConfigureAnnotationsWindow = NULL; - } - - void DrillerCaptureWindow::InformOfMouseOverAnnotation(const Annotation& annotation) - { - if (m_collectedAnnotations.empty()) - { - QTimer::singleShot(0, this, SLOT(CommitAnnotationsCollected())); - } - m_collectedAnnotations.push_back(annotation); - } - - void DrillerCaptureWindow::CommitAnnotationsCollected() - { - FrameNumberType frameCounter = -1; - QString finalText; - AZ::u32 priorCRC = 0; - - AZStd::sort(m_collectedAnnotations.begin(), m_collectedAnnotations.end(), - [](const Annotation& first, const Annotation& second) - { - return first.GetEventIndex() < second.GetEventIndex(); - } - ); - - int numConcated = 0; - for (auto iter = m_collectedAnnotations.begin(); iter != m_collectedAnnotations.end(); ++iter) - { - if (numConcated > 10) - { - int numRemaining = (int)m_collectedAnnotations.size() - numConcated; - finalText += QString("... and %1 other annotations").arg(numRemaining); - break; - } - ++numConcated; - - const Annotation& annot = *iter; - if ((annot.GetFrameIndex() == frameCounter) && (priorCRC == annot.GetChannelCRC())) - { - finalText += QString("Event %1: '%2'
").arg(annot.GetEventIndex()).arg(annot.GetText().c_str()); - } - else if (annot.GetFrameIndex() == frameCounter) - { - finalText += QString("%2
Event %3: '%4'
").arg(annot.GetChannel().c_str()).arg(annot.GetEventIndex()).arg(annot.GetText().c_str()); - } - else - { - finalText += QString("Frame %1
%2
Event %3: '%4'
").arg(annot.GetFrameIndex()).arg(annot.GetChannel().c_str()).arg(annot.GetEventIndex()).arg(annot.GetText().c_str()); - } - - frameCounter = annot.GetFrameIndex(); - priorCRC = annot.GetChannelCRC(); - } - - QToolTip::showText(QCursor::pos(), finalText); - m_collectedAnnotations.clear(); - } - - void DrillerCaptureWindow::InformOfClickAnnotation(const Annotation& annotation) - { - (void)annotation; - } - - ////////////////////////////////////////////////////////////////////////// - // Target Manager Messages - void DrillerCaptureWindow::DesiredTargetConnected(bool connected) - { - m_TargetConnected = connected; - - if (IsInCaptureMode(CaptureMode::Inspecting)) - { - return; - } - - // - have an existing capture? - // - - ask to save it - if (IsInCaptureMode(CaptureMode::Capturing)) - { - OnSaveDrillerFile(); - } - - QString tmpCapturePath; - - if (connected) - { - SetScrubberFrame(0); - SetFrameRangeBegin(0); - SetFrameRangeEnd(0); - SetCaptureDirty(false); - - tmpCapturePath = PrepTempFile(baseTempFileName); - } - else - { - SetScrubberFrame(0); - SetFrameRangeBegin(0); - SetFrameRangeEnd(0); - SetCaptureDirty(false); - - m_gui->captureButton->setEnabled(false); - m_gui->captureButton->setText(tr("Capture")); - m_gui->captureButton->setToolTip(tr("Begin Capturing Driller Data")); - - tmpCapturePath.clear(); - } - - UpdateLiveControls(); - } - - void DrillerCaptureWindow::Reflect(AZ::ReflectContext* context) - { - // data container is the one place that knows about all the aggregators - // and indeed is responsible for creating them - DrillerDataContainer::Reflect(context); - DrillerCaptureWindowWorkspace::Reflect(context); - DrillerCaptureWindowSavedState::Reflect(context); - AnnotationsProvider::Reflect(context); - - AZ::BehaviorContext* behaviorContext = azrtti_cast(context); - if (behaviorContext) - { - behaviorContext->Class("DrillerCaptureWindow")-> - Method("ShowWindow", &DrillerCaptureWindow::OnOpen)-> - Method("HideWindow", &DrillerCaptureWindow::OnClose); - } - } -}//namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.hxx b/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.hxx deleted file mode 100644 index 91374c6ff2..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.hxx +++ /dev/null @@ -1,269 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DrillerCaptureWindow_H -#define DRILLER_DrillerCaptureWindow_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include - -#include "DrillerNetworkMessages.h" -#include "DrillerMainWindowMessages.h" -#include "AzFramework/TargetManagement/TargetManagementAPI.h" -#include -#include "Workspaces/Workspace.h" -#include "Annotations/Annotations.hxx" - - -#pragma once - -class QMenu; -class QAction; -class QToolbar; -class QSettings; - -#include -#include -#include -#endif - -namespace Ui -{ - class DrillerCaptureWindow; -} - -namespace Driller -{ - class ChannelControl; - class DrillerDataContainer; - class CombinedEventsControl; - class AnnotationHeaderView; - class ConfigureAnnotationsWindow; - - /* - This is the original guts of the singular Driller Main Window - - Home of the real commands, channels created from external aggregators when connected, and the floating control panel. - All inputs end up here where they are interpreted and passed downwards to all channels, to maintain consistency. - */ - - ////////////////////////////////////////////////////////////////////////// - //Main Window - class DrillerCaptureWindow - : public QDockWidget - , public Driller::DrillerNetworkMessages::Bus::Handler - , public Driller::DrillerCaptureWindowRequestBus::Handler - , private AzFramework::TargetManagerClient::Bus::Handler - { - Q_OBJECT; - public: - AZ_TYPE_INFO(DrillerCaptureWindow, "08AF3402-FCFA-4441-910D-9F994BD0D146"); - AZ_CLASS_ALLOCATOR(DrillerCaptureWindow,AZ::SystemAllocator,0); - DrillerCaptureWindow(CaptureMode captureMode, int identity, QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - DrillerCaptureWindow(const DrillerCaptureWindow&) - : m_identity(0) - { - // TODO: Once AZ_NO_COPY macros is in the branch in use it! - AZ_Assert(false, "You can't copy this class!"); - } - virtual ~DrillerCaptureWindow(void); - - bool OnGetPermissionToShutDown(); - - // DrillerCaptureWindowRequestBus - void ScrubToFrameRequest(FrameNumberType frameType) override; - - public: - - // Driller network messages - virtual void ConnectedToNetwork(); - virtual void NewAggregatorList( AggregatorList &theList ); - virtual void AddAggregator( Aggregator &theAggregator ); - virtual void DiscardAggregators(); - virtual void DisconnectedFromNetwork(); - virtual void EndFrame(FrameNumberType frame); - virtual void NewAggregatorsAvailable(); - - // Data Viewer request messages - // implement AzFramework::TargetManagerClient::Bus::Handler - void DesiredTargetConnected(bool connected); - - public: - // MainWindow Messages and states. - void SaveWindowState(); - AZStd::set m_inactiveChannels; - - void OnContractAllChannels(); - void OnExpandAllChannels(); - void OnDisableAllChannels(); - void OnEnableAllChannels(); - QString GetDataFileName() { return m_currentDataFilename; } - - private: - // how the main window identifies us - const int m_identity; - CaptureMode m_captureMode; - - // internal workings - typedef QList SortedChannels; - SortedChannels m_channels; - - void SetCaptureMode(CaptureMode captureMode); - void ResetCaptureControls(); - bool IsInLiveMode() const; - bool IsInCaptureMode(CaptureMode captureMode) const; - - void ClearExistingChannels(); - void ClearChannelDisplay( bool withDeletion ); - void SortChannels(); - void PopulateChannelDisplay(); - ChannelControl* FindChannelControl(Aggregator* aggregator); - void AddChannelDisplay(ChannelControl *); - - protected: - // Qt Events - virtual void closeEvent(QCloseEvent* event); - virtual void showEvent( QShowEvent * event ); - virtual void hideEvent( QHideEvent * event ); - virtual bool event(QEvent *evt); - - ////////////////////////////////////////////////////////////////////////// - void StateReset(); - QString PrepDataFileForSaving( QString filename, QString workspaceName ); - QString PrepTempFile( QString filename ); - - void ScrubberToBegin(); - void ScrubberToEnd(); - void SetScrubberFrame( FrameNumberType frame ); - FrameNumberType GetScrubberFrame() { return m_scrubberCurrentFrame; } - void SetPlaybackLoopBegin( FrameNumberType frame ); - FrameNumberType GetPlaybackLoopBegin() { return m_playbackLoopBegin; } - void SetPlaybackLoopEnd( FrameNumberType frame ); - FrameNumberType GetPlaybackLoopEnd() { return m_playbackLoopEnd; } - void SetFrameRangeBegin( FrameNumberType frame ); - FrameNumberType GetFrameRangeBegin() { return m_frameRangeBegin; } - void SetFrameRangeEnd( FrameNumberType frame); - FrameNumberType GetFrameRangeEnd() { return m_frameRangeEnd; } - - void UpdateFrameScrubberbox(); - void ScrubberFrame(FrameNumberType frame); - - void UpdateEventScrubberbox(); - void SetScrubberEvent( EventNumberType eventIdx ); - - void UpdateScrollbar( int diff = 0 ); - void FocusScrollbar( FrameNumberType focusFrame ); - void UpdatePlaybackLoopPoints(); - - void ConnectChannelControl(ChannelControl *dc); - - void SetCaptureDirty( bool isDirty ); - - void UpdateLiveControls(); - - AZ::u32 m_windowStateCRC; - - FrameNumberType m_scrubberCurrentFrame; - FrameNumberType m_frameRangeBegin; - FrameNumberType m_frameRangeEnd; - FrameNumberType m_visibleFrames; - EventNumberType m_scrubberCurrentEvent; - bool m_captureIsDirty; - - int m_playbackIsActive; - FrameNumberType m_playbackLoopBegin; - FrameNumberType m_playbackLoopEnd; - bool m_draggingPlaybackLoopBegin; - bool m_draggingPlaybackLoopEnd; - bool m_draggingAnything; - bool m_manipulatingScrollBar; - DrillerDataContainer* m_data; ///< Pointer to driller data class. - QString m_tmpCaptureFilename; - QString m_currentDataFilename; - AnnotationsProvider m_AnnotationProvider; - - bool m_isLoadingFile; - - AnnotationHeaderView* m_ptrAnnotationsHeaderView; - ConfigureAnnotationsWindow *m_ptrConfigureAnnotationsWindow; - AZStd::vector m_collectedAnnotations; - bool m_bForceNextScrub; - - int m_captureId; - - // are we viewing stored data or are we live drilling? - bool m_TargetConnected; - ////////////////////////////////////////////////////////////////////////// - - static const int s_availableFrameQuantities[]; - - public slots: - void RepopulateAnnotations(); - void RestoreWindowState(); - void OnMenuCloseCurrentWindow(); - void OnOpen(); - void OnClose(); - void OnCloseFile(); - void OnToBegin(); - void OnToEnd(); - void OnPlayToggled(bool toggleState); - void OnCaptureToggled(bool toggleState); - void OnSliderPressed(); - void OnNewSliderValue(int newValue); - void OnFrameScrubberboxChanged(int newValue); - void OnQuantMenuFinal( int range ); - void HandleScrollToFrameRequest( FrameNumberType frame); - void OnChannelControlMouseDown( Qt::MouseButton whichButton, FrameNumberType frame, FrameNumberType range, int modifiers ); - void OnChannelControlMouseMove( FrameNumberType frame, FrameNumberType range, int modifiers ); - void OnChannelControlMouseUp( Qt::MouseButton whichButton, FrameNumberType frame, FrameNumberType range, int modifiers ); - void OnChannelControlMouseWheel( FrameNumberType frame, int wheelAmount, FrameNumberType range, int modifiers ); - void OnOpenDrillerFile(); - void OnOpenDrillerFile(QString fileName); - void OnOpenDrillerFileForWorkspace(QString fileName, QString workspaceFileName); - void OnOpenWorkspaceFile(QString fileName, bool openDrillerFileAlso); // just open it - void OnApplyWorkspaceFile(QString fileName); - void OnSaveDrillerFile(); - void OnSaveWorkspaceFile(QString fileName, bool automated = false); - - void PlaybackTick(); - void OnUpdateScrollSize(); - void EventRequestEventFocus(EventNumberType eventIdx); - - // --- annotations: - void OnSelectedAnnotationChannelsChanged(); - void OnAnnotationOptionsClick(); - void InformOfMouseOverAnnotation(const Annotation& annotation); - void InformOfClickAnnotation(const Annotation& annotation); - void OnAnnotationsDialogDestroyed(); - void CommitAnnotationsCollected(); - - void UpdateEndFrameInControls(); - - QString GetOpenFileName() const; - -signals: - void ScrubberFrameUpdate( FrameNumberType frame ); - void ShowYourself(); - void HideYourself(); - void OnCaptureModeChange(CaptureMode); - void CaptureWindowSetToLive(bool); - - public: - static void Reflect(AZ::ReflectContext* context); - - private: - - Ui::DrillerCaptureWindow* m_gui; - }; -} - -#endif //DRILLER_DrillerCaptureWindow_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.ui b/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.ui deleted file mode 100644 index 5d53341e1c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerCaptureWindow.ui +++ /dev/null @@ -1,610 +0,0 @@ - - - DrillerCaptureWindow - - - - 0 - 0 - 1046 - 497 - - - - - 0 - 0 - - - - - 677 - 177 - - - - - :/general/hex_profiler_icon:/general/hex_profiler_icon - - - true - - - - - - QDockWidget::NoDockWidgetFeatures - - - Qt::BottomDockWidgetArea|Qt::TopDockWidgetArea - - - Driller - - - - false - - - - - - - 0 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 0 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 0 - - - - - 128 - 0 - - - - Select the target Application to be profiled. - - - Target: None - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 60 - 16777215 - - - - Begin capturing Application data - - - Capture - - - C - - - true - - - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - 0 - - - - 2 - - - 6 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - Playback Speed - - - true - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - Playback FPS - - - 1 - - - 60 - - - 60 - - - - - - - - - - - 0 - 0 - - - - - 80 - 0 - - - - - 80 - 26 - - - - - - - Play - - - Space - - - true - - - - - - - Qt::Horizontal - - - - 0 - 30 - - - - - - - - QFrame::NoFrame - - - QFrame::Plain - - - - 1 - - - 2 - - - 3 - - - 2 - - - 2 - - - - - Frame - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - Scrubbed Frame - - - 0 - - - 100000 - - - 0 - - - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - The number of frames visible in the graphs - - - Show: 1000 - - - - 72 - 32 - - - - QToolButton::MenuButtonPopup - - - Qt::ToolButtonTextOnly - - - - - - - - - - - - - 0 - 0 - - - - Qt::ScrollBarAsNeeded - - - Qt::ScrollBarAsNeeded - - - QAbstractScrollArea::AdjustIgnored - - - true - - - Qt::AlignJustify|Qt::AlignTop - - - - - 0 - 0 - 1040 - 16 - - - - - 0 - 0 - - - - - 3 - - - QLayout::SetNoConstraint - - - 0 - - - 0 - - - 0 - - - 3 - - - - - - - - - - 0 - 0 - - - - QFrame::NoFrame - - - QFrame::Raised - - - 0 - - - - 0 - - - 0 - - - 2 - - - 0 - - - 14 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 250 - 20 - - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - true - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 0 - 0 - - - - - - - - - Capture - - - Start Capturing Data From the Active Drills - - - C - - - - - Freeze - - - Stop Capturing From the Drills and Freeze the Data - - - S - - - - - Close Current File - - - Ctrl+F4 - - - - - - Driller::CombinedEventsControl - QWidget -
CombinedEventsControl.hxx
- 1 -
- - AzToolsFramework::AZAutoSizingScrollArea - QScrollArea -
AzToolsFramework/UI/UICore/AZAutoSizingScrollArea.hxx
- 1 -
- - AzToolsFramework::TargetSelectorButton - QPushButton -
AzToolsFramework/UI/UICore/TargetSelectorButton.hxx
-
-
- - fpsBox - frameScrubberBox - - - - - -
diff --git a/Code/Tools/Standalone/Source/Driller/DrillerContext.cpp b/Code/Tools/Standalone/Source/Driller/DrillerContext.cpp deleted file mode 100644 index ab69fe714c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerContext.cpp +++ /dev/null @@ -1,299 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerContext.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace Driller -{ - const char* DrillerDebugName = "Profiler"; - const char* DrillerInfoName = "Profiler"; - - class DrillerSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(DrillerSavedState, "{CBA064FC-B144-4B9D-92B8-F696B0A15E4D}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(DrillerSavedState, AZ::SystemAllocator, 0); - - bool m_MainDrillerWindowIsVisible; - bool m_MainDrillerWindowIsOpen; - - DrillerSavedState() - : m_MainDrillerWindowIsVisible(true) - , m_MainDrillerWindowIsOpen(true) {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(1) - ->Field("m_MainDrillerWindowIsVisible", &DrillerSavedState::m_MainDrillerWindowIsVisible) - ->Field("m_MainDrillerWindowIsOpen", &DrillerSavedState::m_MainDrillerWindowIsOpen); - } - } - }; - - AZ::Uuid ContextID("FB8B7094-63FF-4CD1-9857-3AEFA8E2CFDC"); - - - ////////////////////////////////////////////////////////////////////////// - //Context - Context::Context() - : m_pDrillerMainWindow(NULL) - { - } - - Context::~Context() - { - } - - ////////////////////////////////////////////////////////////////////////// - // AZ::Component - void Context::Init() - { - } - - void Context::Activate() - { - ContextInterface::Handler::BusConnect(ContextID); - LegacyFramework::CoreMessageBus::Handler::BusConnect(); - - AzToolsFramework::MainWindowDescription desc; - desc.name = "Profiler"; - desc.ContextID = ContextID; - desc.hotkeyDesc = AzToolsFramework::HotkeyDescription(AZ_CRC("DrillerOpen", 0x1cbbd497), "Ctrl+Shift+D", "Open Profiler", "General", 1, AzToolsFramework::HotkeyDescription::SCOPE_WINDOW); - EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, AddComponentInfo, desc); - - bool connectedToAssetProcessor = false; - - // When the AssetProcessor is already launched it should take less than a second to perform a connection - // but when the AssetProcessor needs to be launch it could take up to 15 seconds to have the AssetProcessor initialize - // and able to negotiate a connection when running a debug build - // and to negotiate a connection - - AzFramework::AssetSystem::ConnectionSettings connectionSettings; - AzFramework::AssetSystem::ReadConnectionSettingsFromSettingsRegistry(connectionSettings); - connectionSettings.m_connectionDirection = AzFramework::AssetSystem::ConnectionSettings::ConnectionDirection::ConnectToAssetProcessor; - connectionSettings.m_connectionIdentifier = desc.name; - AzFramework::AssetSystemRequestBus::BroadcastResult(connectedToAssetProcessor, - &AzFramework::AssetSystemRequestBus::Events::EstablishAssetProcessorConnection, connectionSettings); - } - - void Context::Deactivate() - { - LegacyFramework::CoreMessageBus::Handler::BusDisconnect(); - ContextInterface::Handler::BusDisconnect(ContextID); - } - - void Context::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - DrillerMainWindow::Reflect(context); - DrillerSavedState::Reflect(context); - - serialize->Class() - ->Version(1) - ; - } - } - - void Context::ApplicationDeactivated() - { - } - - void Context::ApplicationActivated() - { - } - - void Context::ApplicationShow(AZ::Uuid id) - { - if (ContextID == id) - { - ProvisionalShowAndFocus(true); - } - } - void Context::ApplicationHide(AZ::Uuid id) - { - if (ContextID == id) - { - m_pDrillerMainWindow->hide(); - AZStd::intrusive_ptr newState = AZ::UserSettings::CreateFind(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL); - newState->m_MainDrillerWindowIsVisible = false; - } - } - - void Context::ApplicationCensus() - { - AZStd::intrusive_ptr newState = AZ::UserSettings::CreateFind(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL); - EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, ApplicationCensusReply, newState->m_MainDrillerWindowIsVisible); - } - - - ////////////////////////////////////////////////////////////////////////// - // EditorFramework CoreMessages - void Context::OnRestoreState() - { - const AZStd::string k_launchString = "launch"; - const AZStd::string k_drillerString = "driller"; - - bool GUIMode = true; - EBUS_EVENT_RESULT(GUIMode, LegacyFramework::FrameworkApplicationMessages::Bus, IsRunningInGUIMode); - if (!GUIMode) - { - return; - } - - const AzFramework::CommandLine* commandLine = nullptr; - - EBUS_EVENT_RESULT(commandLine, LegacyFramework::FrameworkApplicationMessages::Bus, GetCommandLineParser); - - bool forceShow = false; - bool forceHide = false; - - if (commandLine->HasSwitch(k_launchString)) - { - forceHide = true; - - size_t numSwitchValues = commandLine->GetNumSwitchValues(k_launchString); - - for (size_t i = 0; i < numSwitchValues; ++i) - { - AZStd::string inputValue = commandLine->GetSwitchValue(k_launchString, i); - - if (inputValue.compare(k_drillerString) == 0) - { - forceShow = true; - forceHide = false; - } - } - } - - ProvisionalShowAndFocus(forceShow, forceHide); - } - - bool Context::OnGetPermissionToShutDown() // until everyone returns true, we can't shut down. - { - AZ_TracePrintf(DrillerDebugName, "Context::OnGetPermissionToShutDown()\n"); - - if (m_pDrillerMainWindow) - { - if (!m_pDrillerMainWindow->OnGetPermissionToShutDown()) - { - return false; - } - } - - return true; - } - - // until everyone returns true, we can't shut down. - bool Context::CheckOkayToShutDown() - { - if (m_pDrillerMainWindow) - { - // confirmation that we're quitting. - if (m_pDrillerMainWindow->isVisible()) - { - m_pDrillerMainWindow->setEnabled(false); - m_pDrillerMainWindow->hide(); - } - } - - return true; - } - - void Context::OnSaveState() - { - // notify main view to persist? - if (m_pDrillerMainWindow) - { - m_pDrillerMainWindow->SaveWindowState(); - } - } - - void Context::OnDestroyState() - { - if (m_pDrillerMainWindow) - { - delete m_pDrillerMainWindow; - } - m_pDrillerMainWindow = NULL; - } - - ////////////////////////////////////////////////////////////////////////// - // Utility - void Context::ProvisionalShowAndFocus(bool forcedShow, bool forcedHide) - { - AZStd::intrusive_ptr newState = AZ::UserSettings::CreateFind(AZ_CRC("LUA DRILLER CONTEXT STATE", 0x95052376), AZ::UserSettings::CT_GLOBAL); - - if (forcedShow) - { - newState->m_MainDrillerWindowIsOpen = true; - newState->m_MainDrillerWindowIsVisible = true; - } - else if (forcedHide) - { - newState->m_MainDrillerWindowIsOpen = false; - newState->m_MainDrillerWindowIsVisible = false; - } - - if (newState->m_MainDrillerWindowIsOpen) - { - if (newState->m_MainDrillerWindowIsVisible) - { - if (!m_pDrillerMainWindow) - { - m_pDrillerMainWindow = aznew DrillerMainWindow(); - } - - m_pDrillerMainWindow->show(); - m_pDrillerMainWindow->raise(); - m_pDrillerMainWindow->activateWindow(); - m_pDrillerMainWindow->setFocus(); - } - else - { - if (m_pDrillerMainWindow) - { - m_pDrillerMainWindow->hide(); - } - } - } - } - - - ////////////////////////////////////////////////////////////////////////// - //ContextInterface - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - - void Context::ShowDrillerView() - { - ProvisionalShowAndFocus(true); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/DrillerContext.h b/Code/Tools/Standalone/Source/Driller/DrillerContext.h deleted file mode 100644 index 018c1f58b5..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerContext.h +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include -#include -#include "DrillerContextInterface.h" -#include "DrillerMainWindow.hxx" - -#include - -#pragma once - - -namespace Driller -{ - ////////////////////////////////////////////////////////////////////////// - // Context - // all editor components are responsible for maintaining the list of documents they are responsible for - // and setting up editing facilities on those asset types in that "space". - // editor contexts are components and have component ID's because we will communicate to them via buses. - - // this is the data side of drilling. - // for example, data flow, discovery, that sort of thing. - - class Context - : public AZ::Component - , private LegacyFramework::CoreMessageBus::Handler - , private ContextInterface::Handler - { - friend class ContextFactory; - public: - AZ_COMPONENT(Driller::Context, "{60EC92BD-1D96-4E37-AB46-DF89A5497617}") - - Context(); - virtual ~Context(); - - ////////////////////////////////////////////////////////////////////////// - // AZ::Component - virtual void Init(); - virtual void Activate(); - virtual void Deactivate(); - static void Reflect(AZ::ReflectContext* context); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // EditorFramework CoreMessages - virtual void OnRestoreState(); // sent when everything is registered up and ready to go, this is what bootstraps stuff to get going. - virtual bool OnGetPermissionToShutDown(); - virtual bool CheckOkayToShutDown(); - virtual void OnSaveState(); // sent to everything when the app is about to shut down - do what you need to do. - virtual void OnDestroyState(); - virtual void ApplicationDeactivated(); - virtual void ApplicationActivated(); - virtual void ApplicationShow(AZ::Uuid id); - virtual void ApplicationHide(AZ::Uuid id); - virtual void ApplicationCensus(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // EditorFramework::AssetManagementMessages - //virtual bool RawFileOpenRequested(const EditorFramework::RegisteredAssetType& registeredTypeID, const char *fullPathName); - ////////////////////////////////////////////////////////////////////////// - - virtual void ShowDrillerView(); - - ////////////////////////////////////////////////////////////////////////// - // internal data structure for the class/member/property reference panel - // this is what we serialize and work with - DrillerMainWindow* m_pDrillerMainWindow; - - private: - - // utility - void ProvisionalShowAndFocus(bool forceShow = false, bool forceHide = false); - }; - - class ClassReferenceItem - : public QStandardItem - { - public: - AZ_CLASS_ALLOCATOR(ClassReferenceItem, AZ::SystemAllocator, 0); - - ClassReferenceItem(const QIcon& icon, const QString& text, size_t id); - ClassReferenceItem(const QString& text, size_t id); - ~ClassReferenceItem() {} - - size_t GetTypeID() {return m_ID; } - protected: - size_t m_ID; - }; -}; - diff --git a/Code/Tools/Standalone/Source/Driller/DrillerContextInterface.h b/Code/Tools/Standalone/Source/Driller/DrillerContextInterface.h deleted file mode 100644 index 4fe88e83e5..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerContextInterface.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLERCONTEXTINTERFACE_H -#define DRILLERCONTEXTINTERFACE_H - -#include -#include -#include - -namespace Driller -{ - class ContextInterface - : public LegacyFramework::EditorContextMessages - { - public: - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - virtual void ShowDrillerView() = 0; - }; -} - -#endif //DRILLERCONTEXTINTERFACE_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.cpp b/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.cpp deleted file mode 100644 index 061ead6b03..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.cpp +++ /dev/null @@ -1,283 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerDataContainer.h" - -#include -#include -#include - -#include // temp for DebugHackProcessFile - -#include // metadata is stored this way - -#include "Unsupported/UnsupportedDataAggregator.hxx" -#include "Memory/MemoryDataAggregator.hxx" -#include "Trace/TraceMessageDataAggregator.hxx" -#include "Profiler/ProfilerDataAggregator.hxx" -#include "Carrier/CarrierDataAggregator.hxx" -#include "Replica/ReplicaDataAggregator.hxx" -#include "Rendering/VRAM/VRAMDataAggregator.hxx" -#include "EventTrace/EventTraceDataAggregator.h" -// IMPORTANT: include new aggregators above - - -namespace Driller -{ - class DrillerDataHandler : public AZ::Debug::DrillerHandlerParser - { - public: - AZ_CLASS_ALLOCATOR(DrillerDataHandler,AZ::SystemAllocator,0) - - DrillerDataHandler(int identity, DrillerDataContainer* container) - : AZ::Debug::DrillerHandlerParser(/*true*/false) - , m_identity(identity) - , m_currentFrame(-1) - , m_dataContainer(container) - , m_dataParser(nullptr) - { - m_drillerSessionInfo.m_platform = static_cast(AZ::g_currentPlatform); /// Init with current platform so no endian swapping till we read all the initial settings. - m_inputStream.SetStringPool(&m_stringPool); - m_dataParser = aznew AZ::Debug::DrillerSAXParserHandler(this); - } - - ~DrillerDataHandler() - { - delete m_dataParser; - } - - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName) - { - if( tagName == AZ_CRC("StartData", 0xecf3f53f) ) - return &m_drillerSessionInfo; - if( tagName == AZ_CRC("Frame", 0xb5f83ccd) ) - return this; - for(DrillerNetworkMessages::AggregatorList::iterator it = m_dataContainer->m_aggregators.begin(); it != m_dataContainer->m_aggregators.end(); ++it) - { - if( (*it)->GetDrillerId() == tagName ) - return (*it)->GetDrillerDataParser(); - } - - AZ_TracePrintf("Driller", "We should never get here as we should have added 'Unsupported driller(s)' in OnExitTag('StartData')"); - return nullptr; - } - - virtual void OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)handler; - if( tagName == AZ_CRC("StartData", 0xecf3f53f) ) - { - // create all drillers that were in the session data - for(AZ::Debug::DrillerManager::DrillerListType::iterator itDriller = m_drillerSessionInfo.m_drillers.begin(); itDriller != m_drillerSessionInfo.m_drillers.end(); ++itDriller ) - { - AZ::u32 drillerId = itDriller->id; - bool isCreated = false; - for(DrillerNetworkMessages::AggregatorList::iterator it = m_dataContainer->m_aggregators.begin(); it != m_dataContainer->m_aggregators.end(); ++it) - { - if( (*it)->GetDrillerId() == drillerId ) - { - isCreated = true; - break; - } - } - - if( !isCreated ) - { - // Create the aggregator, if the driller is missing add UnsupportedAggregator - Aggregator* aggr = m_dataContainer->CreateAggregator(drillerId, true); - if( aggr ) - m_dataContainer->m_aggregators.push_back(aggr); - - // two ways to add aggregators: - // 1) "NewAggregatorList" send an entire list which replaces the current setup, which is most efficient - // 2) "AddAggregator" send a single aggregator which gets appended - EBUS_EVENT_ID(m_identity, DrillerNetworkMessages::Bus,AddAggregator, *m_dataContainer->m_aggregators.back()); - } - } - } - } - - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - if( dataNode.m_name == AZ_CRC("FrameNum", 0x85a1a919) ) - { - // Send event that previous frame has finished - if( m_currentFrame != -1 ) - { - EBUS_EVENT_ID(m_identity, DrillerNetworkMessages::Bus,EndFrame, m_currentFrame); - } - dataNode.Read(m_currentFrame); - for(DrillerNetworkMessages::AggregatorList::iterator it = m_dataContainer->m_aggregators.begin(); it != m_dataContainer->m_aggregators.end(); ++it) - { - (*it)->AddNewFrame(); - } - } - } - - void ProcessStream(const char* streamIdentifier, const void* data, unsigned int dataSize) - { - m_inputStream.SetData(streamIdentifier, data, dataSize); - m_dataParser->ProcessStream(m_inputStream); - } - - AZ::Debug::DrillerStartdataHandler m_drillerSessionInfo; - int m_currentFrame; - DrillerDataContainer* m_dataContainer; - AZ::Debug::DrillerSAXParserHandler* m_dataParser; - AZ::Debug::DrillerInputMemoryStream m_inputStream; - AZ::Debug::DrillerDefaultStringPool m_stringPool; - int m_identity; - }; - - DrillerDataContainer::DrillerDataContainer(int identity, const char* tmpCaptureFilename) - : m_dataHandler(nullptr) - , m_identity(identity) - , m_tmpCaptureFilename(tmpCaptureFilename) - { - AzFramework::DrillerNetworkConsoleEventBus::Handler::BusConnect(); - EBUS_EVENT(AzFramework::DrillerNetworkConsoleCommandBus, EnumerateAvailableDrillers); - } - - DrillerDataContainer::~DrillerDataContainer() - { - AzFramework::DrillerNetworkConsoleEventBus::Handler::BusDisconnect(); - DestroyAggregators(); - - delete m_dataHandler; - } - - void DrillerDataContainer::OnReceivedDrillerEnumeration(const AzFramework::DrillerInfoListType& availableDrillers) - { - // TODO: Decide how the available driller list should influence the behavior of the driller - // display. For now we will display whatever is available. - m_availableDrillers = availableDrillers; - EBUS_EVENT_ID(m_identity, DrillerNetworkMessages::Bus, NewAggregatorsAvailable); - } - - void DrillerDataContainer::CreateAggregators() - { - DestroyAggregators(); - - if (m_availableDrillers.size()) - { - for (size_t i = 0; i < m_availableDrillers.size(); ++i) - { - Aggregator* aggr = CreateAggregator(m_availableDrillers[i].m_id, true); - if( aggr ) - m_aggregators.push_back(aggr); - } - } - EBUS_EVENT_ID(m_identity, DrillerNetworkMessages::Bus, NewAggregatorList,m_aggregators); - } - - void DrillerDataContainer::DestroyAggregators() - { - EBUS_EVENT_ID(m_identity, DrillerNetworkMessages::Bus, DiscardAggregators); - - for(DrillerNetworkMessages::AggregatorList::iterator it = m_aggregators.begin(); it != m_aggregators.end(); ++it ) - delete *it; - m_aggregators.clear(); - } - - Aggregator* DrillerDataContainer::CreateAggregator(AZ::u32 id, bool createUnsupported) - { - if( id == MemoryDataAggregator::DrillerId() ) - { - return aznew MemoryDataAggregator(m_identity); - } - else if( id == TraceMessageDataAggregator::DrillerId() ) - { - return aznew TraceMessageDataAggregator(m_identity); - } - else if (id == ProfilerDataAggregator::DrillerId() ) - { - return aznew ProfilerDataAggregator(m_identity); - } - else if(id == CarrierDataAggregator::DrillerId()) - { - return aznew CarrierDataAggregator(m_identity); - } - else if(id == ReplicaDataAggregator::DrillerId()) - { - return aznew ReplicaDataAggregator(m_identity); - } - else if(id == VRAM::VRAMDataAggregator::DrillerId()) - { - return aznew VRAM::VRAMDataAggregator(m_identity); - } - else if (id == EventTraceDataAggregator::DrillerId()) - { - return aznew EventTraceDataAggregator(m_identity); - } - // IMPORTANT: Add new aggregators here - - return createUnsupported ? aznew UnsupportedDataAggregator(id) : nullptr; - } - - void DrillerDataContainer::ProcessIncomingDrillerData(const char* streamIdentifier, const void* data, size_t dataSize) - { - AZ_Assert(m_dataHandler,"You must have a valid data handler parser to parse the data!"); - m_dataHandler->ProcessStream(streamIdentifier, data, static_cast(dataSize)); - } - - void DrillerDataContainer::OnDrillerConnectionLost() - { - StopDrilling(); - } - - void DrillerDataContainer::StartDrilling() - { - DrillerEvent::ResetGlobalEventId(); - - AzFramework::DrillerListType drillersToStart; - for(DrillerNetworkMessages::AggregatorList::iterator it = m_aggregators.begin(); it != m_aggregators.end(); ++it) - { - (*it)->Reset(); - - if ((*it)->IsCaptureEnabled()) - { - drillersToStart.push_back((*it)->GetDrillerId()); - } - } - if (drillersToStart.size()) - { - delete m_dataHandler; - m_dataHandler = aznew DrillerDataHandler(m_identity, this); - - AzFramework::DrillerRemoteSession::StartDrilling(drillersToStart, m_tmpCaptureFilename.c_str()); - } - } - - void DrillerDataContainer::LoadCaptureData(const char* fileName) - { - DrillerEvent::ResetGlobalEventId(); - // Reset data - DestroyAggregators(); - - AZStd::string baseFilename( fileName ); - - delete m_dataHandler; - m_dataHandler = aznew DrillerDataHandler(m_identity, this); - AzFramework::DrillerRemoteSession::LoadCaptureData(fileName); - } - - void DrillerDataContainer::CloseCaptureData() - { - StopDrilling(); - DestroyAggregators(); - } - - void DrillerDataContainer::Reflect(AZ::ReflectContext* context) - { - MemoryDataAggregator::Reflect(context); - TraceMessageDataAggregator::Reflect(context); - ProfilerDataAggregator::Reflect(context); - ReplicaDataAggregator::Reflect(context); - } - -}//namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.h b/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.h deleted file mode 100644 index 4aebfe2edc..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerDataContainer.h +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLER_DATA_CONTAINER -#define DRILLER_DRILLER_DATA_CONTAINER - -#include - -#include "DrillerNetworkMessages.h" - -#include "AzFramework/Driller/RemoteDrillerInterface.h" - -namespace DH -{ - namespace Debug - { - class DrillerInputMemoryStream; - } -} - -namespace Driller -{ - class DrillerDataHandler; - - /** - * Driller data container. Contains all the data (aggregators) - * for a driller session. It interfaces with with DrillerSession - * for local file caching (TODO) and remote data transfer. - */ - class DrillerDataContainer - : public AzFramework::DrillerRemoteSession - , public AzFramework::DrillerNetworkConsoleEventBus::Handler - { - friend class DrillerDataHandler; - - public: - AZ_CLASS_ALLOCATOR(DrillerDataContainer, AZ::SystemAllocator, 0) - - DrillerDataContainer(int identity, const char* tmpCaptureFilename); - ~DrillerDataContainer(); - - ////////////////////////////////////////////////////////////////////////// - // DrillerRemoteSession - virtual void ProcessIncomingDrillerData(const char* streamIdentifier, const void* data, size_t dataSize); - virtual void OnDrillerConnectionLost(); - ////////////////////////////////////////////////////////////////////////// - - ////////////////////////////////////////////////////////////////////////// - // DrillerNetworkConsoleEvents - virtual void OnReceivedDrillerEnumeration(const AzFramework::DrillerInfoListType& availableDrillers); - ////////////////////////////////////////////////////////////////////////// - - void StartDrilling(); - void LoadCaptureData(const char* fileName); - void CloseCaptureData(); - void CreateAggregators(); - - protected: - void DestroyAggregators(); - Aggregator* CreateAggregator(AZ::u32 id, bool createUnsupported = false); - - DrillerNetworkMessages::AggregatorList m_aggregators; - DrillerDataHandler* m_dataHandler; - AzFramework::DrillerInfoListType m_availableDrillers; - AZStd::string m_tmpCaptureFilename; - int m_identity; - - public: - // data container is the one place that knows about all the aggregators - // and indeed is responsible for creating them - // and thus the best place to centralize their reflection - static void Reflect(AZ::ReflectContext* context); - }; -} - -#endif //DRILLER_DRILLER_DATA_CONTAINER -#pragma once diff --git a/Code/Tools/Standalone/Source/Driller/DrillerDataTypes.h b/Code/Tools/Standalone/Source/Driller/DrillerDataTypes.h deleted file mode 100644 index 128b2f381a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerDataTypes.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DATATYPES_H -#define DRILLER_DATATYPES_H - -#include - -namespace Driller -{ - typedef AZ::s32 FrameNumberType; - typedef AZ::s64 EventNumberType; - - static const EventNumberType kInvalidEventIndex = -1; - - enum class CaptureMode - { - Unknown, - Configuration, - Capturing, - Inspecting - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/DrillerEvent.cpp b/Code/Tools/Standalone/Source/Driller/DrillerEvent.cpp deleted file mode 100644 index e16d6ee8d4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerEvent.cpp +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerEvent.h" - -namespace Driller -{ - ////////////////////////////////////////////////////////////////////////// - // Globals - unsigned int DrillerEvent::s_globalEventId = 0; -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/DrillerEvent.h b/Code/Tools/Standalone/Source/Driller/DrillerEvent.h deleted file mode 100644 index 619a82de60..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerEvent.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLER_EVENT_H -#define DRILLER_DRILLER_EVENT_H - -#include - -namespace Driller -{ - class Aggregator; - - /** - * Base class for a driller events. All events collected in aggregators should use this class as a base. - * - * IMPORTANT: It's very important to note that DrillerEvents will NEVER be removed during a driller session - * this allows you to RELY on the fact that data which the event contains will be present at all times. This is important - * because it's heavily used to support StepBackward/StepForward in sequential driller events (almost all driller events are deltas - * and in that sense they are sequential - we can't just jump to a state directly). - */ - class DrillerEvent - { - public: - AZ_RTTI(DrillerEvent, "{3B0B15CF-A359-47AA-B8D3-DCEFA39BD097}"); - DrillerEvent(unsigned int eventType) - : m_eventType(eventType) - , m_globalEventId(s_globalEventId++) {} - virtual ~DrillerEvent() {} - - virtual void StepForward(Aggregator* data) = 0; - virtual void StepBackward(Aggregator* data) = 0; - - static inline unsigned int GetNumGlobalEvents() { return s_globalEventId; } - static inline void ResetGlobalEventId() { s_globalEventId = 0; } - - unsigned int GetGlobalEventId() const { return m_globalEventId; } - unsigned int GetEventType() const { return m_eventType; } - - protected: - unsigned int m_eventType; - unsigned int m_globalEventId; ///< Event unique ID, which is the global event index (in order) too. - - private: - static unsigned int s_globalEventId; ///< Current number of events used in all aggregators. - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainChannelsView.ui b/Code/Tools/Standalone/Source/Driller/DrillerMainChannelsView.ui deleted file mode 100644 index f3fec8d95e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainChannelsView.ui +++ /dev/null @@ -1,147 +0,0 @@ - - - channelsViewWidget - - - - 0 - 0 - 1041 - 777 - - - - Channels View - - - - 0 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - - 0 - 0 - - - - Qt::ScrollBarAlwaysOn - - - Qt::ScrollBarAlwaysOff - - - true - - - Qt::AlignJustify|Qt::AlignTop - - - - - 0 - 0 - 1018 - 591 - - - - - 2 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - Qt::Horizontal - - - - - - - Qt::Vertical - - - QSizePolicy::Fixed - - - - 20 - 25 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 128 - - - - - - - - - Driller::CombinedEventsControl - QWidget -
combinedeventscontrol.hxx
- 1 -
- - Driller::AnnotationHeaderView_Events - QWidget -
Source/riller/Annotations/annotationsheaderview_events.hxx
- 1 -
- - UIFramework::DHAutoSizingScrollArea - QScrollArea -
UICore/DHAutoSizingScrollArea.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.cpp b/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.cpp deleted file mode 100644 index 4fa06ecdc0..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.cpp +++ /dev/null @@ -1,509 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "DrillerMainWindow.hxx" -#include - -#include "DrillerCaptureWindow.hxx" - -#include "DrillerMainWindowMessages.h" -#include "DrillerAggregator.hxx" -#include "ChannelControl.hxx" -#include "CombinedEventsControl.hxx" -#include "DrillerDataContainer.h" -#include "Workspaces/Workspace.h" - -#include -#include -#include -#include -#include -#include - -#include - -#include - -#include - -#include -#include -#include -#include -#include -#include - -namespace Driller::MainWindow -{ - const char* drillerDebugName = "Driller"; -} - -namespace Driller -{ - class DrillerMainWindowSavedState - : public AzToolsFramework::MainWindowSavedState - { - public: - AZ_RTTI(DrillerMainWindowSavedState, "{77A8D5DB-38EB-4F9B-BEA2-F42D725A8177}", AzToolsFramework::MainWindowSavedState); - AZ_CLASS_ALLOCATOR(DrillerMainWindowSavedState, AZ::SystemAllocator, 0); - - AZStd::string m_priorSaveFolder; - AZStd::string m_priorOpenFolder; - - DrillerMainWindowSavedState() {} - - void Init(const QByteArray& windowState, const QByteArray& windowGeom) - { - AzToolsFramework::MainWindowSavedState::Init(windowState, windowGeom); - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_priorSaveFolder", &DrillerMainWindowSavedState::m_priorSaveFolder) - ->Field("m_priorOpenFolder", &DrillerMainWindowSavedState::m_priorOpenFolder) - ->Version(8); - } - } - }; - - // WORKSPACES are files loaded and stored independent of the global application - // designed to be used for DRL data specific view settings and to pass around - class DrillerMainWindowWorkspace - : public AZ::UserSettings - { - public: - AZ_RTTI(DrillerMainWindowWorkspace, "{E7DAC981-84E9-490E-AF1B-DADC116B3B10}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(DrillerMainWindowWorkspace, AZ::SystemAllocator, 0); - - AZStd::vector m_openDataFileNames; - - DrillerMainWindowWorkspace() {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_openDataFileNames", &DrillerMainWindowWorkspace::m_openDataFileNames) - ->Version(8); - } - } - }; -} - -namespace Driller -{ - extern AZ::Uuid ContextID; - - Driller::DrillerMainWindow* s_drillerMainWindowScriptPtr = NULL; // for script access - - int DrillerMainWindow::m_ascendingIdentity = 0; - - ////////////////////////////////////////////////////////////////////////// - //DrillerMainWindow - DrillerMainWindow::DrillerMainWindow(QWidget* parent, Qt::WindowFlags flags) - : QMainWindow(parent, flags) - { - s_drillerMainWindowScriptPtr = this; - - m_isLoadingFile = false; - m_panningMainView = false; - m_panningMainViewStartPoint = 0; - - m_gui = azcreate(Ui::DrillerMainWindow, ()); - m_gui->setupUi(this); - - QMenu* theMenu = new QMenu(this); - (void)theMenu->addAction( - "Close Profiler App", - this, - SLOT(OnMenuCloseCurrentWindow()), - QKeySequence("Alt+F4") - ); - - EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, PopulateApplicationMenu, theMenu); - menuBar()->insertMenu(m_gui->menuDriller->menuAction(), theMenu); - - connect(m_gui->actionContract, SIGNAL(triggered()), this, SLOT(OnContractAllChannels())); - connect(m_gui->actionExpand, SIGNAL(triggered()), this, SLOT(OnExpandAllChannels())); - connect(m_gui->actionDisable, SIGNAL(triggered()), this, SLOT(OnDisableAllChannels())); - connect(m_gui->actionEnable, SIGNAL(triggered()), this, SLOT(OnEnableAllChannels())); - - DrillerDataViewMessages::Handler::BusConnect(); - - QTimer::singleShot(0, this, SLOT(RestoreWindowState())); - - AzFramework::TargetManagerClient::Bus::Handler::BusConnect(); - - m_gui->actionSave->setEnabled(false); - m_gui->actionSaveWorkspace->setEnabled(true); - - // default identity == 0 Live tab - auto captureWindow = aznew DrillerCaptureWindow(CaptureMode::Configuration, m_ascendingIdentity, this); - captureWindow->setAttribute(Qt::WA_DeleteOnClose, true); - - m_captureWindows.insert(AZStd::make_pair(captureWindow, m_ascendingIdentity)); - ++m_ascendingIdentity; - - m_gui->tabbedContents->addTab(captureWindow, QString("LIVE")); - - // Enabling close buttons on our widgets, and hiding the close button on the live - // tab for now. - m_gui->tabbedContents->setTabsClosable(true); - m_gui->tabbedContents->tabBar()->setTabButton(0, QTabBar::ButtonPosition::RightSide, nullptr); - m_gui->tabbedContents->tabBar()->setTabButton(0, QTabBar::ButtonPosition::LeftSide, nullptr); - - connect(m_gui->tabbedContents, SIGNAL(currentChanged(int)), this, SLOT(OnTabChanged(int))); - connect(m_gui->tabbedContents, SIGNAL(tabCloseRequested(int)), this, SLOT(CloseTab(int))); - - connect(captureWindow, SIGNAL(destroyed(QObject*)), this, SLOT(OnCaptureWindowDestroyed(QObject*))); - - EBUS_EVENT(LegacyFramework::CustomMenusMessages::Bus, RegisterMenu, LegacyFramework::CustomMenusCommon::Driller::Application, theMenu); - EBUS_EVENT(LegacyFramework::CustomMenusMessages::Bus, RegisterMenu, LegacyFramework::CustomMenusCommon::Driller::DrillerMenu, m_gui->menuDriller); - EBUS_EVENT(LegacyFramework::CustomMenusMessages::Bus, RegisterMenu, LegacyFramework::CustomMenusCommon::Driller::Channels, m_gui->menuChannels); - - UpdateTabBarDisplay(); - } - - DrillerMainWindow::~DrillerMainWindow(void) - { - AzFramework::TargetManagerClient::Bus::Handler::BusDisconnect(); - - s_drillerMainWindowScriptPtr = NULL; - DrillerDataViewMessages::Handler::BusDisconnect(); - - azdestroy(m_gui); - } - - void DrillerMainWindow::OnTabChanged(int toWhich) - { - // first tab is always Live - if (toWhich) - { - m_gui->actionSave->setEnabled(true); - } - else - { - m_gui->actionSave->setEnabled(false); - } - } - - void DrillerMainWindow::CloseTab(int closeTab) - { - // We never want to close the live tab. - if (closeTab != 0) - { - DrillerCaptureWindow* captureWindow = static_cast(m_gui->tabbedContents->widget(closeTab)); - - if (captureWindow) - { - captureWindow->OnClose(); - } - } - } - - void DrillerMainWindow::OnCaptureWindowDestroyed(QObject* cWindow) - { - auto captureWindow = static_cast(cWindow); - m_gui->tabbedContents->removeTab(m_gui->tabbedContents->indexOf(captureWindow)); - m_captureWindows.erase(captureWindow); - - UpdateTabBarDisplay(); - } - - ////////////////////////////////////////////////////////////////////////// - // Data Viewer Request Messages - void DrillerMainWindow::EventRequestOpenFile(AZStd::string fileName) - { - OnOpenDrillerFile(fileName.c_str()); - } - void DrillerMainWindow::EventRequestOpenWorkspace(AZStd::string fileName) - { - OnOpenWorkspaceFile(fileName.c_str(), true); - } - - ////////////////////////////////////////////////////////////////////////// - // GUI Messages - void DrillerMainWindow::OnMenuCloseCurrentWindow() - { - AZ_TracePrintf(Driller::MainWindow::drillerDebugName, "Close requested\n"); - - SaveWindowState(); - - EBUS_EVENT(AzToolsFramework::FrameworkMessages::Bus, RequestMainWindowClose, ContextID); - } - - void DrillerMainWindow::OnOpen() - { - AZ_TracePrintf(Driller::MainWindow::drillerDebugName, "Open requested\n"); - - this->show(); - emit ShowYourself(); - } - - void DrillerMainWindow::OnClose() - { - AZ_TracePrintf(Driller::MainWindow::drillerDebugName, "Close requested of window (not file)\n"); - } - - void DrillerMainWindow::OnContractAllChannels() - { - static_cast(m_gui->tabbedContents->currentWidget())->OnContractAllChannels(); - } - void DrillerMainWindow::OnExpandAllChannels() - { - static_cast(m_gui->tabbedContents->currentWidget())->OnExpandAllChannels(); - } - void DrillerMainWindow::OnDisableAllChannels() - { - static_cast(m_gui->tabbedContents->currentWidget())->OnDisableAllChannels(); - } - void DrillerMainWindow::OnEnableAllChannels() - { - static_cast(m_gui->tabbedContents->currentWidget())->OnEnableAllChannels(); - } - - ////////////////////////////////////////////////////////////////////////// - // when the Editor Main window is requested to close, it is not destroyed. - ////////////////////////////////////////////////////////////////////////// - // Qt Events - void DrillerMainWindow::closeEvent(QCloseEvent* event) - { - OnMenuCloseCurrentWindow(); - event->ignore(); - } - - void DrillerMainWindow::showEvent(QShowEvent* /*event*/) - { - emit ShowYourself(); - } - void DrillerMainWindow::hideEvent(QHideEvent* /*event*/) - { - emit HideYourself(); - } - - bool DrillerMainWindow::OnGetPermissionToShutDown() - { - for (auto idx = 0; idx < m_gui->tabbedContents->count(); ++idx) - { - bool willShutDown = static_cast(m_gui->tabbedContents->widget(idx))->OnGetPermissionToShutDown(); - if (!willShutDown) - { - AZ_TracePrintf(Driller::MainWindow::drillerDebugName, " ShutDown Denied\n"); - return false; - } - } - - AZ_TracePrintf(Driller::MainWindow::drillerDebugName, " willShutDown == 1\n"); - return true; - } - - void DrillerMainWindow::SaveWindowState() - { - // build state and store it. - auto newState = AZ::UserSettings::CreateFind(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - newState->Init(saveState(), saveGeometry()); - - for (auto iter = m_captureWindows.begin(); iter != m_captureWindows.end(); ++iter) - { - iter->first->SaveWindowState(); - } - } - - void DrillerMainWindow::UpdateTabBarDisplay() - { - // We will always have one window open(live), and we don't want to show - // the tab bar unless we have more then one. - m_gui->tabbedContents->tabBar()->setVisible(m_captureWindows.size() > 1); - } - - void DrillerMainWindow::RestoreWindowState() // call this after you have rebuilt everything. - { - // load the state from our state block: - auto savedState = AZ::UserSettings::Find(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - if (savedState) - { - QByteArray geomData((const char*)savedState->m_windowGeometry.data(), (int)savedState->m_windowGeometry.size()); - QByteArray stateData((const char*)savedState->GetWindowState().data(), (int)savedState->GetWindowState().size()); - - restoreGeometry(geomData); - if (this->isMaximized()) - { - this->showNormal(); - this->showMaximized(); - } - restoreState(stateData); - } - else - { - // default state! - } - } - - void DrillerMainWindow::OnOpenDrillerFile() - { - QString capturePath; - - auto newState = AZ::UserSettings::CreateFind(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - if (!newState->m_priorOpenFolder.empty()) - { - capturePath = newState->m_priorOpenFolder.data(); - } - else - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - - if (capturePath.isEmpty()) - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - } - } - - QString fileName = QFileDialog::getOpenFileName(this, "Open Driller File", capturePath, "Driller Files (*.drl)"); - if (!fileName.isNull()) - { - OnOpenDrillerFile(fileName); - newState->m_priorOpenFolder = QFileInfo(fileName).dir().canonicalPath().toUtf8().data(); - } - } - - void DrillerMainWindow::OnOpenDrillerFile(QString fileName) - { - auto captureWindow = aznew DrillerCaptureWindow(CaptureMode::Inspecting, m_ascendingIdentity, this); - if (captureWindow) - { - m_captureWindows.insert(AZStd::make_pair(captureWindow, m_ascendingIdentity)); - ++m_ascendingIdentity; - - captureWindow->OnOpenDrillerFile(fileName); - connect(captureWindow, SIGNAL(destroyed(QObject*)), this, SLOT(OnCaptureWindowDestroyed(QObject*))); - - m_gui->tabbedContents->setCurrentIndex(m_gui->tabbedContents->addTab(captureWindow, fileName)); - UpdateTabBarDisplay(); - } - } - - void DrillerMainWindow::OnOpenWorkspaceFile() - { - QString capturePath; - - auto newState = AZ::UserSettings::CreateFind(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - if (!newState->m_priorOpenFolder.empty()) - { - capturePath = newState->m_priorOpenFolder.data(); - } - else - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - if (capturePath.isEmpty()) - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - } - } - - QString workspaceFileName = QFileDialog::getOpenFileName(this, tr("Open Workspace File"), capturePath, tr("Workspace Files (*.drw)")); - if (!workspaceFileName.isNull()) - { - OnOpenWorkspaceFile(workspaceFileName, true); - } - } - - void DrillerMainWindow::OnOpenWorkspaceFile(QString workspaceFileName, bool openDrillerFileAlso) - { - auto captureWindow = aznew DrillerCaptureWindow(CaptureMode::Inspecting, m_ascendingIdentity, this); - if (captureWindow) - { - m_captureWindows.insert(AZStd::make_pair(captureWindow, m_ascendingIdentity)); - ++m_ascendingIdentity; - - captureWindow->OnOpenWorkspaceFile(workspaceFileName, openDrillerFileAlso); - connect(captureWindow, SIGNAL(destroyed(QObject*)), this, SLOT(OnCaptureWindowDestroyed(QObject*))); - - m_gui->tabbedContents->setCurrentIndex(m_gui->tabbedContents->addTab(captureWindow, captureWindow->GetDataFileName())); - UpdateTabBarDisplay(); - } - } - - void DrillerMainWindow::OnApplyWorkspaceFile() - { - QString capturePath; - - auto newState = AZ::UserSettings::CreateFind(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - if (!newState->m_priorOpenFolder.empty()) - { - capturePath = newState->m_priorOpenFolder.data(); - } - else - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - if (capturePath.isEmpty()) - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - } - } - - QString fileName = QFileDialog::getOpenFileName(this, "Apply Workspace", capturePath, "Workspace Files (*.drw)"); - if (!fileName.isNull()) - { - static_cast(m_gui->tabbedContents->currentWidget())->OnApplyWorkspaceFile(fileName); - } - } - - void DrillerMainWindow::OnSaveWorkspaceFile() - { - QString capturePath; - - auto newState = AZ::UserSettings::CreateFind(AZ_CRC("DRILLER MAIN WINDOW STATE", 0x9c98b7f6), AZ::UserSettings::CT_GLOBAL); - if (!newState->m_priorOpenFolder.empty()) - { - capturePath = newState->m_priorOpenFolder.data(); - } - else - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); - if (capturePath.isEmpty()) - { - capturePath = QStandardPaths::writableLocation(QStandardPaths::TempLocation); - } - } - - QString fileName = QFileDialog::getSaveFileName(this, "Save Workspace", capturePath, "Workspace Files (*.drw)"); - if (!fileName.isNull()) - { - static_cast(m_gui->tabbedContents->currentWidget())->OnSaveWorkspaceFile(fileName); - } - } - - ////////////////////////////////////////////////////////////////////////// - // Target Manager Messages - void DrillerMainWindow::Reflect(AZ::ReflectContext* context) - { - // data container is the one place that knows about all the aggregators - // and indeed is responsible for creating them - Driller::WorkspaceSettingsProvider::Reflect(context); - DrillerMainWindowWorkspace::Reflect(context); - DrillerMainWindowSavedState::Reflect(context); - DrillerCaptureWindow::Reflect(context); - - // reflect data for script, serialization, editing... - AZ::BehaviorContext* behaviorContext = azrtti_cast(context); - if (behaviorContext) - { - behaviorContext->Class("DrillerMainWindow")-> - Method("ShowWindow", &DrillerMainWindow::OnOpen)-> - Method("HideWindow", &DrillerMainWindow::OnClose); - - behaviorContext->Property("DrillerMainWindow", BehaviorValueGetter(&s_drillerMainWindowScriptPtr), nullptr); - } - } -}//namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.hxx b/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.hxx deleted file mode 100644 index f8d5cfa233..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.hxx +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLERMAINWINDOW_H -#define DRILLER_DRILLERMAINWINDOW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include -#include -#include "Workspaces/Workspace.h" -#include "DrillerNetworkMessages.h" -#include "DrillerMainWindowMessages.h" - -#pragma once - -class QMenu; -class QAction; -class QToolbar; -class QDockWidget; -class QSettings; - -#include -#endif - -namespace Ui -{ - class DrillerMainWindow; -} - -namespace Driller -{ - class ChannelControl; - class DrillerDataContainer; - class CombinedEventsControl; - class DrillerCaptureWindow; - - /* - Driller Main Window : Now with simultaneous data sets - - Home of the real commands, channels created from external aggregators when connected, and the floating control panel. - All inputs end up here where they are interpreted and passed downwards to all channels, to maintain consistency. - */ - - ////////////////////////////////////////////////////////////////////////// - //Main Window - class DrillerMainWindow - : public QMainWindow - , public Driller::DrillerDataViewMessages::Bus::Handler - , private AzFramework::TargetManagerClient::Bus::Handler - { - Q_OBJECT; - public: - AZ_TYPE_INFO(DrillerMainWindow, "{91E48678-AEF8-474F-BB20-DDC51ACAA43A}"); - AZ_CLASS_ALLOCATOR(DrillerMainWindow,AZ::SystemAllocator,0); - DrillerMainWindow(QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~DrillerMainWindow(void); - DrillerMainWindow(const DrillerMainWindow&) - { - // TODO: Once AZ_NO_COPY macros is in the branch in use it! - AZ_Assert(false, "You can't copy this class!"); - } - - bool OnGetPermissionToShutDown(); - - public: - - // Data Viewer request messages - void EventRequestOpenFile(AZStd::string fileName) override; - void EventRequestOpenWorkspace(AZStd::string fileName) override; - - public: - // MainWindow Messages and states. - void SaveWindowState(); - - private: - // internal workings - void UpdateTabBarDisplay(); - - protected: - static int m_ascendingIdentity; - AZStd::map m_captureWindows; - - // Qt Events - virtual void closeEvent(QCloseEvent* event); - virtual void showEvent( QShowEvent * event ); - virtual void hideEvent( QHideEvent * event ); - - bool m_panningMainView; - int m_panningMainViewStartPoint; - - QString m_tmpCaptureFilename; - QString m_currentDataFilename; - - bool m_isLoadingFile; - bool m_bForceNextScrub; - - public slots: - void RestoreWindowState(); - void OnMenuCloseCurrentWindow(); - void OnOpen(); - void OnClose(); - void OnContractAllChannels(); - void OnExpandAllChannels(); - void OnDisableAllChannels(); - void OnEnableAllChannels(); - void OnOpenDrillerFile(); - void OnOpenDrillerFile(QString fileName); - void OnOpenWorkspaceFile(); // prompt user - void OnOpenWorkspaceFile(QString fileName, bool openDrillerFileAlso); // just open it - void OnApplyWorkspaceFile(); - void OnSaveWorkspaceFile(); - void OnCaptureWindowDestroyed(QObject*); - void OnTabChanged(int toWhich); - void CloseTab(int closeTab); - -signals: - void ScrubberFrameUpdate( int frame ); - void ShowYourself(); - void HideYourself(); - - public: - static void Reflect(AZ::ReflectContext* context); - - private: - - Ui::DrillerMainWindow* m_gui; - }; -} - -#endif //DRILLER_DRILLERMAINWINDOW_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.ui b/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.ui deleted file mode 100644 index 4352c3dba1..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainWindow.ui +++ /dev/null @@ -1,245 +0,0 @@ - - - DrillerMainWindow - - - - 0 - 0 - 704 - 595 - - - - - 0 - 0 - - - - Profiler (PREVIEW) - - - - :/general/hex_profiler_icon:/general/hex_profiler_icon - - - QMainWindow::AllowNestedDocks|QMainWindow::AnimatedDocks - - - - - 0 - - - 2 - - - 2 - - - 2 - - - 2 - - - - - -1 - - - - - - - - - 0 - 0 - 704 - 21 - - - - - File - - - - - - - - - - Channels - - - - - - - - - - Capture - - - Start Capturing Data From the Active Drills - - - C - - - - - Freeze - - - Stop Capturing From the Drills and Freeze the Data - - - S - - - - - Contract All - - - - - Expand All - - - - - Disable All - - - Do not record any drill data - - - - - Enable All - - - Record incoming drill data - - - - - Open Data - - - Ctrl+O - - - - - Open Workspace - - - Replace your current environment with both DRL data and a matching Workspace setup - - - - - Apply Workspace - - - Apply this Workspace setup but leave the current DRL data untouched - - - - - Save Data - - - Ctrl+S - - - - - Save Workspace - - - - - - - - - actionOpen - triggered() - DrillerMainWindow - OnOpenDrillerFile() - - - -1 - -1 - - - 387 - 302 - - - - - actionOpenWorkspace - triggered() - DrillerMainWindow - OnOpenWorkspaceFile() - - - -1 - -1 - - - 387 - 302 - - - - - actionApplyWorkspace - triggered() - DrillerMainWindow - OnApplyWorkspaceFile() - - - -1 - -1 - - - 387 - 302 - - - - - actionSaveWorkspace - triggered() - DrillerMainWindow - OnSaveWorkspaceFile() - - - -1 - -1 - - - 387 - 302 - - - - - - OnOpenDrillerFile() - OnOpenWorkspaceFile() - OnApplyWorkspaceFile() - OnSaveWorkspaceFile() - - diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.cpp b/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.cpp deleted file mode 100644 index 9c2d19c9de..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include "DrillerMainWindowMessages.h" - - -namespace Driller -{ -} diff --git a/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.h b/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.h deleted file mode 100644 index b90ccce66d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerMainWindowMessages.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLERMAINWINDOWMESSAGES_H -#define DRILLER_DRILLERMAINWINDOWMESSAGES_H - -#include -#include - -#include -#include - -#pragma once - -namespace Driller -{ - // messages going FROM the Driller Main Window Context TO anyone interested in frame scrubber control - class DrillerMainWindowMessages - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; // components have an actual ID that they report back on - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef int BusIdType; - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - virtual void FrameChanged(FrameNumberType frame) = 0; - virtual void PlaybackLoopBeginChanged(FrameNumberType frame){(void)frame; } - virtual void PlaybackLoopEndChanged(FrameNumberType frame){(void)frame; } - /// Important: eventIndex is the event index for the aggregator, NOT global event id. - virtual void EventChanged(EventNumberType eventIndex) = 0; - - virtual ~DrillerMainWindowMessages() {} - }; - - // messages going FROM the main window TO (data viewers) anyone interested in event actions - class DrillerEventWindowMessages - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; // components have an actual ID that they report back on - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef int BusIdType; - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - virtual void EventFocusChanged(EventNumberType eventIdx) = 0; - - virtual ~DrillerEventWindowMessages() {} - }; - - // messages going FROM the main window TO (aggregators and their data viewers) anyone using Driller Workspace files - class WorkspaceSettingsProvider; - class DrillerWorkspaceWindowMessages - : public AZ::EBusTraits - { - public: - - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; // components have an actual ID that they report back on - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef int BusIdType; - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - // overlay anything you want from the provider into your internal state. - virtual void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) = 0; - - // now open windows / etc that are specified in your internal saved state. - virtual void ActivateWorkspaceSettings(WorkspaceSettingsProvider*) = 0; - virtual void SaveSettingsToWorkspace(WorkspaceSettingsProvider*) = 0; - - virtual ~DrillerWorkspaceWindowMessages() {} - }; - - // messages going FROM any data viewers TO the global window to request action - class DrillerDataViewMessages - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::Single; // we have one bus that we always broadcast to - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - //virtual void EventRequestEventFocus(AZ::s64 eventIdx) = 0; - virtual void EventRequestOpenFile(AZStd::string fileName) = 0; - virtual void EventRequestOpenWorkspace(AZStd::string fileName) = 0; - - virtual ~DrillerDataViewMessages() {} - }; - - // messages going FROM any data viewers TO the capture window - class DrillerCaptureWindowInterface : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; // components have an actual ID that they report back on - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef int BusIdType; - - virtual void ScrubToFrameRequest(FrameNumberType frameType) = 0; - }; - - typedef AZ::EBus DrillerCaptureWindowRequestBus; - -} - -#endif//DRILLER_DRILLERMAINWINDOWMESSAGES_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerNetworkMessages.h b/Code/Tools/Standalone/Source/Driller/DrillerNetworkMessages.h deleted file mode 100644 index ca39689278..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerNetworkMessages.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLERNETWORKMESSAGES_H -#define DRILLER_DRILLERNETWORKMESSAGES_H - -#include -#include - -#include - -#pragma once - -namespace Driller -{ - // forward declarations - class Aggregator; - - // messages going FROM the Driller Network TO anyone interested in watching data (ie. driller main window) - - class DrillerNetworkMessages - : public AZ::EBusTraits - { - public: - ////////////////////////////////////////////////////////////////////////// - // Bus configuration - static const AZ::EBusAddressPolicy AddressPolicy = AZ::EBusAddressPolicy::ById; // components have an actual ID that they report back on - static const AZ::EBusHandlerPolicy HandlerPolicy = AZ:: EBusHandlerPolicy::Multiple; // we can have multiple listeners - ////////////////////////////////////////////////////////////////////////// - typedef int BusIdType; - typedef AZ::EBus Bus; - typedef Bus::Handler Handler; - - typedef AZStd::vector AggregatorList; - - virtual void ConnectedToNetwork() = 0; - virtual void NewAggregatorList(AggregatorList& theList) = 0; - virtual void AddAggregator(Aggregator& theAggregator) = 0; - virtual void DiscardAggregators() = 0; - virtual void DisconnectedFromNetwork() = 0; - virtual void EndFrame(int frame) = 0; - virtual void NewAggregatorsAvailable() = 0; - - virtual ~DrillerNetworkMessages() {} - }; -} - -#endif//DRILLER_DRILLERNETWORKMESSAGES_H diff --git a/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.cpp b/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.cpp deleted file mode 100644 index 25bc2871a9..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "DrillerOperationTelemetryEvent.h" - -namespace Driller -{ - static int k_windowId = 0; - - DrillerWindowLifepsanTelemetry::DrillerWindowLifepsanTelemetry(const char* windowName) - : m_windowId(k_windowId++) - , m_windowName(windowName) - { - m_telemetryEvent.SetAttribute("WindowOpen", m_windowName); - m_telemetryEvent.SetMetric("WindowId", m_windowId); - m_telemetryEvent.Log(); - m_telemetryEvent.ResetEvent(); - } - - DrillerWindowLifepsanTelemetry::~DrillerWindowLifepsanTelemetry() - { - m_telemetryEvent.SetAttribute("WindowClose", m_windowName); - m_telemetryEvent.SetMetric("WindowId", m_windowId); - m_telemetryEvent.Log(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.h b/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.h deleted file mode 100644 index 8df7806ba3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/DrillerOperationTelemetryEvent.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_DRILLEROPERATIONTELEMETRYEVENT_H -#define DRILLER_DRILLEROPERATIONTELEMETRYEVENT_H - -#include - -#include "Source/Telemetry/TelemetryEvent.h" - -namespace Driller -{ - // A class for any general Driller Operations(i.e. something which doesn't strictly related - // to a specific window, for those a localized window operation should be used). - class DrillerOperationTelemetryEvent - : public Telemetry::TelemetryEvent - { - public: - DrillerOperationTelemetryEvent() - : Telemetry::TelemetryEvent("DrillerOperation") - { - } - }; - - class DrillerWindowLifepsanTelemetry - { - public: - DrillerWindowLifepsanTelemetry(const char* windowName); - virtual ~DrillerWindowLifepsanTelemetry(); - - private: - int m_windowId; - AZStd::string m_windowName; - DrillerOperationTelemetryEvent m_telemetryEvent; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.cpp deleted file mode 100644 index 1d90140dd4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include - -#include -#include - -#include "EventTraceDataAggregator.h" -#include "EventTraceEvents.h" - -#include - -#include -#include -#include -#include - -namespace Driller -{ - namespace Platform - { - void LaunchExplorerSelect(const QString& filePath); - } - - namespace - { - const QString ExportFolder = "EventTrace"; - } - - EventTraceDataAggregator::EventTraceDataAggregator(int identity) - : Aggregator(identity) - { - m_parser.SetAggregator(this); - } - - EventTraceDataAggregator::~EventTraceDataAggregator() - { - } - - float EventTraceDataAggregator::ValueAtFrame(FrameNumberType frame) - { - const float maxEventsPerFrame = 1000.0f; // just a scale number - float numEventsPerFrame = static_cast(NumOfEventsAtFrame(frame)); - return AZStd::GetMin(numEventsPerFrame / maxEventsPerFrame, 1.0f) * 2.0f - 1.0f; - } - - QColor EventTraceDataAggregator::GetColor() const - { - return QColor(0, 255, 255); - } - - QString EventTraceDataAggregator::GetName() const - { - return "Chrome Tracing"; - } - - QString EventTraceDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString EventTraceDataAggregator::GetDescription() const - { - return "Timed scope driller"; - } - - QString EventTraceDataAggregator::GetToolTip() const - { - return "Timed scope event profiler which exports to Chrome Tracing"; - } - - AZ::Uuid EventTraceDataAggregator::GetID() const - { - return AZ::Uuid("{3E47A533-55A4-4E36-B420-063270E4D5DF}"); - } - - rapidjson::Document EventTraceDataAggregator::MakeJsonRepresentation( - FrameNumberType frameBegin, - FrameNumberType frameEnd) const - { - AZ_Assert(frameBegin >= 0 && frameEnd < GetFrameCount() && frameBegin <= frameEnd, "Invalid frame range for chrome trace export"); - - rapidjson::Document rootObj(rapidjson::kObjectType); - auto& allocator = rootObj.GetAllocator(); - - rapidjson::Value traceEvents(rapidjson::kArrayType); - - auto addMemberStr = [&allocator](rapidjson::Value& obj, const char* key, const char* str) - { - rapidjson::Value k(rapidjson::StringRef(key), allocator); - rapidjson::Value v(rapidjson::StringRef(str), allocator); - obj.AddMember(k.Move(), v.Move(), allocator); - }; - - auto addMemberU64 = [&allocator](rapidjson::Value& obj, const char* key, AZ::u64 value) - { - rapidjson::Value k(rapidjson::StringRef(key), allocator); - rapidjson::Value v(static_cast(value)); - obj.AddMember(k.Move(), v.Move(), allocator); - }; - - auto addMemberObj = [&allocator](rapidjson::Value& obj, const char* key, rapidjson::Value& value) - { - rapidjson::Value k(rapidjson::StringRef(key), allocator); - obj.AddMember(k.Move(), value.Move(), allocator); - }; - - const EventNumberType FrameBeginIndex = GetFirstIndexAtFrame(frameBegin); - const EventNumberType FrameEndIndex = GetFirstIndexAtFrame(frameEnd) + NumOfEventsAtFrame(frameEnd); - - for (EventNumberType index = FrameBeginIndex; index < FrameEndIndex; ++index) - { - const DrillerEvent& event = static_cast(*GetEvents()[index]); - - switch (event.GetEventType()) - { - case EventTrace::ET_SLICE: - { - const EventTrace::SliceEvent& slice = static_cast(event); - rapidjson::Value obj(rapidjson::kObjectType); - addMemberStr(obj, "name", slice.m_Name); - addMemberStr(obj, "cat", slice.m_Category); - addMemberStr(obj, "ph", "X"); - addMemberU64(obj, "ts", slice.m_Timestamp); - addMemberU64(obj, "dur", slice.m_Duration); - addMemberU64(obj, "tid", slice.m_ThreadId); - addMemberU64(obj, "pid", 0); - - traceEvents.PushBack(obj, allocator); - } break; - - case EventTrace::ET_INSTANT: - { - const EventTrace::InstantEvent& instant = static_cast(event); - - rapidjson::Value obj(rapidjson::kObjectType); - addMemberStr(obj, "name", instant.m_Name); - addMemberStr(obj, "cat", instant.m_Category); - addMemberStr(obj, "ph", "i"); - addMemberU64(obj, "ts", instant.m_Timestamp); - addMemberStr(obj, "s", instant.GetScopeName()); - addMemberU64(obj, "tid", instant.m_ThreadId); - addMemberU64(obj, "pid", 0); - - traceEvents.PushBack(obj, allocator); - - } break; - - case EventTrace::ET_THREAD_INFO: - { - const EventTrace::ThreadInfoEvent& threadInfo = static_cast(event); - rapidjson::Value obj(rapidjson::kObjectType); - - rapidjson::Value args(rapidjson::kObjectType); - addMemberStr(args, "name", threadInfo.m_Name); - - addMemberStr(obj, "name", "thread_name"); - addMemberStr(obj, "ph", "M"); - addMemberU64(obj, "pid", 0); - addMemberU64(obj, "tid", threadInfo.m_ThreadId); - addMemberObj(obj, "args", args); - - traceEvents.PushBack(obj, allocator); - } break; - } - } - - addMemberObj(rootObj, "traceEvents", traceEvents); - return rootObj; - } - - QWidget* EventTraceDataAggregator::DrillDownRequest(FrameNumberType atFrame) - { - const FrameNumberType FrameCountToExport = 10; - const FrameNumberType FrameCountToExportDiv2 = FrameCountToExport / 2; - - QString filename = "Frame_" + QString::number(atFrame) + ".chrometrace"; - QFileInfo fileInfo(QCoreApplication::applicationDirPath() + "/" + ExportFolder, filename); - ExportChromeTrace(fileInfo.absoluteFilePath(), atFrame - FrameCountToExportDiv2, atFrame + FrameCountToExportDiv2); - Platform::LaunchExplorerSelect(fileInfo.absoluteFilePath()); - return nullptr; - } - - void EventTraceDataAggregator::ExportChromeTrace(const QString& filename, FrameNumberType frameStart, FrameNumberType frameEnd) const - { - AZ::IO::SystemFile exportFile; - if (exportFile.Open(filename.toStdString().c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE | AZ::IO::SystemFile::SF_OPEN_CREATE_PATH | AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY)) - { - ExportChromeTrace(exportFile, frameStart, frameEnd); - } - exportFile.Close(); - } - - void EventTraceDataAggregator::ExportChromeTrace(AZ::IO::SystemFile& file, FrameNumberType frameStart, FrameNumberType frameEnd) const - { - frameStart = AZStd::max(frameStart, 0); - frameEnd = AZStd::min(frameEnd, (FrameNumberType)GetFrameCount() - 1); - - if (frameStart <= frameEnd) - { - rapidjson::Document jsonRep = MakeJsonRepresentation(frameStart, frameEnd); - - rapidjson::StringBuffer buffer; - rapidjson::Writer writer(buffer); - jsonRep.Accept(writer); - - file.Write(buffer.GetString(), buffer.GetSize()); - } - } - - void EventTraceDataAggregator::ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) - { - (void)exportSettings; - ExportChromeTrace(file, 0, (FrameNumberType)GetFrameCount() - 1); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.h b/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.h deleted file mode 100644 index 0437e04017..0000000000 --- a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataAggregator.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include "EventTraceDataParser.h" - -#include -#include - -#include -#endif - -namespace Driller -{ - class EventTraceDataAggregator - : public Aggregator - { - Q_OBJECT; - public: - AZ_RTTI(EventTraceDataAggregator, "{D82CC9CF-5477-4A3E-8809-C064D19963F8}"); - AZ_CLASS_ALLOCATOR(EventTraceDataAggregator, AZ::SystemAllocator, 0); - - EventTraceDataAggregator(int identity = 0); - virtual ~EventTraceDataAggregator(); - - static AZ::u32 DrillerId() - { - return EventTraceDataParser::GetDrillerId(); - } - - AZ::u32 GetDrillerId() const override - { - return DrillerId(); - } - - static const char* ChannelName() - { - return "ChromeTracing"; - } - - AZ::Crc32 GetChannelId() const override - { - return AZ::Crc32(ChannelName()); - } - - AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() override - { - return &m_parser; - } - - bool CanExportToCSV() const override - { - return true; - } - - void ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) override; - - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) override {} - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*) override {} - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*) override {} - - public slots: - float ValueAtFrame(FrameNumberType frame) override; - QColor GetColor() const override; - QString GetChannelName() const override; - QString GetName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - void OptionsRequest() override {} - - QWidget* DrillDownRequest(FrameNumberType frame) override; - - private: - rapidjson::Document MakeJsonRepresentation(FrameNumberType frameStart, FrameNumberType frameEnd) const; - void ExportChromeTrace(AZ::IO::SystemFile& file, FrameNumberType frameStart, FrameNumberType frameEnd) const; - void ExportChromeTrace(const QString& filename, FrameNumberType frameStart, FrameNumberType frameEnd) const; - - EventTraceDataParser m_parser; - }; -} diff --git a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.cpp b/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.cpp deleted file mode 100644 index 73f2452212..0000000000 --- a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.cpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "EventTraceDataParser.h" -#include "EventTraceDataAggregator.h" -#include "EventTraceEvents.h" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* EventTraceDataParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid aggregator before we can process the data!"); - if (tagName == AZ_CRC("Slice")) - { - m_data->AddEvent(aznew EventTrace::SliceEvent()); - return this; - } - else if (tagName == AZ_CRC("Instant")) - { - m_data->AddEvent(aznew EventTrace::InstantEvent()); - return this; - } - else if (tagName == AZ_CRC("ThreadInfo")) - { - m_data->AddEvent(aznew EventTrace::ThreadInfoEvent()); - return this; - } - return nullptr; - } - - void EventTraceDataParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid aggregator before we can process the data!"); - - DrillerEvent& drillerEvent = static_cast(*m_data->GetEvents().back()); - - switch (drillerEvent.GetEventType()) - { - case EventTrace::ET_SLICE: - { - EventTrace::SliceEvent& slice = static_cast(drillerEvent); - if (dataNode.m_name == AZ_CRC("Name")) - { - slice.m_Name = dataNode.ReadPooledString(); - } - if (dataNode.m_name == AZ_CRC("Category")) - { - slice.m_Category = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("ThreadId")) - { - dataNode.Read(slice.m_ThreadId); - } - else if (dataNode.m_name == AZ_CRC("Timestamp")) - { - dataNode.Read(slice.m_Timestamp); - } - else if (dataNode.m_name == AZ_CRC("Duration")) - { - dataNode.Read(slice.m_Duration); - } - } break; - - case EventTrace::ET_INSTANT: - { - EventTrace::InstantEvent& instant = static_cast(drillerEvent); - if (dataNode.m_name == AZ_CRC("Name")) - { - instant.m_Name = dataNode.ReadPooledString(); - } - if (dataNode.m_name == AZ_CRC("Category")) - { - instant.m_Category = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("ThreadId")) - { - dataNode.Read(instant.m_ThreadId); - } - else if (dataNode.m_name == AZ_CRC("Timestamp")) - { - dataNode.Read(instant.m_Timestamp); - } - - } break; - - case EventTrace::ET_THREAD_INFO: - { - EventTrace::ThreadInfoEvent& threadInfo = static_cast(drillerEvent); - if (dataNode.m_name == AZ_CRC("Name")) - { - threadInfo.m_Name = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("ThreadId")) - { - dataNode.Read(threadInfo.m_ThreadId); - } - - } break; - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.h b/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.h deleted file mode 100644 index b41dd1ee01..0000000000 --- a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceDataParser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include - -namespace Driller -{ - class EventTraceDataAggregator; - - class EventTraceDataParser - : public AZ::Debug::DrillerHandlerParser - { - public: - EventTraceDataParser() - : m_data(NULL) - {} - - static AZ::u32 GetDrillerId() - { - return AZ_CRC("EventTraceDriller"); - } - - void SetAggregator(EventTraceDataAggregator* data) - { - m_data = data; - } - - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - protected: - EventTraceDataAggregator* m_data; - }; -} diff --git a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceEvents.h b/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceEvents.h deleted file mode 100644 index 6458a6729b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/EventTrace/EventTraceEvents.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include -#include - -namespace Driller -{ - namespace EventTrace - { - enum EventType - { - ET_SLICE, - ET_INSTANT, - ET_THREAD_INFO - }; - - class SliceEvent : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(SliceEvent, AZ::SystemAllocator, 0) - - SliceEvent() - : DrillerEvent(ET_SLICE) - , m_Name{ "" } - , m_Category{ "" } - , m_ThreadId{} - , m_Timestamp{} - , m_Duration{} - {} - - // no stepping as we can just traverse the list of events - virtual void StepForward(Aggregator* data) { (void)data; } - virtual void StepBackward(Aggregator* data) { (void)data; } - - const char* m_Name; - const char* m_Category; - size_t m_ThreadId; - AZStd::sys_time_t m_Timestamp; - AZStd::sys_time_t m_Duration; - }; - - class InstantEvent : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(InstantEvent, AZ::SystemAllocator, 0) - - InstantEvent() - : DrillerEvent(ET_INSTANT) - , m_Name{ "" } - , m_Category{ "" } - , m_ThreadId{} - , m_Timestamp{} - {} - - // no stepping as we can just traverse the list of events - virtual void StepForward(Aggregator* data) { (void)data; } - virtual void StepBackward(Aggregator* data) { (void)data; } - - const char* GetScopeName() const - { - return (m_ThreadId == 0) ? "g" : "t"; - } - - const char* m_Name; - const char* m_Category; - size_t m_ThreadId; - AZStd::sys_time_t m_Timestamp; - }; - - class ThreadInfoEvent : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(ThreadInfoEvent, AZ::SystemAllocator, 0) - - ThreadInfoEvent() - : DrillerEvent(ET_THREAD_INFO) - , m_ThreadId{} - , m_Name{ "" } - {} - - // no stepping as we can just traverse the list of events - virtual void StepForward(Aggregator* data) { (void)data; } - virtual void StepBackward(Aggregator* data) { (void)data; } - - size_t m_ThreadId; - const char* m_Name; - }; - } - -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/FilteredListView.cpp b/Code/Tools/Standalone/Source/Driller/FilteredListView.cpp deleted file mode 100644 index 66e32e7d05..0000000000 --- a/Code/Tools/Standalone/Source/Driller/FilteredListView.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "Source/Driller/FilteredListView.hxx" -#include -#include - -#include -#include - -#include - -namespace Driller -{ - ///////////////////// - // FilteredListView - ///////////////////// - - FilteredListView::FilteredListView(QWidget* parent) - : QWidget(parent) - , m_gui(new Ui::FilteredListView()) - , m_enableCustomOrdering(true) - { - m_gui->setupUi(this); - - m_stringListModel.setStringList(m_stringList); - m_filteredModel.setSourceModel(&m_stringListModel); - - m_gui->listView->setModel(&m_filteredModel); - m_gui->listView->setEditTriggers(QAbstractItemView::NoEditTriggers); - - QObject::connect(m_gui->filter, SIGNAL(textChanged(const QString&)), this, SLOT(filterEdited(const QString&))); - QObject::connect(m_gui->moveUp, SIGNAL(clicked()), this, SLOT(moveSelectionUp())); - QObject::connect(m_gui->moveDown, SIGNAL(clicked()), this, SLOT(moveSelectionDown())); - - m_gui->moveUp->setAutoDefault(false); - m_gui->moveDown->setAutoDefault(false); - } - - FilteredListView::~FilteredListView() - { - delete m_gui; - } - - void FilteredListView::addItem(const char* item) - { - m_stringList.push_back(QString(item)); - m_stringListModel.setStringList(m_stringList); - } - - void FilteredListView::addItems(const QStringList& items) - { - m_stringList.append(items); - m_stringListModel.setStringList(m_stringList); - } - - void FilteredListView::removeItem(const char* item) - { - m_stringList.removeOne(QString(item)); - m_stringListModel.setStringList(m_stringList); - } - - void FilteredListView::removeItems(const QStringList& items) - { - for (const QString& item : items) - { - m_stringList.removeOne(item); - } - - m_stringListModel.setStringList(m_stringList); - } - - void FilteredListView::clearItems() - { - m_stringList.clear(); - m_stringListModel.setStringList(m_stringList); - } - - void FilteredListView::removeSelected() - { - const QModelIndexList& selectedIndexes = m_gui->listView->selectionModel()->selectedIndexes(); - - for (const QModelIndex& modelIndex : selectedIndexes) - { - QString item = modelIndex.data(Qt::DisplayRole).toString(); - - m_stringList.removeOne(item); - } - - m_gui->listView->selectionModel()->clearSelection(); - m_stringListModel.setStringList(m_stringList); - } - - const QStringList& FilteredListView::getAllItems() const - { - return m_stringList; - } - - void FilteredListView::getSelectedItems(QStringList& selectedItems) const - { - const QModelIndexList& selectedIndexes = m_gui->listView->selectionModel()->selectedIndexes(); - - for (const QModelIndex& modelIndex : selectedIndexes) - { - QString item = modelIndex.data(Qt::DisplayRole).toString(); - selectedItems.push_back(item); - } - } - - void FilteredListView::enableCustomOrdering(bool enabled) - { - m_enableCustomOrdering = enabled; - - setButtonsEnabled(m_enableCustomOrdering); - } - - void FilteredListView::filterEdited(const QString& eventFilter) - { - m_gui->listView->selectionModel()->clearSelection(); - m_filteredModel.setFilterRegExp(eventFilter); - setButtonsEnabled(eventFilter.isEmpty() && m_enableCustomOrdering); - } - - void FilteredListView::moveSelectionUp() - { - const QModelIndexList& selectedIndexes = m_gui->listView->selectionModel()->selectedIndexes(); - - AZStd::set sortedIndexes; - - for (const QModelIndex& index : selectedIndexes) - { - sortedIndexes.insert(index.row()); - } - - int lastSelectedRow = -1; - AZStd::unordered_set selectedRows; - - for (int row : sortedIndexes) - { - if (row > 0 && row > lastSelectedRow + 1) - { - m_stringList.swapItemsAt(row, row - 1); - - // Update the row to reflect it's new position. - row = row - 1; - } - - lastSelectedRow = row; - selectedRows.insert(row); - } - - m_gui->listView->selectionModel()->clear(); - - m_stringListModel.setStringList(m_stringList); - - for (int row : selectedRows) - { - m_gui->listView->selectionModel()->select(m_stringListModel.index(row, 0), QItemSelectionModel::Select); - } - } - - void FilteredListView::moveSelectionDown() - { - const QModelIndexList& selectedIndexes = m_gui->listView->selectionModel()->selectedIndexes(); - - AZStd::set sortedIndexes; - - for (const QModelIndex& index : selectedIndexes) - { - sortedIndexes.insert(index.row()); - } - - int lastSelectedRow = m_stringList.size(); - AZStd::unordered_set selectedRows; - - for (AZStd::set::reverse_iterator iter = sortedIndexes.rbegin(); - iter != sortedIndexes.rend(); - ++iter) - { - int row = (*iter); - - if (row < m_stringList.size() - 1 && row < lastSelectedRow - 1) - { - m_stringList.swapItemsAt(row, row + 1); - row = row + 1; - } - - lastSelectedRow = row; - selectedRows.insert(row); - } - - m_gui->listView->selectionModel()->clear(); - - m_stringListModel.setStringList(m_stringList); - - for (int row : selectedRows) - { - m_gui->listView->selectionModel()->select(m_stringListModel.index(row, 0), QItemSelectionModel::Select); - } - } - - void FilteredListView::setButtonsEnabled(bool enabled) - { - m_gui->moveDown->setEnabled(enabled); - m_gui->moveUp->setEnabled(enabled); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/FilteredListView.hxx b/Code/Tools/Standalone/Source/Driller/FilteredListView.hxx deleted file mode 100644 index 3c2531157d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/FilteredListView.hxx +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef AZTOOLSFRAMEWORK_UI_UICORE_FILTEREDLISTVIEW_H -#define AZTOOLSFRAMEWORK_UI_UICORE_FILTEREDLISTVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#pragma once - -#include -#include -#include -#include -#include -#endif - -namespace Ui -{ - class FilteredListView; -} - -namespace Driller -{ - // This widget allows for easy access to a filtered list view that can also be rearranged by the user. - // Useful for things like determining column order, or export fields. - class FilteredListView - : public QWidget - { - Q_OBJECT - - // Apparently we can't just have a non-sorted model... - class FilteredProxyModel : public QSortFilterProxyModel - { - void sort(int column, Qt::SortOrder order) - { - (void) column; (void)order; - } - }; - - public: - AZ_CLASS_ALLOCATOR(FilteredListView, AZ::SystemAllocator,0); - - explicit FilteredListView(QWidget* parent = nullptr); - ~FilteredListView(); - - void addItem(const char* item); - void addItems(const QStringList& items); - - void removeItem(const char* item); - void removeItems(const QStringList& items); - - void clearItems(); - - void removeSelected(); - - void setFilterString(const char* filterString); - const char* getFilterString() const; - - const QStringList& getAllItems() const; - void getSelectedItems(QStringList& selectedItems) const; - - void enableCustomOrdering(bool enabled); - - public slots: - void filterEdited(const QString& eventFilter); - void moveSelectionUp(); - void moveSelectionDown(); - - private: - - void setButtonsEnabled(bool enabled); - - Ui::FilteredListView* m_gui; - bool m_enableCustomOrdering; - FilteredProxyModel m_filteredModel; - QStringListModel m_stringListModel; - QStringList m_stringList; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/FilteredListView.ui b/Code/Tools/Standalone/Source/Driller/FilteredListView.ui deleted file mode 100644 index 5b182f766f..0000000000 --- a/Code/Tools/Standalone/Source/Driller/FilteredListView.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - FilteredListView - - - - 0 - 0 - 320 - 463 - - - - Form - - - - 5 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - - false - - - false - - - QAbstractItemView::ExtendedSelection - - - QAbstractItemView::SelectRows - - - false - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - ^ - - - false - - - false - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 50 - 20 - - - - - - - - V - - - false - - - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.cpp b/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.cpp deleted file mode 100644 index 59884c9b0e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "Source/Driller/GenericCustomizeCSVExportWidget.hxx" -#include -#include - -namespace Driller -{ - //////////////////////////////////// - // GenericCustomizeCSVExportWidget - //////////////////////////////////// - - GenericCustomizeCSVExportWidget::GenericCustomizeCSVExportWidget(GenericCSVExportSettings& genericSettings, QWidget* parent) - : CustomizeCSVExportWidget(genericSettings, parent) - , m_exportFieldsDirty(false) - , m_gui(nullptr) - { - m_gui = azcreate(Ui::GenericCustomizeCSVExportWidget, ()); - m_gui->setupUi(this); - - QStringList items; - genericSettings.GetExportItems(items); - m_gui->exportFieldSelector->setItemList(items); - - items.clear(); - - genericSettings.GetActiveExportItems(items); - m_gui->exportFieldSelector->setActiveItems(items); - items.clear(); - - m_gui->exportFieldSelector->setActiveTitle("Exported Fields"); - m_gui->exportFieldSelector->setInactiveTitle("Unused Fields"); - - QObject::connect(m_gui->exportFieldSelector, SIGNAL(ActiveItemsChanged()), this, SLOT(OnActiveItemsChanged())); - QObject::connect(m_gui->addDescriptor, SIGNAL(stateChanged(int)), this, SLOT(OnShouldExportStateDescriptorChecked(int))); - } - - GenericCustomizeCSVExportWidget::~GenericCustomizeCSVExportWidget() - { - azdestroy(m_gui); - } - - void GenericCustomizeCSVExportWidget::FinalizeSettings() - { - if (m_exportFieldsDirty) - { - m_exportFieldsDirty = false; - - GenericCSVExportSettings& exportSettings = static_cast(m_exportSettings); - const QStringList& activeItems = m_gui->exportFieldSelector->getActiveItems(); - - exportSettings.UpdateExportOrdering(activeItems); - } - } - - void GenericCustomizeCSVExportWidget::OnActiveItemsChanged() - { - m_exportFieldsDirty = true; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.hxx b/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.hxx deleted file mode 100644 index 970e3d53c6..0000000000 --- a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.hxx +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_GENERICCUSTOMIZECSVEXPORTPANEL_H -#define DRILLER_GENERICCUSTOMIZECSVEXPORTPANEL_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#pragma once - -#include "Source/Driller/CustomizeCSVExportWidget.hxx" -#include "Source/Driller/CSVExportSettings.h" -#endif - -namespace Ui -{ - class GenericCustomizeCSVExportWidget; -} - -namespace Driller -{ - class GenericCSVExportSettings; - - class GenericCustomizeCSVExportWidget - : public CustomizeCSVExportWidget - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(GenericCustomizeCSVExportWidget, AZ::SystemAllocator, 0); - - GenericCustomizeCSVExportWidget(GenericCSVExportSettings& exportSettings, QWidget* parent = nullptr); - ~GenericCustomizeCSVExportWidget(); - - void FinalizeSettings() override; - - public slots: - - void OnActiveItemsChanged(); - - private: - - bool m_exportFieldsDirty; - - Ui::GenericCustomizeCSVExportWidget* m_gui; - }; - - class GenericCSVExportSettings - : public CSVExportSettings - { - friend class GenericCustomizeCSVExportWidget; - public: - GenericCSVExportSettings() - { - } - - virtual void GetExportItems(QStringList& items) const = 0; - virtual void GetActiveExportItems(QStringList& items) const = 0; - - protected: - virtual void UpdateExportOrdering(const QStringList& items) = 0; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.ui b/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.ui deleted file mode 100644 index 5aa2839707..0000000000 --- a/Code/Tools/Standalone/Source/Driller/GenericCustomizeCSVExportWidget.ui +++ /dev/null @@ -1,74 +0,0 @@ - - - GenericCustomizeCSVExportWidget - - - - 0 - 0 - 887 - 413 - - - - Form - - - - - - - 0 - 0 - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Add Column Descriptor - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Driller::DoubleListSelector - QWidget -
Source/Driller/DoubleListSelector.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/IO/StreamerDataAggregator.cpp deleted file mode 100644 index 5e4f0a2323..0000000000 --- a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataAggregator.cpp +++ /dev/null @@ -1,584 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "StreamerDataAggregator.hxx" -#include - -#include "StreamerDrillerDialog.hxx" -#include "StreamerEvents.h" -#include -#include -#include "Woodpecker/Driller/Workspaces/Workspace.h" - -#include -#include - -namespace Driller -{ - class StreamerDataAggregatorSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(StreamerDataAggregatorSavedState, "{0174A3EE-C555-482F-9E7B-7D67D9B4B0A7}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(StreamerDataAggregatorSavedState, AZ::SystemAllocator, 0); - StreamerDataAggregatorSavedState() {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(1) - ; - } - } - }; - - // WORKSPACES are files loaded and stored independent of the global application - // designed to be used for DRL data specific view settings and to pass around - class StreamerDataAggregatorWorkspace - : public AZ::UserSettings - { - public: - AZ_RTTI(StreamerDataAggregatorWorkspace, "{D35E8CCA-6FA7-47F6-8A24-8E12EF237E40}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(StreamerDataAggregatorWorkspace, AZ::SystemAllocator, 0); - - int m_activeViewCount; - AZStd::vector m_activeViewTypes; - - StreamerDataAggregatorWorkspace() - : m_activeViewCount(0) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewCount", &StreamerDataAggregatorWorkspace::m_activeViewCount) - ->Field("m_activeViewTypes", &StreamerDataAggregatorWorkspace::m_activeViewTypes) - ->Version(1); - } - } - }; - - ////////////////////////////////////////////////////////////////////////// - StreamerDataAggregator::StreamerDataAggregator(int identity) - : Aggregator(identity) - , m_activeViewCount(0) - , m_highwaterFrame(-1) - { - m_parser.SetAggregator(this); - ResetTrackingInfo(); - } - - StreamerDataAggregator::~StreamerDataAggregator() - { - KillAllViews(); - } - - // gross generalization of activity based on total number of all events this frame - float StreamerDataAggregator::ValueAtFrame(FrameNumberType frame) - { - const float maxEventsPerFrame = 10.0f; // just a scale number - float numEventsPerFrame = static_cast(NumOfEventsAtFrame(frame)); - return AZStd::GetMin(numEventsPerFrame / maxEventsPerFrame, 1.0f) * 2.0f - 1.0f; - } - - QColor StreamerDataAggregator::GetColor() const - { - return QColor(0, 255, 255); - } - - QString StreamerDataAggregator::GetName() const - { - return "Streamer"; - } - - QString StreamerDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString StreamerDataAggregator::GetDescription() const - { - return "Streamer events driller"; - } - - QString StreamerDataAggregator::GetToolTip() const - { - return "Streamer Events"; - } - - AZ::Uuid StreamerDataAggregator::GetID() const - { - return AZ::Uuid("{9A2854C8-8106-4075-9287-3E047821D934}"); - } - - QWidget* StreamerDataAggregator::DrillDownRequest(FrameNumberType frame) - { - StreamerDrillerDialog* dialog = NULL; - - AZ::u32 availableIdx = 0; - bool foundASpot = true; - do - { - foundASpot = true; - for (DataViewMap::iterator iter = m_dataViews.begin(); iter != m_dataViews.end(); ++iter) - { - if (iter->second == availableIdx) - { - foundASpot = false; - ++availableIdx; - break; - } - } - } while (!foundASpot); - - dialog = aznew StreamerDrillerDialog(this, frame, (1024 * GetIdentity()) + availableIdx); - if (dialog) - { - m_dataViews[dialog] = availableIdx; - connect(dialog, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataViewDestroyed(QObject*))); - ++m_activeViewCount; - } - - return dialog; - } - - QWidget* StreamerDataAggregator::DrillDownRequest(FrameNumberType frame, int type) - { - StreamerDrillerDialog* view = static_cast(DrillDownRequest(frame)); - if (view) - { - view->SetChartType(type); - } - - return view; - } - - void StreamerDataAggregator::OptionsRequest() - { - QMenu* popupMenu = new QMenu(); - QMenu* cachedHitsTypeMenu = new QMenu(tr("Cached Hits")); - cachedHitsTypeMenu->addAction(tr("Do Not Report Cache Hits")); - cachedHitsTypeMenu->addAction(tr("Report Cache Hits")); - popupMenu->addMenu(cachedHitsTypeMenu); - QAction* act = cachedHitsTypeMenu->exec(QCursor::pos()); - if (act) - { - if (act->text() == tr("Report Cache Hits")) - { - m_parser.AllowCacheHitsInReportedStream(true); - } - if (act->text() == tr("Do Not Report Cache Hits")) - { - m_parser.AllowCacheHitsInReportedStream(false); - } - } - } - - void StreamerDataAggregator::OnDataViewDestroyed(QObject* dataView) - { - m_dataViews.erase(dataView); - --m_activeViewCount; - } - - void StreamerDataAggregator::KillAllViews() - { - do - { - DataViewMap::iterator iter = m_dataViews.begin(); - if (iter != m_dataViews.end()) - { - delete iter->first; - continue; - } - break; - } while (1); - } - - void StreamerDataAggregator::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - StreamerDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("STREAMER DATA AGGREGATOR WORKSPACE", 0x105be192)); - if (workspace) - { - m_activeViewCount = workspace->m_activeViewCount; - } - } - void StreamerDataAggregator::ActivateWorkspaceSettings(WorkspaceSettingsProvider* provider) - { - StreamerDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("STREAMER DATA AGGREGATOR WORKSPACE", 0x105be192)); - if (workspace) - { - // kill all existing data view windows in preparation of opening the workspace specified ones - KillAllViews(); - - // the internal count should be 0 from the above house cleaning - // and incremented back up from the workspace instantiations - m_activeViewCount = 0; - for (int i = 0; i < workspace->m_activeViewCount; ++i) - { - //// start this check to default - int discoveredType = 0; - if (workspace->m_activeViewTypes.size() > i) - { - discoveredType = workspace->m_activeViewTypes[i]; - } - - Driller::StreamerDrillerDialog* dataView = qobject_cast(DrillDownRequest(1, discoveredType)); - if (dataView) - { - // apply will overlay the workspace settings on top of the local user settings - dataView->ApplySettingsFromWorkspace(provider); - // activate will do the heavy lifting - dataView->ActivateWorkspaceSettings(provider); - } - } - } - } - void StreamerDataAggregator::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - StreamerDataAggregatorWorkspace* workspace = provider->CreateSetting(AZ_CRC("STREAMER DATA AGGREGATOR WORKSPACE", 0x105be192)); - if (workspace) - { - workspace->m_activeViewTypes.clear(); - workspace->m_activeViewCount = m_activeViewCount; - - for (DataViewMap::iterator iter = m_dataViews.begin(); iter != m_dataViews.end(); ++iter) - { - Driller::StreamerDrillerDialog* dataView = qobject_cast(iter->first); - if (dataView) - { - workspace->m_activeViewTypes.push_back(dataView->GetViewType()); - dataView->SaveSettingsToWorkspace(provider); - } - } - } - } - - //========================================================================= - // Reset - // [7/10/2013] - //========================================================================= - void StreamerDataAggregator::Reset() - { - m_devices.clear(); - m_streams.clear(); - m_requests.clear(); - m_seeksInfo.clear(); - ResetTrackingInfo(); - } - - void StreamerDataAggregator::ResetTrackingInfo() - { - m_seekTracking.clear(); - m_highwaterFrame = -1; - - // default device with ID := 0 - SeekTrackingInfo seekTrackingInfo; - seekTrackingInfo.m_currentStreamId = 0; - seekTrackingInfo.m_offset = 0; - m_seekTracking.insert(AZStd::make_pair(0, seekTrackingInfo)); - } - - void StreamerDataAggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - StreamerDataAggregatorSavedState::Reflect(context); - StreamerDataAggregatorWorkspace::Reflect(context); - StreamerDrillerDialog::Reflect(context); - - serialize->Class() - ->Version(1) - ; - } - } - - void StreamerDataAggregator::AdvanceToFrame(FrameNumberType frame) - { - while (m_highwaterFrame < frame) - { - ++m_highwaterFrame; - FrameChanged(m_highwaterFrame); - - m_frameInfo.push_back(); - m_frameInfo.back().m_computedSeeksCount = 0; - m_frameInfo.back().m_computedThroughput = 0; - - AZ::s64 numEvents = NumOfEventsAtFrame(m_highwaterFrame); - if (numEvents) - { - AZ::s64 firstIndex = GetFirstIndexAtFrame(m_highwaterFrame); - - for (AZ::s64 idx = 0; idx < numEvents; ++idx) - { - DrillerEvent* dep = m_events[ idx + firstIndex ]; - AZ::u64 geid = dep->GetGlobalEventId(); - - switch (dep->GetEventType()) - { - case Driller::Streamer::SET_DEVICE_MOUNTED: - { - SeekTrackingInfo seekTrackingInfo; - seekTrackingInfo.m_currentStreamId = 0; - seekTrackingInfo.m_offset = 0; - m_seekTracking.insert(AZStd::make_pair(static_cast(dep)->m_deviceData.m_id, seekTrackingInfo)); - break; - } - case Driller::Streamer::SET_DEVICE_UNMOUNTED: - { - m_seekTracking.erase(static_cast(dep)->m_unmountedDeviceData->m_id); - break; - } - case Driller::Streamer::SET_ADD_REQUEST: - { - break; - } - case Driller::Streamer::SET_CANCEL_REQUEST: - case Driller::Streamer::SET_RESCHEDULE_REQUEST: - case Driller::Streamer::SET_COMPLETE_REQUEST: - { - break; - } - case Driller::Streamer::SET_REGISTER_STREAM: - case Driller::Streamer::SET_UNREGISTER_STREAM: - { - break; - } - // m_stream := possibly NULL in these two cases - case Driller::Streamer::SET_OPERATION_START: - { - auto depEvt = static_cast(dep); - if (depEvt->m_stream) - { - auto trackedDevice = m_seekTracking.find(depEvt->m_stream->m_deviceId); - if (trackedDevice == m_seekTracking.end()) - { - SeekTrackingInfo seekTrackingInfo; - seekTrackingInfo.m_currentStreamId = 0; - seekTrackingInfo.m_offset = 0; - - m_seekTracking.insert(AZStd::make_pair(depEvt->m_stream->m_deviceId, seekTrackingInfo)); - trackedDevice = m_seekTracking.find(depEvt->m_stream->m_deviceId); - } - // reasons a device might SEEK - if (trackedDevice->second.m_currentStreamId != depEvt->m_streamId) - { - if ( - (depEvt->m_stream->m_isCompressed && depEvt->m_operation.m_type == Streamer::SOP_COMPRESSOR_READ) - || - (!depEvt->m_stream->m_isCompressed) - ) - { - m_frameInfo.back().m_seekInfo.push_back(); - m_frameInfo.back().m_seekInfo.back().m_eventId = geid; - m_frameInfo.back().m_seekInfo.back().m_eventReason = SEEK_EVENT_SWITCH; - trackedDevice->second.m_currentStreamId = depEvt->m_streamId; - trackedDevice->second.m_offset = depEvt->m_operation.m_offset; - ++m_frameInfo.back().m_computedSeeksCount; - m_seeksInfo.insert(AZStd::make_pair(geid, SEEK_EVENT_SWITCH)); - } - } - else if (trackedDevice->second.m_offset != depEvt->m_operation.m_offset) - { - if ( - (depEvt->m_stream->m_isCompressed && depEvt->m_operation.m_type == Streamer::SOP_COMPRESSOR_READ) - || - (!depEvt->m_stream->m_isCompressed) - ) - { - m_frameInfo.back().m_seekInfo.push_back(); - m_frameInfo.back().m_seekInfo.back().m_eventId = geid; - m_frameInfo.back().m_seekInfo.back().m_eventReason = SEEK_EVENT_SKIP; - trackedDevice->second.m_offset = depEvt->m_operation.m_offset; - ++m_frameInfo.back().m_computedSeeksCount; - m_seeksInfo.insert(AZStd::make_pair(geid, SEEK_EVENT_SKIP)); - } - } - } - break; - } - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - auto depEvt = azdynamic_cast(dep); - - if (depEvt->m_stream) - { - m_frameInfo.back().m_transferInfo.push_back(); - m_frameInfo.back().m_transferInfo.back().m_eventId = geid; - m_frameInfo.back().m_transferInfo.back().m_eventReason = (TransferEventType)(depEvt->m_type); - - auto trackedDevice = m_seekTracking.find(depEvt->m_stream->m_deviceId); - if (trackedDevice == m_seekTracking.end()) - { - SeekTrackingInfo seekTrackingInfo; - seekTrackingInfo.m_currentStreamId = 0; - seekTrackingInfo.m_offset = 0; - - m_seekTracking.insert(AZStd::make_pair(depEvt->m_stream->m_deviceId, seekTrackingInfo)); - trackedDevice = m_seekTracking.find(depEvt->m_stream->m_deviceId); - } - - if (depEvt->m_stream->m_isCompressed) - { - if (static_cast(depEvt->m_type) == TRANSFER_EVENT_COMPRESSOR_READ || static_cast(depEvt->m_type) == TRANSFER_EVENT_COMPRESSOR_WRITE) - { - m_frameInfo.back().m_transferInfo.back().m_byteCount = depEvt->m_bytesTransferred; - m_frameInfo.back().m_computedThroughput += depEvt->m_bytesTransferred; - trackedDevice->second.m_offset += depEvt->m_bytesTransferred; - } - } - else - { - m_frameInfo.back().m_transferInfo.back().m_byteCount = depEvt->m_bytesTransferred; - m_frameInfo.back().m_computedThroughput += depEvt->m_bytesTransferred; - trackedDevice->second.m_offset += depEvt->m_bytesTransferred; - } - } - break; - } - } - } - } - } - } - - const char* StreamerDataAggregator::GetFilenameFromStreamId(unsigned int globalEventId, AZ::u64 streamId) - { - // starting at eventId, skip backwards through the events until a register stream is found - while (1) - { - if (globalEventId > m_events.size()) - { - break; - } - auto event = m_events[globalEventId]; - auto registerEvent = azdynamic_cast(event); - if (registerEvent && registerEvent->m_streamData.m_id == streamId) - { - return registerEvent->m_streamData.m_name; - } - - if (globalEventId == 0) - { - break; - } - - --globalEventId; - } - - return ""; - } - - const char* StreamerDataAggregator::GetDebugNameFromStreamId(unsigned int globalEventId, AZ::u64 streamId) - { - // starting at eventId, skip backwards through the events until a request added (which has debug info) is found - while (1) - { - if (globalEventId > m_events.size()) - { - break; - } - auto event = m_events[globalEventId]; - auto requestEvent = azdynamic_cast(event); - if (requestEvent && requestEvent->m_requestData.m_streamId == streamId) - { - if (requestEvent->m_requestData.m_debugName) - { - return requestEvent->m_requestData.m_debugName; - } - else - { - return ""; - } - } - - if (globalEventId == 0) - { - break; - } - - --globalEventId; - } - - return ""; - } - - - const AZ::u64 StreamerDataAggregator::GetOffsetFromStreamId(unsigned int globalEventId, AZ::u64 streamId) - { - // starting at eventId, skip backwards through the events until the start operation related to this ID is found - while (1) - { - if (globalEventId > m_events.size()) - { - break; - } - auto event = m_events[globalEventId]; - auto startEvent = azdynamic_cast(event); - if (startEvent && startEvent->m_streamId == streamId) - { - return startEvent->m_operation.m_offset; - } - - if (globalEventId == 0) - { - break; - } - - --globalEventId; - } - - return 0; - } - - float StreamerDataAggregator::ThroughputAtFrame(FrameNumberType frame) - { - if (frame >= 0) - { - AdvanceToFrame(frame); - return (float)m_frameInfo[frame].m_computedThroughput; - } - - return 0.0f; - } - float StreamerDataAggregator::SeeksAtFrame(FrameNumberType frame) - { - if (frame >= 0) - { - AdvanceToFrame(frame); - return (float)m_frameInfo[frame].m_computedSeeksCount; - } - - return 0.0f; - } - Driller::StreamerDataAggregator::TransferBreakoutType& StreamerDataAggregator::ThroughputAtFrameBreakout(FrameNumberType frame) - { - AdvanceToFrame(frame); - return m_frameInfo[frame].m_transferInfo; - } - Driller::StreamerDataAggregator::SeeksBreakoutType& StreamerDataAggregator::SeeksAtFrameBreakout(FrameNumberType frame) - { - AdvanceToFrame(frame); - return m_frameInfo[frame].m_seekInfo; - } - StreamerDataAggregator::SeekEventType StreamerDataAggregator::GetSeekType(AZ::s64 id) - { - auto iter = m_seeksInfo.find(id); - if (iter != m_seeksInfo.end()) - { - return iter->second; - } - return SEEK_EVENT_NONE; - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataParser.cpp b/Code/Tools/Standalone/Source/Driller/IO/StreamerDataParser.cpp deleted file mode 100644 index 733f32c004..0000000000 --- a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataParser.cpp +++ /dev/null @@ -1,327 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "StreamerDataAggregator.hxx" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* StreamerDrillerHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - - if (tagName == AZ_CRC("OnDeviceMounted", 0xc6bdd55e)) - { - m_subTag = ST_DEVICE_MOUNTED; - m_data->AddEvent(aznew StreamerMountDeviceEvent()); - return this; - } - else if (tagName == AZ_CRC("OnRegisterStream", 0x893513c1)) - { - m_subTag = ST_STREAM_REGISTER; - m_data->AddEvent(aznew StreamerRegisterStreamEvent()); - return this; - } - else if (tagName == AZ_CRC("OnReadCacheHit", 0xd4535712)) - { - m_subTag = ST_READ_CACHE_HIT; - if (m_allowCacheHitsInReportedStream) - { - m_data->AddEvent(aznew StreamerReadCacheHit()); - } - return this; - } - else if (tagName == AZ_CRC("OnAddRequest", 0xee41c96e)) - { - m_subTag = ST_REQUEST_ADD; - m_data->AddEvent(aznew StreamerAddRequestEvent()); - return this; - } - else if (tagName == AZ_CRC("OnCompleteRequest", 0x7f6b66f7)) - { - m_subTag = ST_REQUEST_COMPLETE; - m_data->AddEvent(aznew StreamerCompleteRequestEvent()); - return this; - } - else if (tagName == AZ_CRC("OnRescheduleRequest", 0x883b3e85)) - { - m_subTag = ST_REQUEST_RESCHEDULE; - m_data->AddEvent(aznew StreamerRescheduleRequestEvent()); - return this; - } - else if (tagName == AZ_CRC("OnRead", 0xd7714b7b)) - { - m_subTag = ST_OPERATION_READ; - m_data->AddEvent(aznew StreamerOperationStartEvent(Streamer::SOP_READ)); - return this; - } - else if (tagName == AZ_CRC("OnReadComplete", 0x0efa014b)) - { - m_subTag = ST_OPERATION_READ_COMPLETE; - m_data->AddEvent(aznew StreamerOperationCompleteEvent(Streamer::SOP_READ)); - return this; - } - else if (tagName == AZ_CRC("OnWrite", 0x6925001a)) - { - m_subTag = ST_OPERATION_WRITE; - m_data->AddEvent(aznew StreamerOperationStartEvent(Streamer::SOP_WRITE)); - return this; - } - else if (tagName == AZ_CRC("OnWriteComplete", 0x6c5f7c79)) - { - m_subTag = ST_OPERATION_WRITE_COMPLETE; - m_data->AddEvent(aznew StreamerOperationCompleteEvent(Streamer::SOP_WRITE)); - return this; - } - else if (tagName == AZ_CRC("OnCompressorRead", 0xbd093b22)) - { - m_subTag = ST_OPERATION_COMPRESSOR_READ; - m_data->AddEvent(aznew StreamerOperationStartEvent(Streamer::SOP_COMPRESSOR_READ)); - return this; - } - else if (tagName == AZ_CRC("OnCompressorReadComplete", 0x9c08d9cd)) - { - m_subTag = ST_OPERATION_COMPRESSOR_READ_COMPLETE; - m_data->AddEvent(aznew StreamerOperationCompleteEvent(Streamer::SOP_COMPRESSOR_READ)); - return this; - } - else if (tagName == AZ_CRC("OnCompressorWrite", 0x7bf8913a)) - { - m_subTag = ST_OPERATION_COMPRESSOR_WRITE; - m_data->AddEvent(aznew StreamerOperationStartEvent(Streamer::SOP_COMPRESSOR_WRITE)); - return this; - } - else if (tagName == AZ_CRC("OnCompressorWriteComplete", 0x6816a8b4)) - { - m_subTag = ST_OPERATION_COMPRESSOR_WRITE_COMPLETE; - m_data->AddEvent(aznew StreamerOperationCompleteEvent(Streamer::SOP_COMPRESSOR_WRITE)); - return this; - } - else - { - m_subTag = ST_NONE; - } - return NULL; - } - - void StreamerDrillerHandlerParser::OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)tagName; - if (handler != nullptr) - { - m_subTag = ST_NONE; // we have only one level just go back to the default state - } - } - - void StreamerDrillerHandlerParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - (void)dataNode; - switch (m_subTag) - { - case ST_NONE: - { - if (dataNode.m_name == AZ_CRC("OnDeviceUnmounted", 0x7395545a)) - { - StreamerUnmountDeviceEvent* event = aznew StreamerUnmountDeviceEvent(); - dataNode.Read(event->m_deviceId); - m_data->AddEvent(event); - } - else if (dataNode.m_name == AZ_CRC("OnUnregisterStream", 0x3374d0cb)) - { - StreamerUnregisterStreamEvent* event = aznew StreamerUnregisterStreamEvent(); - dataNode.Read(event->m_streamId); - m_data->AddEvent(event); - } - else if (dataNode.m_name == AZ_CRC("OnCancelRequest", 0x89d4ea74)) - { - StreamerCancelRequestEvent* event = aznew StreamerCancelRequestEvent(); - dataNode.Read(event->m_requestId); - m_data->AddEvent(event); - } - } break; - case ST_DEVICE_MOUNTED: - { - StreamerMountDeviceEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("DeviceId", 0x383bcd03)) - { - dataNode.Read(event->m_deviceData.m_id); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_deviceData.m_name = dataNode.ReadPooledString(); - } - } break; - case ST_STREAM_REGISTER: - { - StreamerRegisterStreamEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("DeviceId", 0x383bcd03)) - { - dataNode.Read(event->m_streamData.m_deviceId); - } - else if (dataNode.m_name == AZ_CRC("StreamId", 0x7597546f)) - { - dataNode.Read(event->m_streamData.m_id); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_streamData.m_name = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("Flags", 0x0b0541ba)) - { - dataNode.Read(event->m_streamData.m_flags); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_streamData.m_size); - } - else if (dataNode.m_name == AZ_CRC("IsCompressed", 0xdd32876c)) - { - dataNode.Read(event->m_streamData.m_isCompressed); - } - } break; - case ST_READ_CACHE_HIT: - { - if (m_allowCacheHitsInReportedStream) - { - StreamerReadCacheHit* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("StreamId", 0x7597546f)) - { - dataNode.Read(event->m_streamId); - } - else if (dataNode.m_name == AZ_CRC("Offset", 0x590acad0)) - { - dataNode.Read(event->m_offset); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_size); - } - else if (dataNode.m_name == AZ_CRC("DebugName", 0x6c3ea120)) - { - event->m_debugName = dataNode.ReadPooledString(); - } - } - } break; - case ST_REQUEST_ADD: - { - StreamerAddRequestEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RequestId", 0x34e754a3)) - { - dataNode.Read(event->m_requestData.m_id); - } - else if (dataNode.m_name == AZ_CRC("StreamId", 0x7597546f)) - { - dataNode.Read(event->m_requestData.m_streamId); - } - else if (dataNode.m_name == AZ_CRC("Offset", 0x590acad0)) - { - dataNode.Read(event->m_requestData.m_offset); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_requestData.m_size); - } - else if (dataNode.m_name == AZ_CRC("Deadline", 0xb74774f2)) - { - dataNode.Read(event->m_requestData.m_deadline); - } - else if (dataNode.m_name == AZ_CRC("Priority", 0x62a6dc27)) - { - dataNode.Read(event->m_requestData.m_priority); - } - else if (dataNode.m_name == AZ_CRC("Operation", 0x1981a66d)) - { - dataNode.Read(event->m_requestData.m_operation); - } - else if (dataNode.m_name == AZ_CRC("DebugName", 0x6c3ea120)) - { - event->m_requestData.m_debugName = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("Timestamp", 0xa5d6e63e)) - { - dataNode.Read(event->m_timeStamp); - } - } break; - case ST_REQUEST_COMPLETE: - { - StreamerCompleteRequestEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RequestId", 0x34e754a3)) - { - dataNode.Read(event->m_requestId); - } - else if (dataNode.m_name == AZ_CRC("State", 0xa393d2fb)) - { - dataNode.Read(event->m_state); - } - else if (dataNode.m_name == AZ_CRC("Timestamp", 0xa5d6e63e)) - { - dataNode.Read(event->m_timeStamp); - } - } break; - case ST_REQUEST_RESCHEDULE: - { - StreamerRescheduleRequestEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RequestId", 0x34e754a3)) - { - dataNode.Read(event->m_requestId); - } - else if (dataNode.m_name == AZ_CRC("NewDeadLine", 0x184cc661)) - { - dataNode.Read(event->m_newDeadline); - } - else if (dataNode.m_name == AZ_CRC("NewPriority", 0xcdad6eb4)) - { - dataNode.Read(event->m_newPriority); - } - } break; - case ST_OPERATION_READ: - case ST_OPERATION_WRITE: - case ST_OPERATION_COMPRESSOR_READ: - case ST_OPERATION_COMPRESSOR_WRITE: - { - StreamerOperationStartEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("StreamId", 0x7597546f)) - { - dataNode.Read(event->m_streamId); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_operation.m_size); - } - else if (dataNode.m_name == AZ_CRC("Offset", 0x590acad0)) - { - dataNode.Read(event->m_operation.m_offset); - } - else if (dataNode.m_name == AZ_CRC("Timestamp", 0xa5d6e63e)) - { - dataNode.Read(event->m_timeStamp); - } - } break; - - case ST_OPERATION_READ_COMPLETE: - case ST_OPERATION_WRITE_COMPLETE: - case ST_OPERATION_COMPRESSOR_READ_COMPLETE: - case ST_OPERATION_COMPRESSOR_WRITE_COMPLETE: - { - StreamerOperationCompleteEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("StreamId", 0x7597546f)) - { - dataNode.Read(event->m_streamId); - } - else if (dataNode.m_name == AZ_CRC("bytesTransferred", 0x35684b99)) - { - dataNode.Read(event->m_bytesTransferred); - } - else if (dataNode.m_name == AZ_CRC("Timestamp", 0xa5d6e63e)) - { - dataNode.Read(event->m_timeStamp); - } - } break; - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataView.cpp b/Code/Tools/Standalone/Source/Driller/IO/StreamerDataView.cpp deleted file mode 100644 index 6e9786e1cd..0000000000 --- a/Code/Tools/Standalone/Source/Driller/IO/StreamerDataView.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "StreamerDataView.hxx" -#include - -#include -#include - -namespace Driller -{ - StreamerDrillerTableView::StreamerDrillerTableView(QWidget* pParent) - : QTableView(pParent) - , m_isScrollAfterInsert(true) - { - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - m_scheduledMaxScroll = false; - } - - StreamerDrillerTableView::~StreamerDrillerTableView() - { - } - - void StreamerDrillerTableView::rowsAboutToBeInserted() - { - m_isScrollAfterInsert = IsAtMaxScroll(); - } - - void StreamerDrillerTableView::rowsInserted() - { - if ((m_isScrollAfterInsert) && (!m_scheduledMaxScroll)) - { - m_scheduledMaxScroll = true; - QTimer::singleShot(0, this, SLOT(doScrollToBottom())); - } - } - - void StreamerDrillerTableView::doScrollToBottom() - { - m_scheduledMaxScroll = false; - scrollToBottom(); - m_isScrollAfterInsert = true; - } - - bool StreamerDrillerTableView::IsAtMaxScroll() const - { - return (verticalScrollBar()->value() == verticalScrollBar()->maximum()); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/IO/StreamerDrillerDialog.cpp b/Code/Tools/Standalone/Source/Driller/IO/StreamerDrillerDialog.cpp deleted file mode 100644 index 98262c5311..0000000000 --- a/Code/Tools/Standalone/Source/Driller/IO/StreamerDrillerDialog.cpp +++ /dev/null @@ -1,1527 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "StreamerDrillerDialog.hxx" -#include - -#include "StreamerDataAggregator.hxx" -#include "StreamerEvents.h" - -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include - -namespace Driller -{ - class StreamerDrillerDialogSavedState; - - // NB: update StreamerDataView.hxx GetXxxxColumn() calls to return matching numbers to SDM_ enums - - enum - { - SDM_NAME = 0, - SDM_DEBUG_NAME, - SDM_EVENT_TYPE, - SDM_OPERATION, - SDM_DELTA_TIME, - SDM_DATA_TRANSFER, - SDM_READ_SIZE, - SDM_OFFSET, - SDM_TOTAL - }; - static const char* SDM_STRING[] = { - "Name", - "Debug Name", - "Event Type", - "Operation", - "uSec Used", - "Data Transfer", - "Read Size", - "Offset", - }; - enum - { - VIEW_TYPE_THROUGHPUT = 0, - VIEW_TYPE_SEEKINFO - }; - - static const char* eventTypeToString[] = - { - "Show All Events", - "Device Mounted", - "Device UnMounted", - "Register Stream", - "UnRegister Stream", - "Cache Hit", - "Request Added", - "Request Canceled", - "Request Rescheduled", - "Request Completed", - "Operation Start", - "Operation Complete", - NULL - }; - static const int eventTypeFromIndex[] = { -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; - - static const char* operationTypeToString[] = - { - "All Operations", - "Invalid", - "Read", - "Write", - "Compressor Read", - "Compressor Write", - NULL - }; - static const int operationTypeFromIndex[] = { -1, 0, 1, 2, 3, 4 }; - - static const char* secondsToDisplayString[] = - { - "10 Seconds", - "15 Seconds", - "30 Seconds", - "60 Seconds", - NULL - }; - static const int secondsFromIndex[] = { 10, 15, 30, 60, 0 }; - - static const char* tableLengthToDisplayString[] = - { - "All Events", - " 1K Events", - " 5K Events", - "10K Events", - "50K Events", - "Playback Start Relative", - NULL - }; - static const int tableLengthFromIndex[] = { 0, 1000, 5000, 10000, 50000, -1, 0 }; - - static const char* chartTypeToDisplayString[] = - { - "Throughput", - "Seek Count", - NULL - }; - static const int chartTypeFromIndex[] = { 0, 1 }; - - static const char* seekTypeToString[] = - { - "", - "Skip Position", - "Switch Streams", - NULL - }; - - class StreamerDrillerDialogLocal - : public AZ::UserSettings - { - public: - AZ_RTTI(StreamerDrillerDialogLocal, "{FBC1032F-A1DE-40CB-97E1-8C5014E31850}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(StreamerDrillerDialogLocal, AZ::SystemAllocator, 0); - - AZStd::vector m_tableColumnStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_tableColumnStorage", &StreamerDrillerDialogLocal::m_tableColumnStorage) - ->Version(1); - } - } - }; - - class StreamerDrillerDialogSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(StreamerDrillerDialogSavedState, "{F97F6145-10D6-4C7F-87DB-FD268EB0EF21}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(StreamerDrillerDialogSavedState, AZ::SystemAllocator, 0); - - int m_viewType; - bool m_autoZoom; - float m_manualZoomMin; // if we're not automatically zooming, then we remember the prior zoom to re-apply it - float m_manualZoomMax; - int m_chartLengthInSeconds; - AZStd::string m_chartNameFilter; - int m_chartOperationFilter; - int m_chartEventFilter; - int m_tableEventLimiter; - FrameNumberType m_frameDeltaLock; - - StreamerDrillerDialogSavedState() - { - m_viewType = VIEW_TYPE_THROUGHPUT; - m_autoZoom = true; - m_manualZoomMin = 2000000000.0f; - m_manualZoomMax = -2000000000.0f; - m_chartLengthInSeconds = 10; - // -1 := no filter and 0..n := filtered by type - m_chartOperationFilter = -1; - m_chartEventFilter = -1; - m_tableEventLimiter = 0; - m_frameDeltaLock = 0; - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_viewType", &StreamerDrillerDialogSavedState::m_viewType) - ->Field("m_autoZoom", &StreamerDrillerDialogSavedState::m_autoZoom) - ->Field("m_manualZoomMin", &StreamerDrillerDialogSavedState::m_manualZoomMin) - ->Field("m_manualZoomMax", &StreamerDrillerDialogSavedState::m_manualZoomMax) - ->Field("m_chartLengthInSeconds", &StreamerDrillerDialogSavedState::m_chartLengthInSeconds) - ->Field("m_chartNameFilter", &StreamerDrillerDialogSavedState::m_chartNameFilter) - ->Field("m_chartOperationFilter", &StreamerDrillerDialogSavedState::m_chartOperationFilter) - ->Field("m_chartEventFilter", &StreamerDrillerDialogSavedState::m_chartEventFilter) - ->Field("m_tableEventLimiter", &StreamerDrillerDialogSavedState::m_tableEventLimiter) - ->Field("m_frameDeltaLock", &StreamerDrillerDialogSavedState::m_frameDeltaLock) - ->Version(8); - } - } - }; - - ////////////////////////////////////////////////////////////////////////// - // Qt supports A "filter proxy model" - // you have a normal model - // and then you wrap that model in a filter proxy model. - // this allows you to filter the inner model and feed the outer (filtered) model to the view. - - // this particular filter model lets you specify search criteria in the Window or the Message field - class StreamerFilterModel - : public QSortFilterProxyModel - { - public: - AZ_CLASS_ALLOCATOR(StreamerFilterModel, AZ::SystemAllocator, 0); - int m_nameColumn; - int m_eventColumn; - int m_operationColumn; - StreamerDataAggregator* m_dataSource; - - QString m_currentNameFilter; - int m_currentEventFilter; - int m_currentOperationFilter; - - FrameNumberType m_frameDeltaLock; - - StreamerFilterModel(StreamerDataAggregator* dataSource, int nameColumn, int eventColumn, int operationColumn, QObject* pParent) - : QSortFilterProxyModel(pParent) - { - m_dataSource = dataSource; - m_nameColumn = nameColumn; - m_eventColumn = eventColumn; - m_operationColumn = operationColumn; - m_currentEventFilter = eventTypeFromIndex[0]; - m_currentOperationFilter = operationTypeFromIndex[0]; - m_frameDeltaLock = 0; - } - - void InvalidateFilter() - { - invalidateFilter(); - } - void SetDeltaLock(FrameNumberType lock) - { - m_frameDeltaLock = lock; - invalidateFilter(); - } - void UpdateNameFilter(const QString& newFilter) - { - if (newFilter.compare(m_currentNameFilter) != 0) - { - if (m_nameColumn >= 0) - { - m_currentNameFilter = newFilter; - invalidateFilter(); - } - } - } - void UpdateEventFilter(int newFilter) - { - if (newFilter != m_currentEventFilter) - { - if (m_eventColumn >= 0) - { - m_currentEventFilter = newFilter; - invalidateFilter(); - } - } - } - void UpdateOperationFilter(int newFilter) - { - if (newFilter != m_currentOperationFilter) - { - if (m_operationColumn >= 0) - { - m_currentOperationFilter = newFilter; - invalidateFilter(); - } - } - } - - protected: - virtual bool filterAcceptsRow(int source_row, const QModelIndex& /*source parent*/) const - { - StreamerDrillerLogModel* ptrModel = static_cast(sourceModel()); - - if (!ptrModel) - { - return true; - } - - EventNumberType firstIndex = ptrModel->GetAggregator()->GetFirstIndexAtFrame(m_frameDeltaLock); - EventNumberType rowEventIndex = ptrModel->RowToGlobalEventIndex(source_row); - if (firstIndex == Driller::kInvalidEventIndex - || rowEventIndex == Driller::kInvalidEventIndex - || rowEventIndex < firstIndex) - { - return false; - } - - AZ_Assert(rowEventIndex < static_cast(m_dataSource->GetEvents().size()), "EventIndex outside of Events vector size."); - - auto pEvt = m_dataSource->GetEvents()[rowEventIndex]; - - if (m_currentNameFilter.size()) - { - QString sourceName = ptrModel->data(source_row, m_nameColumn, Qt::DisplayRole).toString(); - QString sourceDebugName = ptrModel->data(source_row, m_nameColumn + 1, Qt::DisplayRole).toString(); - if ( - (!sourceName.contains(m_currentNameFilter, Qt::CaseInsensitive)) - && - (!sourceDebugName.contains(m_currentNameFilter, Qt::CaseInsensitive)) - ) - { - return false; - } - } - - if (m_currentEventFilter != eventTypeFromIndex[0]) - { - if ((unsigned int)m_currentEventFilter != pEvt->GetEventType()) - { - return false; - } - } - if (m_currentOperationFilter != operationTypeFromIndex[0]) - { - if (pEvt->GetEventType() == Driller::Streamer::SET_OPERATION_COMPLETE) - { - auto completeOp = static_cast(pEvt); - if (m_currentOperationFilter == completeOp->m_type) - { - return true; - } - } - - return false; - } - - return true; - } - }; - - ////////////////////////////////////////////////////////////////////////// - StreamerAxisFormatter::StreamerAxisFormatter(QObject* pParent) - : QAbstractAxisFormatter(pParent) - { - m_dataType = DATA_TYPE_BYTES_PER_SECOND; - m_lastAxisValueForScaling = 1.0f; - } - - QString StreamerAxisFormatter::formatMegabytes(float value) - { - // data is in Bytes per Second! - // so how big is the division size? - if (m_lastAxisValueForScaling > 499999.0f) // greater than half MB - { - return QObject::tr("%1Mb/s").arg(QString::number(value / 1000000.0f, 'f', 1)); - } - else if (m_lastAxisValueForScaling > 1000.0f) // greater than one K - { - if (m_lastAxisValueForScaling > 1000.0f) // whole milliseconds - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 0)).arg("Kb/s"); - } - else - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 1)).arg("Kb/s"); - } - } - else if (m_lastAxisValueForScaling > 1.0f) - { - return QObject::tr("%1B/s").arg((int)value); - } - else - { - return QObject::tr("%1B/s").arg(QString::number((double)value, 'f', 2)); - } - } - - void StreamerAxisFormatter::SetDataType(int type) - { - m_dataType = type; - } - - QString StreamerAxisFormatter::convertAxisValueToText(Charts::AxisType axis, float value, float /*minDisplayedValue*/, float /*maxDisplayedValue*/, float divisionSize) - { - if (axis == Charts::AxisType::Vertical) - { - m_lastAxisValueForScaling = divisionSize; - if (m_dataType == DATA_TYPE_BYTES_PER_SECOND) - { - return formatMegabytes(value); - } - else - { - return QObject::tr("%1%2").arg(QString::number(value, 'f', 0)).arg("/s"); - } - } - else - { - return QString::number((int)value); - } - }; - - ////////////////////////////////////////////////////////////////////////// - StreamerDrillerDialog::StreamerDrillerDialog(StreamerDataAggregator* aggregator, FrameNumberType atFrame, int profilerIndex) - : QDialog() - , m_aggregator(aggregator) - , m_frame(atFrame) - , m_viewIndex(profilerIndex) - , m_isDeltaLocked(false) - , frameModulo(10) - { - m_gui = azcreate(Ui::StreamerDrillerDialog, ()); - m_gui->setupUi(this); - - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags((this->windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint) & ~(Qt::WindowContextHelpButtonHint)); - - setWindowTitle(aggregator->GetDialogTitle()); - - show(); - raise(); - activateWindow(); - setFocus(); - - m_axisFormatter = aznew StreamerAxisFormatter(this); - m_gui->widgetDataStrip->SetAxisTextFormatter(m_axisFormatter); - - this->layout()->addWidget(m_gui->widgetTableView); - - m_gui->widgetTableView->horizontalHeader()->setSectionsMovable(true); - m_gui->widgetTableView->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive); - m_gui->widgetTableView->horizontalHeader()->setStretchLastSection(false); - m_gui->widgetTableView->verticalHeader()->setSectionResizeMode(QHeaderView::Fixed); - m_gui->widgetTableView->verticalHeader()->setStretchLastSection(false); - m_gui->widgetTableView->verticalHeader()->setSectionsMovable(false); - m_gui->widgetTableView->verticalHeader()->hide(); - - m_ptrOriginalModel = aznew StreamerDrillerLogModel(aggregator, this); - m_ptrFilter = aznew StreamerFilterModel(m_aggregator, m_gui->widgetTableView->GetNameColumn(), m_gui->widgetTableView->GetEventColumn(), m_gui->widgetTableView->GetOperationColumn(), this); - m_ptrFilter->setSourceModel(m_ptrOriginalModel); - m_gui->widgetTableView->setModel(m_ptrFilter); - - // context menu - actionSelectAll = new QAction(tr("Select All"), this); - connect(actionSelectAll, SIGNAL(triggered()), this, SLOT(SelectAll())); - - actionSelectNone = new QAction(tr("Select None"), this); - connect(actionSelectNone, SIGNAL(triggered()), this, SLOT(SelectNone())); - - actionCopySelected = new QAction(tr("Copy Selected Row(s)"), this); - actionCopySelected->setShortcutContext(Qt::WidgetWithChildrenShortcut); - connect(actionCopySelected, SIGNAL(triggered()), this, SLOT(CopySelected())); - - actionCopyAll = new QAction(tr("Copy All Rows"), this); - connect(actionCopyAll, SIGNAL(triggered()), this, SLOT(CopyAll())); - - // context menu for the table - m_gui->widgetTableView->setContextMenuPolicy(Qt::ActionsContextMenu); - m_gui->widgetTableView->addAction(actionSelectAll); - m_gui->widgetTableView->addAction(actionSelectNone); - m_gui->widgetTableView->addAction(actionCopySelected); - m_gui->widgetTableView->addAction(actionCopyAll); - - connect(aggregator, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataDestroyed())); - - connect(m_ptrFilter, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), m_gui->widgetTableView, SLOT(rowsAboutToBeInserted())); - connect(m_ptrFilter, SIGNAL(rowsInserted(const QModelIndex &, int, int)), m_gui->widgetTableView, SLOT(rowsInserted())); - connect(m_gui->nameFilter, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChangeWindowFilter(const QString&))); - - connect(m_ptrFilter, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrFilter, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrFilter, SIGNAL(modelReset()), this, SLOT(UpdateSummary())); - - connect(m_ptrOriginalModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrOriginalModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrOriginalModel, SIGNAL(modelReset()), this, SLOT(UpdateSummary())); - - connect(m_gui->checkBoxAutoZoom, SIGNAL(toggled(bool)), this, SLOT(OnAutoZoomChange(bool))); - - { - QMenu* eventMenu = new QMenu(this); - - for (int i = 0; eventTypeToString[i]; ++i) - { - eventMenu->addAction(CreateEventFilterAction(eventTypeToString[i], eventTypeFromIndex[i])); - } - - m_gui->eventTypeFilterButton->setText(eventTypeToString[0]); - m_gui->eventTypeFilterButton->setMenu(eventMenu); - } - { - QMenu* operationMenu = new QMenu(this); - - for (int i = 0; operationTypeToString[i]; ++i) - { - operationMenu->addAction(CreateOperationFilterAction(operationTypeToString[i], operationTypeFromIndex[i])); - } - - m_gui->operationTypeFilterButton->setText(operationTypeToString[0]); - m_gui->operationTypeFilterButton->setMenu(operationMenu); - } - { - QMenu* secondsMenu = new QMenu(this); - for (int i = 0; secondsToDisplayString[i]; ++i) - { - secondsMenu->addAction(CreateSecondsMenuAction(secondsToDisplayString[i], secondsFromIndex[i])); - } - - m_gui->chartLengthButton->setText(secondsToDisplayString[0]); - m_gui->chartLengthButton->setMenu(secondsMenu); - } - { - QMenu* chartTypeMenu = new QMenu(this); - for (int i = 0; chartTypeToDisplayString[i]; ++i) - { - chartTypeMenu->addAction(CreateChartTypeMenuAction(chartTypeToDisplayString[i], chartTypeFromIndex[i])); - } - - m_gui->chartTypeButton->setText(chartTypeToDisplayString[0]); - m_gui->chartTypeButton->setMenu(chartTypeMenu); - } - { - QMenu* tableLengthMenu = new QMenu(this); - for (int i = 0; tableLengthToDisplayString[i]; ++i) - { - tableLengthMenu->addAction(CreateTableLengthMenuAction(tableLengthToDisplayString[i], i)); - } - - m_gui->tableLengthButton->setText(tableLengthToDisplayString[0]); - m_gui->tableLengthButton->setMenu(tableLengthMenu); - } - - DrillerMainWindowMessages::Handler::BusConnect(m_aggregator->GetIdentity()); - DrillerEventWindowMessages::Handler::BusConnect(m_aggregator->GetIdentity()); - - AZStd::string windowStateStr = AZStd::string::format("STREAMER DATA VIEW WINDOW STATE %i", m_viewIndex); - m_windowStateCRC = AZ::Crc32(windowStateStr.c_str()); - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (windowState) - { - windowState->RestoreGeometry(this); - } - - AZStd::string tableStateStr = AZStd::string::format("STREAMER TABLE VIEW STATE %i", m_viewIndex); - m_tableStateCRC = AZ::Crc32(tableStateStr.c_str()); - auto tableState = AZ::UserSettings::Find(m_tableStateCRC, AZ::UserSettings::CT_GLOBAL); - if (tableState) - { - QByteArray treeData((const char*)tableState->m_tableColumnStorage.data(), (int)tableState->m_tableColumnStorage.size()); - m_gui->widgetTableView->horizontalHeader()->restoreState(treeData); - } - - AZStd::string dataViewStateStr = AZStd::string::format("STREAMER DATA VIEW STATE %i", m_viewIndex); - m_dataViewStateCRC = AZ::Crc32(dataViewStateStr.c_str()); - m_persistentState = AZ::UserSettings::CreateFind(m_dataViewStateCRC, AZ::UserSettings::CT_GLOBAL); - ApplyPersistentState(); - - FrameChanged(atFrame); - } - - StreamerDrillerDialog::~StreamerDrillerDialog() - { - SaveOnExit(); - azdestroy(m_gui); - } - - QAction* StreamerDrillerDialog::CreateSecondsMenuAction(QString qs, int seconds) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("Seconds", seconds); - connect(act, SIGNAL(triggered()), this, SLOT(OnSecondsMenu())); - return act; - } - QAction* StreamerDrillerDialog::CreateTableLengthMenuAction(QString qs, int limit) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("Limit", limit); - connect(act, SIGNAL(triggered()), this, SLOT(OnTableLengthMenu())); - return act; - } - QAction* StreamerDrillerDialog::CreateChartTypeMenuAction(QString qs, int dataType) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("DataType", dataType); - connect(act, SIGNAL(triggered()), this, SLOT(OnDataTypeMenu())); - return act; - } - - QAction* StreamerDrillerDialog::CreateEventFilterAction(QString qs, int eventType) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("EventType", eventType); - connect(act, SIGNAL(triggered()), this, SLOT(OnEventFilterMenu())); - return act; - } - - QAction* StreamerDrillerDialog::CreateOperationFilterAction(QString qs, int operationType) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("OperationType", operationType); - connect(act, SIGNAL(triggered()), this, SLOT(OnOperationFilterMenu())); - return act; - } - - void StreamerDrillerDialog::SaveOnExit() - { - auto tableState = AZ::UserSettings::CreateFind(m_tableStateCRC, AZ::UserSettings::CT_GLOBAL); - if (tableState) - { - if (m_gui->widgetTableView && m_gui->widgetTableView->horizontalHeader()) - { - QByteArray qba = m_gui->widgetTableView->horizontalHeader()->saveState(); - tableState->m_tableColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - auto pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (m_persistentState) - { - pState->CaptureGeometry(this); - } - } - void StreamerDrillerDialog::hideEvent(QHideEvent* evt) - { - QDialog::hideEvent(evt); - } - void StreamerDrillerDialog::closeEvent(QCloseEvent* evt) - { - QDialog::closeEvent(evt); - } - void StreamerDrillerDialog::OnDataDestroyed() - { - deleteLater(); - } - - void StreamerDrillerDialog::onTextChangeWindowFilter(const QString& newText) - { - m_ptrFilter->UpdateNameFilter(newText); - m_persistentState->m_chartNameFilter = newText.toUtf8().data(); - } - void StreamerDrillerDialog::OnEventFilterMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - m_gui->eventTypeFilterButton->setText(qa->objectName()); - int eventType = qa->property("EventType").toInt(); - m_ptrFilter->UpdateEventFilter(eventType); - m_persistentState->m_chartEventFilter = eventType; - } - } - void StreamerDrillerDialog::OnOperationFilterMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - m_gui->operationTypeFilterButton->setText(qa->objectName()); - int operationType = qa->property("OperationType").toInt(); - m_ptrFilter->UpdateOperationFilter(operationType); - m_persistentState->m_chartOperationFilter = operationType; - } - } - void StreamerDrillerDialog::OnSecondsMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - m_gui->chartLengthButton->setText(qa->objectName()); - int seconds = qa->property("Seconds").toInt(); - SetChartLength(seconds); - } - } - void StreamerDrillerDialog::OnTableLengthMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - int limit = qa->property("Limit").toInt(); - OnTableLengthMenu(limit); - } - } - void StreamerDrillerDialog::OnTableLengthMenu(int limit) - { - if (tableLengthFromIndex[limit] >= 0) - { - m_gui->tableLengthButton->setText(tableLengthToDisplayString[limit]); - m_persistentState->m_tableEventLimiter = limit; - m_isDeltaLocked = false; - SetTableLengthLimit(tableLengthFromIndex[limit]); - m_ptrFilter->SetDeltaLock(0); - } - else - { - m_gui->tableLengthButton->setText(QString("Delta:%1").arg(m_frame)); - m_isDeltaLocked = true; - m_ptrFilter->SetDeltaLock(m_persistentState->m_frameDeltaLock); - } - - BuildChart(m_frame, m_persistentState->m_viewType, m_persistentState->m_chartLengthInSeconds); - } - void StreamerDrillerDialog::OnDataTypeMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnDataTypeMenu(qa->property("DataType").toInt()); - } - } - void StreamerDrillerDialog::OnDataTypeMenu(int type) - { - m_gui->chartTypeButton->setText(chartTypeToDisplayString[type]); - m_persistentState->m_viewType = type; - SetChartType(type); - m_axisFormatter->SetDataType(type); - } - void StreamerDrillerDialog::OnAutoZoomChange(bool newValue) - { - if (!newValue) - { - m_persistentState->m_autoZoom = false; - m_gui->widgetDataStrip->GetWindowRange(Charts::AxisType::Vertical, m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax); - } - else - { - m_persistentState->m_autoZoom = true; - m_persistentState->m_manualZoomMin = 2000000000.0f; - m_persistentState->m_manualZoomMax = -2000000000.0f; - } - BuildChart(m_frame, m_persistentState->m_viewType, m_persistentState->m_chartLengthInSeconds); - } - void StreamerDrillerDialog::SetChartLength(int newLength) - { - m_persistentState->m_chartLengthInSeconds = newLength; - BuildChart(m_frame, m_persistentState->m_viewType, newLength); - } - void StreamerDrillerDialog::SetChartType(int newType) - { - BuildChart(m_frame, newType, m_persistentState->m_chartLengthInSeconds); - } - void StreamerDrillerDialog::SetTableLengthLimit(int limit) - { - m_ptrOriginalModel->SetLengthLimit(limit); - m_ptrFilter->InvalidateFilter(); - } - int StreamerDrillerDialog::GetViewType() - { - return m_persistentState->m_viewType; - } - - // Backing code to the context menu - void StreamerDrillerDialog::SelectAll() - { - m_gui->widgetTableView->selectAll(); - } - - void StreamerDrillerDialog::SelectNone() - { - m_gui->widgetTableView->clearSelection(); - } - - QString StreamerDrillerDialog::ConvertRowToText(const QModelIndex& row) - { - auto pModel = m_ptrFilter; - - if (!pModel) - { - return QString(); - } - - int columnCount = pModel->columnCount(); - QString finalString = ""; - - QModelIndex sourceRow = m_ptrFilter->mapToSource(row); - - for (int column = 0; column < columnCount; ++column) - { - QString displayString = m_ptrOriginalModel->data(sourceRow.row(), column, Qt::DisplayRole).toString(); - if ((column != 0) && (finalString.length() > 0)) - { - finalString += "; "; - } - if (displayString.length()) - { - finalString += displayString.toUtf8().data(); - } - else - { - // must enforce some length even on empty strings in the table - // so that comma-delimiters output properly - finalString += " "; - } - } - finalString += "\n"; - - return finalString; - } - - void StreamerDrillerDialog::CopySelected() - { - auto pModel = m_ptrFilter; - if (!pModel) - { - return; - } - - AZStd::string accumulator; - QItemSelectionModel* selectionModel = m_gui->widgetTableView->selectionModel(); - QModelIndexList indices = selectionModel->selectedRows(); - for (QModelIndexList::iterator iter = indices.begin(); iter != indices.end(); ++iter) - { - QString res = this->ConvertRowToText(*iter); - accumulator += res.toUtf8().data(); - } - - if (accumulator.size()) - { - QClipboard* clipboard = QApplication::clipboard(); - if (clipboard) - { - clipboard->setText(accumulator.c_str()); - } - } - } - - void StreamerDrillerDialog::CopyAll() - { - auto pModel = m_ptrFilter; - if (!pModel) - { - return; - } - - QString finalString = ""; - - int numRows = pModel->rowCount(); - for (int rowIdx = 0; rowIdx < numRows; ++rowIdx) - { - QModelIndex idx = pModel->index(rowIdx, 0); - finalString += this->ConvertRowToText(idx); - } - - QClipboard* clipboard = QApplication::clipboard(); - - if (clipboard) - { - clipboard->setText(finalString); - } - } - - void StreamerDrillerDialog::ApplyPersistentState() - { - onTextChangeWindowFilter(m_persistentState->m_chartNameFilter.c_str()); - OnDataTypeMenu(m_persistentState->m_viewType); - - m_gui->tableLengthButton->setText(tableLengthToDisplayString[m_persistentState->m_tableEventLimiter]); - SetTableLengthLimit(tableLengthFromIndex[m_persistentState->m_tableEventLimiter]); - - if (m_isDeltaLocked) - { - m_gui->tableLengthButton->setText(QString("Delta:%1").arg(m_persistentState->m_frameDeltaLock)); - m_ptrFilter->SetDeltaLock(m_persistentState->m_frameDeltaLock); - } - else - { - m_ptrFilter->SetDeltaLock(0); - } - - m_gui->checkBoxAutoZoom->setChecked(m_persistentState->m_autoZoom); - OnAutoZoomChange(m_persistentState->m_autoZoom); - - for (int i = 0; secondsFromIndex[i]; ++i) - { - if (m_persistentState->m_chartLengthInSeconds == secondsFromIndex[i]) - { - m_gui->chartLengthButton->setText(secondsToDisplayString[i]); - break; - } - } - - BuildChart(m_frame, m_persistentState->m_viewType, m_persistentState->m_chartLengthInSeconds); // full seconds, 60 frames per entry on the chart, modulo even seconds - - UpdateSummary(); - } - - void StreamerDrillerDialog::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("STREAMER DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - StreamerDrillerDialogSavedState* workspace = provider->FindSetting(workspaceStateCRC); - if (workspace) - { - *m_persistentState = *workspace; - } - } - - void StreamerDrillerDialog::ActivateWorkspaceSettings(WorkspaceSettingsProvider*) - { - ApplyPersistentState(); - } - - void StreamerDrillerDialog::FrameChanged(FrameNumberType frame) - { - m_frame = frame; - BuildChart(m_frame, m_persistentState->m_viewType, m_persistentState->m_chartLengthInSeconds); // full seconds, 60 frames per entry on the chart, modulo even seconds - } - - void StreamerDrillerDialog::PlaybackLoopBeginChanged(FrameNumberType frame) - { - m_persistentState->m_frameDeltaLock = frame; - FrameNumberType lockedFrame = m_isDeltaLocked ? m_persistentState->m_frameDeltaLock : 0; - m_ptrFilter->SetDeltaLock(lockedFrame); - BuildChart(m_frame, m_persistentState->m_viewType, m_persistentState->m_chartLengthInSeconds); // full seconds, 60 frames per entry on the chart, modulo even seconds - } - - void StreamerDrillerDialog::BuildChart(FrameNumberType atFrame, int viewType, int howFar) - { - BuildAllLabels(atFrame, viewType); - - FrameNumberType lockedFrame = m_isDeltaLocked ? m_persistentState->m_frameDeltaLock : 0; - const char* vAxisLabel[] = {"Transfer", "Seek"}; - - m_gui->widgetDataStrip->Reset(); - FrameNumberType flooredFrame = (atFrame + frameModulo - 1) / frameModulo; - float calculatedFrame = (float)(flooredFrame - howFar >= 0 ? flooredFrame - howFar : 0); - m_gui->widgetDataStrip->AddAxis("Time", calculatedFrame, (float)calculatedFrame + howFar, true, true); - m_gui->widgetDataStrip->AddAxis(vAxisLabel[viewType], m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax, false, false); - int channelID = m_gui->widgetDataStrip->AddChannel("ThroughputOrSeeks"); - m_gui->widgetDataStrip->SetChannelStyle(channelID, StripChart::Channel::STYLE_CONNECTED_LINE); - m_gui->widgetDataStrip->SetChannelColor(channelID, Qt::green); - - FrameNumberType currentFrame = atFrame - (atFrame % frameModulo) - 1; - float accumulator = 0; - - while (howFar > 0 && currentFrame >= (lockedFrame - frameModulo)) - { - FrameNumberType displayFrame = currentFrame; - float thisSecond = 0.0f; - - if (viewType == VIEW_TYPE_THROUGHPUT) - { - while ((currentFrame % frameModulo) && (currentFrame >= 0)) - { - thisSecond += m_aggregator->ThroughputAtFrame(currentFrame); - accumulator += m_aggregator->ThroughputAtFrame(currentFrame); - --currentFrame; - } - ; - thisSecond += m_aggregator->ThroughputAtFrame(currentFrame); - accumulator += m_aggregator->ThroughputAtFrame(currentFrame); - } - else if (viewType == VIEW_TYPE_SEEKINFO) - { - while ((currentFrame % frameModulo) && (currentFrame >= 0)) - { - thisSecond += m_aggregator->SeeksAtFrame(currentFrame); - accumulator += m_aggregator->SeeksAtFrame(currentFrame); - --currentFrame; - } - ; - thisSecond += m_aggregator->SeeksAtFrame(currentFrame); - accumulator += m_aggregator->SeeksAtFrame(currentFrame); - } - - m_gui->widgetDataStrip->AddData(channelID, displayFrame / frameModulo, (float)displayFrame / (float)frameModulo, thisSecond * (60.0f / (float)frameModulo)); - - --currentFrame; - --howFar; - } - - if (m_persistentState->m_autoZoom) - { - m_gui->widgetDataStrip->ZoomExtents(Charts::AxisType::Vertical); - } - else - { - m_gui->widgetDataStrip->ZoomManual(Charts::AxisType::Vertical, m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax); - } - } - - void StreamerDrillerDialog::BuildAllLabels(FrameNumberType atFrame, int viewType) - { - FrameNumberType currentFrame = atFrame; - float accumulateDelta = 0; - FrameNumberType lockedFrame = m_isDeltaLocked ? m_persistentState->m_frameDeltaLock : 0; - - while (currentFrame >= lockedFrame) - { - if (viewType == VIEW_TYPE_THROUGHPUT) - { - accumulateDelta += m_aggregator->ThroughputAtFrame(currentFrame); - } - else if (viewType == VIEW_TYPE_SEEKINFO) - { - accumulateDelta += m_aggregator->SeeksAtFrame(currentFrame); - } - - --currentFrame; - } - - QString deltaString = UpdateDeltaLabel(accumulateDelta); - - float accumulateTime = float(atFrame - lockedFrame + 1) / 60.0f; - QString timeString = QString("T=%1s").arg(QString::number(accumulateTime, 'f', 1)); - - float accumulateAverage = 0.0f; - if (atFrame >= lockedFrame) - { - if (viewType == VIEW_TYPE_THROUGHPUT) - { - accumulateAverage = m_aggregator->ThroughputAtFrame(atFrame); - } - else if (viewType == VIEW_TYPE_SEEKINFO) - { - accumulateAverage = m_aggregator->SeeksAtFrame(atFrame); - } - } - QString averageString = UpdateAverageLabel(accumulateAverage); - QString eventsString = UpdateSummary(); - - QString finalString = eventsString + QString(" ") + deltaString + QString(" ") + averageString + QString(" ") + timeString; - m_gui->summaryLabel->setText(finalString); - - m_gui->summaryLabel->update(); - } - - QString StreamerDrillerDialog::UpdateSummary() - { - int filterRows = m_ptrFilter->rowCount(); - int originalRows = m_ptrOriginalModel->rowCount(); - - return QString("[%1 / %2]").arg(filterRows).arg(originalRows); - } - - QString StreamerDrillerDialog::UpdateDeltaLabel(float accumulator) - { - if (m_persistentState->m_viewType == VIEW_TYPE_THROUGHPUT) - { - QString formattedBytes = FormatMegabytes(accumulator); - return QString("Data=%1").arg(formattedBytes); - } - else - { - return QString("Seek=%1").arg(QString::number(accumulator, 'f', 0)); - } - } - - QString StreamerDrillerDialog::UpdateAverageLabel(float accumulator) - { - if (m_persistentState->m_viewType == VIEW_TYPE_THROUGHPUT) - { - QString formattedBytes = FormatMegabytes(accumulator); - return QString("Now=%1").arg(formattedBytes); - } - else - { - return QString("Seek=%1").arg(QString::number(accumulator, 'f', 0)); - } - } - - QString StreamerDrillerDialog::FormatMegabytes(float value) - { - // data is in Bytes - // so how big is the division size? - if (value > 499999.0f) // greater than half MB - { - return QObject::tr("%1Mb").arg(QString::number(value / 1000000.0f, 'f', 1)); - } - else if (value > 1000.0f) // greater than one K - { - if (value > 1000.0f) // whole milliseconds - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 0)).arg("Kb"); - } - else - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 1)).arg("Kb"); - } - } - else if (value > 1.0f) - { - return QObject::tr("%1B").arg((int)value); - } - else - { - return QObject::tr("%1B").arg(QString::number((double)value, 'f', 2)); - } - } - - void StreamerDrillerDialog::EventFocusChanged(EventNumberType /*eventIdx*/) - { - } - - void StreamerDrillerDialog::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("STREAMER DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - { - StreamerDrillerDialogSavedState* workspace = provider->CreateSetting(workspaceStateCRC); - if (workspace) - { - *workspace = *m_persistentState; - } - } - } - - void StreamerDrillerDialog::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - StreamerDrillerDialogSavedState::Reflect(context); - StreamerDrillerDialogLocal::Reflect(context); - } - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // StreamerDrillerLogModel - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - StreamerDrillerLogModel::StreamerDrillerLogModel(StreamerDataAggregator* data, QObject* pParent) - : QAbstractTableModel(pParent) - , m_data(data) - , m_lastShownEvent(-1) - , m_lengthLimit(0) - { - connect(data, SIGNAL(OnDataCurrentEventChanged()), this, SLOT(OnDataCurrentEventChanged())); - connect(data, SIGNAL(OnDataAddEvent()), this, SLOT(OnDataAddEvent())); - - m_lastShownEvent = m_data->GetCurrentEvent(); - } - - StreamerDrillerLogModel::~StreamerDrillerLogModel() - { - } - - void StreamerDrillerLogModel::OnDataCurrentEventChanged() - { - // real source data changes operate in real space, not the window of the length limited - int limitStore = m_lengthLimit; - SetLengthLimit(0); - - AZ::s64 currentEvent = m_data->GetCurrentEvent(); - // NOTE: we add +1 to all events, because we are EXECUTING the current event (so it must be shown) - if (m_lastShownEvent > currentEvent) - { - // remove rows - beginRemoveRows(QModelIndex(), (int)currentEvent + 1, (int)m_lastShownEvent); - endRemoveRows(); - } - else if (m_lastShownEvent < currentEvent) - { - // add rows - beginInsertRows(QModelIndex(), (int)m_lastShownEvent + 1, (int)currentEvent); - endInsertRows(); - } - m_lastShownEvent = currentEvent; - - SetLengthLimit(limitStore); - } - - void StreamerDrillerLogModel::OnDataAddEvent() - { - } - - void StreamerDrillerLogModel::SetLengthLimit(int limit) - { - beginResetModel(); - m_lengthLimit = limit; - endResetModel(); - } - - int StreamerDrillerLogModel::rowCount(const QModelIndex&) const - { - AZ::s64 currentEvent = m_data->GetCurrentEvent(); - if (m_lengthLimit && (m_lengthLimit < (currentEvent + 1))) - { - return m_lengthLimit; - } - return (int)currentEvent + 1; - } - int StreamerDrillerLogModel::columnCount(const QModelIndex&) const - { - return SDM_TOTAL; - } - Qt::ItemFlags StreamerDrillerLogModel::flags(const QModelIndex& index) const - { - if (!index.isValid()) - { - return Qt::ItemIsEnabled; - } - - return QAbstractItemModel::flags(index); - } - - QVariant StreamerDrillerLogModel::headerData (int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - return QVariant(SDM_STRING[section]); - } - // purposefully ignoring the ::Vertical orientation as part of an optimiztion - } - - return QVariant(); - } - - EventNumberType StreamerDrillerLogModel::RowToGlobalEventIndex(int row) - { - EventNumberType currentEvent = m_data->GetCurrentEvent(); - if (m_lengthLimit && (m_lengthLimit < (currentEvent + 1))) - { - row = row + (int)currentEvent - m_lengthLimit + 1; - } - - return row; - } - - QVariant StreamerDrillerLogModel::data(const QModelIndex& index, int role) const - { - return data(index.row(), index.column(), role); - } - - QVariant StreamerDrillerLogModel::data(int row, int column, int role) const - { - AZ::s64 currentEvent = m_data->GetCurrentEvent(); - if (m_lengthLimit && (m_lengthLimit < (currentEvent + 1))) - { - row = row + (int)currentEvent - m_lengthLimit + 1; - } - - return data(m_data->GetEvents()[row], row, column, role); - } - - QVariant StreamerDrillerLogModel::data(DrillerEvent* event, int row, int column, int role) const - { - using namespace AZ::Debug; - - const bool dummyCompressedFlag = false; // placeholder until set from stream info - - if (role == Qt::DisplayRole) - { - // COLUMN ------------------------------------------------------------- - if (column == SDM_NAME) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_DEVICE_MOUNTED: - { - return QVariant(QString(static_cast(event)->m_deviceData.m_name)); - break; - } - case Driller::Streamer::SET_DEVICE_UNMOUNTED: - { - return QVariant(QString(static_cast(event)->m_unmountedDeviceData->m_name)); - break; - } - case Driller::Streamer::SET_REGISTER_STREAM: - { - return QVariant(QString(static_cast(event)->m_streamData.m_name)); - break; - } - case Driller::Streamer::SET_UNREGISTER_STREAM: - { - auto depEvt = static_cast(event); - if (depEvt && depEvt->m_removedStreamData) - { - return QVariant(QString(depEvt->m_removedStreamData->m_name)); - } - return QVariant(QString(m_data->GetFilenameFromStreamId(row, depEvt->m_streamId))); - break; - } - case Driller::Streamer::SET_ADD_REQUEST: - { - auto depEvt = static_cast(event); - return QVariant(QString(m_data->GetFilenameFromStreamId(row, depEvt->m_requestData.m_streamId))); - break; - } - case Driller::Streamer::SET_CANCEL_REQUEST: - { - return QVariant(QString(m_data->GetFilenameFromStreamId(row, static_cast(event)->m_cancelledRequestData->m_streamId))); - break; - } - case Driller::Streamer::SET_RESCHEDULE_REQUEST: - { - return QVariant(QString(m_data->GetFilenameFromStreamId(row, static_cast(event)->m_rescheduledRequestData->m_streamId))); - break; - } - case Driller::Streamer::SET_COMPLETE_REQUEST: - { - auto depEvt = static_cast(event); - return QVariant(QString(m_data->GetFilenameFromStreamId(row, depEvt->m_removedRequest->m_streamId))); - break; - } - case Driller::Streamer::SET_OPERATION_START: - { - auto depEvt = static_cast(event); - return QVariant(QString("%1").arg(m_data->GetFilenameFromStreamId(row, depEvt->m_streamId))); - break; - } - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - auto depEvt = static_cast(event); - return QVariant(QString("%1").arg(m_data->GetFilenameFromStreamId(row, depEvt->m_streamId))); - break; - } - } - } - // COLUMN ------------------------------------------------------------- - if (column == SDM_DEBUG_NAME) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_ADD_REQUEST: - { - auto depEvt = static_cast(event); - if (depEvt->m_requestData.m_debugName) - { - return QVariant(QString(depEvt->m_requestData.m_debugName)); - } - break; - } - case Driller::Streamer::SET_CANCEL_REQUEST: - { - return QVariant(QString(static_cast(event)->m_cancelledRequestData->m_debugName)); - break; - } - case Driller::Streamer::SET_RESCHEDULE_REQUEST: - { - return QVariant(QString(static_cast(event)->m_rescheduledRequestData->m_debugName)); - break; - } - case Driller::Streamer::SET_COMPLETE_REQUEST: - { - auto depEvt = static_cast(event); - if (depEvt->m_removedRequest->m_debugName) - { - return QVariant(QString(depEvt->m_removedRequest->m_debugName)); - } - break; - } - case Driller::Streamer::SET_OPERATION_START: - { - auto depEvt = static_cast(event); - return QVariant(QString("%1").arg(m_data->GetDebugNameFromStreamId(row, depEvt->m_streamId))); - break; - } - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - auto depEvt = static_cast(event); - return QVariant(QString("%1").arg(m_data->GetDebugNameFromStreamId(row, depEvt->m_streamId))); - break; - } - } - } - // COLUMN ------------------------------------------------------------- - else if (column == SDM_EVENT_TYPE) - { - return QVariant(QString(eventTypeToString[ event->GetEventType() + 1 ])); - } - // COLUMN ------------------------------------------------------------- - else if (column == SDM_OPERATION) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - return QVariant(QString(operationTypeToString[ static_cast(event)->m_type + 1 ])); - break; - } - } - } - // COLUMN ------------------------------------------------------------- - else if (column == SDM_DELTA_TIME) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_OPERATION_START: - { - auto depEvt = static_cast(event); - - StreamerDataAggregator::SeekEventType seekType = m_data->GetSeekType(depEvt->GetGlobalEventId()); - QString seekNotice = seekTypeToString[seekType]; - - return QVariant(QString("%1").arg(seekNotice)); - break; - } - case Driller::Streamer::SET_ADD_REQUEST: - { - // this is a delta between this new request and a previous completion - // useful to determine slack time in incoming request sequences - auto depEvt = static_cast(event); - - int backtrackRow = row - 1; - while (backtrackRow >= 0) - { - DrillerEvent* pastEvent = m_data->GetEvents()[backtrackRow]; - if (pastEvent->GetEventType() == Driller::Streamer::SET_COMPLETE_REQUEST) - { - auto olderRequest = static_cast(pastEvent); - return QVariant(QString("%L1").arg(depEvt->m_timeStamp - olderRequest->m_timeStamp)); - } - - --backtrackRow; - } - break; - } - case Driller::Streamer::SET_COMPLETE_REQUEST: - { - auto thisEvent = static_cast(event); - - int backtrackRow = row - 1; - while (backtrackRow >= 0) - { - DrillerEvent* pastEvent = m_data->GetEvents()[backtrackRow]; - if (pastEvent->GetEventType() == Driller::Streamer::SET_ADD_REQUEST) - { - auto originalRequest = static_cast(pastEvent); - if (thisEvent->m_requestId == originalRequest->m_requestData.m_id) - { - return QVariant(QString("%L1").arg(thisEvent->m_timeStamp - originalRequest->m_timeStamp)); - } - } - - --backtrackRow; - } - break; - } - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - auto thisEvent = static_cast(event); - - int backtrackRow = row - 1; - while (backtrackRow >= 0) - { - DrillerEvent* pastEvent = m_data->GetEvents()[backtrackRow]; - if (pastEvent->GetEventType() == Driller::Streamer::SET_OPERATION_START) - { - auto originalOperation = static_cast(pastEvent); - if (thisEvent->m_streamId == originalOperation->m_streamId) - { - return QVariant(QString("%L1").arg(thisEvent->m_timeStamp - originalOperation->m_timeStamp)); - } - } - - --backtrackRow; - } - break; - } - } - } - // COLUMN ------------------------------------------------------------- - else if (column == SDM_DATA_TRANSFER) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_OPERATION_COMPLETE: - { - auto socEvent = static_cast(event); - - if (dummyCompressedFlag) - { - if (static_cast(socEvent->m_type) == StreamerDataAggregator::TRANSFER_EVENT_COMPRESSOR_READ || static_cast(socEvent->m_type) == StreamerDataAggregator::TRANSFER_EVENT_COMPRESSOR_WRITE) - { - return QVariant(QString("%1").arg(socEvent->m_bytesTransferred)); - } - } - else - { - return QVariant(QString("%1").arg(socEvent->m_bytesTransferred)); - } - - break; - } - } - } - // COLUMN ------------------------------------------------------------- - else if (column == SDM_READ_SIZE) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_ADD_REQUEST: - { - return QVariant(QString("%1").arg(static_cast(event)->m_requestData.m_size)); - break; - } - case Driller::Streamer::SET_COMPLETE_REQUEST: - { - return QVariant(QString("%1").arg(static_cast(event)->m_removedRequest->m_size)); - break; - } - } - } - else if (column == SDM_OFFSET) - { - switch (event->GetEventType()) - { - case Driller::Streamer::SET_ADD_REQUEST: - { - StreamerAddRequestEvent* actualData = static_cast(event); - return QVariant(QString::number(actualData->m_requestData.m_offset)); - } - break; - case Driller::Streamer::SET_OPERATION_START: - { - StreamerOperationStartEvent* actualData = static_cast(event); - return QVariant(QString::number(actualData->m_operation.m_offset)); - } - break; - } - } - } - - return QVariant(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/IO/StreamerEvents.cpp b/Code/Tools/Standalone/Source/Driller/IO/StreamerEvents.cpp deleted file mode 100644 index 78e2e1c611..0000000000 --- a/Code/Tools/Standalone/Source/Driller/IO/StreamerEvents.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "StreamerEvents.h" - -#include "StreamerDataAggregator.hxx" - -namespace Driller -{ - void StreamerMountDeviceEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_devices.push_back(&m_deviceData); - } - - void StreamerMountDeviceEvent::StepBackward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::DeviceArrayType::iterator it = AZStd::find(aggr->m_devices.begin(), aggr->m_devices.end(), &m_deviceData); - if (it != aggr->m_devices.end()) // we can potentially not have registered the device if we did NOT capture the full state! TODO: warn about this - { - aggr->m_devices.erase(it); - } - } - - void StreamerUnmountDeviceEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - for (StreamerDataAggregator::DeviceArrayType::iterator it = aggr->m_devices.begin(); it != aggr->m_devices.end(); ++it) - { - if ((*it)->m_id == m_deviceId) - { - m_unmountedDeviceData = *it; - aggr->m_devices.erase(it); - break; - } - } - } - - void StreamerUnmountDeviceEvent::StepBackward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_devices.push_back(m_unmountedDeviceData); - } - - void StreamerRegisterStreamEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_streams.insert(AZStd::make_pair(m_streamData.m_id, &m_streamData)); - } - - void StreamerRegisterStreamEvent::StepBackward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_streams.erase(m_streamData.m_id); - } - - void StreamerUnregisterStreamEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::StreamMapType::iterator it = aggr->m_streams.find(m_streamId); - if (it != aggr->m_streams.end()) - { - m_removedStreamData = it->second; - aggr->m_streams.erase(it); - } - } - - void StreamerUnregisterStreamEvent::StepBackward(Aggregator* data) - { - if (m_removedStreamData != nullptr) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_streams.insert(AZStd::make_pair(m_streamId, m_removedStreamData)); - } - } - - void StreamerReadCacheHit::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - (void)aggr; // Add to read cache hit map - } - - void StreamerReadCacheHit::StepBackward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - (void)aggr; // Remove from read cache hit map - } - - void StreamerAddRequestEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_requests.insert(AZStd::make_pair(m_requestData.m_id, &m_requestData)); - } - - void StreamerAddRequestEvent::StepBackward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_requests.erase(m_requestData.m_id); - } - - void StreamerCompleteRequestEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::RequestMapType::iterator it = aggr->m_requests.find(m_requestId); - if (it != aggr->m_requests.end()) - { - m_removedRequest = it->second; - m_oldState = m_removedRequest->m_completeState; - m_removedRequest->m_completeState = m_state; - aggr->m_requests.erase(it); - } - else - { - // TODO warn, this is possible if we did not capture the full state from the beginning - } - } - - void StreamerCompleteRequestEvent::StepBackward(Aggregator* data) - { - if (m_removedRequest != nullptr) - { - StreamerDataAggregator* aggr = static_cast(data); - m_removedRequest->m_completeState = m_oldState; - aggr->m_requests.insert(AZStd::make_pair(m_requestId, m_removedRequest)); - } - } - - void StreamerCancelRequestEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::RequestMapType::iterator it = aggr->m_requests.find(m_requestId); - if (it != aggr->m_requests.end()) - { - m_cancelledRequestData = it->second; - aggr->m_requests.erase(it); - } - } - - void StreamerCancelRequestEvent::StepBackward(Aggregator* data) - { - if (m_cancelledRequestData != nullptr) - { - StreamerDataAggregator* aggr = static_cast(data); - aggr->m_requests.insert(AZStd::make_pair(m_requestId, m_cancelledRequestData)); - } - } - - - void StreamerRescheduleRequestEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::RequestMapType::iterator it = aggr->m_requests.find(m_requestId); - if (it != aggr->m_requests.end()) - { - m_rescheduledRequestData = it->second; - m_oldDeadline = m_rescheduledRequestData->m_deadline; - m_oldPriority = m_rescheduledRequestData->m_priority; - m_rescheduledRequestData->m_deadline = m_newDeadline; - m_rescheduledRequestData->m_priority = m_newPriority; - } - else - { - // TODO warn, this is possible if we did not capture the full state from the beginning - } - } - - void StreamerRescheduleRequestEvent::StepBackward(Aggregator* data) - { - (void)data; - if (m_rescheduledRequestData != nullptr) - { - m_rescheduledRequestData->m_deadline = m_oldDeadline; - m_rescheduledRequestData->m_priority = m_oldPriority; - } - } - - void StreamerOperationStartEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::StreamMapType::iterator it = aggr->m_streams.find(m_streamId); - if (it != aggr->m_streams.end()) - { - m_stream = it->second; - m_previousOperation = m_stream->m_operation; - m_stream->m_operation = &m_operation; - } - else - { - // TODO warn in a smart way too many warnings while scrubbing - //AZ_Warning("Streamer Driller",false,"Operation could not find a stream 0x%08x this can be ok deoending on the streamer mode (if it captures the inital state or not)!",m_streamId); - } - } - - void StreamerOperationStartEvent::StepBackward(Aggregator* data) - { - (void)data; - if (m_stream != nullptr) - { - m_stream->m_operation = m_previousOperation; - } - } - - void StreamerOperationCompleteEvent::StepForward(Aggregator* data) - { - StreamerDataAggregator* aggr = static_cast(data); - StreamerDataAggregator::StreamMapType::iterator it = aggr->m_streams.find(m_streamId); - if (it != aggr->m_streams.end()) - { - m_stream = it->second; - m_stream->m_operation->m_bytesTransferred = m_bytesTransferred; - } - } - - void StreamerOperationCompleteEvent::StepBackward(Aggregator* data) - { - (void)data; - if (m_stream != nullptr) - { - m_stream->m_operation->m_bytesTransferred = 0; - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.cpp deleted file mode 100644 index 71d0cf3975..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "MemoryDataAggregator.hxx" -#include -#include "MemoryDataView.hxx" - -#include "MemoryEvents.h" -#include -#include -#include "Source/Driller/Workspaces/Workspace.h" - -namespace Driller -{ - class MemoryDataAggregatorSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(MemoryDataAggregatorSavedState, "{9A117AF1-842B-43C4-8E98-F08E8080579A}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(MemoryDataAggregatorSavedState, AZ::SystemAllocator, 0); - MemoryDataAggregatorSavedState() - : m_activeViewCount(0) - {} - - int m_activeViewCount; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewCount", &MemoryDataAggregatorSavedState::m_activeViewCount) - ->Version(2); - } - } - }; - - class MemoryDataAggregatorWorkspace - : public AZ::UserSettings - { - public: - AZ_RTTI(MemoryDataAggregatorWorkspace, "{4CBE496B-1CC3-4219-A0E2-D88850F6BCFD}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(MemoryDataAggregatorWorkspace, AZ::SystemAllocator, 0); - - int m_activeViewCount; - - MemoryDataAggregatorWorkspace() - : m_activeViewCount(0) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewCount", &MemoryDataAggregatorWorkspace::m_activeViewCount) - ->Version(2); - } - } - }; - - ////////////////////////////////////////////////////////////////////////// - MemoryDataAggregator::MemoryDataAggregator(int identity) - : Aggregator(identity) - { - m_parser.SetAggregator(this); - - m_persistentState = AZ::UserSettings::CreateFind(AZ_CRC("MEMORY DATA AGGREGATOR SAVED STATE", 0x672155eb), AZ::UserSettings::CT_GLOBAL); - AZ_Assert(m_persistentState, "Persistent State is NULL?"); - } - - MemoryDataAggregator::~MemoryDataAggregator() - { - KillAllViews(); - } - - float MemoryDataAggregator::ValueAtFrame(FrameNumberType frame) - { - const float maxEventsPerFrame = 1000.0f; // just a scale number - float numEventsPerFrame = static_cast(NumOfEventsAtFrame(frame)); - return AZStd::GetMin(numEventsPerFrame / maxEventsPerFrame, 1.0f) * 2.0f - 1.0f; - } - - QColor MemoryDataAggregator::GetColor() const - { - return QColor(255, 0, 0); - } - - QString MemoryDataAggregator::GetName() const - { - return "Memory"; - } - - QString MemoryDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString MemoryDataAggregator::GetDescription() const - { - return "Memory allocations driller"; - } - - QString MemoryDataAggregator::GetToolTip() const - { - return "Information about Memory allocations"; - } - - AZ::Uuid MemoryDataAggregator::GetID() const - { - return AZ::Uuid("{D97E63EC-D85C-4DBB-B7CD-B092E2AB3A63}"); - } - - QWidget* MemoryDataAggregator::DrillDownRequest(FrameNumberType frame) - { - AZ::u32 availableIdx = 0; - bool foundASpot = true; - do - { - foundASpot = true; - for (DataViewMap::iterator iter = m_dataViews.begin(); iter != m_dataViews.end(); ++iter) - { - if (iter->second == availableIdx) - { - foundASpot = false; - ++availableIdx; - break; - } - } - } while (!foundASpot); - - Driller::MemoryDataView* dv = NULL; - if (m_events.size()) - { - dv = aznew Driller::MemoryDataView(this, frame, (1024 * GetIdentity()) + availableIdx); - if (dv) - { - m_dataViews[dv] = availableIdx; - connect(dv, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataViewDestroyed(QObject*))); - ++m_persistentState->m_activeViewCount; - } - } - - return dv; - } - void MemoryDataAggregator::OptionsRequest() - { - } - void MemoryDataAggregator::OnDataViewDestroyed(QObject* dataView) - { - m_dataViews.erase(static_cast(dataView)); - --m_persistentState->m_activeViewCount; - } - - MemoryDataAggregator::AllocatorInfoArrayType::iterator MemoryDataAggregator::FindAllocatorById(AZ::u64 id) - { - for (MemoryDataAggregator::AllocatorInfoArrayType::iterator alIt = m_allocators.begin(); alIt != m_allocators.end(); ++alIt) - { - if ((*alIt)->m_id == id) - { - return alIt; - } - } - return m_allocators.end(); - } - - MemoryDataAggregator::AllocatorInfoArrayType::iterator MemoryDataAggregator::FindAllocatorByRecordsId(AZ::u64 recordsId) - { - for (MemoryDataAggregator::AllocatorInfoArrayType::iterator alIt = m_allocators.begin(); alIt != m_allocators.end(); ++alIt) - { - if ((*alIt)->m_recordsId == recordsId) - { - return alIt; - } - } - return m_allocators.end(); - } - - void MemoryDataAggregator::KillAllViews() - { - do - { - DataViewMap::iterator iter = m_dataViews.begin(); - if (iter != m_dataViews.end()) - { - iter->first->hide(); - delete iter->first; - continue; - } - break; - } while (1); - } - - void MemoryDataAggregator::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - MemoryDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("MEMORY DATA AGGREGATOR WORKSPACE", 0x41ee95bc)); - if (workspace) - { - m_persistentState->m_activeViewCount = workspace->m_activeViewCount; - } - } - void MemoryDataAggregator::ActivateWorkspaceSettings(WorkspaceSettingsProvider* provider) - { - MemoryDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("MEMORY DATA AGGREGATOR WORKSPACE", 0x41ee95bc)); - if (workspace) - { - // kill all existing data view windows in preparation of opening the workspace specified ones - KillAllViews(); - - // the internal count should be 0 from the above house cleaning - // and incremented back up from the workspace instantiations - m_persistentState->m_activeViewCount = 0; - for (int i = 0; i < workspace->m_activeViewCount; ++i) - { - // driller must be created at (frame > 0) for it to have a valid tree to display - Driller::MemoryDataView* dataView = qobject_cast(DrillDownRequest(1)); - if (dataView) - { - // apply will overlay the workspace settings on top of the local user settings - dataView->ApplySettingsFromWorkspace(provider); - // activate will do the heavy lifting - dataView->ActivateWorkspaceSettings(provider); - } - } - } - } - void MemoryDataAggregator::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - MemoryDataAggregatorWorkspace* workspace = provider->CreateSetting(AZ_CRC("MEMORY DATA AGGREGATOR WORKSPACE", 0x41ee95bc)); - if (workspace) - { - workspace->m_activeViewCount = m_persistentState->m_activeViewCount; - - for (DataViewMap::iterator iter = m_dataViews.begin(); iter != m_dataViews.end(); ++iter) - { - iter->first->SaveSettingsToWorkspace(provider); - } - } - } - - //========================================================================= - // Reset - // [7/10/2013] - //========================================================================= - void MemoryDataAggregator::Reset() - { - m_allocators.clear(); - } - - void MemoryDataAggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - MemoryDataAggregatorSavedState::Reflect(context); - MemoryDataAggregatorWorkspace::Reflect(context); - MemoryDataView::Reflect(context); - - serialize->Class() - ->Version(1) - ->SerializeWithNoData(); - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.hxx deleted file mode 100644 index f124d55947..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataAggregator.hxx +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_MEMORY_DATAAGGREGATOR_TESTS_H -#define DRILLER_MEMORY_DATAAGGREGATOR_TESTS_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/DrillerAggregatorOptions.hxx" - -#include - -#include "MemoryDataParser.h" -#include "MemoryDataView.hxx" -#endif - -namespace Driller -{ - namespace Memory - { - struct AllocationInfo; - struct AllocatorInfo; - } - class MemoryDataAggregatorSavedState; - - /** - * Memory data drilling aggregator. - */ - class MemoryDataAggregator : public Aggregator - { - friend class MemoryDataView; - MemoryDataAggregator(const MemoryDataAggregator&) = delete; - Q_OBJECT; - public: - AZ_RTTI(MemoryDataAggregator, "{18589F5B-B9F0-4893-90E7-95C6E08DF798}"); - AZ_CLASS_ALLOCATOR(MemoryDataAggregator,AZ::SystemAllocator,0); - - MemoryDataAggregator(int identity = 0); - virtual ~MemoryDataAggregator(); - - static AZ::u32 DrillerId() { return MemoryDrillerHandlerParser::GetDrillerId(); } - virtual AZ::u32 GetDrillerId() const override { return DrillerId(); } - - static const char* ChannelName() { return "Memory"; } - virtual AZ::Crc32 GetChannelId() const override { return AZ::Crc32(ChannelName()); } - - virtual AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() { return &m_parser; } - - virtual void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - virtual void ActivateWorkspaceSettings(WorkspaceSettingsProvider *); - virtual void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - - void KillAllViews(); - - ////////////////////////////////////////////////////////////////////////// - // Aggregator - virtual void Reset(); - public slots: - float ValueAtFrame( FrameNumberType frame ) override; - QColor GetColor() const override; - QString GetChannelName() const override; - QString GetName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - void OptionsRequest() override; - void OnDataViewDestroyed(QObject*); - - //protected: - public: - typedef AZStd::vector AllocatorInfoArrayType; - - AllocatorInfoArrayType::iterator FindAllocatorById(AZ::u64 id); - AllocatorInfoArrayType::iterator FindAllocatorByRecordsId(AZ::u64 recordsId); - AllocatorInfoArrayType::iterator GetAllocatorEnd() { return m_allocators.end(); } - - AllocatorInfoArrayType m_allocators; ///< Current state of allocators - MemoryDrillerHandlerParser m_parser; ///< Parser for this aggregator - - typedef AZStd::unordered_map DataViewMap; - DataViewMap m_dataViews; /// track active dialog indexes - AZStd::intrusive_ptr m_persistentState; - - static void Reflect(AZ::ReflectContext* context); - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.cpp deleted file mode 100644 index 4ced538257..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "MemoryDataParser.h" -#include "MemoryDataAggregator.hxx" -#include "MemoryEvents.h" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* MemoryDrillerHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - - if (tagName == AZ_CRC("RegisterAllocator", 0x19f08114)) - { - m_subTag = ST_REGISTER_ALLOCATOR; - m_data->AddEvent(aznew MemoryDrillerRegisterAllocatorEvent()); - return this; // m_registerAllocatorHanler - } - else if (tagName == AZ_CRC("RegisterAllocation", 0x992a9780)) - { - m_subTag = ST_REGISTER_ALLOCATION; - m_data->AddEvent(aznew MemoryDrillerRegisterAllocationEvent()); - return this; // m_registerAllocation - } - else if (tagName == AZ_CRC("UnRegisterAllocation", 0xea5dc4cd)) - { - m_subTag = ST_UNREGISTER_ALLOCATION; - m_data->AddEvent(aznew MemoryDrillerUnregisterAllocationEvent()); - return this; // m_unregisterAllocation - } - else if (tagName == AZ_CRC("ResizeAllocation", 0x8a9c78dc)) - { - m_subTag = ST_RESIZE_ALLOCATION; - m_data->AddEvent(aznew MemoryDrillerResizeAllocationEvent()); - return this; // m_resizeAllocation - } - else - { - m_subTag = ST_NONE; - } - return NULL; - } - - void MemoryDrillerHandlerParser::OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)tagName; - if (handler != NULL) - { - m_subTag = ST_NONE; // we have only one level just go back to the default state - } - } - - void MemoryDrillerHandlerParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - - switch (m_subTag) - { - case ST_NONE: - { - if (dataNode.m_name == AZ_CRC("UnregisterAllocator", 0xb2b54f93)) - { - AZ::u64 allocatorId; - dataNode.Read(allocatorId); - MemoryDrillerUnregisterAllocatorEvent* event = aznew MemoryDrillerUnregisterAllocatorEvent(); - event->m_allocatorId = allocatorId; - m_data->AddEvent(event); - } - } break; - case ST_REGISTER_ALLOCATOR: - { - MemoryDrillerRegisterAllocatorEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_allocatorInfo.m_name = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_allocatorInfo.m_id); - } - else if (dataNode.m_name == AZ_CRC("Capacity", 0xb5e8b174)) - { - dataNode.Read(event->m_allocatorInfo.m_capacity); - } - else if (dataNode.m_name == AZ_CRC("RecordsId", 0x7caaca88)) - { - dataNode.Read(event->m_allocatorInfo.m_recordsId); - } - else if (dataNode.m_name == AZ_CRC("RecordsMode", 0x764c147a)) - { - dataNode.Read(event->m_allocatorInfo.m_recordMode); - } - else if (dataNode.m_name == AZ_CRC("NumStackLevels", 0xad9cff15)) - { - dataNode.Read(event->m_allocatorInfo.m_numStackLevels); - } - } break; - case ST_REGISTER_ALLOCATION: - { - MemoryDrillerRegisterAllocationEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RecordsId", 0x7caaca88)) - { - dataNode.Read(event->m_allocationInfo.m_recordsId); - } - else if (dataNode.m_name == AZ_CRC("Address", 0x0d4e6f81)) - { - dataNode.Read(event->m_address); - } - else if (dataNode.m_name == AZ_CRC("Alignment", 0x2cce1e5c)) - { - dataNode.Read(event->m_allocationInfo.m_alignment); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_allocationInfo.m_size); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_allocationInfo.m_name = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("FileName", 0x3c0be965)) - { - event->m_allocationInfo.m_fileName = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("FileLine", 0xb33c2395)) - { - dataNode.Read(event->m_allocationInfo.m_fileLine); - } - else if (dataNode.m_name == AZ_CRC("Stack", 0x41a87b6a)) - { - // TODO: we can pool that stack memory - event->m_allocationInfo.m_stackFrames = reinterpret_cast(azmalloc(dataNode.m_dataSize)); - dataNode.Read(event->m_allocationInfo.m_stackFrames, dataNode.m_dataSize); - } - } break; - case ST_UNREGISTER_ALLOCATION: - { - MemoryDrillerUnregisterAllocationEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RecordsId", 0x7caaca88)) - { - dataNode.Read(event->m_recordsId); - } - else if (dataNode.m_name == AZ_CRC("Address", 0x0d4e6f81)) - { - dataNode.Read(event->m_address); - } - } break; - case ST_RESIZE_ALLOCATION: - { - MemoryDrillerResizeAllocationEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("RecordsId", 0x7caaca88)) - { - dataNode.Read(event->m_recordsId); - } - else if (dataNode.m_name == AZ_CRC("Address", 0x0d4e6f81)) - { - dataNode.Read(event->m_address); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_newSize); - } - } break; - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.h b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.h deleted file mode 100644 index c7dad612d7..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataParser.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_MEMORY_DRILLER_PARSER_H -#define DRILLER_MEMORY_DRILLER_PARSER_H - -#include - -namespace Driller -{ - class MemoryDataAggregator; - - class MemoryDrillerHandlerParser - : public AZ::Debug::DrillerHandlerParser - { - public: - enum SubTags - { - ST_NONE = 0, - ST_REGISTER_ALLOCATOR, - ST_REGISTER_ALLOCATION, - ST_UNREGISTER_ALLOCATION, - ST_RESIZE_ALLOCATION, - }; - - MemoryDrillerHandlerParser() - : m_subTag(ST_NONE) - , m_data(NULL) - {} - - static AZ::u32 GetDrillerId() { return AZ_CRC("MemoryDriller", 0x1b31269d); } - - void SetAggregator(MemoryDataAggregator* data) { m_data = data; } - - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - virtual void OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName); - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - protected: - SubTags m_subTag; - MemoryDataAggregator* m_data; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.cpp b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.cpp deleted file mode 100644 index 3ccad8fae0..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.cpp +++ /dev/null @@ -1,642 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "MemoryDataView.hxx" -#include - -#include "MemoryDataAggregator.hxx" -#include "MemoryEvents.h" -#include "Source/Driller/DrillerEvent.h" -#include - -#include "Source/Driller/ChannelDataView.hxx" -#include "Source/Driller/DrillerMainWindowMessages.h" - -#include -#include - -#include - -#include -#include -#include - -namespace Driller -{ - static const char* frameRangeToDisplayString[] = - { - "Show 1 Frame", - "Show 2 Frames", - "Show 5 Frames", - "Show 15 Frames", - "Show 30 Frames", - "Show 60 Frames", - "Show 120 Frames", - NULL - }; - static const int frameRangeFromIndex[] = { 1, 2, 5, 15, 30, 60, 120, 0 }; - - MemoryAxisFormatter::MemoryAxisFormatter(QObject* pParent) - : QAbstractAxisFormatter(pParent) - { - } - - QString MemoryAxisFormatter::formatMemorySize(float value, float scalingValue) - { - // data is in whole byte numbers. - - // so how big is the division size? - if (scalingValue > 128.0f * 1024.0f) // greater than a 0.1 mb - { - if (scalingValue > 1024.0f * 1024.0f) // whole seconds - { - return QObject::tr("%1MB").arg(QString::number(value / (1024.0f * 1024.0f), 'f', 0)); - } - else - { - return QObject::tr("%1MB").arg(QString::number(value / (1024.0f * 1024.0f), 'f', 1)); - } - } - else if (scalingValue > 128.0f) // greater than a 128 bytes - { - if (scalingValue > 1024.0f) // whole kilobytes - { - return QObject::tr("%1KB").arg(QString::number(value / 1024.0f, 'f', 0)); - } - else - { - return QObject::tr("%1KB").arg(QString::number(value / 1024, 'f', 1)); - } - } - else - { - return QObject::tr("%1B").arg((AZ::s64)value); - } - } - - - QString MemoryAxisFormatter::convertAxisValueToText(Charts::AxisType axis, float value, float /*minDisplayedValue*/, float /*maxDisplayedValue*/, float divisionSize) - { - if (axis == Charts::AxisType::Vertical) - { - return formatMemorySize(value, divisionSize); - } - else - { - return QString::number((int)value); - } - }; - - - class MemoryDataViewSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(MemoryDataViewSavedState, "{1F25755D-8477-48B3-AAB5-6CDBB4152723}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(MemoryDataViewSavedState, AZ::SystemAllocator, 0); - - AZStd::string m_filterMenuString; - AZ::u64 m_filterId; - int m_frameRange; - bool m_autoZoom; - float m_manualZoomMin; // if we're not automatically zooming, then we remember the prior zoom to re-apply it - float m_manualZoomMax; - - MemoryDataViewSavedState() - : m_filterMenuString("Filter: All") - , m_filterId(0) - , m_frameRange(1) - , m_autoZoom(true) - , m_manualZoomMin(2000000000.0f) - , m_manualZoomMax(-2000000000.0f) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_filterMenuString", &MemoryDataViewSavedState::m_filterMenuString) - ->Field("m_filterId", &MemoryDataViewSavedState::m_filterId) - ->Field("m_frameRange", &MemoryDataViewSavedState::m_frameRange) - ->Field("m_autoZoom", &MemoryDataViewSavedState::m_autoZoom) - ->Field("m_manualZoomMin", &MemoryDataViewSavedState::m_manualZoomMin) - ->Field("m_manualZoomMax", &MemoryDataViewSavedState::m_manualZoomMax) - ->Version(3); - } - } - }; - - - MemoryDataView::MemoryDataView(MemoryDataAggregator* aggregator, FrameNumberType atFrame, int profilerIndex) - : QDialog() - , m_aggregator(aggregator) - , m_Frame(atFrame) - , m_HighestFrameSoFar(-1) - , m_viewIndex(profilerIndex) - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); - - m_ScrubberIndex = 0; - - show(); - raise(); - activateWindow(); - setFocus(); - - m_gui = azcreate(Ui::MemoryDataView, ()); - m_gui->setupUi(this); - - setWindowTitle(QString("Memory Data View %1 from %2").arg(profilerIndex).arg(aggregator->GetIdentity())); - - m_ptrFormatter = aznew MemoryAxisFormatter(this); - m_gui->widgetDataStrip->SetAxisTextFormatter(m_ptrFormatter); - - connect(m_aggregator, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataDestroyed())); - - connect(m_gui->widgetDataStrip, SIGNAL(onMouseLeftDownDomainValue(float)), this, SLOT(onMouseLeftDownDomainValue(float))); - connect(m_gui->widgetDataStrip, SIGNAL(onMouseLeftDragDomainValue(float)), this, SLOT(onMouseLeftDragDomainValue(float))); - - connect(m_gui->widgetDataStrip, SIGNAL(onMouseOverDataPoint(int, AZ::u64, float, float)), this, SLOT(onMouseOverDataPoint(int, AZ::u64, float, float))); - connect(m_gui->widgetDataStrip, SIGNAL(onMouseOverNothing(float, float)), this, SLOT(onMouseOverNothing(float, float))); - - connect(m_gui->checkLockRight, SIGNAL(stateChanged(int)), this, SLOT(OnCheckLockRight(int))); - connect(m_gui->buttonViewFull, SIGNAL(pressed()), this, SLOT(OnViewFull())); - - connect(m_gui->filterButton, SIGNAL(pressed()), this, SLOT(OnFilterButton())); - - connect(m_gui->checkBoxAutoZoom, SIGNAL(toggled(bool)), this, SLOT(OnAutoZoomChange(bool))); - - { - QMenu* frameRangeMenu = new QMenu(this); - for (int i = 0; frameRangeToDisplayString[i]; ++i) - { - frameRangeMenu->addAction(CreateFrameRangeMenuAction(frameRangeToDisplayString[i], frameRangeFromIndex[i])); - } - - m_gui->frameRangeButton->setText(frameRangeToDisplayString[0]); - m_gui->frameRangeButton->setMenu(frameRangeMenu); - } - - m_aggregatorIdentityCached = m_aggregator->GetIdentity(); - DrillerMainWindowMessages::Handler::BusConnect(m_aggregatorIdentityCached); - DrillerEventWindowMessages::Handler::BusConnect(m_aggregatorIdentityCached); - - AZStd::string windowStateStr = AZStd::string::format("MEMORY DATA VIEW WINDOW STATE %i", m_viewIndex); - m_windowStateCRC = AZ::Crc32(windowStateStr.c_str()); - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (windowState) - { - windowState->RestoreGeometry(this); - } - - AZStd::string dataViewStateStr = AZStd::string::format("MEMORY DATA VIEW STATE %i", m_viewIndex); - m_viewStateCRC = AZ::Crc32(dataViewStateStr.c_str()); - m_persistentState = AZ::UserSettings::CreateFind(m_viewStateCRC, AZ::UserSettings::CT_GLOBAL); - ApplyPersistentState(); - - SetFrameNumber(); - } - - MemoryDataView::~MemoryDataView() - { - SaveOnExit(); - azdestroy(m_gui); - } - - void MemoryDataView::SaveOnExit() - { - DrillerEventWindowMessages::Handler::BusDisconnect(m_aggregatorIdentityCached); - DrillerMainWindowMessages::Handler::BusDisconnect(m_aggregatorIdentityCached); - - AZStd::intrusive_ptr pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - pState->CaptureGeometry(this); - } - void MemoryDataView::hideEvent(QHideEvent* evt) - { - QDialog::hideEvent(evt); - } - void MemoryDataView::closeEvent(QCloseEvent* evt) - { - QDialog::closeEvent(evt); - } - void MemoryDataView::OnDataDestroyed() - { - deleteLater(); - } - - QAction* MemoryDataView::CreateFrameRangeMenuAction(QString qs, int range) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setProperty("Range", range); - connect(act, SIGNAL(triggered()), this, SLOT(OnFrameRangeMenu())); - return act; - } - - QAction* MemoryDataView::CreateFilterSelectorAction(QString qs, AZ::u64 id) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setData(id); - connect(act, SIGNAL(triggered()), this, SLOT(OnFilterSelectorMenu())); - return act; - } - - void MemoryDataView::OnFrameRangeMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - m_gui->frameRangeButton->setText(qa->objectName()); - int range = qa->property("Range").toInt(); - m_persistentState->m_frameRange = range; - - // force a new data build - SetFrameNumber(); - update(); - } - } - - void MemoryDataView::OnFilterButton() - { - QMenu* filterIDMenu = new QMenu(this); - filterIDMenu->addAction(CreateFilterSelectorAction("Filter: All", 0)); - - for (auto iter = m_aggregator->m_allocators.begin(); iter != m_aggregator->m_allocators.end(); ++iter) - { - filterIDMenu->addAction(CreateFilterSelectorAction(QString("Filter: %1").arg((*iter)->m_name), (*iter)->m_id)); - } - - filterIDMenu->exec(QCursor::pos()); - delete filterIDMenu; - } - - void MemoryDataView::OnFilterSelectorMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnFilterSelectorMenu(qa->objectName(), qa->data().toULongLong()); - } - } - - void MemoryDataView::OnFilterSelectorMenu(QString fromMenu, AZ::u64 id) - { - m_gui->filterButton->setText(fromMenu); - - m_persistentState->m_filterMenuString = fromMenu.toUtf8().data(); - m_persistentState->m_filterId = id; - - // force a new data build - SetFrameNumber(); - update(); - } - - void MemoryDataView::OnAutoZoomChange(bool newValue) - { - if (!newValue) - { - m_persistentState->m_autoZoom = false; - m_gui->widgetDataStrip->GetWindowRange(Charts::AxisType::Vertical, m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax); - } - else - { - m_persistentState->m_autoZoom = true; - m_persistentState->m_manualZoomMin = 2000000000.0f; - m_persistentState->m_manualZoomMax = -2000000000.0f; - } - - UpdateChart(); - } - - void MemoryDataView::ApplyPersistentState() - { - if (m_persistentState) - { - m_gui->checkBoxAutoZoom->setChecked(m_persistentState->m_autoZoom); - OnAutoZoomChange(m_persistentState->m_autoZoom); - - OnFilterSelectorMenu(m_persistentState->m_filterMenuString.c_str(), m_persistentState->m_filterId); - m_gui->frameRangeButton->setText(frameRangeToDisplayString[0]); - for (int i = 0; frameRangeFromIndex[i]; ++i) - { - if (m_persistentState->m_frameRange == frameRangeFromIndex[i]) - { - m_gui->frameRangeButton->setText(frameRangeToDisplayString[i]); - break; - } - } - } - } - - void MemoryDataView::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("MEMORY DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - MemoryDataViewSavedState* workspace = provider->FindSetting(workspaceStateCRC); - if (workspace) - { - m_persistentState->m_filterMenuString = workspace->m_filterMenuString; - m_persistentState->m_filterId = workspace->m_filterId; - m_persistentState->m_frameRange = workspace->m_frameRange; - } - } - } - - void MemoryDataView::ActivateWorkspaceSettings(WorkspaceSettingsProvider*) - { - ApplyPersistentState(); - } - - void MemoryDataView::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("MEMORY DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - MemoryDataViewSavedState* workspace = provider->CreateSetting(workspaceStateCRC); - if (workspace) - { - workspace->m_filterMenuString = m_persistentState->m_filterMenuString; - workspace->m_filterId = m_persistentState->m_filterId; - workspace->m_frameRange = m_persistentState->m_frameRange; - } - } - } - - void MemoryDataView::onMouseOverDataPoint(int channelID, AZ::u64 sampleID, float primaryAxisValue, float dependentAxisValue) - { - (void)primaryAxisValue; - (void)dependentAxisValue; - (void)channelID; - DrillerEvent* dep = m_aggregator->GetEvents()[ sampleID ]; - QString finalText; - - // highlight both channels - - m_gui->widgetDataStrip->SetChannelSampleHighlight(0, sampleID, true); - m_gui->widgetDataStrip->SetChannelSampleHighlight(1, sampleID, true); - - switch (dep->GetEventType()) - { - case Driller::Memory::MET_REGISTER_ALLOCATION: - { - Memory::AllocationInfo* mai = &static_cast(dep)->m_allocationInfo; - - finalText = tr("ALLOCATE %1
%2:%3
%4") - .arg(m_ptrFormatter->formatMemorySize((float)mai->m_size, (float)mai->m_size)) - .arg(mai->m_fileName ? mai->m_fileName : "") - .arg(mai->m_fileLine) - .arg(mai->m_name ? mai->m_name : ""); - } - break; - case Driller::Memory::MET_UNREGISTER_ALLOCATION: - { - MemoryDrillerUnregisterAllocationEvent* uae = static_cast(dep); - if (uae->m_removedAllocationInfo) - { - finalText = tr("DEALLOCATE %1
%2:%3
%4") - .arg(m_ptrFormatter->formatMemorySize((float)uae->m_removedAllocationInfo->m_size, (float)uae->m_removedAllocationInfo->m_size)) - .arg(uae->m_removedAllocationInfo->m_fileName ? uae->m_removedAllocationInfo->m_fileName : "") - .arg(uae->m_removedAllocationInfo->m_fileLine) - .arg(uae->m_removedAllocationInfo->m_name ? uae->m_removedAllocationInfo->m_name : ""); - } - else - { - finalText = tr("DEALLOCATE UNKNOWN "); - } - } - break; - case Driller::Memory::MET_RESIZE_ALLOCATION: - { - MemoryDrillerResizeAllocationEvent* rae = static_cast(dep); - if (rae->m_modifiedAllocationInfo) - { - finalText = tr("RESIZE %1 TO %2
%3:%4
%5") - .arg(m_ptrFormatter->formatMemorySize((float)rae->m_oldSize, (float)rae->m_oldSize)) - .arg(m_ptrFormatter->formatMemorySize((float)rae->m_newSize, (float)rae->m_newSize)) - .arg(rae->m_modifiedAllocationInfo->m_fileName ? rae->m_modifiedAllocationInfo->m_fileName : "") - .arg(rae->m_modifiedAllocationInfo->m_fileLine) - .arg(rae->m_modifiedAllocationInfo->m_name ? rae->m_modifiedAllocationInfo->m_name : ""); - } - else - { - finalText = tr("RESIZE UNKNOWN %1 TO %2") - .arg(m_ptrFormatter->formatMemorySize((float)rae->m_oldSize, (float)rae->m_oldSize)) - .arg(m_ptrFormatter->formatMemorySize((float)rae->m_newSize, (float)rae->m_newSize)); - } - } - break; - } - - if (finalText.length() > 0) - { - if (QApplication::activeWindow() == this) - { - QToolTip::showText(m_gui->widgetDataStrip->mapToGlobal(QPoint(0, -10)), finalText, m_gui->widgetDataStrip); - } - } - } - - void MemoryDataView::onMouseOverNothing(float primaryAxisValue, float dependentAxisValue) - { - (void)primaryAxisValue; - (void)dependentAxisValue; - m_gui->widgetDataStrip->SetChannelSampleHighlight(0, 0, false); - m_gui->widgetDataStrip->SetChannelSampleHighlight(1, 0, false); - QToolTip::hideText(); - } - - void MemoryDataView::onMouseLeftDownDomainValue(float domainValue) - { - AZ::s64 globalEvtID = (AZ::s64)(domainValue); - emit EventRequestEventFocus(globalEvtID); - } - - void MemoryDataView::onMouseLeftDragDomainValue(float domainValue) - { - AZ::s64 globalEvtID = (AZ::s64)(domainValue); - emit EventRequestEventFocus(globalEvtID); - } - - - void MemoryDataView::FrameChanged(FrameNumberType frame) - { - m_Frame = frame; - m_aggregator->FrameChanged(frame); - SetFrameNumber(); - OnViewFull(); - } - - void MemoryDataView::SetFrameNumber() - { - if (m_persistentState->m_filterId) - { - auto found = m_aggregator->FindAllocatorById(m_persistentState->m_filterId); - if (found == m_aggregator->GetAllocatorEnd()) - { - m_gui->progressBar->hide(); - } - else - { - Memory::AllocatorInfo* pinfo = (*found); - if (pinfo->m_capacity) - { - m_gui->progressBar->show(); - int newValue = (int)(((double)pinfo->m_allocatedMemory / (double)pinfo->m_capacity) * 100.0); - if (m_gui->progressBar->value() != newValue) - { - m_gui->progressBar->setValue(newValue); - m_gui->progressBar->setFormat(QString("%1 / %2") - .arg(MemoryAxisFormatter::formatMemorySize((float)pinfo->m_allocatedMemory, (float)pinfo->m_allocatedMemory * 0.1f)) - .arg(MemoryAxisFormatter::formatMemorySize((float)pinfo->m_capacity, (float)pinfo->m_capacity * 0.1f))); - } - } - else - { - m_gui->progressBar->hide(); - } - } - } - else - { - m_gui->progressBar->hide(); - } - - UpdateChart(); - } - - void MemoryDataView::UpdateChart() - { - m_gui->widgetDataStrip->Reset(); - - m_gui->widgetDataStrip->AddAxis("Event", 0.0f, 1.0f, false, false); - m_gui->widgetDataStrip->AddAxis("Size", m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax, true, true); - - m_gui->widgetDataStrip->AddChannel("Total Change"); - m_gui->widgetDataStrip->SetChannelColor(0, QColor(255, 64, 255, 255)); - m_gui->widgetDataStrip->SetChannelStyle(0, StripChart::Channel::STYLE_CONNECTED_LINE); - - m_gui->widgetDataStrip->AddChannel("Delta"); - m_gui->widgetDataStrip->SetChannelColor(1, QColor(255, 255, 0, 255)); - m_gui->widgetDataStrip->SetChannelStyle(1, StripChart::Channel::STYLE_PLUSMINUS); - - if (m_aggregator->IsValid()) - { - float accumulator = 0.0f; - - int frameOffset = m_persistentState->m_frameRange - 1; - if ((m_Frame - frameOffset) < 0) - { - frameOffset = 0; - } - - for (EventNumberType index = m_aggregator->m_frameToEventIndex[m_Frame - frameOffset]; index < static_cast(m_aggregator->m_frameToEventIndex[m_Frame] + m_aggregator->NumOfEventsAtFrame(m_Frame)); ++index) - { - DrillerEvent* dep = m_aggregator->GetEvents()[ index ]; - unsigned int gevtID = dep->GetGlobalEventId(); - - switch (dep->GetEventType()) - { - case Driller::Memory::MET_REGISTER_ALLOCATION: - { - auto mai = static_cast(dep); - if (m_persistentState->m_filterId && m_persistentState->m_filterId != mai->m_modifiedAllocatorInfo->m_id) - { - continue; // outer for() loop - } - accumulator += mai->m_allocationInfo.m_size; - m_gui->widgetDataStrip->AddData(1, (AZ::u64)index, (float)(gevtID), (float)mai->m_allocationInfo.m_size); - } - break; - case Driller::Memory::MET_UNREGISTER_ALLOCATION: - { - auto uae = static_cast(dep); - if (m_persistentState->m_filterId && m_persistentState->m_filterId != uae->m_modifiedAllocatorInfo->m_id) - { - continue; // outer for() loop - } - float uaeValue = (float)(uae->m_removedAllocationInfo != NULL ? uae->m_removedAllocationInfo->m_size : 0.0f); - accumulator -= uaeValue; - m_gui->widgetDataStrip->AddData(1, (AZ::u64)index, (float)(gevtID), -uaeValue); - } - break; - case Driller::Memory::MET_RESIZE_ALLOCATION: - { - auto rae = static_cast(dep); - if (rae->m_modifiedAllocationInfo) - { - auto testIter = m_aggregator->FindAllocatorByRecordsId(rae->m_modifiedAllocationInfo->m_recordsId); - if (testIter != m_aggregator->m_allocators.end()) - { - if (m_persistentState->m_filterId && m_persistentState->m_filterId != (*testIter)->m_id) - { - continue; // outer for() loop - } - } - } - accumulator += rae->m_newSize - rae->m_oldSize; - m_gui->widgetDataStrip->AddData(1, (AZ::u64)index, (float)(gevtID), (float)rae->m_newSize - (float)rae->m_oldSize); - } - break; - } - - m_gui->widgetDataStrip->AddData(0, (AZ::u64)index, (float)(gevtID), accumulator); - } - - FrameNumberType hCalculated = m_Frame - m_persistentState->m_frameRange + 1; - if (hCalculated < 0) - { - hCalculated = 0; - } - - float h1 = (float)(m_aggregator->GetEvents()[ m_aggregator->m_frameToEventIndex[hCalculated] ]->GetGlobalEventId()); - float h2 = (float)(m_aggregator->GetEvents()[ m_aggregator->m_frameToEventIndex[m_Frame] + m_aggregator->NumOfEventsAtFrame(m_Frame) - 1 ]->GetGlobalEventId()); - m_gui->widgetDataStrip->SetWindowRange(Charts::AxisType::Horizontal, h1, h2); - - if (m_persistentState->m_autoZoom) - { - m_gui->widgetDataStrip->ZoomExtents(Charts::AxisType::Vertical); - } - else - { - m_gui->widgetDataStrip->SetWindowRange(Charts::AxisType::Vertical, m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax); - m_gui->widgetDataStrip->ZoomManual(Charts::AxisType::Vertical, m_persistentState->m_manualZoomMin, m_persistentState->m_manualZoomMax); - } - } - } - - void MemoryDataView::OnViewFull() - { - m_gui->widgetDataStrip->SetViewFull(); - } - void MemoryDataView::OnCheckLockRight(int state) - { - m_gui->widgetDataStrip->SetLockRight(state ? true : false); - } - - ////////////////////////////////////////////////////////////////////////// - // Event Window Messages - void MemoryDataView::EventFocusChanged(EventNumberType eventIdx) - { - m_ScrubberIndex = eventIdx; - m_gui->widgetDataStrip->SetMarkerPosition((float)m_ScrubberIndex); - } - - void MemoryDataView::Reflect(AZ::ReflectContext* context) - { - MemoryDataViewSavedState::Reflect(context); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.hxx b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.hxx deleted file mode 100644 index 69dc1a8650..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.hxx +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef MEMORYDATAVIEW_H -#define MEMORYDATAVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#include -#include -#include -#endif - -namespace AZ { class ReflectContext; } - -namespace Ui -{ - class MemoryDataView; -} - -namespace Driller -{ - /* - A modeless dialog that combines custom drawing and active widgets. - */ - - class MemoryAxisFormatter : public Charts::QAbstractAxisFormatter - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(MemoryAxisFormatter, AZ::SystemAllocator, 0); - MemoryAxisFormatter(QObject *pParent); - - static QString formatMemorySize(float value, float scalingValue); - virtual QString convertAxisValueToText(Charts::AxisType axis, float value, float minDisplayedValue, float maxDisplayedValue, float divisionSize); - - private: - - }; - - class MemoryDataAggregator; - class MemoryDataViewSavedState; - - class MemoryDataView - : public QDialog - , public Driller::DrillerMainWindowMessages::Bus::Handler - , public Driller::DrillerEventWindowMessages::Bus::Handler - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(MemoryDataView,AZ::SystemAllocator,0); - MemoryDataView( MemoryDataAggregator *aggregator, FrameNumberType atFrame, int profilerIndex ); - virtual ~MemoryDataView(void); - - MemoryDataAggregator *m_aggregator; - int m_aggregatorIdentityCached; - FrameNumberType m_Frame; - int m_HighestFrameSoFar; - EventNumberType m_ScrubberIndex; - AZ::u32 m_windowStateCRC; - int m_viewIndex; - AZ::u32 m_viewStateCRC; - - void SetFrameNumber(); - void UpdateChart(); - - // NB: These three methods mimic the workspace bus. - // Because the ProfilerDataAggregator can't know to open these DataView windows - // until after the EBUS message has gone out, the owning aggregator must - // first create these windows and then pass along the provider manually - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - void ApplyPersistentState(); - - AZStd::intrusive_ptr m_persistentState; - - QAction * CreateFilterSelectorAction( QString qs, AZ::u64 id ); - QAction *CreateFrameRangeMenuAction( QString qs, int range ); - - void SaveOnExit(); - virtual void closeEvent(QCloseEvent *evt); - virtual void hideEvent(QHideEvent *evt); - - public: - // MainWindow Bus Commands - void FrameChanged(FrameNumberType frame) override; - void EventFocusChanged(EventNumberType eventIndex) override; - void EventChanged(EventNumberType /*eventIndex*/) override{} - - static void Reflect(AZ::ReflectContext* context); - - public slots: - void OnDataDestroyed(); - void OnViewFull(); - void OnCheckLockRight(int state); - void onMouseLeftDownDomainValue(float domainValue); - void onMouseLeftDragDomainValue(float domainValue); - void onMouseOverDataPoint(int channelID, AZ::u64 sampleID, float primaryAxisValue, float dependentAxisValue); - void onMouseOverNothing(float primaryAxisValue, float dependentAxisValue); - void OnFilterButton(); - void OnFilterSelectorMenu(); - void OnFilterSelectorMenu( QString fromMenu, AZ::u64 id ); - void OnFrameRangeMenu(); - void OnAutoZoomChange(bool); - -signals: - void EventRequestEventFocus(AZ::s64); - - private: - Ui::MemoryDataView* m_gui; - MemoryAxisFormatter *m_ptrFormatter; - }; - -} - - -#endif // MEMORYDATAVIEW_H diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.ui b/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.ui deleted file mode 100644 index 6740cfcb82..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryDataView.ui +++ /dev/null @@ -1,188 +0,0 @@ - - - MemoryDataView - - - - 0 - 0 - 684 - 302 - - - - Memory Data View - - - - - - - - - 0 - 0 - - - - - 224 - 86 - - - - - - - - - - - 0 - 0 - - - - - 0 - 24 - - - - - 16777215 - 24 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 64 - 16777215 - - - - View Full - - - - - - - - 0 - 0 - - - - Filter: All - - - - - - - Show 1 Frame - - - - - - - - 84 - 16777215 - - - - Lock Right - - - - - - - Autozoom - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 1 - 0 - - - - 0 - - - Qt::AlignCenter - - - true - - - %p % used - - - - - - - - - - - StripChart::DataStrip - QWidget -
../StripChart.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.cpp b/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.cpp deleted file mode 100644 index 3ed07f5f29..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "MemoryEvents.h" - -#include "MemoryDataAggregator.hxx" - -namespace Driller -{ - void MemoryDrillerRegisterAllocatorEvent::StepForward(Aggregator* data) - { - MemoryDataAggregator* aggr = static_cast(data); - // add to list of active allocators - aggr->m_allocators.push_back(&m_allocatorInfo); - } - - void MemoryDrillerRegisterAllocatorEvent::StepBackward(Aggregator* data) - { - MemoryDataAggregator* aggr = static_cast(data); - // remove from the list of active allocators - aggr->m_allocators.erase(AZStd::find(aggr->m_allocators.begin(), aggr->m_allocators.end(), &m_allocatorInfo)); - } - - void MemoryDrillerUnregisterAllocatorEvent::StepForward(Aggregator* data) - { - MemoryDataAggregator* aggr = static_cast(data); - MemoryDataAggregator::AllocatorInfoArrayType::iterator alIt = aggr->FindAllocatorById(m_allocatorId); - m_removedAllocatorInfo = *alIt; - aggr->m_allocators.erase(alIt); - } - - void MemoryDrillerUnregisterAllocatorEvent::StepBackward(Aggregator* data) - { - MemoryDataAggregator* aggr = static_cast(data); - aggr->m_allocators.push_back(m_removedAllocatorInfo); - } - - void MemoryDrillerRegisterAllocationEvent::StepForward(Aggregator* data) - { - if (m_modifiedAllocatorInfo == nullptr) - { - MemoryDataAggregator* aggr = static_cast(data); - MemoryDataAggregator::AllocatorInfoArrayType::iterator infoIter = aggr->FindAllocatorByRecordsId(m_allocationInfo.m_recordsId); - - if (infoIter == aggr->GetAllocatorEnd()) - { - AZ_Assert(false, "MemoryDriller - Invalid RecordsId"); - return; - } - - m_modifiedAllocatorInfo = (*infoIter); - } - // add to map of allocations - m_modifiedAllocatorInfo->m_allocations.insert(AZStd::make_pair(m_address, &m_allocationInfo)); - m_modifiedAllocatorInfo->m_allocatedMemory += m_allocationInfo.m_size; - } - - void MemoryDrillerRegisterAllocationEvent::StepBackward(Aggregator* data) - { - if (m_modifiedAllocatorInfo == nullptr) - { - MemoryDataAggregator* aggr = static_cast(data); - MemoryDataAggregator::AllocatorInfoArrayType::iterator infoIter = aggr->FindAllocatorByRecordsId(m_allocationInfo.m_recordsId); - - if (infoIter == aggr->GetAllocatorEnd()) - { - AZ_Assert(false, "MemoryDriller - Invalid RecordsId"); - return; - } - - m_modifiedAllocatorInfo = (*infoIter); - } - - // remove from the list of active allocators - m_modifiedAllocatorInfo->m_allocations.erase(m_address); - m_modifiedAllocatorInfo->m_allocatedMemory -= m_allocationInfo.m_size; - } - - void MemoryDrillerUnregisterAllocationEvent::StepForward(Aggregator* data) - { - if (m_modifiedAllocatorInfo == nullptr) - { - MemoryDataAggregator* aggr = static_cast(data); - // removed from the map of allocations - MemoryDataAggregator::AllocatorInfoArrayType::iterator infoIter = aggr->FindAllocatorByRecordsId(m_recordsId); - - if (infoIter == aggr->GetAllocatorEnd()) - { - AZ_Assert(false, "MemoryDriller - Invalid RecordsId"); - return; - } - - m_modifiedAllocatorInfo = (*infoIter); - } - - Memory::AllocatorInfo::AllocationMapType::iterator allocIt = m_modifiedAllocatorInfo->m_allocations.find(m_address); - m_removedAllocationInfo = allocIt->second; - // we're UNALLOCATING, so subract: - m_modifiedAllocatorInfo->m_allocatedMemory -= m_removedAllocationInfo->m_size; - m_modifiedAllocatorInfo->m_allocations.erase(m_address); - } - - void MemoryDrillerUnregisterAllocationEvent::StepBackward(Aggregator* data) - { - if (m_modifiedAllocatorInfo == nullptr) - { - MemoryDataAggregator* aggr = static_cast(data); - // removed from the map of allocations - MemoryDataAggregator::AllocatorInfoArrayType::iterator infoIter = aggr->FindAllocatorByRecordsId(m_recordsId); - - if (infoIter == aggr->GetAllocatorEnd()) - { - AZ_Assert(false, "MemoryDriller - Invalid RecordsId"); - return; - } - - m_modifiedAllocatorInfo = (*infoIter); - } - - // add back to the map of allocations - auto insertionPair = AZStd::make_pair(m_address, m_removedAllocationInfo); - m_modifiedAllocatorInfo->m_allocations.insert(insertionPair); - - // we're doing the opposite of unallocating, which is allocating, so we add: - m_modifiedAllocatorInfo->m_allocatedMemory += m_removedAllocationInfo->m_size; - } - - void MemoryDrillerResizeAllocationEvent::StepForward(Aggregator* data) - { - if (m_modifiedAllocationInfo == nullptr) - { - MemoryDataAggregator* aggr = static_cast(data); - // change the allocation size - m_modifiedAllocatorInfo = *aggr->FindAllocatorByRecordsId(m_recordsId); - Memory::AllocatorInfo::AllocationMapType::iterator allocIt = m_modifiedAllocatorInfo->m_allocations.find(m_address); - m_modifiedAllocationInfo = allocIt->second; - } - - // reallocating remove old size and add new size: - m_oldSize = m_modifiedAllocationInfo->m_size; - m_modifiedAllocationInfo->m_size = m_newSize; - - m_modifiedAllocatorInfo->m_allocatedMemory -= m_oldSize; - m_modifiedAllocatorInfo->m_allocatedMemory += m_newSize; - } - - void MemoryDrillerResizeAllocationEvent::StepBackward(Aggregator* data) - { - (void)data; - // restore the old size - m_modifiedAllocationInfo->m_size = m_oldSize; - - m_modifiedAllocatorInfo->m_allocatedMemory -= m_newSize; - m_modifiedAllocatorInfo->m_allocatedMemory += m_oldSize; - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.h b/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.h deleted file mode 100644 index e9ee33a0ef..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Memory/MemoryEvents.h +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_MEMORY_EVENTS_H -#define DRILLER_MEMORY_EVENTS_H - -#include "Source/Driller/DrillerEvent.h" - -#include - -namespace Driller -{ - namespace Memory - { - struct AllocationInfo - { - AllocationInfo() - : m_recordsId(0) - , m_name(nullptr) - , m_alignment(0) - , m_size(0) - , m_fileName(nullptr) - , m_fileLine(0) - , m_stackFrames(nullptr) - {} - AZ::u64 m_recordsId; - const char* m_name; - unsigned int m_alignment; - AZ::u64 m_size; - const char* m_fileName; - int m_fileLine; - AZ::u64* m_stackFrames; - }; - - struct AllocatorInfo - { - AllocatorInfo() - : m_id(0) - , m_recordsId(0) - , m_name(nullptr) - , m_capacity(0) - , m_recordMode(AZ::Debug::AllocationRecords::RECORD_NO_RECORDS) - , m_numStackLevels(0) - , m_allocatedMemory(0) - {} - AZ::u64 m_id; - AZ::u64 m_recordsId; - const char* m_name; - AZ::u64 m_capacity; - char m_recordMode; - char m_numStackLevels; - typedef AZStd::unordered_map AllocationMapType; - AllocationMapType m_allocations; ///< Current state of allocations - size_t m_allocatedMemory; ///< Number of bytes of allocated memory. - }; - - enum MemoryEventType - { - MET_REGISTER_ALLOCATOR = 0, - MET_UNREGISTER_ALLOCATOR, - MET_REGISTER_ALLOCATION, - MET_RESIZE_ALLOCATION, - MET_UNREGISTER_ALLOCATION, - }; - } - - class MemoryDrillerRegisterAllocatorEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(MemoryDrillerRegisterAllocatorEvent, AZ::SystemAllocator, 0) - - MemoryDrillerRegisterAllocatorEvent() - : DrillerEvent(Memory::MET_REGISTER_ALLOCATOR) {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - Memory::AllocatorInfo m_allocatorInfo; - }; - - class MemoryDrillerUnregisterAllocatorEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(MemoryDrillerUnregisterAllocatorEvent, AZ::SystemAllocator, 0) - - MemoryDrillerUnregisterAllocatorEvent() - : DrillerEvent(Memory::MET_UNREGISTER_ALLOCATOR) - , m_allocatorId(0) - , m_removedAllocatorInfo(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_allocatorId; - Memory::AllocatorInfo* m_removedAllocatorInfo; - }; - - class MemoryDrillerRegisterAllocationEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(MemoryDrillerRegisterAllocationEvent, AZ::SystemAllocator, 0) - - MemoryDrillerRegisterAllocationEvent() - : DrillerEvent(Memory::MET_REGISTER_ALLOCATION) - , m_address(0) - , m_modifiedAllocatorInfo(nullptr) - {} - - ~MemoryDrillerRegisterAllocationEvent() - { - if (m_allocationInfo.m_stackFrames) - { - azfree(m_allocationInfo.m_stackFrames); - } - } - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_address; - Memory::AllocationInfo m_allocationInfo; - Memory::AllocatorInfo* m_modifiedAllocatorInfo; - }; - - class MemoryDrillerUnregisterAllocationEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(MemoryDrillerUnregisterAllocationEvent, AZ::SystemAllocator, 0) - - MemoryDrillerUnregisterAllocationEvent() - : DrillerEvent(Memory::MET_UNREGISTER_ALLOCATION) - , m_recordsId(0) - , m_address(0) - , m_removedAllocationInfo(nullptr) - , m_modifiedAllocatorInfo(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_recordsId; - AZ::u64 m_address; - Memory::AllocationInfo* m_removedAllocationInfo; - Memory::AllocatorInfo* m_modifiedAllocatorInfo; - }; - - class MemoryDrillerResizeAllocationEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(MemoryDrillerResizeAllocationEvent, AZ::SystemAllocator, 0) - - MemoryDrillerResizeAllocationEvent() - : DrillerEvent(Memory::MET_RESIZE_ALLOCATION) - , m_recordsId(0) - , m_address(0) - , m_newSize(0) - , m_oldSize(0) - , m_modifiedAllocationInfo(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_recordsId; - AZ::u64 m_address; - AZ::u64 m_newSize; - AZ::u64 m_oldSize; - Memory::AllocationInfo* m_modifiedAllocationInfo; - Memory::AllocatorInfo* m_modifiedAllocatorInfo; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.cpp deleted file mode 100644 index e67f8e329f..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.cpp +++ /dev/null @@ -1,465 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ProfilerDataAggregator.hxx" -#include - -#include "ProfilerDataView.hxx" -#include "ProfilerEvents.h" -#include -#include -#include "Source/Driller/Workspaces/Workspace.h" - -namespace Driller -{ - // used against m_roiVersion to silently clear and reinitialize on internal updates - static const int dataAggregatorVersion = 2; - - // USER SETTINGS are local only, global settings to the application - // designed to be used for window placement, global preferences, that kind of thing - class ProfilerDataAggregatorSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(ProfilerDataAggregatorSavedState, "{98494FFE-783F-48A7-A35F-714138425640}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ProfilerDataAggregatorSavedState, AZ::SystemAllocator, 0); - - struct RegisterOfInterest - { - AZ_RTTI(RegisterOfInterest, "{885335FD-79D1-4462-B637-177FC0FCF01C}"); - AZStd::string m_name; - float m_dataScale; - int m_usesDelta; - int m_useSubValue; - - virtual ~RegisterOfInterest() {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_name", &RegisterOfInterest::m_name) - ->Field("m_dataScale", &RegisterOfInterest::m_dataScale) - ->Field("m_usesDelta", &RegisterOfInterest::m_usesDelta) - ->Field("m_useSubValue", &RegisterOfInterest::m_useSubValue) - ->Version(3); - } - } - }; - - int m_activeViewCount; - - AZStd::vector m_registersOfInterest; - int m_roiVersion; - - ProfilerDataAggregatorSavedState() - : m_activeViewCount(0) - , m_roiVersion(1) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - RegisterOfInterest::Reflect(context); - - serialize->Class() - ->Field("m_activeViewCount", &ProfilerDataAggregatorSavedState::m_activeViewCount) - ->Field("m_registersOfInterest", &ProfilerDataAggregatorSavedState::m_registersOfInterest) - ->Field("m_roiVersion", &ProfilerDataAggregatorSavedState::m_roiVersion) - ->Version(7); - } - } - }; - - // WORKSPACES are files loaded and stored independent of the global application - // designed to be used for DRL data specific view settings and to pass around - class ProfilerDataAggregatorWorkspace - : public AZ::UserSettings - { - public: - AZ_RTTI(ProfilerDataAggregatorWorkspace, "{2C41A0B1-E200-448D-8727-5109DF877B0E}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ProfilerDataAggregatorWorkspace, AZ::SystemAllocator, 0); - - int m_activeViewCount; - AZStd::vector m_activeViewTypes; - - ProfilerDataAggregatorWorkspace() - : m_activeViewCount(0) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewCount", &ProfilerDataAggregatorWorkspace::m_activeViewCount) - ->Field("m_activeViewTypes", &ProfilerDataAggregatorWorkspace::m_activeViewTypes) - ->Version(3); - } - } - }; - - - ////////////////////////////////////////////////////////////////////////// - ProfilerDataAggregator::ProfilerDataAggregator(int identity) - : Aggregator(identity) - , m_currentDisplayRegister(0) - , m_dataView(nullptr) - { - m_parser.SetAggregator(this); - - // find state and restore it - m_persistentState = AZ::UserSettings::CreateFind(AZ_CRC("PROFILER DATA AGGREGATOR SAVED STATE", 0x49c357f6), AZ::UserSettings::CT_GLOBAL); - AZ_Assert(m_persistentState, "Persistent State is NULL?"); - // please see ::dataAggregatorVersion to control updates - if (m_persistentState->m_registersOfInterest.empty() || m_persistentState->m_roiVersion != dataAggregatorVersion) - { - m_persistentState->m_registersOfInterest.clear(); - m_persistentState->m_registersOfInterest.push_back(); - m_persistentState->m_registersOfInterest[0].m_name = "Component application tick function"; - m_persistentState->m_registersOfInterest[0].m_dataScale = 1.0f / 64000.0f; - m_persistentState->m_registersOfInterest[0].m_usesDelta = 1; // this is a delta time calculated on the fly here - m_persistentState->m_registersOfInterest[0].m_useSubValue = 0; // user data 0 is m_time from the register union - } - - m_allRegistersOfInterestInData.clear(); - if (!m_persistentState->m_registersOfInterest.empty()) - { - m_allRegistersOfInterestInData.resize(m_persistentState->m_registersOfInterest.size(), NULL); - m_allCorrespondingIdsForRegistersOfInterestInData.resize(m_persistentState->m_registersOfInterest.size(), 0); - } - } - - ProfilerDataAggregator::~ProfilerDataAggregator() - { - KillAllViews(); - } - - // this aggregator has to dive deeper into the source data - // to synthesize a meaningful -1...+1 value for the main display - float ProfilerDataAggregator::ValueAtFrame(FrameNumberType frame) - { - size_t numEvents = NumOfEventsAtFrame(frame); - if (numEvents && frame > 0) - { - for (EventNumberType eventIndex = m_frameToEventIndex[frame]; eventIndex < static_cast(m_frameToEventIndex[frame] + numEvents); ++eventIndex) - { - DrillerEvent* drillerEvent = drillerEvent = GetEvents()[ eventIndex ]; - if (drillerEvent->GetEventType() == Driller::Profiler::PET_UPDATE_REGISTER) - { - Driller::ProfilerDrillerUpdateRegisterEvent* reg = static_cast(drillerEvent); - for (auto iter = m_allCorrespondingIdsForRegistersOfInterestInData.begin(); iter != m_allCorrespondingIdsForRegistersOfInterestInData.end(); ++iter) - { - if (reg->GetRegisterId() == *iter) - { - float t = 0.0f; - if (m_persistentState->m_registersOfInterest[m_currentDisplayRegister].m_usesDelta) - { - switch (m_persistentState->m_registersOfInterest[m_currentDisplayRegister].m_useSubValue) - { - case 0: - t = (float)(reg->GetData().m_valueData.m_value1 - (reg->GetPreviousSample() == NULL ? 0 : reg->GetPreviousSample()->GetData().m_valueData.m_value1)); - break; - case 1: - t = (float)(reg->GetData().m_valueData.m_value2 - (reg->GetPreviousSample() == NULL ? 0 : reg->GetPreviousSample()->GetData().m_valueData.m_value2)); - break; - case 2: - t = (float)(reg->GetData().m_valueData.m_value3 - (reg->GetPreviousSample() == NULL ? 0 : reg->GetPreviousSample()->GetData().m_valueData.m_value3)); - break; - case 3: - t = (float)(reg->GetData().m_valueData.m_value4 - (reg->GetPreviousSample() == NULL ? 0 : reg->GetPreviousSample()->GetData().m_valueData.m_value4)); - break; - } - } - else - { - switch (m_persistentState->m_registersOfInterest[m_currentDisplayRegister].m_useSubValue) - { - case 0: - t = (float)reg->GetData().m_valueData.m_value1; - break; - case 1: - t = (float)reg->GetData().m_valueData.m_value2; - break; - case 2: - t = (float)reg->GetData().m_valueData.m_value3; - break; - case 3: - t = (float)reg->GetData().m_valueData.m_value4; - break; - } - } - - t *= m_persistentState->m_registersOfInterest[m_currentDisplayRegister].m_dataScale; - t = t * 2.0f - 1.0f; - t = t > 1.0f ? 1.0f : t; - t = t < -1.0f ? -1.0f : t; - return t; - } - } - } - } - } - - return -1.0f; - } - - QColor ProfilerDataAggregator::GetColor() const - { - return QColor(255, 127, 0); - } - - QString ProfilerDataAggregator::GetName() const - { - return "CPU"; - } - - QString ProfilerDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString ProfilerDataAggregator::GetDescription() const - { - return "Profiler Driller"; - } - - QString ProfilerDataAggregator::GetToolTip() const - { - return "Information about CPU usage time and function usage tracking)"; - } - - AZ::Uuid ProfilerDataAggregator::GetID() const - { - return AZ::Uuid("{A6DB5318-82BF-416B-BF3D-FFD187329845}"); - } - - QWidget* ProfilerDataAggregator::DrillDownRequest(FrameNumberType frame) - { - return DrillDownRequest(frame, Profiler::RegisterInfo::PRT_TIME); - } - - QWidget* ProfilerDataAggregator::DrillDownRequest(FrameNumberType frame, int viewType) - { - Driller::ProfilerDataView* pdv = NULL; - - if (m_dataView) - { - KillAllViews(); - } - - pdv = aznew Driller::ProfilerDataView(this, frame, 0, viewType); - if (pdv) - { - m_dataView = pdv; - connect(pdv, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataViewDestroyed(QObject*))); - ++m_persistentState->m_activeViewCount; - } - - return pdv; - } - - void ProfilerDataAggregator::OptionsRequest() - { - char output[64]; - GetID().ToString(output, AZ_ARRAY_SIZE(output), true, true); - AZ_TracePrintf("Driller", "Options Request for ProfilerDataAggregator %s\n", output); - } - - void ProfilerDataAggregator::OnDataViewDestroyed(QObject* dataView) - { - if (dataView == m_dataView) - { - m_dataView = nullptr; - --m_persistentState->m_activeViewCount; - } - } - - void ProfilerDataAggregator::KillAllViews() - { - if (m_dataView) - { - QObject* object = m_dataView; - OnDataViewDestroyed(m_dataView); - m_dataView = nullptr; - delete object; - } - } - - void ProfilerDataAggregator::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - ProfilerDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("PROFILER DATA AGGREGATOR WORKSPACE", 0xfdb6cb89)); - if (workspace) - { - m_persistentState->m_activeViewCount = workspace->m_activeViewCount; - } - } - void ProfilerDataAggregator::ActivateWorkspaceSettings(WorkspaceSettingsProvider* provider) - { - ProfilerDataAggregatorWorkspace* workspace = provider->FindSetting(AZ_CRC("PROFILER DATA AGGREGATOR WORKSPACE", 0xfdb6cb89)); - if (workspace) - { - // kill all existing data view windows in preparation of opening the workspace specified ones - KillAllViews(); - - // the internal count should be 0 from the above house cleaning - // and incremented back up from the workspace instantiations - m_persistentState->m_activeViewCount = 0; - for (int i = 0; i < workspace->m_activeViewCount; ++i) - { - // older workspaces will not have any active view types - // therefore this check to default PRT_TIME - int discoveredType = Profiler::RegisterInfo::PRT_TIME; - if (workspace->m_activeViewTypes.size() > i) - { - discoveredType = workspace->m_activeViewTypes[i]; - } - - Driller::ProfilerDataView* dataView = qobject_cast(DrillDownRequest(1, discoveredType)); - if (dataView) - { - // apply will overlay the workspace settings on top of the local user settings - dataView->ApplySettingsFromWorkspace(provider); - // activate will do the heavy lifting - dataView->ActivateWorkspaceSettings(provider); - } - } - } - } - void ProfilerDataAggregator::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - ProfilerDataAggregatorWorkspace* workspace = provider->CreateSetting(AZ_CRC("PROFILER DATA AGGREGATOR WORKSPACE", 0xfdb6cb89)); - if (workspace) - { - workspace->m_activeViewTypes.clear(); - workspace->m_activeViewCount = m_persistentState->m_activeViewCount; - - if (m_dataView) - { - Driller::ProfilerDataView* dataView = qobject_cast(m_dataView); - - if (dataView) - { - workspace->m_activeViewTypes.push_back(dataView->GetViewType()); - dataView->SaveSettingsToWorkspace(provider); - } - } - } - } - - //========================================================================= - // OnEventLoaded - // [7/10/2013] - //========================================================================= - void ProfilerDataAggregator::OnEventLoaded(DrillerEvent* event) - { - switch (event->GetEventType()) - { - case Profiler::PET_NEW_REGISTER: - { - Driller::ProfilerDrillerNewRegisterEvent* reg = static_cast(event); - - for (AZStd::size_t idx = 0; idx < m_persistentState->m_registersOfInterest.size(); ++idx) - { - AZStd::string registerName; - if (reg->GetInfo().m_name == NULL) - { - registerName = AZStd::string::format("%s(%d)" - , reg->GetInfo().m_function ? reg->GetInfo().m_function : "N/A" - , reg->GetInfo().m_line); - } - else - { - registerName = reg->GetInfo().m_name; - } - - if (!qstricmp(registerName.data(), m_persistentState->m_registersOfInterest[idx].m_name.data())) - { - m_allRegistersOfInterestInData[idx] = reg; - m_allCorrespondingIdsForRegistersOfInterestInData[idx] = reg->GetInfo().m_id; - } - } - - if (m_lifeTimeThreads.find(reg->GetInfo().m_threadId) == m_lifeTimeThreads.end()) - { - // this register belongs to a thread which was not AZStd::thread or was NOT reported to the - // AZStd::ThreadEventBus. This is possible for middleware and so on. Although we should attempt - // to report those threads too (the best we can, with some name at least) - // as of now just add the id. - // NB: threadId can be be defaulted at 0 if this is an older data set - // in which case we do not add it to the threads - if (reg->GetInfo().m_threadId != 0) - { - if (m_lifeTimeThreads.find(reg->GetInfo().m_threadId) == m_lifeTimeThreads.end()) - { - m_lifeTimeThreads.insert(AZStd::make_pair(reg->GetInfo().m_threadId, nullptr)); - } - } - } - break; - } - case Profiler::PET_UPDATE_REGISTER: - { - Driller::ProfilerDrillerUpdateRegisterEvent* reg = static_cast(event); - - for (AZStd::size_t idx = 0; idx < m_allCorrespondingIdsForRegistersOfInterestInData.size(); ++idx) - { - if (reg->GetRegisterId() == m_allCorrespondingIdsForRegistersOfInterestInData[idx]) - { - reg->PreComputeForward(m_allRegistersOfInterestInData[idx]); - } - } - } - break; - - case Profiler::PET_ENTER_THREAD: - { - // make sure we have a valid list with all the threads in the world - ProfilerDrillerEnterThreadEvent* newThread = static_cast(event); - if (m_lifeTimeThreads.find(newThread->m_threadId) == m_lifeTimeThreads.end()) - { - m_lifeTimeThreads.insert(AZStd::make_pair(newThread->m_threadId, newThread)); - } - } break; - } - } - - //========================================================================= - // Reset() - // [7/10/2013] - //========================================================================= - void ProfilerDataAggregator::Reset() - { - m_systems.clear(); - m_threads.clear(); - m_lifeTimeThreads.clear(); - m_registers.clear(); - - KillAllViews(); - } - - void ProfilerDataAggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - ProfilerDataAggregatorSavedState::Reflect(context); - ProfilerDataAggregatorWorkspace::Reflect(context); - ProfilerDataView::Reflect(context); - - serialize->Class() - ->Version(1) - ->SerializeWithNoData(); - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.hxx deleted file mode 100644 index 85a2841f39..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataAggregator.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_PROFILER_DATAAGGREGATOR_TESTS_H -#define DRILLER_PROFILER_DATAAGGREGATOR_TESTS_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/DrillerAggregatorOptions.hxx" -#include "AzCore/std/string/string.h" -#include "AzCore/std/containers/map.h" -#include "AzCore/RTTI/RTTI.h" -#include "AzCore/Memory/SystemAllocator.h" - -#include "ProfilerDataParser.h" -#endif - -namespace AZ -{ - class SerializeContext; -} - -namespace Driller -{ - class ProfilerDrillerNewRegisterEvent; - class ProfilerDrillerEnterThreadEvent; - class ProfilerDrillerRegisterSystemEvent; - class ProfilerDataAggregatorSavedState; - - /** - * Profiler data drilling aggregator. - */ - class ProfilerDataAggregator : public Aggregator - { - friend class ProfilerDataView; - ProfilerDataAggregator(const ProfilerDataAggregator&) = delete; - Q_OBJECT; - public: - AZ_RTTI(ProfilerDataAggregator, "{0DDEB1EA-0D49-4A5E-866A-885F51231FDA}"); - AZ_CLASS_ALLOCATOR(ProfilerDataAggregator,AZ::SystemAllocator,0); - - ProfilerDataAggregator(int identity = 0); - virtual ~ProfilerDataAggregator(); - - static AZ::u32 DrillerId() { return ProfilerDrillerHandlerParser::GetDrillerId(); } - virtual AZ::u32 GetDrillerId() const { return DrillerId(); } - - static const char* ChannelName() { return "Timing"; } - virtual AZ::Crc32 GetChannelId() const override { return AZ::Crc32(ChannelName()); } - - virtual AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() { return &m_parser; } - - virtual void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - virtual void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - virtual void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - - /// Called after an event has been loaded - void OnEventLoaded(DrillerEvent* event); - - void KillAllViews(); - - ////////////////////////////////////////////////////////////////////////// - // Aggregator - - virtual void Reset(); - - public slots: - float ValueAtFrame( FrameNumberType frame ) override; - QColor GetColor() const override; - QString GetName() const override; - QString GetChannelName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - QWidget* DrillDownRequest(FrameNumberType frame, int viewType); - virtual void OptionsRequest(); - void OnDataViewDestroyed(QObject*); - - //protected: - public: - typedef AZStd::unordered_map RegisterMapType; - typedef AZStd::unordered_map ThreadMapType; - typedef AZStd::multimap ThreadMultiMapType; - typedef AZStd::unordered_map SystemMapType; - - /** - * Map with all systems in use (system is a logical group of registers, - * which we can enable/disable sampling in order to improve performance and data granularity - */ - SystemMapType m_systems; - ThreadMapType m_threads; ///< Map with all the threads which are currently running. - /** - * Map with all the threads we have ever encountered. - * IMPORTANT: Thread which were NOT reported to AZStd::ThreadEventBus - * will still be in the map, but the ProfilerDrillerEnterThreadEvent* pointer will be null. - * make sure your code accounts for that. - */ - ThreadMultiMapType m_lifeTimeThreads; - RegisterMapType m_registers; - - AZStd::vector m_allRegistersOfInterestInData; - AZStd::vector m_allCorrespondingIdsForRegistersOfInterestInData; - AZ::u64 m_currentDisplayRegister; - - QObject* m_dataView; - ProfilerDrillerHandlerParser m_parser; ///< Parser for this aggregator - - AZStd::intrusive_ptr m_persistentState; - - static void Reflect(AZ::ReflectContext* context); - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.cpp b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.cpp deleted file mode 100644 index 5714d75b0f..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.cpp +++ /dev/null @@ -1,1517 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -#include -#include - -#include "ProfilerDataPanel.hxx" -#include -#include "ProfilerDataAggregator.hxx" -#include - -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h" - -#include "ProfilerEvents.h" - -#include -#include -#include -#include -#include -#include - -namespace Driller -{ - enum - { - PDM_FUNCTIONNAME = 0, - PDM_COMMENT, - PDM_EXCLUSIVE_TIME, - PDM_INCLUSIVE_TIME, - PDM_EXCLUSIVE_PCT, - PDM_INCLUSIVE_PCT, - PDM_CALLS, - PDM_CHILDREN_TIME, - PDM_ACCUMULATED_TIME, - PDM_CHILDREN_CALLS, - PDM_ACCUMULATED_CALLS, - PDM_THREAD_ID, - PDM_TIME_TOTAL - }; - static const char* PDM_TIME_STRING[] = { - "Function", - "Comment", - "Excl. Time (Micro)", - "Incl. Time (Micro)", - "Excl. Pct", - "Incl. Pct", - "Calls", - "Child Time (Micro)", - "Total Time (Micro)", - "Child Calls", - "Total Calls", - "Thread ID" - }; - enum - { - PDM_NUMERIC_DATA_ROLE = Qt::UserRole + 1 - }; - - enum - { - PDM_VALUE_FUNCTIONNAME = 0, - PDM_VALUE_COMMENT, - PDM_VALUE_1, - PDM_VALUE_2, - PDM_VALUE_3, - PDM_VALUE_4, - PDM_VALUE_5, - PDM_VALUE_THREAD_ID, - PDM_VALUE_TOTAL - }; - static const char* PDM_VALUE_STRING[] = { - "Function", - "Comment", - "Value 1", - "Value 2", - "Value 3", - "Value 4", - "Value 5", - "Thread ID" - }; - - int ProfilerDataModel::m_colorIndexTracker = 0; - - class ProfilerFilterModel - : public QSortFilterProxyModel - { - public: - AZ_CLASS_ALLOCATOR(ProfilerFilterModel, AZ::SystemAllocator, 0); - ProfilerFilterModel(QObject* pParent) - : QSortFilterProxyModel(pParent) - { - setFilterCaseSensitivity(Qt::CaseSensitive); - setDynamicSortFilter(false); - } - protected: - virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const - { - switch (left.column()) - { - case PDM_FUNCTIONNAME: - case PDM_COMMENT: - return QSortFilterProxyModel::lessThan(left, right); - break; - default: - AZ::u64 leftNumber = 0; - AZ::u64 rightNumber = 0; - // inner switch sanity check that we only pull numbers from numeric fields and default the rest to 0<0 false - switch (left.column()) - { - case PDM_INCLUSIVE_TIME: - case PDM_EXCLUSIVE_TIME: - case PDM_INCLUSIVE_PCT: - case PDM_EXCLUSIVE_PCT: - case PDM_CHILDREN_TIME: - case PDM_ACCUMULATED_TIME: - case PDM_CALLS: - case PDM_CHILDREN_CALLS: - case PDM_ACCUMULATED_CALLS: - case PDM_THREAD_ID: - QVariant retrievedColumnLeft = sourceModel()->data(left, PDM_NUMERIC_DATA_ROLE); - QVariant retrievedColumnRight = sourceModel()->data(right, PDM_NUMERIC_DATA_ROLE); - - leftNumber = retrievedColumnLeft.toULongLong(); - rightNumber = retrievedColumnRight.toULongLong(); - - break; - } - - return leftNumber < rightNumber; - break; - } - } - }; - - class ProfilerValueFilterModel - : public QSortFilterProxyModel - { - public: - AZ_CLASS_ALLOCATOR(ProfilerValueFilterModel, AZ::SystemAllocator, 0); - ProfilerValueFilterModel(QObject* pParent) - : QSortFilterProxyModel(pParent) - { - setFilterCaseSensitivity(Qt::CaseSensitive); - setDynamicSortFilter(false); - } - protected: - virtual bool lessThan(const QModelIndex& left, const QModelIndex& right) const - { - switch (left.column()) - { - case PDM_FUNCTIONNAME: - case PDM_COMMENT: - return QSortFilterProxyModel::lessThan(left, right); - break; - default: - AZ::u64 leftNumber = 0; - AZ::u64 rightNumber = 0; - // inner switch sanity check that we only pull numbers from numeric fields and default the rest to 0<0 false - switch (left.column()) - { - case PDM_VALUE_1: - case PDM_VALUE_2: - case PDM_VALUE_3: - case PDM_VALUE_4: - case PDM_VALUE_5: - case PDM_VALUE_THREAD_ID: - QVariant retrievedColumnLeft = sourceModel()->data(left, PDM_NUMERIC_DATA_ROLE); - QVariant retrievedColumnRight = sourceModel()->data(right, PDM_NUMERIC_DATA_ROLE); - - leftNumber = retrievedColumnLeft.toULongLong(); - rightNumber = retrievedColumnRight.toULongLong(); - - break; - } - - return leftNumber < rightNumber; - break; - } - } - }; - - ProfilerAxisFormatter::ProfilerAxisFormatter(QObject* pParent, int whichTypeOfRegister) - : QAbstractAxisFormatter(pParent) - { - m_lastAxisValueForScaling = 1.0f; - m_whatKindOfRegister = whichTypeOfRegister; - } - - QString ProfilerAxisFormatter::formatMicroseconds(float value) - { - // data is in microseconds! - // so how big is the division size? - if (m_lastAxisValueForScaling > 100000.0f) // greater than a 0.1 second per division - { - if (m_lastAxisValueForScaling > 1000000.0f) // whole seconds - { - return QObject::tr("%1s").arg(QString::number(value / 1000000.0f, 'f', 0)); - } - else - { - return QObject::tr("%1s").arg(QString::number(value / 1000000.0f, 'f', 1)); - } - } - else if (m_lastAxisValueForScaling > 100.0f) // greater than a 0.1 millisecond per division - { - if (m_lastAxisValueForScaling > 1000.0f) // whole milliseconds - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 0)).arg("ms"); - } - else - { - return QObject::tr("%1%2").arg(QString::number(value / 1000.0f, 'f', 1)).arg("ms"); - } - } - else if (m_lastAxisValueForScaling > 1.0f) - { - return QObject::tr("%1%2s").arg((int)value).arg(QChar(0x00b5)); - } - else - { - return QObject::tr("%1%2s").arg(QString::number((double)value, 'f', 2)).arg(QChar(0x00b5)); - } - } - - QString ProfilerAxisFormatter::convertAxisValueToText(Charts::AxisType axis, float value, float /*minDisplayedValue*/, float /*maxDisplayedValue*/, float divisionSize) - { - if (axis == Charts::AxisType::Vertical) - { - if (m_whatKindOfRegister == (int)Profiler::RegisterInfo::PRT_TIME) - { - m_lastAxisValueForScaling = divisionSize; - return formatMicroseconds(value); - } - else - { - return QString::number(value); - } - } - else - { - return QString::number((int)value); - } - }; - - - /////////////////////// - // ProfilerDataWidget - /////////////////////// - - ProfilerDataWidget::ProfilerDataWidget(QWidget* parent) - : AzToolsFramework::QTreeViewWithStateSaving(parent) - , m_dataModel(NULL) - { - m_cachedChart = NULL; - m_cachedColumn = PDM_EXCLUSIVE_TIME; - m_autoZoom = true; - m_cachedFlatView = false; - m_cachedDeltaData = true; - m_manualZoomMin = 2000000000.0f; - m_manualZoomMax = -2000000000.0f; - m_iLastHighlightedChannel = -1; - - setFocusPolicy(Qt::StrongFocus); // required for key press handling - - setEnabled(true); - setSortingEnabled(true); - sortByColumn(0, Qt::AscendingOrder); - header()->setSectionResizeMode(QHeaderView::Interactive); - header()->setSectionsMovable(true); - header()->setStretchLastSection(false); - setUniformRowHeights(true); - - connect(this, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(OnDoubleClicked(const QModelIndex &))); - } - - ProfilerDataWidget::~ProfilerDataWidget() - { - //m_stateSaver->Detach(); - - if (m_dataModel) - { - delete m_dataModel; - } - } - - void ProfilerDataWidget::SetViewType(int viewType) - { - m_viewType = viewType; - if (m_viewType == Profiler::RegisterInfo::PRT_TIME) - { - m_dataModel = new ProfilerDataModel(); - if (m_dataModel) - { - m_filterModel = aznew ProfilerFilterModel(this); - m_filterModel->setSourceModel(m_dataModel); - setModel(m_filterModel); - } - } - if (m_viewType == Profiler::RegisterInfo::PRT_VALUE) - { - m_dataModel = new ProfilerCounterDataModel(); - if (m_dataModel) - { - m_filterModel = aznew ProfilerValueFilterModel(this); - m_filterModel->setSourceModel(m_dataModel); - setModel(m_filterModel); - } - } - - AZ_Assert(m_dataModel, "SetViewType has an invalid argument, profiler data model cannot be created!"); - } - - void ProfilerDataWidget::OnChartTypeMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnChartTypeMenu(qa->objectName()); - } - } - - void ProfilerDataWidget::OnChartTypeMenu(QString typeStr) - { - ProfilerOperationTelemetryEvent chartTypeChanged; - - int newValue = 0; - - if (m_viewType == Profiler::RegisterInfo::PRT_TIME) - { - newValue = PDM_EXCLUSIVE_TIME; - - chartTypeChanged.SetAttribute("ChartTimeType", typeStr.toStdString().c_str()); - - if (typeStr == "Incl.Time") - { - newValue = PDM_INCLUSIVE_TIME; - } - if (typeStr == "Excl.Time") - { - newValue = PDM_EXCLUSIVE_TIME; - } - if (typeStr == "Calls") - { - newValue = PDM_CALLS; - } - if (typeStr == "Acc.Time") - { - newValue = PDM_ACCUMULATED_TIME; - } - if (typeStr == "Acc.Calls") - { - newValue = PDM_ACCUMULATED_CALLS; - } - } - else if (m_viewType == Profiler::RegisterInfo::PRT_VALUE) - { - newValue = PDM_VALUE_1; - - chartTypeChanged.SetAttribute("ChartValueType", typeStr.toStdString().c_str()); - - if (typeStr == "Value 1") - { - newValue = PDM_VALUE_1; - } - if (typeStr == "Value 2") - { - newValue = PDM_VALUE_2; - } - if (typeStr == "Value 3") - { - newValue = PDM_VALUE_3; - } - if (typeStr == "Value 4") - { - newValue = PDM_VALUE_4; - } - if (typeStr == "Value 5") - { - newValue = PDM_VALUE_5; - } - } - - chartTypeChanged.Log(); - m_cachedColumn = newValue; - RedrawChart(); - } - - void ProfilerDataWidget::BeginDataModelUpdate() - { - PauseTreeViewSaving(); - - m_dataModel->BeginAddRegisters(); - } - - void ProfilerDataWidget::EndDataModelUpdate() - { - m_dataModel->EndAddRegisters(); - - // this will capture any changes/zoom to the chart by the user - if ((!m_autoZoom) && (m_cachedChart)) - { - m_cachedChart->GetWindowRange(Charts::AxisType::Vertical, m_manualZoomMin, m_manualZoomMax); - } - - UnpauseTreeViewSaving(); - ApplyTreeViewSnapshot(); - } - - void ProfilerDataWidget::OnExpandAll() - { - expandAll(); - CaptureTreeViewSnapshot(); // expand all doesn't signal, this captures the fully open tree - - // now that column organization is being stored in user settings - // I'm disabling this so the user isn't surprised by his view suddenly changing - //resizeColumnToContents( 0 ); - } - - void ProfilerDataWidget::OnHideSelected() - { - m_iLastHighlightedChannel = -1; - QModelIndexList list = selectionModel()->selectedIndexes(); - foreach (QModelIndex index, list) - { - if (index.column() == 0) - { - QModelIndex sourceIndex = m_filterModel->mapToSource(index); - const Driller::ProfilerDrillerUpdateRegisterEvent* tp = (Driller::ProfilerDrillerUpdateRegisterEvent*)(sourceIndex.internalPointer()); - if (tp) - { - if (m_dataModel->m_enabledChartingMap.find(tp->GetRegister()->GetInfo().m_id) != m_dataModel->m_enabledChartingMap.end()) - { - m_dataModel->m_enabledChartingMap[ tp->GetRegister()->GetInfo().m_id ] = 0; - QModelIndex column0(m_dataModel->index(index.row(), 0)); - emit dataChanged(column0, column0); - } - } - } - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnShowSelected() - { - QModelIndexList list = selectionModel()->selectedIndexes(); - foreach (QModelIndex index, list) - { - if (index.column() == 0) - { - QModelIndex sourceIndex = m_filterModel->mapToSource(index); - const Driller::ProfilerDrillerUpdateRegisterEvent* tp = (Driller::ProfilerDrillerUpdateRegisterEvent*)(sourceIndex.internalPointer()); - if (tp) - { - if (m_dataModel->m_enabledChartingMap.find(tp->GetRegister()->GetInfo().m_id) != m_dataModel->m_enabledChartingMap.end()) - { - m_dataModel->m_enabledChartingMap[ tp->GetRegister()->GetInfo().m_id ] = 1; - QModelIndex column0(m_dataModel->index(index.row(), 0)); - emit dataChanged(column0, column0); - } - } - } - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnInvertHidden() - { - AZStd::map::iterator iter = m_dataModel->m_enabledChartingMap.begin(); - while (iter != m_dataModel->m_enabledChartingMap.end()) - { - int current = iter->second; - iter->second = !current; - ++iter; - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnHideAll() - { - m_iLastHighlightedChannel = -1; - AZStd::map::iterator iter = m_dataModel->m_enabledChartingMap.begin(); - while (iter != m_dataModel->m_enabledChartingMap.end()) - { - iter->second = 0; - ++iter; - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnShowAll() - { - AZStd::map::iterator iter = m_dataModel->m_enabledChartingMap.begin(); - while (iter != m_dataModel->m_enabledChartingMap.end()) - { - iter->second = 1; - ++iter; - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnAutoZoomChange(bool newValue) - { - if (!newValue) - { - m_autoZoom = false; - m_cachedChart->GetWindowRange(Charts::AxisType::Vertical, m_manualZoomMin, m_manualZoomMax); - } - else - { - m_autoZoom = true; - m_manualZoomMin = 2000000000.0f; - m_manualZoomMax = -2000000000.0f; - } - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnFlatView(bool isOn) - { - m_cachedFlatView = isOn; - m_dataModel->SetFlatView(m_cachedFlatView); - - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnDeltaData(bool isOn) - { - m_cachedDeltaData = isOn; - m_dataModel->SetDeltaData(m_cachedDeltaData); - - update(); - RedrawChart(); - } - - void ProfilerDataWidget::OnDoubleClicked(const QModelIndex& index) - { - if (index.isValid()) - { - QModelIndex sourceIndex = m_filterModel->mapToSource(index); - const Driller::ProfilerDrillerUpdateRegisterEvent* tp = (Driller::ProfilerDrillerUpdateRegisterEvent*)(sourceIndex.internalPointer()); - if (tp) - { - if (m_dataModel->m_enabledChartingMap.find(tp->GetRegister()->GetInfo().m_id) != m_dataModel->m_enabledChartingMap.end()) - { - int current = m_dataModel->m_enabledChartingMap.find(tp->GetRegister()->GetInfo().m_id)->second; - m_dataModel->m_enabledChartingMap[ tp->GetRegister()->GetInfo().m_id ] = !current; - QModelIndex column0(m_dataModel->index(index.row(), 0)); - emit dataChanged(column0, column0); // no matter where we clicked, update only column 0 - RedrawChart(); - } - } - } - } - - void ProfilerDataWidget::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) - { - QTreeView::selectionChanged(selected, deselected); - } - - void ProfilerDataWidget::RedrawChart() - { - if (m_cachedChart) - { - m_iLastHighlightedChannel = -1; - m_cachedChart->Reset(); - - m_cachedChart->AddAxis("Frame", static_cast(m_cachedStartFrame), static_cast(m_cachedStartFrame + m_cachedDisplayRange), true, true); - m_cachedChart->AddAxis("", m_manualZoomMin, m_manualZoomMax, false, false); - - m_cachedChart->SetDataDirty(); - } - } - - void ProfilerDataWidget::ConfigureChart(StripChart::DataStrip* chart, FrameNumberType atFrame, int howFar, FrameNumberType frameCount) - { - (void)frameCount; - // this can be NULL - if (chart) - { - // stored against the need to update on local selection changes, and used internally - if (m_cachedChart != chart) - { - m_cachedChart = chart; - ProfilerAxisFormatter* prf = aznew ProfilerAxisFormatter(this, (int)m_viewType); - m_cachedChart->SetAxisTextFormatter(prf); - m_formatter = prf; - - m_cachedChart->AttachDataSourceWidget(this); - } - - m_cachedDisplayRange = howFar; - - m_cachedCurrentFrame = atFrame; - m_cachedEndFrame = atFrame; - m_cachedStartFrame = AZStd::GetMax(atFrame - m_cachedDisplayRange, 0); - - RedrawChart(); - } - } - - void ProfilerDataWidget::ProvideData(StripChart::DataStrip* chart) - { - PlotTimeHistory(chart); - } - - void ProfilerDataWidget::onMouseOverNothing(float primaryAxisValue, float dependentAxisValue) - { - (void)primaryAxisValue; - (void)dependentAxisValue; - if (m_iLastHighlightedChannel != -1) - { - m_cachedChart->SetChannelHighlight(m_iLastHighlightedChannel, false); - m_iLastHighlightedChannel = -1; - m_dataModel->SetHighlightedRegisterID(0); - } - } - - void ProfilerDataWidget::onMouseOverDataPoint(int channelID, AZ::u64 sampleID, float primaryAxisValue, float dependentAxisValue) - { - if (!m_cachedChart) - { - return; - } - - (void)primaryAxisValue; - - auto found = m_ChannelsToRegisters.find(channelID); - if (found == m_ChannelsToRegisters.end()) - { - return; - } - const Driller::ProfilerDrillerNewRegisterEvent* currentRegister = found->second; - - if (!currentRegister) - { - return; - } - - if (m_iLastHighlightedChannel != -1) - { - m_cachedChart->SetChannelHighlight(m_iLastHighlightedChannel, false); - m_iLastHighlightedChannel = -1; - m_dataModel->SetHighlightedRegisterID(0); - } - - m_iLastHighlightedChannel = channelID; - m_cachedChart->SetChannelHighlight(m_iLastHighlightedChannel, true); - auto foundChannel = m_ChannelsToRegisters.find(channelID); - if (foundChannel != m_ChannelsToRegisters.end()) - { - m_dataModel->SetHighlightedRegisterID(foundChannel->second->GetInfo().m_id); - } - - const Driller::ProfilerDrillerUpdateRegisterEvent* previousRegister = currentRegister->GetLastSample(); - while ((previousRegister) && (previousRegister->GetGlobalEventId() != (unsigned int)sampleID)) - { - previousRegister = previousRegister->GetPreviousSample(); - } - - if (previousRegister) - { - QString tooltip; - QString identifier = tr("%1(%2) %3") - .arg(currentRegister->GetInfo().m_function ? currentRegister->GetInfo().m_function : "???") - .arg(currentRegister->GetInfo().m_line) - .arg(currentRegister->GetInfo().m_name ? QString("'%1'").arg(currentRegister->GetInfo().m_name) : ""); - - if (previousRegister->GetRegister()->GetInfo().m_type == Profiler::RegisterInfo::PRT_TIME) - { - QString displayValue; - - switch (m_cachedColumn) - { - case PDM_INCLUSIVE_TIME: - displayValue = tr("Inclusive: %1").arg(m_formatter->formatMicroseconds(dependentAxisValue)); - break; - case PDM_EXCLUSIVE_TIME: - displayValue = tr("Exclusive: %1").arg(m_formatter->formatMicroseconds(dependentAxisValue)); - break; - case PDM_CALLS: - displayValue = tr("%1 calls").arg((int)dependentAxisValue); - break; - case PDM_ACCUMULATED_TIME: - displayValue = tr("Accumulated: %1%").arg(m_formatter->formatMicroseconds(dependentAxisValue)); - break; - case PDM_ACCUMULATED_CALLS: - displayValue = tr("%1 accumulated calls").arg((int)dependentAxisValue); - break; - } - - tooltip = QString("%1: %2").arg(identifier).arg(displayValue); - - if (QApplication::activeWindow() == this->parent()) - { - QToolTip::showText(m_cachedChart->mapToGlobal(QPoint(0, 0)), tooltip, m_cachedChart); - } - } - else - { - // value register: - } - } - } - - void ProfilerDataWidget::PlotTimeHistory(StripChart::DataStrip* chart) - { - m_ChannelsToRegisters.clear(); - - if (chart) - { - float maxVerticalValue = 0; - - chart->SetMarkerColor(QColor(255, 0, 0)); - chart->SetMarkerPosition(static_cast(m_cachedCurrentFrame)); - - chart->StartBatchDataAdd(); - - for (const Driller::ProfilerDrillerUpdateRegisterEvent* currentRegister : m_dataModel->m_profilerDrillerUpdateRegisterEvents) - { - const Driller::ProfilerDrillerUpdateRegisterEvent* previousRegister = currentRegister->GetPreviousSample(); - - if (previousRegister) - { - if (m_dataModel->m_enabledChartingMap.find(currentRegister->GetRegister()->GetInfo().m_id)->second) - { - FrameNumberType localAtFrame = m_cachedCurrentFrame; - FrameNumberType localHowFar = m_cachedDisplayRange; - - int channelID = -1; - const Driller::ProfilerDrillerNewRegisterEvent* reg = currentRegister->GetRegister(); - if (reg) - { - if ((reg->GetInfo().m_name) && (strlen(reg->GetInfo().m_name) > 0)) - { - channelID = chart->AddChannel(reg->GetInfo().m_name); - } - else if ((reg->GetInfo().m_function) && (strlen(reg->GetInfo().m_function) > 0)) - { - channelID = chart->AddChannel(tr("%1(%2)").arg(reg->GetInfo().m_function).arg(reg->GetInfo().m_line)); - } - else - { - channelID = chart->AddChannel(tr("Unknown Register:%1").arg(reg->GetInfo().m_id)); - } - - chart->SetChannelStyle(channelID, StripChart::Channel::STYLE_CONNECTED_LINE); - chart->SetChannelColor(channelID, m_dataModel->m_colorMap.find(currentRegister->GetRegister()->GetInfo().m_id)->second); - } - else - { - channelID = chart->AddChannel("NULL"); - chart->SetChannelStyle(channelID, StripChart::Channel::STYLE_CONNECTED_LINE); - chart->SetChannelColor(channelID, m_dataModel->m_colorMap.find(0)->second); - } - - // If we don't have a valid channel ID skip over. - if (!chart->IsValidChannelId(channelID)) - { - continue; - } - - m_ChannelsToRegisters[channelID] = reg; - - while (localAtFrame >= 0 && localHowFar >= 0) - { - float sample = 0.0f; - - if (m_viewType == Profiler::RegisterInfo::PRT_TIME) - { - switch (m_cachedColumn) - { - case PDM_INCLUSIVE_TIME: - sample = (float)(currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time)); - break; - case PDM_EXCLUSIVE_TIME: - sample = (float)(((currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time)) - (currentRegister->GetData().m_timeData.m_childrenTime - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenTime)))); - break; - case PDM_CALLS: - sample = (float)(currentRegister->GetData().m_timeData.m_calls - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_calls)); - break; - case PDM_ACCUMULATED_TIME: - sample = (float)(currentRegister->GetData().m_timeData.m_time); - break; - case PDM_ACCUMULATED_CALLS: - sample = (float)(currentRegister->GetData().m_timeData.m_calls); - break; - } - } - else if (m_viewType == Profiler::RegisterInfo::PRT_VALUE) - { - AZ::u64 columnNumber = 0; - AZ::u64 columnDelta = 0; - - switch (m_cachedColumn) - { - case PDM_VALUE_1: - columnNumber = currentRegister->GetData().m_valueData.m_value1; - break; - case PDM_VALUE_2: - columnNumber = currentRegister->GetData().m_valueData.m_value2; - break; - case PDM_VALUE_3: - columnNumber = currentRegister->GetData().m_valueData.m_value3; - break; - case PDM_VALUE_4: - columnNumber = currentRegister->GetData().m_valueData.m_value4; - break; - case PDM_VALUE_5: - columnNumber = currentRegister->GetData().m_valueData.m_value5; - break; - case PDM_VALUE_THREAD_ID: - columnNumber = currentRegister->GetRegister()->GetInfo().m_threadId; - break; - } - if (m_cachedDeltaData) - { - switch (m_cachedColumn) - { - case PDM_VALUE_1: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value1); - break; - case PDM_VALUE_2: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value2); - break; - case PDM_VALUE_3: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value3); - break; - case PDM_VALUE_4: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value4); - break; - case PDM_VALUE_5: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value5); - break; - } - } - - sample = (float)(columnNumber - columnDelta); - } - - maxVerticalValue = AZStd::GetMax(sample, maxVerticalValue); - - chart->AddBatchedData(channelID, currentRegister->GetGlobalEventId(), (float)localAtFrame, sample); - - currentRegister = previousRegister; - if (!currentRegister) - { - break; - } - previousRegister = currentRegister->GetPreviousSample(); - - --localAtFrame; - --localHowFar; - } - } - } - } - - // Always assume 0 as the minimum - chart->SetWindowRange(Charts::AxisType::Vertical, 0, maxVerticalValue); - - // Adding one here so I can actually see the scrubber mark. - float minValue = 0.0f; - float maxValue = 0.0f; - if (chart->GetAxisRange(Charts::AxisType::Horizontal, minValue, maxValue)) - { - chart->SetWindowRange(Charts::AxisType::Horizontal, minValue, maxValue + 0.5f); - } - - chart->EndBatchDataAdd(); - } - - if (m_autoZoom) - { - chart->ZoomExtents(Charts::AxisType::Vertical); - } - else - { - chart->ZoomManual(Charts::AxisType::Vertical, m_manualZoomMin, m_manualZoomMax); - } - - } - - //------------------------------------------------------------------------ - - ProfilerDataModel::ProfilerDataModel() - { - m_SourceAggregator = NULL; - m_cachedFlatView = false; - m_highlightedRegisterID = 0; - } - - ProfilerDataModel::~ProfilerDataModel() - { - EmptyTheEventCache(); - m_colorMap.clear(); - m_iconMap.clear(); - m_enabledChartingMap.clear(); - } - - QVariant ProfilerDataModel::headerData (int section, Qt::Orientation orientation, int role) const - { - (void)orientation; - - if (role == Qt::DisplayRole) - { - return QVariant(PDM_TIME_STRING[section]); - } - - return QVariant(); - } - - QVariant ProfilerDataModel::data (const QModelIndex& index, int role) const - { - if (index.isValid() && m_SourceAggregator && m_SourceAggregator->IsValid()) - { - const Driller::ProfilerDrillerUpdateRegisterEvent* registerEvent = static_cast(index.internalPointer()); - - if (role == Qt::BackgroundRole) - { - if (m_highlightedRegisterID != 0) - { - if (registerEvent->GetRegisterId() == m_highlightedRegisterID) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - } - // a color swatch to match register to chart, or black if not drawn to the chart - if (role == Qt::DecorationRole && index.column() == 0 /*COLOR SWATCH*/) - { - if (registerEvent->GetRegister()) - { - if (m_enabledChartingMap.find(registerEvent->GetRegister()->GetInfo().m_id) != m_enabledChartingMap.end()) - { - if (m_enabledChartingMap.find(registerEvent->GetRegister()->GetInfo().m_id)->second) - { - return QVariant(m_iconMap.find(registerEvent->GetRegister()->GetInfo().m_id)->second); - } - else - { - return QVariant(m_iconMap.find(0)->second); - } - } - else - { - return QVariant(m_iconMap.find(0)->second); - } - } - } - if (role == Qt::DisplayRole || role == PDM_NUMERIC_DATA_ROLE) - { - const Driller::ProfilerDrillerUpdateRegisterEvent* currentRegister = registerEvent; - const Driller::ProfilerDrillerUpdateRegisterEvent* previousRegister = currentRegister->GetPreviousSample(); - - if (role == Qt::DisplayRole) - { - switch (index.column()) - { - case PDM_FUNCTIONNAME: - if (currentRegister->GetRegister()) - { - AZStd::string name = AZStd::string::format("%s(%d)" - , currentRegister->GetRegister()->GetInfo().m_function ? currentRegister->GetRegister()->GetInfo().m_function : "N/A" - , currentRegister->GetRegister()->GetInfo().m_line); - return QVariant(name.c_str()); - } - else - { - return QVariant("N/A"); - } - break; - case PDM_COMMENT: - return QVariant(QString(currentRegister->GetRegister() ? currentRegister->GetRegister()->GetInfo().m_name ? currentRegister->GetRegister()->GetInfo().m_name : "" : "")); - break; - } - } - - AZ::u64 columnNumber = 0; - - switch (index.column()) - { - case PDM_INCLUSIVE_TIME: - columnNumber = currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time); - break; - case PDM_EXCLUSIVE_TIME: - columnNumber = (currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time)) - (currentRegister->GetData().m_timeData.m_childrenTime - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenTime)); - break; - case PDM_INCLUSIVE_PCT: - columnNumber = currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time); - break; - case PDM_EXCLUSIVE_PCT: - columnNumber = (currentRegister->GetData().m_timeData.m_time - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_time)) - (currentRegister->GetData().m_timeData.m_childrenTime - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenTime)); - break; - case PDM_CHILDREN_TIME: - columnNumber = currentRegister->GetData().m_timeData.m_childrenTime - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenTime); - break; - case PDM_ACCUMULATED_TIME: - columnNumber = currentRegister->GetData().m_timeData.m_time; - break; - case PDM_CALLS: - columnNumber = currentRegister->GetData().m_timeData.m_calls - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_calls); - break; - case PDM_CHILDREN_CALLS: - columnNumber = currentRegister->GetData().m_timeData.m_childrenCalls - (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenCalls); - break; - case PDM_ACCUMULATED_CALLS: - columnNumber = currentRegister->GetData().m_timeData.m_calls; - break; - case PDM_THREAD_ID: - columnNumber = currentRegister->GetRegister()->GetInfo().m_threadId; - break; - } - - if (role == Qt::DisplayRole) - { - if (index.column() == PDM_INCLUSIVE_PCT || index.column() == PDM_EXCLUSIVE_PCT) - { - float percent = (float)columnNumber / (float)m_totalTime; - return QVariant(QString::number(percent * 100.0f, 'f', 2)); - } - if (index.column() == PDM_THREAD_ID) - { - return QVariant(QString("%1").arg(columnNumber)); - } - else - { - return QVariant(QString("%L1").arg(columnNumber)); - } - } - else if (role == PDM_NUMERIC_DATA_ROLE) - { - return QVariant(columnNumber); - } - - return QVariant(); - } - } - - return QVariant(); - } - - Qt::ItemFlags ProfilerDataModel::flags (const QModelIndex& index) const - { - if (!index.isValid()) - { - return Qt::ItemFlags(); - } - - return Qt::ItemIsSelectable | Qt::ItemIsEnabled; - } - - QModelIndex ProfilerDataModel::index (int row, int column, const QModelIndex& parent) const - { - if (hasIndex(row, column, parent) && m_SourceAggregator && m_SourceAggregator->IsValid()) - { - if (m_cachedFlatView) - { - // look up the rowTh data item - return createIndex(row, column, (void*)(m_profilerDrillerUpdateRegisterEvents[row])); - } - - if (!parent.isValid()) - { - // look up the rowTh data item with no parent itself - int foundCount = 0; - DVVector::const_iterator iter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (iter != m_profilerDrillerUpdateRegisterEvents.end()) - { - if ((*iter)->GetData().m_timeData.m_lastParentRegisterId == 0) - { - if (foundCount == row) - { - return createIndex(row, column, (void*)(*iter)); - } - - ++foundCount; - } - ++iter; - } - } - else - { - Driller::ProfilerDrillerUpdateRegisterEvent* registerEvent = static_cast(parent.internalPointer()); - // look up the rowTh data item with pt as a parent - int foundCount = 0; - DVVector::const_iterator iter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (iter != m_profilerDrillerUpdateRegisterEvents.end()) - { - if ((*iter)->GetData().m_timeData.m_lastParentRegisterId == registerEvent->GetRegister()->GetInfo().m_id) - { - if (foundCount == row) - { - return createIndex(row, column, (void*)(*iter)); - } - ++foundCount; - } - ++iter; - } - } - } - - return QModelIndex(); - } - - QModelIndex ProfilerDataModel::parent (const QModelIndex& index) const - { - if (m_cachedFlatView) - { - return QModelIndex(); - } - if (index.isValid() && m_SourceAggregator && m_SourceAggregator->IsValid()) - { - Driller::ProfilerDrillerUpdateRegisterEvent* childItem = static_cast(index.internalPointer()); - - DVVector::const_iterator mainIter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (mainIter != m_profilerDrillerUpdateRegisterEvents.end()) - { - // 0th frame the updates haven't been linked to their registers yet, that happens on 1st - // this is a guard against that - if ((*mainIter)->GetRegister()) - { - if ((*mainIter)->GetRegister()->GetInfo().m_id == childItem->GetData().m_timeData.m_lastParentRegisterId) - { - // row() should be the parent's row in it's own parent - int parentRow = 0; - DVVector::const_iterator parentIter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (parentIter != m_profilerDrillerUpdateRegisterEvents.end()) - { - if ((*parentIter)->GetRegister()->GetData().m_timeData.m_lastParentRegisterId == (*mainIter)->GetData().m_timeData.m_lastParentRegisterId) - { - if (*parentIter == *mainIter) - { - return createIndex(parentRow, 0, (void*)(*mainIter)); - } - ++parentRow; - } - ++parentIter; - } - } - } - - ++mainIter; - } - } - - return QModelIndex(); - } - - int ProfilerDataModel::rowCount (const QModelIndex& parent) const - { - int foundCount = 0; - - if (m_SourceAggregator && m_SourceAggregator->IsValid()) - { - if (m_cachedFlatView && !parent.isValid()) - { - foundCount = (int)m_profilerDrillerUpdateRegisterEvents.size(); - } - else if (m_cachedFlatView) - { - foundCount = 0; - } - else if (!parent.isValid()) - { - // count data items with no parent id - DVVector::const_iterator iter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (iter != m_profilerDrillerUpdateRegisterEvents.end()) - { - if ((*iter)->GetData().m_timeData.m_lastParentRegisterId == 0) - { - ++foundCount; - } - ++iter; - } - } - else - { - Driller::ProfilerDrillerUpdateRegisterEvent* registerEvent = static_cast(parent.internalPointer()); - // count data items with pt as a parent - DVVector::const_iterator iter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (iter != m_profilerDrillerUpdateRegisterEvents.end()) - { - // 0th frame the updates haven't been linked to their registers yet, that happens on 1st - // this is a guard against that - if (registerEvent->GetRegister()) - { - if ((*iter)->GetData().m_timeData.m_lastParentRegisterId == registerEvent->GetRegister()->GetInfo().m_id) - { - ++foundCount; - } - } - ++iter; - } - } - } - - return foundCount; - } - - int ProfilerDataModel::columnCount (const QModelIndex& /*parent*/) const - { - return PDM_TIME_TOTAL; - } - - void ProfilerDataModel::EmptyTheEventCache() - { - m_profilerDrillerUpdateRegisterEvents.clear(); - } - void ProfilerDataModel::BeginAddRegisters() - { - beginResetModel(); - EmptyTheEventCache(); - m_totalTime = 0; - } - void ProfilerDataModel::AddRegister(const Driller::ProfilerDrillerUpdateRegisterEvent* newData) - { - if (newData->GetRegister()) - { - if (newData->GetRegister()->GetInfo().m_type == Profiler::RegisterInfo::PRT_TIME) - { - m_profilerDrillerUpdateRegisterEvents.push_back(newData); - - const Driller::ProfilerDrillerUpdateRegisterEvent* currentRegister = newData; - const Driller::ProfilerDrillerUpdateRegisterEvent* previousRegister = currentRegister->GetPreviousSample(); - - const AZ::u64 previousRegisterTime = (previousRegister == nullptr ? 0 : previousRegister->GetData().m_timeData.m_time); - const AZ::u64 registerDeltaTime = currentRegister->GetData().m_timeData.m_time - previousRegisterTime; - - const AZ::u64 previousChildTime = (previousRegister == NULL ? 0 : previousRegister->GetData().m_timeData.m_childrenTime); - const AZ::u64 childDeltaTime = currentRegister->GetData().m_timeData.m_childrenTime - previousChildTime; - - AZ::u64 t = registerDeltaTime - childDeltaTime; - m_totalTime += t; - } - } - } - - void ProfilerDataModel::EndAddRegisters() - { - Recolor(); - endResetModel(); - } - void ProfilerDataModel::SetAggregator(Driller::ProfilerDataAggregator* aggregator) - { - m_SourceAggregator = aggregator; - } - - QColor ProfilerDataModel::GetColorByIndex(int colorIdx, int maxNumColors) - { - QColor col; - float sat = .9f; - float val = .9f; - col.setHsvF((float)(colorIdx % maxNumColors) / (float(maxNumColors)), sat, val); - return col; - } - - // lazy build of a mapping between Event ID# and QColor for chart display(s) - void ProfilerDataModel::Recolor() - { - // these two numbers used to cycle broadly around the color wheel - // so that proximal entries are never too similar in hue - const int magicNumber = 32; // magic number - const int magicIncrement = 5; - - // black for disabled on the chart - if (m_colorMap.find(0) == m_colorMap.end()) - { - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(Qt::black); - painter.drawRect(0, 0, 16, 16); - QIcon itemIcon(pixmap); - m_iconMap[ 0 ] = itemIcon; - } - - DVVector::const_iterator iter = m_profilerDrillerUpdateRegisterEvents.begin(); - while (iter != m_profilerDrillerUpdateRegisterEvents.end()) - { - if ((*iter)->GetRegister()) - { - if (m_colorMap.find((*iter)->GetRegister()->GetInfo().m_id) == m_colorMap.end()) - { - // charting map and color map always in lockstep - m_enabledChartingMap[ (*iter)->GetRegister()->GetInfo().m_id ] = 1; - - QColor qc = GetColorByIndex(m_colorIndexTracker, magicNumber); - m_colorMap[ (*iter)->GetRegister()->GetInfo().m_id ] = qc; - - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(qc); - painter.drawRect(0, 0, 16, 16); - QIcon itemIcon(pixmap); - m_iconMap[ (*iter)->GetRegister()->GetInfo().m_id ] = itemIcon; - - m_colorIndexTracker += magicIncrement; - } - } - - ++iter; - } - } - - void ProfilerDataModel::SetFlatView(bool on) - { - emit layoutAboutToBeChanged(); - m_cachedFlatView = on; - emit layoutChanged(); - } - - void ProfilerDataModel::SetDeltaData(bool on) - { - emit layoutAboutToBeChanged(); - m_cachedDeltaData = on; - emit layoutChanged(); - } - - void ProfilerDataModel::SetHighlightedRegisterID(AZ::u64 regid) - { - if (m_highlightedRegisterID != regid) - { - m_highlightedRegisterID = regid; - emit dataChanged(index(0, 0), index(rowCount() - 1, columnCount() - 1)); - } - } - - - //------------------------------------------------------------------------ - - ProfilerCounterDataModel::ProfilerCounterDataModel() - { - } - - ProfilerCounterDataModel::~ProfilerCounterDataModel() - { - } - void ProfilerCounterDataModel::AddRegister(const Driller::ProfilerDrillerUpdateRegisterEvent* newData) - { - if (newData->GetRegister()) - { - if (newData->GetRegister()->GetInfo().m_type == Profiler::RegisterInfo::PRT_VALUE) - { - m_profilerDrillerUpdateRegisterEvents.push_back(newData); - } - } - } - - QVariant ProfilerCounterDataModel::headerData (int section, Qt::Orientation orientation, int role) const - { - (void)orientation; - - if (role == Qt::DisplayRole) - { - return QVariant(PDM_VALUE_STRING[section]); - } - - return QVariant(); - } - - QVariant ProfilerCounterDataModel::data (const QModelIndex& index, int role) const - { - if (index.isValid() && m_SourceAggregator && m_SourceAggregator->IsValid()) - { - const Driller::ProfilerDrillerUpdateRegisterEvent* registerEvent = static_cast(index.internalPointer()); - - if (role == Qt::BackgroundRole) - { - if (m_highlightedRegisterID != 0) - { - if (registerEvent->GetRegisterId() == m_highlightedRegisterID) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - } - // a color swatch to match register to chart, or black if not drawn to the chart - if (role == Qt::DecorationRole && index.column() == 0 /*COLOR SWATCH*/) - { - if (registerEvent->GetRegister()) - { - if (m_enabledChartingMap.find(registerEvent->GetRegister()->GetInfo().m_id) != m_enabledChartingMap.end()) - { - if (m_enabledChartingMap.find(registerEvent->GetRegister()->GetInfo().m_id)->second) - { - return QVariant(m_iconMap.find(registerEvent->GetRegister()->GetInfo().m_id)->second); - } - else - { - return QVariant(m_iconMap.find(0)->second); - } - } - else - { - return QVariant(m_iconMap.find(0)->second); - } - } - } - if (role == Qt::DisplayRole || role == PDM_NUMERIC_DATA_ROLE) - { - const Driller::ProfilerDrillerUpdateRegisterEvent* currentRegister = registerEvent; - const Driller::ProfilerDrillerUpdateRegisterEvent* previousRegister = currentRegister->GetPreviousSample(); - - if (role == Qt::DisplayRole) - { - switch (index.column()) - { - case PDM_FUNCTIONNAME: - if (currentRegister->GetRegister()) - { - AZStd::string name = AZStd::string::format("%s(%d)" - , currentRegister->GetRegister()->GetInfo().m_function ? currentRegister->GetRegister()->GetInfo().m_function : "N/A" - , currentRegister->GetRegister()->GetInfo().m_line); - return QVariant(name.c_str()); - } - else - { - return QVariant("N/A"); - } - break; - case PDM_COMMENT: - return QVariant(QString(currentRegister->GetRegister() ? currentRegister->GetRegister()->GetInfo().m_name ? currentRegister->GetRegister()->GetInfo().m_name : "" : "")); - break; - } - } - - AZ::u64 columnNumber = 0; - AZ::u64 columnDelta = 0; - - switch (index.column()) - { - case PDM_VALUE_1: - columnNumber = currentRegister->GetData().m_valueData.m_value1; - break; - case PDM_VALUE_2: - columnNumber = currentRegister->GetData().m_valueData.m_value2; - break; - case PDM_VALUE_3: - columnNumber = currentRegister->GetData().m_valueData.m_value3; - break; - case PDM_VALUE_4: - columnNumber = currentRegister->GetData().m_valueData.m_value4; - break; - case PDM_VALUE_5: - columnNumber = currentRegister->GetData().m_valueData.m_value5; - break; - case PDM_VALUE_THREAD_ID: - columnNumber = currentRegister->GetRegister()->GetInfo().m_threadId; - break; - } - if (m_cachedDeltaData) - { - switch (index.column()) - { - case PDM_VALUE_1: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value1); - break; - case PDM_VALUE_2: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value2); - break; - case PDM_VALUE_3: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value3); - break; - case PDM_VALUE_4: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value4); - break; - case PDM_VALUE_5: - columnDelta = (previousRegister == NULL ? 0 : previousRegister->GetData().m_valueData.m_value5); - break; - } - } - - columnNumber -= columnDelta; - - if (role == Qt::DisplayRole) - { - if (index.column() == PDM_VALUE_THREAD_ID) - { - return QVariant(QString("%1").arg(columnNumber)); - } - else - { - return QVariant(QString("%L1").arg(columnNumber)); - } - } - else if (role == PDM_NUMERIC_DATA_ROLE) - { - return QVariant(columnNumber); - } - - return QVariant(); - } - } - - return QVariant(); - } - - int ProfilerCounterDataModel::columnCount (const QModelIndex& /*parent*/) const - { - return PDM_VALUE_TOTAL; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.hxx b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.hxx deleted file mode 100644 index 9d31204ba8..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataPanel.hxx +++ /dev/null @@ -1,199 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef PROFILER_DATA_PANEL_H -#define PROFILER_DATA_PANEL_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include -#endif - -namespace StripChart -{ - class DataStrip; -} - -class QSortFilterProxyModel; - -#pragma once - - -namespace Driller -{ - class Aggregator; - class ProfilerDrillerUpdateRegisterEvent; - class ProfilerDataAggregator; - class ProfilerFilterModel; - class ProfilerDrillerNewRegisterEvent; - - class ProfilerDataModel : public QAbstractItemModel - { - Q_OBJECT; - - public: - - friend class ProfilerDataWidget; - - ProfilerDataModel(); - ~ProfilerDataModel(); - - virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - virtual Qt::ItemFlags flags ( const QModelIndex & index ) const; - virtual QModelIndex index ( int row, int column, const QModelIndex & parent = QModelIndex() ) const; - virtual QModelIndex parent ( const QModelIndex & index ) const; - virtual int rowCount ( const QModelIndex & parent = QModelIndex() ) const; - virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; - virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; - - void EmptyTheEventCache(); - void BeginAddRegisters(); - virtual void AddRegister( const Driller::ProfilerDrillerUpdateRegisterEvent *newData ); - void SetAggregator( Driller::ProfilerDataAggregator *aggregator ); - void EndAddRegisters(); - void Recolor(); - void SetFlatView( bool on ); - void SetDeltaData( bool on ); - - void SetHighlightedRegisterID(AZ::u64 regid); - - protected: - // the data = a tree of accumulated profiled events - // cached locally as a vector of pointers into the aggregator data block because - // the aggregator data block is a stream of different types of events - typedef AZStd::vector DVVector; // aggregator hosted pointers guaranteed to not disappear - DVVector m_profilerDrillerUpdateRegisterEvents; - Driller::ProfilerDataAggregator *m_SourceAggregator; - - QColor GetColorByIndex( int colorIdx, int maxNumColors ); - static int m_colorIndexTracker; - AZStd::map m_colorMap; - AZStd::map m_iconMap; - AZStd::map m_enabledChartingMap; - AZ::u64 m_totalTime; // used in percentage calculation - bool m_cachedFlatView; - bool m_cachedDeltaData; - AZ::u64 m_highlightedRegisterID; - QPersistentModelIndex m_LastHighlightedRegister; - }; - - class ProfilerCounterDataModel : public ProfilerDataModel - { - Q_OBJECT; - - public: - - friend class ProfilerDataWidget; - - ProfilerCounterDataModel(); - ~ProfilerCounterDataModel(); - - virtual QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - virtual int columnCount ( const QModelIndex & parent = QModelIndex() ) const; - virtual QVariant headerData ( int section, Qt::Orientation orientation, int role = Qt::DisplayRole ) const; - virtual void AddRegister( const Driller::ProfilerDrillerUpdateRegisterEvent *newData ); - }; - - class ProfilerAxisFormatter : public Charts::QAbstractAxisFormatter - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(ProfilerAxisFormatter, AZ::SystemAllocator, 0); - ProfilerAxisFormatter(QObject *pParent, int whichTypeOfRegister); - - QString formatMicroseconds(float value); - virtual QString convertAxisValueToText(Charts::AxisType axis, float value, float minDisplayedValue, float maxDisplayedValue, float divisionSize); - - private: - float m_lastAxisValueForScaling; - int m_whatKindOfRegister; - - }; - - class ProfilerDataWidget - : public AzToolsFramework::QTreeViewWithStateSaving - { - Q_OBJECT; - public: - - friend class ProfilerDataView; - - ProfilerDataWidget( QWidget * parent = 0 ); - virtual ~ProfilerDataWidget(); - - void SetViewType(int viewType); - void BeginDataModelUpdate(); - void EndDataModelUpdate(); - void ConfigureChart( StripChart::DataStrip *chart, FrameNumberType atFrame, int howFar, FrameNumberType frameCount ); - - public slots: - void OnExpandAll(); - void OnHideSelected(); - void OnShowSelected(); - void OnInvertHidden(); - void OnHideAll(); - void OnShowAll(); - void OnChartTypeMenu(); - void OnChartTypeMenu(QString typeStr); - void OnAutoZoomChange(bool newValue); - void OnFlatView(bool); - void OnDeltaData(bool); - void ProvideData(StripChart::DataStrip*); - - protected: - - void RedrawChart(); - void PlotTimeHistory( StripChart::DataStrip *chart ); - - ProfilerDataModel *m_dataModel; - QSortFilterProxyModel* m_filterModel; - StripChart::DataStrip *m_cachedChart; - ProfilerAxisFormatter* m_formatter; - - FrameNumberType m_cachedStartFrame; - FrameNumberType m_cachedEndFrame; - FrameNumberType m_cachedCurrentFrame; - FrameNumberType m_cachedDisplayRange; - - int m_cachedColumn; - bool m_autoZoom; // do we automatically zoom extents? - float m_manualZoomMin; // if we're not automatically zooming, then we remember the prior zoom to re-apply it - float m_manualZoomMax; - bool m_cachedFlatView; - bool m_cachedDeltaData; - - int m_viewType; - - typedef AZStd::unordered_map ChannelIDToRegisterMap; - - ChannelIDToRegisterMap m_ChannelsToRegisters; - - int m_iLastHighlightedChannel; - - public slots: - void OnDoubleClicked( const QModelIndex & ); - void selectionChanged( const QItemSelection & selected, const QItemSelection & deselected ); - void onMouseOverDataPoint(int channelID, AZ::u64 sampleID,float primaryAxisValue, float dependentAxisValue); - void onMouseOverNothing(float primaryAxisValue, float dependentAxisValue); - }; - - -} - -#endif //PROFILER_DATA_PANEL_H diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.cpp deleted file mode 100644 index d8daa26b53..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.cpp +++ /dev/null @@ -1,255 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ProfilerDataParser.h" -#include "ProfilerDataAggregator.hxx" -#include "ProfilerEvents.h" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* ProfilerDrillerHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - - if (tagName == AZ_CRC("NewRegister", 0xf0f2f287)) - { - m_subTag = ST_NEW_REGSTER; - m_data->AddEvent(aznew ProfilerDrillerNewRegisterEvent()); - return this; - } - else if (tagName == AZ_CRC("UpdateRegister", 0x6c00b890)) - { - m_subTag = ST_UPDATE_REGSTER; - m_data->AddEvent(aznew ProfilerDrillerUpdateRegisterEvent()); - return this; - } - else if (tagName == AZ_CRC("ThreadEnter", 0x60e4acfb)) - { - m_subTag = ST_ENTER_THREAD; - m_data->AddEvent(aznew ProfilerDrillerEnterThreadEvent()); - return this; - } - else if (tagName == AZ_CRC("OnThreadExit", 0x16042db9)) - { - m_subTag = ST_EXIT_THREAD; - m_data->AddEvent(aznew ProfilerDrillerExitThreadEvent()); - return this; - } - else if (tagName == AZ_CRC("RegisterSystem", 0x957739ef)) - { - m_subTag = ST_REGISTER_SYSTEM; - m_data->AddEvent(aznew ProfilerDrillerRegisterSystemEvent()); - return this; - } - else if (tagName == AZ_CRC("UnregisterSystem", 0xa20538e4)) - { - m_subTag = ST_UNREGISTER_SYSTEM; - m_data->AddEvent(aznew ProfilerDrillerUnregisterSystemEvent()); - return this; - } - else - { - m_subTag = ST_NONE; - } - return nullptr; - } - - void ProfilerDrillerHandlerParser::OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)tagName; - if (handler != nullptr) - { - if (m_subTag != ST_NONE) - { - m_data->OnEventLoaded(m_data->GetEvents().back()); - m_subTag = ST_NONE; // we have only one level just go back to the default state - } - } - } - - void ProfilerDrillerHandlerParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid memory aggregator before we can process the data!"); - - switch (m_subTag) - { - case ST_NEW_REGSTER: - { - ProfilerDrillerNewRegisterEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_registerInfo.m_id); - } - else if (dataNode.m_name == AZ_CRC("ThreadId", 0xd0fd9043)) - { - dataNode.Read(event->m_registerInfo.m_threadId); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_registerInfo.m_name = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("Function", 0xcaae163d)) - { - event->m_registerInfo.m_function = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("Line", 0xd114b4f6)) - { - dataNode.Read(event->m_registerInfo.m_line); - } - else if (dataNode.m_name == AZ_CRC("SystemId", 0x0dfecf6f)) - { - dataNode.Read(event->m_registerInfo.m_systemId); - } - else if (dataNode.m_name == AZ_CRC("Type", 0x8cde5729)) - { - dataNode.Read(event->m_registerInfo.m_type); - } - else if (dataNode.m_name == AZ_CRC("Time", 0x6f949845)) - { - dataNode.Read(event->m_registerData.m_timeData.m_time); - } - else if (dataNode.m_name == AZ_CRC("ChildrenTime", 0x46162d3f)) - { - dataNode.Read(event->m_registerData.m_timeData.m_childrenTime); - } - else if (dataNode.m_name == AZ_CRC("Calls", 0xdaa35c8f)) - { - dataNode.Read(event->m_registerData.m_timeData.m_calls); - } - else if (dataNode.m_name == AZ_CRC("ChildrenCalls", 0x6a5a4618)) - { - dataNode.Read(event->m_registerData.m_timeData.m_childrenCalls); - } - else if (dataNode.m_name == AZ_CRC("ParentId", 0x856a684c)) - { - dataNode.Read(event->m_registerData.m_timeData.m_lastParentRegisterId); - } - else if (dataNode.m_name == AZ_CRC("Value1", 0xa2756c5a)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value1); - } - else if (dataNode.m_name == AZ_CRC("Value2", 0x3b7c3de0)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value2); - } - else if (dataNode.m_name == AZ_CRC("Value3", 0x4c7b0d76)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value3); - } - else if (dataNode.m_name == AZ_CRC("Value4", 0xd21f98d5)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value4); - } - else if (dataNode.m_name == AZ_CRC("Value5", 0xa518a843)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value5); - } - } break; - case ST_UPDATE_REGSTER: - { - ProfilerDrillerUpdateRegisterEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_registerId); - } - else if (dataNode.m_name == AZ_CRC("Time", 0x6f949845)) - { - dataNode.Read(event->m_registerData.m_timeData.m_time); - } - else if (dataNode.m_name == AZ_CRC("ChildrenTime", 0x46162d3f)) - { - dataNode.Read(event->m_registerData.m_timeData.m_childrenTime); - } - else if (dataNode.m_name == AZ_CRC("Calls", 0xdaa35c8f)) - { - dataNode.Read(event->m_registerData.m_timeData.m_calls); - } - else if (dataNode.m_name == AZ_CRC("ChildrenCalls", 0x6a5a4618)) - { - dataNode.Read(event->m_registerData.m_timeData.m_childrenCalls); - } - else if (dataNode.m_name == AZ_CRC("ParentId", 0x856a684c)) - { - dataNode.Read(event->m_registerData.m_timeData.m_lastParentRegisterId); - } - else if (dataNode.m_name == AZ_CRC("Value1", 0xa2756c5a)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value1); - } - else if (dataNode.m_name == AZ_CRC("Value2", 0x3b7c3de0)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value2); - } - else if (dataNode.m_name == AZ_CRC("Value3", 0x4c7b0d76)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value3); - } - else if (dataNode.m_name == AZ_CRC("Value4", 0xd21f98d5)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value4); - } - else if (dataNode.m_name == AZ_CRC("Value5", 0xa518a843)) - { - dataNode.Read(event->m_registerData.m_valueData.m_value5); - } - } break; - case ST_ENTER_THREAD: - { - ProfilerDrillerEnterThreadEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_threadId); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_threadName = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("CpuId", 0xdf558508)) - { - dataNode.Read(event->m_cpuId); - } - else if (dataNode.m_name == AZ_CRC("Priority", 0x62a6dc27)) - { - dataNode.Read(event->m_priority); - } - else if (dataNode.m_name == AZ_CRC("StackSize", 0x9cfaf35b)) - { - dataNode.Read(event->m_stackSize); - } - } break; - case ST_EXIT_THREAD: - { - ProfilerDrillerExitThreadEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_threadId); - } - } break; - case ST_REGISTER_SYSTEM: - { - ProfilerDrillerRegisterSystemEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_systemId); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_name = dataNode.ReadPooledString(); - } - } break; - case ST_UNREGISTER_SYSTEM: - { - ProfilerDrillerUnregisterSystemEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Id", 0xbf396750)) - { - dataNode.Read(event->m_systemId); - } - } break; - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.h b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.h deleted file mode 100644 index 78b7f10b55..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataParser.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_PROFILER_DRILLER_PARSER_H -#define DRILLER_PROFILER_DRILLER_PARSER_H - -#include - -namespace Driller -{ - class ProfilerDataAggregator; - - class ProfilerDrillerHandlerParser - : public AZ::Debug::DrillerHandlerParser - { - public: - enum SubTags - { - ST_NONE = 0, - ST_NEW_REGSTER, - ST_UPDATE_REGSTER, - ST_ENTER_THREAD, - ST_EXIT_THREAD, - ST_REGISTER_SYSTEM, - ST_UNREGISTER_SYSTEM, - }; - - ProfilerDrillerHandlerParser() - : m_subTag(ST_NONE) - , m_data(NULL) - {} - - static AZ::u32 GetDrillerId() { return AZ_CRC("ProfilerDriller", 0x172c5268); } - - void SetAggregator(ProfilerDataAggregator* data) { m_data = data; } - - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - virtual void OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName); - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - protected: - SubTags m_subTag; - ProfilerDataAggregator* m_data; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.cpp b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.cpp deleted file mode 100644 index 26bcb82fea..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.cpp +++ /dev/null @@ -1,628 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ProfilerDataView.hxx" -#include - -#include "ProfilerDataAggregator.hxx" - -#include "ProfilerEvents.h" -#include "Source/Driller/DrillerEvent.h" - -#include "Source/Driller/ChannelDataView.hxx" -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h" - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -namespace Driller -{ - static const char* menuLengthStrings[] = - { - "60 Frames", - "120 Frames", - "240 Frames", - "480 Frames", - NULL - }; - static const char* menuTypeStrings[] = - { - "Incl.Time", - "Excl.Time", - "Calls", - "Acc.Time", - "Acc.Calls", - NULL - }; - static const int menuTypeViews[] = - { - Profiler::RegisterInfo::PRT_TIME, - Profiler::RegisterInfo::PRT_TIME, - Profiler::RegisterInfo::PRT_VALUE, - Profiler::RegisterInfo::PRT_TIME, - Profiler::RegisterInfo::PRT_VALUE - }; - static const char* menuValueTypeStrings[] = - { - "Value 1", - "Value 2", - "Value 3", - "Value 4", - "Value 5", - NULL - }; - - class ProfilerDataViewLocal - : public AZ::UserSettings - { - public: - AZ_RTTI(ProfilerDataViewLocal, "{7E893482-98BC-4017-B52B-5A36D325976B}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ProfilerDataViewLocal, AZ::SystemAllocator, 0); - - AZStd::vector m_treeColumnStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_treeColumnStorage", &ProfilerDataViewLocal::m_treeColumnStorage) - ->Version(1); - } - } - }; - - class ProfilerDataViewSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(ProfilerDataViewSavedState, "{432824F6-4078-49F6-BE9E-357EF71B8AB8}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ProfilerDataViewSavedState, AZ::SystemAllocator, 0); - - AZStd::string m_chartLengthStr; - AZStd::string m_chartTypeStr; - AZStd::string m_threadIDStr; - AZ::u64 m_threadID; - bool m_autoZoom; - bool m_flatView; - bool m_deltaData; - AZStd::vector< AZStd::string > m_treeExpansionData; - - ProfilerDataViewSavedState() - : m_chartLengthStr(menuLengthStrings[0]) - , m_chartTypeStr(menuTypeStrings[0]) - , m_threadIDStr("All Threads") - , m_threadID(0) - , m_autoZoom(true) - , m_flatView(false) - , m_deltaData(true) - {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_chartLengthStr", &ProfilerDataViewSavedState::m_chartLengthStr) - ->Field("m_chartTypeStr", &ProfilerDataViewSavedState::m_chartTypeStr) - ->Field("m_threadIDStr", &ProfilerDataViewSavedState::m_threadIDStr) - ->Field("m_threadID", &ProfilerDataViewSavedState::m_threadID) - ->Field("m_flatView", &ProfilerDataViewSavedState::m_flatView) - ->Field("m_treeExpansionData", &ProfilerDataViewSavedState::m_treeExpansionData) - ->Field("m_autoZoom", &ProfilerDataViewSavedState::m_autoZoom) - ->Field("m_deltaData", &ProfilerDataViewSavedState::m_deltaData) - ->Version(10); - } - } - }; - - ProfilerDataView::ProfilerDataView(ProfilerDataAggregator* aggregator, FrameNumberType atFrame, int profilerIndex, int viewType) - : QDialog() - , m_aggregator(aggregator) - , m_frame(atFrame) - , m_chartLength(60) - , m_windowStateCRC(0) - , m_dataViewStateCRC(0) - , m_viewIndex(profilerIndex) - , m_filterThreadID(0) - , m_viewType(viewType) - , m_lifespanTelemetry("ProfilerDataView") - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint); - - show(); - raise(); - activateWindow(); - setFocus(); - - m_gui = azcreate(Ui::ProfilerDataView, ()); - m_gui->setupUi(this); - - QByteArray fileName = m_aggregator->GetInspectionFileName().toUtf8(); - - AZStd::string treeViewStateStr = AZStd::string::format("PROFILER DATA TREE VIEW STATE %s", fileName.data()); - AZ::u32 treeViewCrc = AZ::Crc32(treeViewStateStr.c_str()); - m_gui->widgetProfilerData->InitializeTreeViewSaving(treeViewCrc); - - for (int i = 0; menuTypeStrings[i]; ++i) - { - m_chartTypeStringToViewType.insert(AZStd::make_pair(menuTypeStrings[i], menuTypeViews[i])); - } - - m_gui->widgetProfilerData->SetViewType(m_viewType); - setWindowTitle(m_aggregator->GetDialogTitle()); - - connect(m_aggregator, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataDestroyed())); - - connect(m_gui->pushButton_ExpandAll, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnExpandAll())); - connect(m_gui->pushButton_ExpandAll, SIGNAL(released()), this, SLOT(OnSanityCheck())); - connect(m_gui->pushButton_HideSelected, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnHideSelected())); - connect(m_gui->pushButton_ShowSelected, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnShowSelected())); - connect(m_gui->pushButton_InvertHidden, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnInvertHidden())); - connect(m_gui->pushButton_HideAll, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnHideAll())); - connect(m_gui->pushButton_ShowAll, SIGNAL(clicked()), m_gui->widgetProfilerData, SLOT(OnShowAll())); - connect(m_gui->checkBoxAutoZoom, SIGNAL(toggled(bool)), m_gui->widgetProfilerData, SLOT(OnAutoZoomChange(bool))); - connect(m_gui->checkBoxFlatView, SIGNAL(toggled(bool)), m_gui->widgetProfilerData, SLOT(OnFlatView(bool))); - connect(m_gui->checkBoxDelta, SIGNAL(toggled(bool)), m_gui->widgetProfilerData, SLOT(OnDeltaData(bool))); - - connect(m_gui->widgetDataStrip, SIGNAL(onMouseOverDataPoint(int, AZ::u64, float, float)), m_gui->widgetProfilerData, SLOT(onMouseOverDataPoint(int, AZ::u64, float, float))); - connect(m_gui->widgetDataStrip, SIGNAL(onMouseOverNothing(float, float)), m_gui->widgetProfilerData, SLOT(onMouseOverNothing(float, float))); - - m_gui->checkBoxAutoZoom->setChecked(true); - m_gui->checkBoxFlatView->setChecked(false); - - if (m_viewType == Profiler::RegisterInfo::PRT_TIME) - { - QMenu* chartTypeMenu = new QMenu(this); - - for (int i = 0; menuTypeStrings[i]; ++i) - { - chartTypeMenu->addAction(CreateChartTypeAction(menuTypeStrings[i])); - } - - m_gui->chartTypeButton->setText("Excl.Time"); - m_gui->chartTypeButton->setMenu(chartTypeMenu); - } - else if (m_viewType == Profiler::RegisterInfo::PRT_VALUE) - { - QMenu* chartTypeMenu = new QMenu(this); - - for (int i = 0; menuValueTypeStrings[i]; ++i) - { - chartTypeMenu->addAction(CreateChartTypeAction(menuValueTypeStrings[i])); - } - - m_gui->chartTypeButton->setText("Value 1"); - m_gui->chartTypeButton->setMenu(chartTypeMenu); - } - - QMenu* chartLengthMenu = new QMenu(this); - - for (int i = 0; menuLengthStrings[i]; ++i) - { - chartLengthMenu->addAction(CreateChartLengthAction(menuLengthStrings[i])); - } - - connect(m_gui->threadSelectorButton, SIGNAL(clicked()), this, SLOT(OnThreadSelectorButtonClick())); - - m_gui->chartLengthButton->setText("60 Frames"); - m_gui->chartLengthButton->setMenu(chartLengthMenu); - - m_aggregatorIdentityCached = m_aggregator->GetIdentity(); - DrillerMainWindowMessages::Handler::BusConnect(m_aggregatorIdentityCached); - DrillerEventWindowMessages::Handler::BusConnect(m_aggregatorIdentityCached); - - m_gui->widgetDataStrip->AddAxis("Frame", 0.0f, 1.0f, false); - m_gui->widgetDataStrip->AddAxis("", -1.0f, 1.0f, true); - - SetFrameNumber(); - - AZStd::string windowStateStr = AZStd::string::format("PROFILER DATA VIEW WINDOW STATE %i", m_viewIndex); - m_windowStateCRC = AZ::Crc32(windowStateStr.c_str()); - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (windowState) - { - windowState->RestoreGeometry(this); - } - - AZStd::string treeStateStr = AZStd::string::format("PROFILER DATA VIEW LOCAL STATE %i", m_viewIndex); - m_treeStateCRC = AZ::Crc32(treeStateStr.c_str()); - auto treeState = AZ::UserSettings::Find(m_treeStateCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - QByteArray treeData((const char*)treeState->m_treeColumnStorage.data(), (int)treeState->m_treeColumnStorage.size()); - m_gui->widgetProfilerData->header()->restoreState(treeData); - } - - AZStd::string dataViewStateStr = AZStd::string::format("PROFILER DATA VIEW STATE %i", m_viewIndex); - m_dataViewStateCRC = AZ::Crc32(dataViewStateStr.c_str()); - m_persistentState = AZ::UserSettings::CreateFind(m_dataViewStateCRC, AZ::UserSettings::CT_GLOBAL); - ApplyPersistentState(); - } - - ProfilerDataView::~ProfilerDataView() - { - SaveOnExit(); - azdestroy(m_gui); - } - - QAction* ProfilerDataView::CreateChartTypeAction(QString qs) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - connect(act, SIGNAL(triggered()), this, SLOT(OnChartTypeMenu())); - connect(act, SIGNAL(triggered()), m_gui->widgetProfilerData, SLOT(OnChartTypeMenu())); - return act; - } - - QAction* ProfilerDataView::CreateChartLengthAction(QString qs) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - connect(act, SIGNAL(triggered()), this, SLOT(OnChartLengthMenu())); - return act; - } - - QAction* ProfilerDataView::CreateThreadSelectorAction(QString qs, AZ::u64 id) - { - QAction* act = new QAction(qs, this); - act->setObjectName(qs); - act->setData(id); - connect(act, SIGNAL(triggered()), this, SLOT(OnThreadSelectorMenu())); - return act; - } - - void ProfilerDataView::OnThreadSelectorButtonClick() - { - QMenu* threadIDMenu = new QMenu(this); - threadIDMenu->addAction(CreateThreadSelectorAction("All Threads", 0)); - - for (auto iter = m_aggregator->m_lifeTimeThreads.begin(); iter != m_aggregator->m_lifeTimeThreads.end(); ++iter) - { - auto threadID = iter->first; - threadIDMenu->addAction(CreateThreadSelectorAction(QString("Thread = %1").arg(threadID), threadID)); - } - - threadIDMenu->exec(QCursor::pos()); - delete threadIDMenu; - } - - void ProfilerDataView::OnSanityCheck() - { - AZ_TracePrintf("ProfilerDataView", "Released"); - } - - void ProfilerDataView::ApplyPersistentState() - { - if (m_persistentState) - { - // the bridge between our AZStd::string storage and QT's own string type - QString lengthMenuText(m_persistentState->m_chartLengthStr.c_str()); - OnChartLengthMenu(lengthMenuText); - - QString typeMenuText(m_persistentState->m_chartTypeStr.c_str()); - if (IsStringCompatibleWithType(m_persistentState->m_chartTypeStr)) - { - OnChartTypeMenu(typeMenuText); - } - - QString threadMenuText(m_persistentState->m_threadIDStr.c_str()); - OnThreadSelectorMenu(threadMenuText, m_persistentState->m_threadID); - - m_gui->checkBoxAutoZoom->setChecked(m_persistentState->m_autoZoom); - m_gui->checkBoxFlatView->setChecked(m_persistentState->m_flatView); - m_gui->checkBoxDelta->setChecked(m_persistentState->m_deltaData); - m_gui->widgetProfilerData->OnAutoZoomChange(m_persistentState->m_autoZoom); - m_gui->widgetProfilerData->OnFlatView(m_persistentState->m_flatView); - m_gui->widgetProfilerData->OnDeltaData(m_persistentState->m_deltaData); - - QSet qSetQString; - AZStd::vector< AZStd::string >::iterator iter = m_persistentState->m_treeExpansionData.begin(); - while (iter != m_persistentState->m_treeExpansionData.end()) - { - qSetQString.insert(QString(iter->c_str())); - ++iter; - } - - m_gui->widgetProfilerData->ReadTreeViewStateFrom(qSetQString); - } - } - - bool ProfilerDataView::IsStringCompatibleWithType(AZStd::string candidateStr) - { - if (m_viewType == Profiler::RegisterInfo::PRT_TIME) - { - for (int i = 0; menuTypeStrings[i]; ++i) - { - if (candidateStr == menuTypeStrings[i]) - { - return true; - } - } - } - if (m_viewType == Profiler::RegisterInfo::PRT_VALUE) - { - for (int i = 0; menuValueTypeStrings[i]; ++i) - { - if (candidateStr == menuValueTypeStrings[i]) - { - return true; - } - } - } - - return false; - } - - void ProfilerDataView::OnChartTypeMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnChartTypeMenu(qa->objectName()); - } - } - - void ProfilerDataView::OnChartTypeMenu(QString menuText) - { - m_gui->chartTypeButton->setText(menuText); - m_gui->widgetProfilerData->OnChartTypeMenu(menuText); - } - - void ProfilerDataView::OnChartLengthMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnChartLengthMenu(qa->objectName()); - } - } - - void ProfilerDataView::OnChartLengthMenu(QString fromMenu) - { - ProfilerOperationTelemetryEvent chartLengthChange; - chartLengthChange.SetAttribute("ChartLength", fromMenu.toStdString().c_str()); - chartLengthChange.Log(); - - m_gui->chartLengthButton->setText(fromMenu); - - if (fromMenu == "60 Frames") - { - m_chartLength = 60; - } - if (fromMenu == "120 Frames") - { - m_chartLength = 120; - } - if (fromMenu == "240 Frames") - { - m_chartLength = 240; - } - if (fromMenu == "480 Frames") - { - m_chartLength = 480; - } - - SetFrameNumber(); - } - - void ProfilerDataView::OnThreadSelectorMenu() - { - QAction* qa = qobject_cast(sender()); - if (qa) - { - OnThreadSelectorMenu(qa->objectName(), qa->data().toULongLong()); - } - } - - void ProfilerDataView::OnThreadSelectorMenu(QString fromMenu, AZ::u64 id) - { - const char* k_changeThreadFilter = "ThreadFilter"; - - ProfilerOperationTelemetryEvent threadSelector; - - m_gui->threadSelectorButton->setText(fromMenu); - m_persistentState->m_threadIDStr = fromMenu.toUtf8().data(); - m_persistentState->m_threadID = id; - - if (id == 0) - { - threadSelector.SetAttribute(k_changeThreadFilter, "All Threads"); - m_filterThreadID = 0; - } - else - { - threadSelector.SetAttribute(k_changeThreadFilter, m_persistentState->m_threadIDStr); - m_filterThreadID = id; - } - - threadSelector.Log(); - - // force a new data set - SetFrameNumber(); - } - - void ProfilerDataView::SaveOnExit() - { - auto treeState = AZ::UserSettings::CreateFind(m_treeStateCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - if (m_gui->widgetProfilerData && m_gui->widgetProfilerData->header()) - { - QByteArray qba = m_gui->widgetProfilerData->header()->saveState(); - treeState->m_treeColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - auto pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (m_persistentState) - { - if ( - m_gui->chartLengthButton - && m_gui->chartTypeButton - && m_gui->threadSelectorButton - && m_gui->checkBoxAutoZoom - && m_gui->checkBoxDelta - && m_gui->widgetProfilerData - && m_gui->widgetProfilerData->IsTreeViewSavingReady() - ) - { - pState->CaptureGeometry(this); - m_persistentState->m_chartLengthStr = m_gui->chartLengthButton->text().toUtf8().data(); - m_persistentState->m_chartTypeStr = m_gui->chartTypeButton->text().toUtf8().data(); - m_persistentState->m_threadIDStr = m_gui->threadSelectorButton->text().toUtf8().data(); - m_persistentState->m_autoZoom = (int)m_gui->checkBoxAutoZoom->isChecked(); - m_persistentState->m_flatView = (int)m_gui->checkBoxFlatView->isChecked(); - m_persistentState->m_deltaData = (int)m_gui->checkBoxDelta->isChecked(); - - m_persistentState->m_treeExpansionData.clear(); - QSet qSetQString; - m_gui->widgetProfilerData->WriteTreeViewStateTo(qSetQString); - QSet::iterator iter = qSetQString.begin(); - for (auto iterStrings = qSetQString.begin(); iterStrings != qSetQString.end(); ++iterStrings) - { - m_persistentState->m_treeExpansionData.push_back(iterStrings->toUtf8().data()); - } - } - } - } - void ProfilerDataView::hideEvent(QHideEvent* evt) - { - QDialog::hideEvent(evt); - } - void ProfilerDataView::closeEvent(QCloseEvent* evt) - { - DrillerEventWindowMessages::Handler::BusDisconnect(m_aggregatorIdentityCached); - DrillerMainWindowMessages::Handler::BusDisconnect(m_aggregatorIdentityCached); - QDialog::closeEvent(evt); - } - void ProfilerDataView::OnDataDestroyed() - { - deleteLater(); - } - - void ProfilerDataView::FrameChanged(FrameNumberType frame) - { - m_frame = frame; - SetFrameNumber(); - } - - void ProfilerDataView::SetFrameNumber() - { - size_t numEvents = m_aggregator->NumOfEventsAtFrame(m_frame); - - m_aggregator->FrameChanged(m_frame); - - m_gui->widgetProfilerData->BeginDataModelUpdate(); - - if (numEvents) - { - m_gui->widgetProfilerData->m_dataModel->SetAggregator(m_aggregator); - - for (EventNumberType eventIndex = m_aggregator->m_frameToEventIndex[m_frame]; eventIndex < static_cast(m_aggregator->m_frameToEventIndex[m_frame] + numEvents); ++eventIndex) - { - Driller::DrillerEvent* dep = m_aggregator->GetEvents()[ eventIndex ]; - if (dep->GetEventType() == Driller::Profiler::PET_UPDATE_REGISTER) - { - Driller::ProfilerDrillerUpdateRegisterEvent* regEvt = static_cast(dep); - - if (regEvt->GetRegister()) - { - if (m_filterThreadID == 0 || regEvt->GetRegister()->GetInfo().m_threadId == m_filterThreadID) - { - m_gui->widgetProfilerData->m_dataModel->AddRegister(regEvt); - } - } - } - } - - m_gui->widgetProfilerData->EndDataModelUpdate(); - - // build the chart - // this data view responsible for length of history setting and deciding what kind of data is displayed - // that data panel, which owns the data model, responsible for each register on/off and charting - m_gui->widgetProfilerData->ConfigureChart(m_gui->widgetDataStrip, m_frame, m_chartLength, static_cast(m_aggregator->GetFrameCount())); // magic number 60 = frame count to go back in time - } - } - - - void ProfilerDataView::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("PROFILER DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - ProfilerDataViewSavedState* workspace = provider->FindSetting(workspaceStateCRC); - if (workspace) - { - m_persistentState->m_chartLengthStr = workspace->m_chartLengthStr; - m_persistentState->m_chartTypeStr = workspace->m_chartTypeStr; - m_persistentState->m_threadIDStr = workspace->m_threadIDStr; - m_persistentState->m_threadID = workspace->m_threadID; - m_persistentState->m_flatView = workspace->m_flatView; - m_persistentState->m_autoZoom = workspace->m_autoZoom; - m_persistentState->m_deltaData = workspace->m_deltaData; - m_persistentState->m_treeExpansionData = workspace->m_treeExpansionData; - } - } - } - - void ProfilerDataView::ActivateWorkspaceSettings(WorkspaceSettingsProvider*) - { - ApplyPersistentState(); - } - - void ProfilerDataView::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("PROFILER DATA VIEW WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - ProfilerDataViewSavedState* workspace = provider->CreateSetting(workspaceStateCRC); - if (workspace) - { - workspace->m_chartLengthStr = m_persistentState->m_chartLengthStr; - workspace->m_chartTypeStr = m_persistentState->m_chartTypeStr; - workspace->m_threadIDStr = m_persistentState->m_threadIDStr; - workspace->m_threadID = m_persistentState->m_threadID; - workspace->m_flatView = m_persistentState->m_flatView; - workspace->m_autoZoom = m_persistentState->m_autoZoom; - workspace->m_deltaData = m_persistentState->m_deltaData; - workspace->m_treeExpansionData = m_persistentState->m_treeExpansionData; - } - } - } - - void ProfilerDataView::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - ProfilerDataViewSavedState::Reflect(context); - ProfilerDataViewLocal::Reflect(context); - - // Driller doesn't use AzToolsFramework directly, so we have to initialize the serialization for the QTreeViewStateSaver - AzToolsFramework::QTreeViewWithStateSaving::Reflect(context); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.hxx b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.hxx deleted file mode 100644 index 44ca07617c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef PROFILERDATAVIEW_H -#define PROFILERDATAVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -#include -#include - -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Ui -{ - class ProfilerDataView; -} - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class ProfilerDataAggregator; - class ProfilerDataViewSavedState; - - class ProfilerDataView - : public QDialog - , public Driller::DrillerMainWindowMessages::Bus::Handler - , public Driller::DrillerEventWindowMessages::Bus::Handler - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(ProfilerDataView,AZ::SystemAllocator,0); - ProfilerDataView( ProfilerDataAggregator *aggregator, FrameNumberType atFrame, int profilerIndex, int viewType ); - virtual ~ProfilerDataView(void); - - void SetFrameNumber(); - // called after loading user settings or applying workspace settings on top of local user settings - int GetViewType() { return m_viewType; } - - // MainWindow Bus Commands - void FrameChanged(FrameNumberType frame) override; - void EventFocusChanged(EventNumberType /*eventIndex*/ ) override { }; - void EventChanged(EventNumberType /*eventIndex*/) override {} - - // NB: These three methods mimic the workspace bus. - // Because the ProfilerDataAggregator can't know to open these DataView windows - // until after the EBUS message has gone out, the owning aggregator must - // first create these windows and then pass along the provider manually - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - void ApplyPersistentState(); - - void SaveOnExit(); - virtual void closeEvent(QCloseEvent *evt); - virtual void hideEvent(QHideEvent *evt); - - ProfilerDataAggregator *m_aggregator; - // persistent state is used as if they were internal variables, - // though they reside in a storage class - // this lasts for the entire lifetime of this object - AZStd::intrusive_ptr m_persistentState; - - FrameNumberType m_frame; - int m_aggregatorIdentityCached; - AZ::u32 m_windowStateCRC; - AZ::u32 m_dataViewStateCRC; - int m_viewIndex; - QMenu *m_threadIDMenu; - AZ::u64 m_filterThreadID; - int m_viewType; - AZ::u32 m_treeStateCRC; - AZStd::unordered_map m_chartTypeStringToViewType; - - public: - - QAction *CreateChartTypeAction( QString qs ); - QAction *CreateChartLengthAction( QString qs ); - QAction *CreateThreadSelectorAction( QString qs, AZ::u64 id ); - void ClearThreadSelectorActions(); - bool IsStringCompatibleWithType(AZStd::string candidateStr); - - int m_chartLength; - - - public: - static void Reflect(AZ::ReflectContext* context); - - public slots: - void OnDataDestroyed(); - void OnChartTypeMenu(); - void OnChartTypeMenu( QString fromMenu ); - void OnChartLengthMenu(); - void OnChartLengthMenu( QString fromMenu ); - void OnThreadSelectorMenu(); - void OnThreadSelectorMenu( QString fromMenu, AZ::u64 id ); - void OnThreadSelectorButtonClick(); - void OnSanityCheck(); - - private: - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - Ui::ProfilerDataView* m_gui; - }; - -} - - -#endif // PROFILERDATAVIEW_H diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.ui b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.ui deleted file mode 100644 index e4b6b3e229..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerDataView.ui +++ /dev/null @@ -1,490 +0,0 @@ - - - ProfilerDataView - - - - 0 - 0 - 1075 - 320 - - - - Profiler Data View - - - - 4 - - - 4 - - - 4 - - - 4 - - - - - - - - 0 - 1 - - - - - 0 - 128 - - - - - - - - - 0 - 32 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - 1 - - - 1 - - - 1 - - - 1 - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Hides the selected rows in the tree - - - Hide Selected - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Shows the selected rows in the tree - - - Show Selected - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Hides all rows in the tree - - - Hide All - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Shows all rows in the tree - - - Show All - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Inverts what is showing and hiding in the tree - - - Invert - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - Expands all rows in the tree - - - Expand Tree - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 25 - 20 - - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - What threads are being displayed in the graph/tree - - - All Threads - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - What information is being graphed - - - Excl.Time - - - - - - - - 0 - 0 - - - - - 85 - 0 - - - - Qt::NoFocus - - - How many history frames the graph displays - - - 60 Frames - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - 48 - 16777215 - - - - Delta - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - Autozoom - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 64 - 16777215 - - - - Flattens the tree structure - - - Flat View - - - - - - - Qt::Horizontal - - - - 0 - 0 - - - - - - - - - - - - 0 - 2 - - - - - 224 - 128 - - - - true - - - QAbstractItemView::ExtendedSelection - - - Qt::ElideMiddle - - - true - - - true - - - false - - - false - - - 128 - - - 64 - - - - - - - - - - StripChart::DataStrip - QWidget -
../StripChart.hxx
- 1 -
- - Driller::ProfilerDataWidget - QTreeView -
ProfilerDataPanel.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.cpp b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.cpp deleted file mode 100644 index aa1ad4ae89..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ProfilerEvents.h" - -#include "ProfilerDataAggregator.hxx" - -namespace Driller -{ - //========================================================================= - // ProfilerDrillerUpdateRegisterEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerUpdateRegisterEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - - ProfilerDataAggregator::RegisterMapType::iterator it = aggr->m_registers.find(m_registerId); - if (it != aggr->m_registers.end()) - { - m_register = it->second; - m_previousSample = m_register->m_lastUpdate; - m_register->m_lastUpdate = this; - } - } - - //========================================================================= - // ProfilerDrillerUpdateRegisterEvent::PreProcess - //========================================================================= - void ProfilerDrillerUpdateRegisterEvent::PreComputeForward(ProfilerDrillerNewRegisterEvent* newEvt) - { - m_register = newEvt; - m_previousSample = m_register->m_lastPrecomputed; - m_register->m_lastPrecomputed = this; - } - - //========================================================================= - // ProfilerDrillerUpdateRegisterEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerUpdateRegisterEvent::StepBackward(Aggregator* data) - { - (void)data; - - if (m_register) - { - m_register->m_lastUpdate = m_previousSample; - } - } - - //========================================================================= - // ProfilerDrillerNewRegisterEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerNewRegisterEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - aggr->m_registers.insert(AZStd::make_pair(m_registerInfo.m_id, this)); - } - - //========================================================================= - // ProfilerDrillerNewRegisterEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerNewRegisterEvent::StepBackward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - // NOTE: we can store the iterator in this register class, this way we can avoid this search - // as of now search should be fast (at least as fast as insert) plus I am avoiding including "ProfilerDataAggregator.hxx" - // into the header file. - aggr->m_registers.erase(m_registerInfo.m_id); - } - - //========================================================================= - // ProfilerDrillerEnterThreadEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerEnterThreadEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - aggr->m_threads.insert(AZStd::make_pair(m_threadId, this)); - } - - //========================================================================= - // ProfilerDrillerEnterThreadEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerEnterThreadEvent::StepBackward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - // NOTE: we can store the iterator in this register class, this way we can avoid this search - // as of now search should be fast (at least as fast as insert) plus I am avoiding including "ProfilerDataAggregator.hxx" - // into the header file. - aggr->m_threads.erase(m_threadId); - } - - //========================================================================= - // ProfilerDrillerExitThreadEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerExitThreadEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - ProfilerDataAggregator::ThreadMapType::iterator it = aggr->m_threads.find(m_threadId); - m_threadData = it->second; - aggr->m_threads.erase(it); - } - - //========================================================================= - // ProfilerDrillerEnterThreadEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerExitThreadEvent::StepBackward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - aggr->m_threads.insert(AZStd::make_pair(m_threadId, m_threadData)); - } - - //========================================================================= - // ProfilerDrillerRegisterSystemEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerRegisterSystemEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - aggr->m_systems.insert(AZStd::make_pair(m_systemId, this)); - } - - //========================================================================= - // ProfilerDrillerEnterThreadEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerRegisterSystemEvent::StepBackward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - // NOTE: we can store the iterator in this register class, this way we can avoid this search - // as of now search should be fast (at least as fast as insert) plus I am avoiding including "ProfilerDataAggregator.hxx" - // into the header file. - aggr->m_threads.erase(m_systemId); - } - - //========================================================================= - // ProfilerDrillerUnregisterSystemEvent::StepForward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerUnregisterSystemEvent::StepForward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - ProfilerDataAggregator::SystemMapType::iterator it = aggr->m_systems.find(m_systemId); - m_systemData = it->second; - aggr->m_systems.erase(it); - } - - //========================================================================= - // ProfilerDrillerUnregisterSystemEvent::StepBackward - // [6/3/2013] - //========================================================================= - void ProfilerDrillerUnregisterSystemEvent::StepBackward(Aggregator* data) - { - ProfilerDataAggregator* aggr = static_cast(data); - aggr->m_systems.insert(AZStd::make_pair(m_systemId, m_systemData)); - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.h b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.h deleted file mode 100644 index 7963a080b8..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerEvents.h +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_PROFILER_EVENTS_H -#define DRILLER_PROFILER_EVENTS_H - -#include "Source/Driller/DrillerEvent.h" -#include - -namespace Driller -{ - namespace Profiler - { - /// Time register data. - struct TimeData - { - AZ::u64 m_time; ///< Total inclusive time current and children in microseconds. - AZ::u64 m_childrenTime; ///< Time taken by child profilers in microseconds. - AZ::s64 m_calls; ///< Number of calls for this register. - AZ::s64 m_childrenCalls;///< Number of children calls. - AZ::u64 m_lastParentRegisterId; ///< Id of the last parent register. - }; - - /// Value register data. - struct ValuesData - { - AZ::s64 m_value1; - AZ::s64 m_value2; - AZ::s64 m_value3; - AZ::s64 m_value4; - AZ::s64 m_value5; - }; - - /// Data that will change every frame (technically only when registers are called) - struct RegisterData - { - RegisterData() - { - m_valueData.m_value1 = 0; - m_valueData.m_value2 = 0; - m_valueData.m_value3 = 0; - m_valueData.m_value4 = 0; - m_valueData.m_value5 = 0; - } - - union - { - TimeData m_timeData; - ValuesData m_valueData; - }; - }; - - /// Data that never changes - struct RegisterInfo - { - RegisterInfo() - : m_id(0) - , m_threadId(0) - , m_name(nullptr) - , m_function(nullptr) - , m_line(-1) - , m_systemId(0) - {} - - enum Type - { - PRT_TIME = 0, ///< Time register - RegisterData::m_time data is used. - PRT_VALUE, ///< Value register - RegisterData::m_values data is used. - }; - - unsigned char m_type; ///< Register type (time or values) - AZ::u64 m_id; ///< Register id (technically the pointer during execution). - AZ::u64 m_threadId; ///< Native thread handle (AZStd::native_thread_id_type) typically a pointer too. - const char* m_name; ///< Name/description of the register it's optional for time registers. - const char* m_function; ///< Name of the function which we are sampling. - int m_line; ///< Line in the code where this register is created (start sampling). - AZ::u32 m_systemId; ///< Crc32 of the system name provided by the user. - }; - - enum ProfilerEventType - { - PET_NEW_REGISTER = 0, - PET_UPDATE_REGISTER, - PET_ENTER_THREAD, - PET_EXIT_THREAD, - PET_REGISTER_SYSTEM, - PET_UNREGISTER_SYSTEM, - }; - } - - class ProfilerDrillerNewRegisterEvent; - class ProfilerDataAggregator; - - class ProfilerDrillerUpdateRegisterEvent - : public DrillerEvent - { - friend class ProfilerDrillerNewRegisterEvent; - friend class ProfilerDrillerHandlerParser; - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerUpdateRegisterEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerUpdateRegisterEvent() - : DrillerEvent(Profiler::PET_UPDATE_REGISTER) - , m_register(nullptr) - , m_previousSample(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - void PreComputeForward(ProfilerDrillerNewRegisterEvent* newEvt); - - const Profiler::RegisterData& GetData() const { return m_registerData; } - const ProfilerDrillerNewRegisterEvent* GetRegister() const { return m_register; } - const ProfilerDrillerUpdateRegisterEvent* GetPreviousSample() const { return m_previousSample; } - const AZ::u64 GetRegisterId() const { return m_registerId; } - - private: - AZ::u64 m_registerId; ///< Id if the register. - Profiler::RegisterData m_registerData; ///< Register sample data. - ProfilerDrillerNewRegisterEvent* m_register; ///< Cached pointer to the register. - ProfilerDrillerUpdateRegisterEvent* m_previousSample; ///< Pointer to the previous register values (null if this is the first sample). - }; - - class ProfilerDrillerNewRegisterEvent - : public DrillerEvent - { - friend class ProfilerDrillerUpdateRegisterEvent; - friend class ProfilerDrillerHandlerParser; - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerNewRegisterEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerNewRegisterEvent() - : DrillerEvent(Profiler::PET_NEW_REGISTER) - , m_lastUpdate(nullptr) - , m_lastPrecomputed(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - const Profiler::RegisterData& GetData() const { return m_lastUpdate ? m_lastUpdate->m_registerData : m_registerData; } - const Profiler::RegisterInfo& GetInfo() const { return m_registerInfo; } - const ProfilerDrillerUpdateRegisterEvent* GetLastSample() const { return m_lastUpdate; } - - private: - Profiler::RegisterInfo m_registerInfo; ///< Register information. - Profiler::RegisterData m_registerData; ///< Register sample data. - - // m_lastUpdate is actually also the current scrubber frame for that register. - ProfilerDrillerUpdateRegisterEvent* m_lastUpdate; ///< Pointer to the last set of RegisterData (null if there is not last set) - - // because we precompute a small number of registers in order to show the note track in the main view, we need - // a seperate pointer to the prior precomputed data. - ProfilerDrillerUpdateRegisterEvent* m_lastPrecomputed; - }; - - class ProfilerDrillerEnterThreadEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerEnterThreadEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerEnterThreadEvent() - : DrillerEvent(Profiler::PET_ENTER_THREAD) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_threadId; - const char* m_threadName; ///< Debug name of thread if one is provided. - AZ::s32 m_cpuId; ///< If of the CPU where this thread should run. - AZ::s32 m_priority; - AZ::u32 m_stackSize; - }; - - class ProfilerDrillerExitThreadEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerExitThreadEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerExitThreadEvent() - : DrillerEvent(Profiler::PET_EXIT_THREAD) - , m_threadData(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_threadId; - ProfilerDrillerEnterThreadEvent* m_threadData; - }; - - class ProfilerDrillerRegisterSystemEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerRegisterSystemEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerRegisterSystemEvent() - : DrillerEvent(Profiler::PET_REGISTER_SYSTEM) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u32 m_systemId; - const char* m_name; ///< Debug name of thread system. - }; - - class ProfilerDrillerUnregisterSystemEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(ProfilerDrillerUnregisterSystemEvent, AZ::SystemAllocator, 0) - - ProfilerDrillerUnregisterSystemEvent() - : DrillerEvent(Profiler::PET_UNREGISTER_SYSTEM) - , m_systemData(nullptr) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u32 m_systemId; - ProfilerDrillerRegisterSystemEvent* m_systemData; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h b/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h deleted file mode 100644 index ce8956698a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef DRILLER_PROFILER_PROFILEROPERATIONTELEMETRYEVENT_H -#define DRILLER_PROFILER_PROFILEROPERATIONTELEMETRYEVENT_H - -#include "Source/Telemetry/TelemetryEvent.h" - -namespace Driller -{ - class ProfilerOperationTelemetryEvent - : public Telemetry::TelemetryEvent - { - public: - ProfilerOperationTelemetryEvent() - : Telemetry::TelemetryEvent("ProfileDataViewOperation") - { - } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/RacetrackChart.cpp b/Code/Tools/Standalone/Source/Driller/RacetrackChart.cpp deleted file mode 100644 index bf87f7da43..0000000000 --- a/Code/Tools/Standalone/Source/Driller/RacetrackChart.cpp +++ /dev/null @@ -1,608 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "RacetrackChart.hxx" -#include -#include "DrillerMainWindowMessages.h" -#include "Axis.hxx" -#include "ChartNumberFormats.h" - -#include -#include -#include -#include - -namespace Racetrack -{ - ////////////////////////////////////////////////////////////////////////// - DataRacetrack::DataRacetrack(QWidget* parent, Qt::WindowFlags flags) - : QWidget(parent, flags) - , m_Axis(NULL) - , m_InsetL(2) - , m_InsetR(2) - , m_InsetT(2) - , m_InsetB(32) - , m_IsDragging(false) - , m_ZoomLimit(15) - , m_IsLeftDragging(false) - , m_ZeroBasedAxisDisplay(false) - { - m_Axis = aznew Charts::Axis(this); - connect(m_Axis, SIGNAL(Invalidated()), this, SLOT(OnAxisInvalidated())); - this->setMouseTracking(true); - m_iChannelHighlight = -1; - } - - Charts::Axis* DataRacetrack::GetAxis() const - { - return m_Axis; - } - - void DataRacetrack::OnAxisInvalidated() - { - update(); - } - - DataRacetrack::~DataRacetrack() - { - } - - void DataRacetrack::SetZoomLimit(float limit) - { - m_ZoomLimit = limit; - } - - int DataRacetrack::AddChannel(QString name) - { - int id = (int)m_Channels.size(); - m_Channels.push_back(); - m_Channels[id].SetName(name); - - return id; - } - - void DataRacetrack::SetChannelColor(int channelID, QColor color) - { - m_Channels[channelID].SetColor(color); - } - - void DataRacetrack::SetZeroBasedAxisNumbering(bool tf) - { - m_ZeroBasedAxisDisplay = tf; - update(); - } - - void DataRacetrack::SetMarkerColor(QColor qc) - { - m_MarkerColor = qc; - update(); - } - void DataRacetrack::SetMarkerPosition(float qposn) - { - m_MarkerPosition = qposn; - update(); - } - - - void DataRacetrack::AddData(int channelID, float h, float v) - { - m_Channels[channelID].m_Data.push_back(); - m_Channels[channelID].m_Data.back().first = h; - m_Channels[channelID].m_Data.back().second = v; - } - - void DataRacetrack::Clear() - { - m_Axis->Clear(); - m_Channels.clear(); - } - - void DataRacetrack::ClearData(int channelID) - { - if (channelID < m_Channels.size()) - { - m_Channels[channelID].m_Data.clear(); - } - } - - - void DataRacetrack::SetupAxis(QString label, float minimum, float maximum, bool locked) - { - m_Axis->SetLabel(label); - m_Axis->SetAxisRange(minimum, maximum); - m_Axis->SetLockedRange(locked); - } - - void DataRacetrack::Zoom(QPoint pt, int steps) - { - if (m_Axis->GetValid()) - { - if (m_Inset.intersects(QRect(pt, pt))) - { - float ratio = float(pt.x() - m_Inset.left()) / float(m_Inset.width()); - if (m_Axis->GetLockedRight()) - { - ratio = 1.0f; - } - if (!m_Axis->GetLockedRange()) - { - m_Axis->SetAutoWindow(false); - - float testMin = m_Axis->GetWindowMin(); - float testMax = m_Axis->GetWindowMax(); - - testMin -= float(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()) * 0.05f * ratio * float(-steps); - testMax += float(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()) * 0.05f * (1.0f - ratio) * float(-steps); - if ((testMax - testMin) > 0.0f) - { - if (testMax > m_Axis->GetRangeMax()) - { - float offset = m_Axis->GetRangeMax() - testMax; - testMax += offset; - testMin += offset; - } - if (testMin < m_Axis->GetRangeMin()) - { - float offset = testMin - m_Axis->GetRangeMin(); - testMax -= offset; - testMin -= offset; - } - if ((float)m_Inset.width() / (testMax - testMin) < m_ZoomLimit) - { - m_Axis->SetWindowMin(testMin); - m_Axis->SetWindowMax(testMax); - } - - if ((testMax - testMin) > (m_Axis->GetRangeMax() - m_Axis->GetRangeMin())) - { - m_Axis->SetViewFull(); - } - } - } - } - } - } - - void DataRacetrack::Drag(int deltaX) - { - if (m_Axis->GetValid()) - { - if (!m_Axis->GetLockedRange() && !m_Axis->GetLockedRight()) - { - // delta is in pixels. Convert to domain units: - - float pixelWidth = (float)m_Inset.width(); - float domainWidth = m_Axis->GetWindowMax() - m_Axis->GetWindowMin(); - float domainPerPixel = domainWidth / pixelWidth; - float deltaInDomain = domainPerPixel * (float)deltaX; - - if (m_Axis->GetWindowMin() + deltaInDomain > m_Axis->GetRangeMin() && m_Axis->GetWindowMax() + deltaInDomain < m_Axis->GetRangeMax()) - { - m_Axis->SetAutoWindow(false); - m_Axis->UpdateWindowRange((float)deltaInDomain); - } - } - } - } - - QPoint DataRacetrack::Transform(float v) - { - QPoint pt; - - if (m_Axis->GetValid()) - { - if ((v >= m_Axis->GetWindowMin()) && (v <= m_Axis->GetWindowMax())) - { - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - - float ratio = float(v - m_Axis->GetWindowMin()) / fullRange; - pt.setY(m_Inset.bottom() - int((float(m_Inset.height()) * ratio))); - } - } - - return pt; - } - - TransformResult DataRacetrack::Transform(float h, QPoint& outPoint) - { - TransformResult tr = INVALID_RANGE; - QPoint pt(0, 0); - - if (m_Axis->GetValid()) - { - if (h < m_Axis->GetWindowMin()) - { - tr = OUTSIDE_LEFT; - pt.setX(m_Inset.left()); - } - else if (h > m_Axis->GetWindowMax()) - { - tr = OUTSIDE_RIGHT; - pt.setX(m_Inset.left() + m_Inset.width()); - } - else - { - tr = INSIDE_RANGE; - - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = float(h - m_Axis->GetWindowMin()) / fullRange; - pt.setX(m_Inset.left() + int((float(m_Inset.width()) * ratio))); - } - } - - outPoint = pt; - return tr; - } - - void DataRacetrack::wheelEvent (QWheelEvent* event) - { - if (!m_Axis->GetValid()) - { - return; - } - - int numDegrees = event->angleDelta().y() / 8; - int numSteps = numDegrees / 15; - // +step := zoom IN - // -step := zoom OUT - QPoint zoomPt = event->position().toPoint() - m_Inset.topLeft(); - - Zoom(zoomPt, numSteps); - - update(); - - event->accept(); - } - void DataRacetrack::mouseMoveEvent (QMouseEvent* event) - { - if (!m_Axis->GetValid()) - { - return; - } - if (m_IsDragging) - { - // far far did we move in the DOMAIN? - QPoint pt = m_DragTracker - event->pos(); - Drag(pt.x()); - m_DragTracker = event->pos(); - update(); - } - else - { - if (m_IsLeftDragging) - { - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = (float)(event->pos().x() - m_InsetL) / (float)(width() - m_InsetL - m_InsetR); - float localValue = fullRange * ratio; - Driller::EventNumberType globalEvtID = (Driller::EventNumberType)(m_Axis->GetWindowMin() + localValue); - - emit EventRequestEventFocus(globalEvtID); - } - else - { - int oldChannelHighlight = m_iChannelHighlight; - m_iChannelHighlight = -1; - if (m_Channels.size() > 0) - { - if (m_Inset.contains(event->pos())) - { - QPoint offset = event->pos() - m_Inset.topLeft(); - float ratio = (float)offset.y() / m_Inset.height(); - if (ratio < 1.0f) - { - // so which channel is it over? - int channel = (int)(ratio * (float)m_Channels.size()); - if (m_iChannelHighlight != channel) - { - m_iChannelHighlight = channel; - } - } - } - } - - if (oldChannelHighlight != m_iChannelHighlight) - { - update(); - } - } - } - } - void DataRacetrack::mousePressEvent (QMouseEvent* event) - { - if (!m_Axis->GetValid()) - { - return; - } - - if (event->button() == Qt::RightButton) - { - m_IsDragging = true; - m_DragTracker = event->pos(); - } - else if (event->button() == Qt::LeftButton) - { - m_IsLeftDragging = true; - - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = (float)(event->pos().x() - m_Inset.x()) / (float)(width() - m_InsetL - m_InsetR); - float localValue = fullRange * ratio; - Driller::EventNumberType globalEvtID = (Driller::EventNumberType)(m_Axis->GetWindowMin() + localValue); - - emit EventRequestEventFocus(globalEvtID); - } - - event->accept(); - } - - void DataRacetrack::leaveEvent(QEvent*) - { - if (m_iChannelHighlight != -1) - { - m_iChannelHighlight = -1; - update(); - } - } - - void DataRacetrack::mouseReleaseEvent (QMouseEvent* event) - { - if (!m_Axis->GetValid()) - { - return; - } - - if (event->button() == Qt::RightButton) - { - m_IsDragging = false; - } - else - { - if (m_IsLeftDragging) - { - m_IsLeftDragging = false; - } - } - - event->accept(); - } - void DataRacetrack::resizeEvent(QResizeEvent* event) - { - RecalculateInset(); - event->ignore(); - } - - void DataRacetrack::RecalculateInset() - { - m_Inset = QRect(m_InsetL, m_InsetT, rect().width() - m_InsetL - m_InsetR, rect().height() - m_InsetT - m_InsetB); - } - - void DataRacetrack::paintEvent(QPaintEvent* event) - { - (void)event; - - QPen pen; - pen.setWidth(1); - QBrush brush; - brush.setStyle(Qt::SolidPattern); - pen.setBrush(brush); - - QPainter p(this); - p.setPen(pen); - - p.fillRect(rect(), QColor(32, 32, 32, 255)); - p.fillRect(m_Inset, Qt::black); - - brush.setColor(QColor(255, 255, 0, 255)); - pen.setColor(QColor(0, 255, 255, 255)); - p.setPen(pen); - - if (m_Channels.empty()) - { - return; - } - - if (!m_Axis->GetValid()) - { - return; - } - - // HORIZ - if (m_Axis) - { - int barHeight = m_Inset.height() / (int)m_Channels.size() - (int)m_Channels.size(); - - p.drawText(0, 0, rect().width(), rect().height(), Qt::AlignHCenter | Qt::AlignBottom, m_Axis->GetLabel()); - - pen.setStyle(Qt::DashDotLine); - pen.setColor(QColor(72, 72, 72, 255)); - p.setPen(pen); - RenderHorizCallouts(&p); - - TransformResult tr1, tr2; - QPoint pt1, pt2; - tr1 = Transform(m_Axis->GetWindowMin(), pt1); - tr2 = Transform(m_Axis->GetWindowMin() + 1.0f, pt2); - int drawWidth = pt2.x() - pt1.x() + 1; - - int chidx = 0; - for (Channels::iterator chiter = m_Channels.begin(); chiter != m_Channels.end(); ++chiter, ++chidx) - { - Channel& cptr = *chiter; - - - pen.setStyle(Qt::SolidLine); - brush.setColor(chiter->m_Color); - brush.setStyle(Qt::SolidPattern); - pen.setColor(chiter->m_Color); - pen.setBrush(brush); - p.setPen(pen); - - { - float start(0.0f), last(0.0f), current(0.0f); - TransformResult startTR, lastTR; - - AZStd::vector< AZStd::pair >::iterator datiter = cptr.m_Data.begin(); - if (datiter != cptr.m_Data.end()) - { - start = datiter->first; - last = datiter->first; - current = datiter->first; - ++datiter; - while (datiter != cptr.m_Data.end()) - { - current = datiter->first; - ++datiter; - if ((current == last + 1) && (datiter != cptr.m_Data.end())) - { - last = current; - } - else - { - QPoint drawPtS, drawPtL; - startTR = Transform(start, drawPtS); - lastTR = Transform(last, drawPtL); - - if ((startTR == INSIDE_RANGE && lastTR == INSIDE_RANGE) || (startTR != lastTR)) - { - p.fillRect(m_Inset.x() + drawPtS.x(), m_Inset.y() + chidx * barHeight + 1, drawPtL.x() - drawPtS.x() + drawWidth, barHeight, chiter->m_Color); - } - - start = current; - last = current; - } - } - - QPoint drawPtS, drawPtL; - startTR = Transform(start, drawPtS); - lastTR = Transform(last, drawPtL); - if ((startTR == INSIDE_RANGE && lastTR == INSIDE_RANGE) || (startTR != lastTR)) - { - p.fillRect(m_Inset.x() + drawPtS.x(), m_Inset.y() + chidx * barHeight + 1, drawPtL.x() - drawPtS.x() + drawWidth, barHeight, chiter->m_Color); - } - } - } - - // draw the name of the current channel as a highlight: - if (chidx == m_iChannelHighlight) - { - QRect textRect(m_Inset.x() + 8, m_Inset.y() + chidx * barHeight + 1, m_Inset.width() - 16, barHeight); - p.setPen(QPen(QColor(255, 255, 255, 255))); - QRect bound = p.boundingRect(textRect, Qt::AlignVCenter | Qt::AlignLeft, cptr.m_Name); - bound.adjust(-2, -2, 2, 2); - p.fillRect(bound, QColor(0, 0, 0, 128)); - p.drawText(textRect, Qt::AlignVCenter | Qt::AlignLeft, cptr.m_Name); - } - } - - pen.setStyle(Qt::SolidLine); - brush.setStyle(Qt::SolidPattern); - brush.setColor(Qt::black); - pen.setColor(Qt::black); - p.setPen(pen); - - if (drawWidth >= m_ZoomLimit) - { - for (float tickWalker = floorf(m_Axis->GetWindowMin()); tickWalker < ceilf(m_Axis->GetWindowMax()); tickWalker += 1.0f) - { - QPoint markerPt; - if (Transform(tickWalker, markerPt) == INSIDE_RANGE) - { - p.drawLine(m_Inset.x() + markerPt.x(), 0, m_Inset.x() + markerPt.x(), m_Inset.y() + m_Inset.height()); - } - } - } - - brush.setStyle(Qt::Dense2Pattern); - brush.setColor(m_MarkerColor); - pen.setColor(m_MarkerColor); - p.setPen(pen); - - QPoint markerPt; - if (Transform(m_MarkerPosition + 0.5f, markerPt) == INSIDE_RANGE) - { - int xDrawPos = m_Inset.x() + markerPt.x(); - int yDrawPos = m_Inset.y() + m_Inset.height(); - p.drawLine(xDrawPos, 0, xDrawPos, m_Inset.y() + m_Inset.height()); - - // event ID overlay at the bottom of the bar - const float frameWidth = 10.0f; - QPen selPen (QColor(255, 255, 255, 255)); - selPen.setWidth(1); - p.setPen(selPen); - p.setBrush(QColor(0, 0, 0, 255)); - int xOffset = xDrawPos - (int)frameWidth < 0 ? xDrawPos + (int)frameWidth : 0; - xOffset = xDrawPos + xOffset + (int)(frameWidth * 7.0f) > m_Inset.width() ? (int)(-frameWidth * 7.0f) : xOffset; - p.drawRect(xDrawPos - (int)frameWidth + xOffset, yDrawPos - 8, (int)(frameWidth * 7.0f), 16); - p.setBrush(QColor(255, 255, 255, 255)); - int eventNum = (int)(m_MarkerPosition); - - QString frameText = DrillerCharts::FriendlyFormat((AZ::s64)eventNum); - - p.drawText(xDrawPos - (int)frameWidth + 2 + xOffset, yDrawPos + 4, frameText); - } - } - } - - void DataRacetrack::RenderHorizCallouts(QPainter* painter) - { - float textSpaceRequired = (float)painter->fontMetrics().horizontalAdvance("9,999,999.99"); - int fontH = painter->fontMetrics().height(); - - AZStd::vector divisions; - divisions.reserve(10); - m_Axis->ComputeAxisDivisions((float)m_Inset.width(), divisions, textSpaceRequired, textSpaceRequired, false); - - QPen dottedPen; - dottedPen.setStyle(Qt::DotLine); - dottedPen.setColor(QColor(64, 64, 64, 255)); - dottedPen.setWidth(1); - QBrush solidBrush; - QPen solidPen; - solidPen.setStyle(Qt::SolidLine); - solidPen.setColor(QColor(0, 255, 255, 255)); - solidPen.setWidth(1); - - for (auto it = divisions.begin(); it != divisions.end(); ++it) - { - float currentUnit = *it; - QPoint leftEdge; - - // offset by a half becuase we want to slice through the middle of these event tracks. - currentUnit += 0.5f; - - Transform(currentUnit, leftEdge); - - currentUnit -= 0.5f; - - leftEdge += m_Inset.topLeft(); - - QPoint leftline((int)leftEdge.x(), m_Inset.bottom()); - QPoint leftend = leftline - QPoint(0, m_Inset.height()); - painter->setPen(dottedPen); - painter->drawLine(leftline, leftend); - - QString text; - text = QString("%1").number(currentUnit, 'f', 0); - - int textW = painter->fontMetrics().horizontalAdvance(text); - - painter->setPen(solidPen); - painter->drawText((int)leftEdge.x() - textW / 2, m_Inset.bottom() + fontH, text); - } - } - - - void DataRacetrack::DrawRotatedText(QString text, QPainter* painter, float degrees, int x, int y, float scale) - { - painter->save(); - painter->translate(x, y); - painter->scale(scale, scale); - painter->rotate(degrees); - painter->drawText(0, 0, text); - painter->restore(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/RacetrackChart.hxx b/Code/Tools/Standalone/Source/Driller/RacetrackChart.hxx deleted file mode 100644 index ee4610bcdc..0000000000 --- a/Code/Tools/Standalone/Source/Driller/RacetrackChart.hxx +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef RACETRACKCHART_H -#define RACETRACKCHART_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include "Source/Driller/DrillerDataTypes.h" -#endif - -namespace Charts -{ - class Axis; -} - - -namespace Racetrack -{ - typedef enum - { - OUTSIDE_LEFT = -1, - INSIDE_RANGE = 0, - OUTSIDE_RIGHT = 1, - INVALID_RANGE = 2 - } TransformResult; - - struct Channel - { - AZ_CLASS_ALLOCATOR(Channel,AZ::SystemAllocator,0); - Channel() : m_Color(QColor(255,255,0,255)) {} - - void SetName( QString name ) { m_Name = name; } - void SetColor( QColor &color ) { m_Color = color; } - - QString m_Name; - AZStd::vector< AZStd::pair > m_Data; - QColor m_Color; - }; - - - class DataRacetrack - : public QWidget - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(DataRacetrack,AZ::SystemAllocator,0); - DataRacetrack( QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~DataRacetrack(void); - - void SetupAxis(QString label, float minimum, float maximum, bool locked = true ); - - int AddChannel( QString name ); - void AddData( int channelID, float h, float v = 0.0f ); - void Clear(); - void ClearData( int channelID ); - void SetChannelColor( int channelID, QColor color ); - void SetZoomLimit( float limit ); - void SetZeroBasedAxisNumbering( bool tf ); - - void SetMarkerColor(QColor qc); - void SetMarkerPosition(float qposn); - - Charts::Axis *GetAxis() const; - public slots: - - protected: - virtual void wheelEvent ( QWheelEvent * event ); - virtual void mouseMoveEvent ( QMouseEvent * event ); - virtual void mousePressEvent ( QMouseEvent * event ); - virtual void mouseReleaseEvent ( QMouseEvent * event ); - virtual void resizeEvent( QResizeEvent * event ); - virtual void leaveEvent(QEvent *); - - protected: - int m_InsetL; - int m_InsetR; - int m_InsetT; - int m_InsetB; - QRect m_Inset; - float m_ZoomLimit; - - typedef AZStd::vector Channels; - Channels m_Channels; - QPoint m_DragTracker; - - bool m_IsDragging; - bool m_IsLeftDragging; - - Charts::Axis *m_Axis; - // first submission = horizontal - - QColor m_MarkerColor; - float m_MarkerPosition; - bool m_ZeroBasedAxisDisplay; - int m_iChannelHighlight; - - // internal ops - virtual void paintEvent(QPaintEvent *event); - void DrawRotatedText(QString text, QPainter *painter, float degrees, int x, int y, float scale = 1.0f); - void RecurseVert(QPainter *painter, float step, float ratio ); - void RenderHorizCallouts( QPainter *painter ); - void RecalculateInset(); - void Zoom( QPoint pt, int steps ); - void Drag( int deltaX); - QPoint Transform( float h ); - TransformResult Transform( float h, QPoint &outQPoint ); - - public slots: - void OnAxisInvalidated(); - -signals: - void EventRequestEventFocus(Driller::EventNumberType); - }; - -} - - -#endif //RACETRACKCHART_H diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.cpp deleted file mode 100644 index 09cda0d0b8..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.cpp +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "VRAMDataAggregator.hxx" -#include -#include "VRAMEvents.h" -#include -#include -#include "Source/Driller/Workspaces/Workspace.h" - -namespace Driller -{ - namespace VRAM - { - //========================================================================= - - enum class ExportField - { - RESOURCE_NAME, - ALLOCATION_SIZE, - UNKNOWN - }; - - /** - * VRAM CSV export settings - */ - class VRAMExportSettings - : public GenericCSVExportSettings - { - public: - AZ_CLASS_ALLOCATOR(VRAMExportSettings, AZ::SystemAllocator, 0); - - VRAMExportSettings() - { - m_columnDescriptors = - { - {ExportField::RESOURCE_NAME, "Resource Name"}, - {ExportField::ALLOCATION_SIZE, "VRAM Allocation Size"}, - }; - - m_exportOrdering = - { - ExportField::RESOURCE_NAME, - ExportField::ALLOCATION_SIZE, - }; - - for (const AZStd::pair< ExportField, AZStd::string >& item : m_columnDescriptors) - { - m_stringToExportEnum[item.second] = item.first; - } - } - - virtual void GetExportItems(QStringList& items) const - { - for (const AZStd::pair< ExportField, AZStd::string>& item : m_columnDescriptors) - { - items.push_back(QString(item.second.c_str())); - } - } - - virtual void GetActiveExportItems(QStringList& items) const - { - for (ExportField currentField : m_exportOrdering) - { - if (currentField != ExportField::UNKNOWN) - { - items.push_back(QString(FindColumnDescriptor(currentField).c_str())); - } - } - } - - const AZStd::vector< ExportField >& GetExportOrder() const - { - return m_exportOrdering; - } - - const AZStd::string& FindColumnDescriptor(ExportField exportField) const - { - static const AZStd::string emptyDescriptor; - - AZStd::unordered_map::const_iterator descriptorIter = m_columnDescriptors.find(exportField); - - if (descriptorIter == m_columnDescriptors.end()) - { - AZ_Warning("Standalone Tools", false, "Unknown column descriptor in VRAM CSV Export"); - return emptyDescriptor; - } - else - { - return descriptorIter->second; - } - } - - protected: - virtual void UpdateExportOrdering(const QStringList& activeItems) - { - m_exportOrdering.clear(); - - for (const QString& activeItem : activeItems) - { - ExportField field = FindExportFieldFromDescriptor(activeItem.toStdString().c_str()); - - AZ_Warning("Standalone Tools", field != ExportField::UNKNOWN, "Unknown descriptor %s", activeItem.toStdString().c_str()); - if (field != ExportField::UNKNOWN) - { - m_exportOrdering.push_back(field); - } - } - } - - private: - ExportField FindExportFieldFromDescriptor(const char* columnDescriptor) const - { - AZStd::unordered_map::const_iterator exportIter = m_stringToExportEnum.find(columnDescriptor); - - ExportField retVal = ExportField::UNKNOWN; - - if (exportIter != m_stringToExportEnum.end()) - { - retVal = exportIter->second; - } - - return retVal; - } - - AZStd::unordered_map< ExportField, AZStd::string > m_columnDescriptors; - AZStd::unordered_map< AZStd::string, ExportField > m_stringToExportEnum; - AZStd::vector< ExportField > m_exportOrdering; - }; - - //========================================================================= - - VRAMDataAggregator::VRAMDataAggregator(int identity) - : Aggregator(identity) - { - m_parser.SetAggregator(this); - m_csvExportSettings = aznew VRAMExportSettings(); - } - - VRAMDataAggregator::~VRAMDataAggregator() - { - delete m_csvExportSettings; - } - - float VRAMDataAggregator::ValueAtFrame(FrameNumberType frame) - { - const float maxEventsPerFrame = 1000.0f; // just a scale number - float numEventsPerFrame = static_cast(NumOfEventsAtFrame(frame)); - return AZStd::GetMin(numEventsPerFrame / maxEventsPerFrame, 1.0f) * 2.0f - 1.0f; - } - - QColor VRAMDataAggregator::GetColor() const - { - return QColor(0, 255, 255); - } - - QString VRAMDataAggregator::GetName() const - { - return "VRAM"; - } - - QString VRAMDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString VRAMDataAggregator::GetDescription() const - { - return "VRAM allocations driller"; - } - - QString VRAMDataAggregator::GetToolTip() const - { - return "Information about VRAM allocations"; - } - - AZ::Uuid VRAMDataAggregator::GetID() const - { - return AZ::Uuid("{9D895E46-6CF7-4AA1-AC8F-79D8B6FB202E}"); - } - - bool VRAMDataAggregator::RegisterCategory(AZ::u32 categoryId, CategoryInfo* categoryInfo) - { - for (CategoryInfoArrayType::iterator iter = m_categories.begin(); iter != m_categories.end(); ++iter) - { - if ((*iter)->m_categoryId == categoryId) - { - AZ_Assert(0, "Category %u has already been registered", categoryId); - return false; - } - } - - m_categories.push_back(categoryInfo); - return true; - } - - bool VRAMDataAggregator::UnregisterCategory(AZ::u32 categoryId) - { - for (CategoryInfoArrayType::iterator iter = m_categories.begin(); iter != m_categories.end(); ++iter) - { - if ((*iter)->m_categoryId == categoryId) - { - m_categories.erase(iter); - return true; - } - } - - AZ_Assert(0, "Attempting to unregister a category %u which has not been registered", categoryId); - return false; - } - - CategoryInfo* VRAMDataAggregator::FindCategory(AZ::u32 categoryId) - { - for (CategoryInfoArrayType::iterator iter = m_categories.begin(); iter != m_categories.end(); ++iter) - { - if ((*iter)->m_categoryId == categoryId) - { - return (*iter); - } - } - return nullptr; - } - - AllocationInfo* VRAMDataAggregator::FindAndRemoveAllocation(AZ::u64 address) - { - for (CategoryInfoArrayType::iterator iter = m_categories.begin(); iter != m_categories.end(); ++iter) - { - CategoryInfo* category = *iter; - AllocationMapType::iterator allocIt = category->m_allocations.find(address); - if (allocIt != category->m_allocations.end()) - { - AllocationInfo* allocInfo = allocIt->second; - - // Deallocation, so subtract and remove from the allocation table - category->m_allocatedMemory -= allocInfo->m_size; - category->m_allocations.erase(address); - - return allocInfo; - } - } - - return nullptr; - } - - void VRAMDataAggregator::Reset() - { - m_categories.clear(); - } - - //========================================================================= - - CustomizeCSVExportWidget* VRAMDataAggregator::CreateCSVExportCustomizationWidget() - { - return aznew GenericCustomizeCSVExportWidget(*m_csvExportSettings); - } - - void VRAMDataAggregator::ExportCategoryHeaderToCSV(AZ::IO::SystemFile& file) - { - const AZStd::string categoryHeader = AZStd::string("Category,Number of Allocations, Memory Usage,\n"); - file.Write(categoryHeader.c_str(), categoryHeader.size()); - - for (VRAM::CategoryInfo* currentCategory : m_categories) - { - const AZStd::string categoryInfo = AZStd::string::format("%s,%zu,%zu,\n", currentCategory->m_categoryName, currentCategory->m_allocations.size(), currentCategory->m_allocatedMemory); - file.Write(categoryInfo.c_str(), categoryInfo.size()); - } - - file.Write("\n", 1); - } - - void VRAMDataAggregator::ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) - { - // Write the category information at the top of the file - ExportCategoryHeaderToCSV(file); - - VRAMExportSettings* vramExportSettings = static_cast(exportSettings); - const AZStd::vector< ExportField >& exportOrdering = vramExportSettings->GetExportOrder(); - - bool addComma = false; - - // Now export all of our VRAM allocations - for (ExportField currentField : exportOrdering) - { - if (addComma) - { - file.Write(",", 1); - } - - const AZStd::string& columnDescriptor = vramExportSettings->FindColumnDescriptor(currentField); - file.Write(columnDescriptor.c_str(), columnDescriptor.size()); - addComma = true; - } - - file.Write("\n", 1); - } - - void VRAMDataAggregator::ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) - { - // We don't care about logging the category registration events - if (azrtti_istypeof(drillerEvent)) - { - return; - } - - bool isDeallocation = azrtti_istypeof(drillerEvent); - AZ_Assert(azrtti_istypeof(drillerEvent) || isDeallocation, "Invalid Event"); - - const VRAM::AllocationInfo* allocationInformation = nullptr; - if (isDeallocation) - { - const VRAMDrillerUnregisterAllocationEvent* vramDeallocationEvent = static_cast(drillerEvent); - allocationInformation = vramDeallocationEvent->m_removedAllocationInfo; - } - else - { - const VRAMDrillerRegisterAllocationEvent* vramAllocationEvent = static_cast(drillerEvent); - allocationInformation = &vramAllocationEvent->m_allocationInfo; - } - - if (allocationInformation == nullptr) - { - AZ_Warning("System", 0, "Error: Allocation information not found for VRAM tracking event"); - return; - } - - VRAMExportSettings* vramExportSettings = static_cast(exportSettings); - const AZStd::vector< ExportField >& exportOrdering = vramExportSettings->GetExportOrder(); - - bool addComma = false; - AZStd::string field; - - for (ExportField currentField : exportOrdering) - { - if (addComma) - { - file.Write(",", 1); - } - - switch (currentField) - { - case ExportField::RESOURCE_NAME: - { - field = allocationInformation->m_name; - break; - } - case ExportField::ALLOCATION_SIZE: - { - if (isDeallocation) - { - field = AZStd::string::format("-%llu", allocationInformation->m_size); - } - else - { - field = AZStd::string::format("%llu", allocationInformation->m_size); - } - break; - } - default: - AZ_Warning("Standalone Tools", false, "Unknown Export Field for VRAMDataAggreagtor"); - break; - } - - file.Write(field.c_str(), field.length()); - addComma = true; - } - - file.Write("\n", 1); - } - - //========================================================================= - } // namespace VRAM -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.hxx deleted file mode 100644 index ae1d544e89..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataAggregator.hxx +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_VRAM_DATAAGGREGATOR_H -#define DRILLER_VRAM_DATAAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/DrillerAggregatorOptions.hxx" -#include "Source/Driller/GenericCustomizeCSVExportWidget.hxx" -#include "VRAMDataParser.h" -#include "AzCore/std/string/string.h" -#include "AzCore/RTTI/RTTI.h" -#endif - -namespace Driller -{ - namespace VRAM - { - //========================================================================= - - struct CategoryInfo; - typedef AZStd::list CategoryInfoArrayType; - - /** - * VRAM data drilling aggregator - */ - class VRAMDataAggregator - : public Aggregator - { - Q_OBJECT; - public: - AZ_RTTI(VRAMDataAggregator, "{D17F2623-A980-4A08-9CEB-B8F89C811C1C}"); - AZ_CLASS_ALLOCATOR(VRAMDataAggregator, AZ::SystemAllocator, 0); - - VRAMDataAggregator(int identity = 0); - virtual ~VRAMDataAggregator(); - - static AZ::u32 DrillerId() - { - return VRAMDrillerHandlerParser::GetDrillerId(); - } - - AZ::u32 GetDrillerId() const override - { - return DrillerId(); - } - - static const char* ChannelName() - { - return "VRAM"; - } - - AZ::Crc32 GetChannelId() const override - { - return AZ::Crc32(ChannelName()); - } - - AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() override - { - return &m_parser; - } - - bool CanExportToCSV() const override - { - return true; - } - - CustomizeCSVExportWidget* CreateCSVExportCustomizationWidget(); - - bool RegisterCategory(AZ::u32 categoryId, CategoryInfo* categoryInfo); - bool UnregisterCategory(AZ::u32 categoryId); - CategoryInfo* FindCategory(AZ::u32 categoryId); - - // Search all categories for this address, remove it from the hash table and return its allocation info. - struct AllocationInfo* FindAndRemoveAllocation( AZ::u64 address ); - - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) override {} - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*) override {} - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*) override {} - - void Reset() override; - - public slots: - float ValueAtFrame(FrameNumberType frame) override; - QColor GetColor() const override; - QString GetChannelName() const override; - QString GetName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - void OptionsRequest() override {} - QWidget* DrillDownRequest(FrameNumberType frame) override - { - // Create a Qt view window to show a graph view of the VRAM usage - (void)frame; - return nullptr; - } - - protected: - void ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) override; - void ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) override; - void ExportCategoryHeaderToCSV(AZ::IO::SystemFile& file); - - class VRAMExportSettings* m_csvExportSettings; - VRAMDrillerHandlerParser m_parser; - - // Different categories of VRAM allocations and all of the allocations that live in that category. - CategoryInfoArrayType m_categories; - }; - - //========================================================================= - } // namespace VRAM -} // namespace Driller - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.cpp deleted file mode 100644 index 419f48d9a3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "VRAMDataParser.h" -#include "VRAMDataAggregator.hxx" -#include "VRAMEvents.h" - -namespace Driller -{ - namespace VRAM - { - AZ::Debug::DrillerHandlerParser* VRAMDrillerHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid VRAM aggregator before we can process the data!"); - - if (tagName == AZ_CRC("RegisterAllocation", 0x992a9780)) - { - m_subTag = ST_REGISTER_ALLOCATION; - m_data->AddEvent(aznew VRAMDrillerRegisterAllocationEvent()); - return this; - } - else if (tagName == AZ_CRC("UnRegisterAllocation", 0xea5dc4cd)) - { - m_subTag = ST_UNREGISTER_ALLOCATION; - m_data->AddEvent(aznew VRAMDrillerUnregisterAllocationEvent()); - return this; - } - else if (tagName == AZ_CRC("RegisterCategory")) - { - m_subTag = ST_REGISTER_CATEGORY; - m_data->AddEvent(aznew VRAMDrillerRegisterCategoryEvent()); - return this; - } - else if (tagName == AZ_CRC("UnregisterCategory")) - { - m_subTag = ST_UNREGISTER_CATEGORY; - m_data->AddEvent(aznew VRAMDrillerUnregisterCategoryEvent()); - return this; - } - else - { - m_subTag = ST_NONE; - } - return NULL; - } - - void VRAMDrillerHandlerParser::OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)tagName; - if (handler != NULL) - { - m_subTag = ST_NONE; // we have only one level just go back to the default state - } - } - - void VRAMDrillerHandlerParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid VRAM aggregator before we can process the data!"); - - switch (m_subTag) - { - case ST_REGISTER_ALLOCATION: - { - VRAMDrillerRegisterAllocationEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Category")) - { - dataNode.Read(event->m_allocationInfo.m_category); - } - else if (dataNode.m_name == AZ_CRC("Subcategory")) - { - dataNode.Read(event->m_allocationInfo.m_subcategory); - } - else if (dataNode.m_name == AZ_CRC("Address", 0x0d4e6f81)) - { - dataNode.Read(event->m_address); - } - else if (dataNode.m_name == AZ_CRC("Size", 0xf7c0246a)) - { - dataNode.Read(event->m_allocationInfo.m_size); - } - else if (dataNode.m_name == AZ_CRC("Name", 0x5e237e06)) - { - event->m_allocationInfo.m_name = dataNode.ReadPooledString(); - } - } - break; - - case ST_UNREGISTER_ALLOCATION: - { - VRAMDrillerUnregisterAllocationEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Address", 0x0d4e6f81)) - { - dataNode.Read(event->m_address); - } - } - break; - - case ST_REGISTER_CATEGORY: - { - VRAMDrillerRegisterCategoryEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Category")) - { - dataNode.Read(event->m_categoryId); - event->m_categoryInfo.m_categoryId = event->m_categoryId; - } - else if (dataNode.m_name == AZ_CRC("CategoryName")) - { - event->m_categoryInfo.m_categoryName = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("SubcategoryId")) - { - // NOTE: "SubcategoryId" and "SubcategoryName" have to be done in two separate Read events. - // The SubcategoryId read will create a SubcategoryInfo, and we assume when we hit SubcategoryName that we had just registered a new SubcategoryId on the previous read. - unsigned int subcategoryId = 0; - dataNode.Read(subcategoryId); - event->m_categoryInfo.m_subcategories.push_back(SubcategoryInfo(subcategoryId)); - } - else if (dataNode.m_name == AZ_CRC("SubcategoryName")) - { - AZ_Assert(event->m_categoryInfo.m_subcategories.size(), "Error: Found a SubcategoryName data tag, but did not find a previous SubcategoryId tag"); - - // Get the most recently registered subcategory - SubcategoryInfo& subcategory = event->m_categoryInfo.m_subcategories[event->m_categoryInfo.m_subcategories.size() - 1]; - AZ_Assert(subcategory.m_subcategoryName == nullptr, "Error: Subcategory 0x%08x already has a SubcategoryName", subcategory.m_subcategoryId); - - subcategory.m_subcategoryName = dataNode.ReadPooledString(); - } - } - break; - - case ST_UNREGISTER_CATEGORY: - { - VRAMDrillerUnregisterCategoryEvent* event = static_cast(m_data->GetEvents().back()); - if (dataNode.m_name == AZ_CRC("Category")) - { - dataNode.Read(event->m_categoryId); - } - } - break; - } - } - } // namespace VRAM -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.h b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.h deleted file mode 100644 index d66ac32516..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMDataParser.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_VRAM_DRILLER_PARSER_H -#define DRILLER_VRAM_DRILLER_PARSER_H - -#include - -namespace Driller -{ - namespace VRAM - { - //========================================================================= - - class VRAMDataAggregator; - - class VRAMDrillerHandlerParser - : public AZ::Debug::DrillerHandlerParser - { - public: - enum SubTags - { - ST_NONE = 0, - ST_REGISTER_ALLOCATION, - ST_UNREGISTER_ALLOCATION, - ST_REGISTER_CATEGORY, - ST_UNREGISTER_CATEGORY - }; - - VRAMDrillerHandlerParser() - : m_subTag(ST_NONE) - , m_data(NULL) - {} - - static AZ::u32 GetDrillerId() - { - return AZ_CRC("VRAMDriller"); - } - - void SetAggregator(VRAMDataAggregator* data) - { - m_data = data; - } - - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - virtual void OnExitTag(DrillerHandlerParser* handler, AZ::u32 tagName); - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - protected: - SubTags m_subTag; - VRAMDataAggregator* m_data; - }; - - //========================================================================= - } -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.cpp b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.cpp deleted file mode 100644 index b0b85beb6b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.cpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "VRAMEvents.h" -#include "VRAMDataAggregator.hxx" - -namespace Driller -{ - namespace VRAM - { - //========================================================================= - - CategoryInfo* GetCategory(Aggregator* data, AZ::u32 categoryId) - { - VRAMDataAggregator* aggregator = static_cast(data); - CategoryInfo* category = aggregator->FindCategory(categoryId); - - if (category == nullptr) - { - AZ_Assert(false, "VRAMDriller - Invalid Category"); - return nullptr; - } - return category; - } - - //========================================================================= - - void VRAMDrillerRegisterAllocationEvent::StepForward(Aggregator* data) - { - CategoryInfo* m_categoryInfo = GetCategory(data, m_allocationInfo.m_category); - if (!m_categoryInfo) - { - return; - } - - // Add the allocation - m_categoryInfo->m_allocations.insert(AZStd::make_pair(m_address, &m_allocationInfo)); - m_categoryInfo->m_allocatedMemory += m_allocationInfo.m_size; - } - - void VRAMDrillerRegisterAllocationEvent::StepBackward(Aggregator* data) - { - CategoryInfo* m_categoryInfo = GetCategory(data, m_allocationInfo.m_category); - if (!m_categoryInfo) - { - return; - } - - // Remove the allocation - m_categoryInfo->m_allocations.erase(m_address); - m_categoryInfo->m_allocatedMemory -= m_allocationInfo.m_size; - } - - //========================================================================= - - void VRAMDrillerUnregisterAllocationEvent::StepForward(Aggregator* data) - { - VRAMDataAggregator* aggregator = static_cast(data); - m_removedAllocationInfo = aggregator->FindAndRemoveAllocation(m_address); - - if (!m_removedAllocationInfo) - { - AZ_Warning("System", 0, "Error: Allocation not found for VRAMDrillerUnregisterAllocationEvent"); - } - } - - void VRAMDrillerUnregisterAllocationEvent::StepBackward(Aggregator* data) - { - if (m_removedAllocationInfo == nullptr) - { - AZ_Warning("System", 0, "Error: Allocation not found for VRAMDrillerUnregisterAllocationEvent"); - return; - } - - CategoryInfo* m_categoryInfo = GetCategory(data, m_removedAllocationInfo->m_category); - if (!m_categoryInfo) - { - return; - } - - // "Reallocation" - auto insertionPair = AZStd::make_pair(m_address, m_removedAllocationInfo); - m_categoryInfo->m_allocations.insert(insertionPair); - - // The opposite of deallocation, which is allocating, so we add: - m_categoryInfo->m_allocatedMemory += m_removedAllocationInfo->m_size; - } - - //========================================================================= - - void VRAMDrillerRegisterCategoryEvent::StepForward(Aggregator* data) - { - VRAMDataAggregator* aggregator = static_cast(data); - aggregator->RegisterCategory(m_categoryId, &m_categoryInfo); - } - - void VRAMDrillerRegisterCategoryEvent::StepBackward(Aggregator* data) - { - VRAMDataAggregator* aggregator = static_cast(data); - aggregator->UnregisterCategory(m_categoryId); - } - - //========================================================================= - - void VRAMDrillerUnregisterCategoryEvent::StepForward(Aggregator* data) - { - // TODO: Need to get m_unregisteredCategoryInfo from the category we are unregistering so we can re-register the category on StepBackward - VRAMDataAggregator* aggregator = static_cast(data); - aggregator->UnregisterCategory(m_categoryId); - } - - void VRAMDrillerUnregisterCategoryEvent::StepBackward(Aggregator* data) - { - VRAMDataAggregator* aggregator = static_cast(data); - aggregator->RegisterCategory(m_categoryId, &m_unregisteredCategoryInfo); - } - - //========================================================================= - } // namespace VRAM -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.h b/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.h deleted file mode 100644 index 88cb6a69e4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Rendering/VRAM/VRAMEvents.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_VRAM_EVENTS_H -#define DRILLER_VRAM_EVENTS_H - -#include "Source/Driller/DrillerEvent.h" -#include - -namespace Driller -{ - namespace VRAM - { - //========================================================================= - - struct AllocationInfo - { - // This is an index for which category this allocation belongs to - AZ::u32 m_category = 0; - - // This is an index for which subcategory this allocation belongs to - AZ::u32 m_subcategory = 0; - - const char* m_name = nullptr; - AZ::u64 m_size = 0; - }; - - struct SubcategoryInfo - { - SubcategoryInfo(AZ::u32 subcategoryId) - : m_subcategoryId(subcategoryId) - {} - - SubcategoryInfo(AZ::u32 subcategoryId, const char* subcategoryName) - : m_subcategoryId(subcategoryId) - , m_subcategoryName(subcategoryName) - {} - - AZ::u32 m_subcategoryId = 0; - const char* m_subcategoryName = nullptr; - }; - - typedef AZStd::unordered_map AllocationMapType; - typedef AZStd::vector SubcategoryVectorType; - - struct CategoryInfo - { - const char* m_categoryName = nullptr; - AZ::u32 m_categoryId = 0; - - // The total amount of memory allocated for this category. - // Note that this amount may be different - size_t m_allocatedMemory = 0; - - // Map of all allocations - AllocationMapType m_allocations; - - // Container of all subcategories - SubcategoryVectorType m_subcategories; - }; - - enum VRAMEventType - { - ET_REGISTER_ALLOCATION, - ET_UNREGISTER_ALLOCATION, - ET_REGISTER_CATEGORY, - ET_UNREGISTER_CATEGORY - }; - - //========================================================================= - - class VRAMDrillerRegisterAllocationEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(VRAMDrillerRegisterAllocationEvent, AZ::SystemAllocator, 0) - AZ_RTTI(VRAMDrillerRegisterAllocationEvent, "{458DE527-390F-479E-A5AA-408EF44DB93F}", DrillerEvent); - - VRAMDrillerRegisterAllocationEvent() - : DrillerEvent(VRAM::ET_REGISTER_ALLOCATION) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_address = 0; - VRAM::AllocationInfo m_allocationInfo; - }; - - //========================================================================= - - class VRAMDrillerUnregisterAllocationEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(VRAMDrillerUnregisterAllocationEvent, AZ::SystemAllocator, 0) - AZ_RTTI(VRAMDrillerUnregisterAllocationEvent, "{674F8DE3-11C1-4B1E-B0A5-EB45B5F72F68}", DrillerEvent); - - VRAMDrillerUnregisterAllocationEvent() - : DrillerEvent(VRAM::ET_UNREGISTER_ALLOCATION) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u64 m_address = 0; - AllocationInfo* m_removedAllocationInfo = nullptr; - }; - - //========================================================================= - - class VRAMDrillerRegisterCategoryEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(VRAMDrillerRegisterCategoryEvent, AZ::SystemAllocator, 0) - AZ_RTTI(VRAMDrillerUnregisterAllocationEvent, "{F024BA49-E8C9-4699-B999-9E6F988CFF8E}", DrillerEvent); - - VRAMDrillerRegisterCategoryEvent() - : DrillerEvent(VRAM::ET_REGISTER_CATEGORY) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u32 m_categoryId = 0; - CategoryInfo m_categoryInfo; - }; - - //========================================================================= - - class VRAMDrillerUnregisterCategoryEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(VRAMDrillerUnregisterCategoryEvent, AZ::SystemAllocator, 0) - AZ_RTTI(VRAMDrillerUnregisterCategoryEvent, "{6549C4A4-70E4-47AD-8688-47C00543197A}", DrillerEvent); - - VRAMDrillerUnregisterCategoryEvent() - : DrillerEvent(VRAM::ET_UNREGISTER_CATEGORY) - {} - - virtual void StepForward(Aggregator* data); - virtual void StepBackward(Aggregator* data); - - AZ::u32 m_categoryId = 0; - CategoryInfo m_unregisteredCategoryInfo; - }; - - //========================================================================= - } // namespace VRAM -} // namespace Driller - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.h b/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.h deleted file mode 100644 index 2db8966a2e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.h +++ /dev/null @@ -1,674 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_BASEDETAILVIEW_H -#define DRILLER_REPLICA_BASEDETAILVIEW_H - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include - -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/Replica/BaseDetailViewQObject.hxx" -#include "Source/Driller/Replica/ReplicaBandwidthChartData.h" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Replica/ReplicaDisplayTypes.h" -#include "Source/Driller/Replica/ReplicaDataView.hxx" -#include "Source/Driller/Replica/ReplicaTreeViewModel.hxx" -#include "Source/Driller/Replica/BaseDetailViewSavedState.h" - -#include - -namespace Driller -{ - template - class BaseDetailTreeViewModel; - - template - class BaseDetailView - : public BaseDetailViewQObject - { - typedef AZStd::unordered_set IdSet; - - friend class BaseDetailTreeViewModel; - friend class ReplicaDataView; - - protected: - - enum class DisplayMode - { - Unknown = -2, - Start, - Active, - Aggregate, - End - }; - - enum class DetailMode - { - Unknown = -2, - Start, - Low, - Medium, - High, - End - }; - - public: - AZ_CLASS_ALLOCATOR(BaseDetailView, AZ::SystemAllocator, 0); - - BaseDetailView(ReplicaDataView* replicaDataView) - : BaseDetailViewQObject(nullptr) - , m_displayMode(DisplayMode::Unknown) - , m_detailMode(DetailMode::Low) - , m_bandwidthUsageDisplayType(ReplicaDisplayTypes::BUDT_COMBINED) - , m_windowStateCRC(0) - , m_splitterStateCRC(0) - , m_treeStateCRC(0) - , m_replicaDataView(replicaDataView) - , m_gui(nullptr) - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint); - - m_gui = azcreate(Ui::BaseDetailView, ()); - m_gui->setupUi(this); - - for (int i = static_cast(DetailMode::Start) + 1; i < static_cast(DetailMode::End); ++i) - { - switch (static_cast(i)) - { - case DetailMode::High: - m_gui->graphDetailType->addItem("High"); - break; - case DetailMode::Medium: - m_gui->graphDetailType->addItem("Medium"); - break; - case DetailMode::Low: - m_gui->graphDetailType->addItem("Low"); - break; - default: - AZ_Error("Standalone Tools", false, "Unknown GraphDetailMode."); - m_gui->graphDetailType->addItem("???"); - break; - } - } - - m_gui->graphDetailType->setCurrentIndex(static_cast(m_detailMode)); - - for (int i = ReplicaDisplayTypes::BUDT_START + 1; i < ReplicaDisplayTypes::BUDT_END; ++i) - { - switch (i) - { - case ReplicaDisplayTypes::BUDT_COMBINED: - m_gui->bandwidthUsageDisplayType->addItem(ReplicaDisplayTypes::DisplayNames::BUDT_COMBINED_NAME); - break; - case ReplicaDisplayTypes::BUDT_SENT: - m_gui->bandwidthUsageDisplayType->addItem(ReplicaDisplayTypes::DisplayNames::BUDT_SENT_NAME); - break; - case ReplicaDisplayTypes::BUDT_RECEIVED: - m_gui->bandwidthUsageDisplayType->addItem(ReplicaDisplayTypes::DisplayNames::BUDT_RECEIVED_NAME); - break; - default: - AZ_Error("StandaloneTools", false, "Unknown Bandwidth Usage Display Type"); - m_gui->bandwidthUsageDisplayType->addItem("???"); - break; - } - } - - m_gui->bandwidthUsageDisplayType->setCurrentIndex(m_bandwidthUsageDisplayType); - - SetupSignals(m_replicaDataView,m_gui); - } - - void LoadSavedState() - { - m_windowStateCRC = CreateWindowGeometryCRC(); - - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (windowState) - { - windowState->RestoreGeometry(this); - } - - m_splitterStateCRC = CreateSplitterStateCRC(); - - auto splitterState = AZ::UserSettings::Find(m_splitterStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (splitterState) - { - QByteArray splitterData((const char*)splitterState->m_splitterStorage.data(), (int)splitterState->m_splitterStorage.size()); - m_gui->splitter->restoreState(splitterData); - } - - m_treeStateCRC = CreateTreeStateCRC(); - - auto treeState = AZ::UserSettings::Find(m_treeStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (treeState) - { - QByteArray treeData((const char*)treeState->m_treeColumnStorage.data(), (int)treeState->m_treeColumnStorage.size()); - m_gui->treeView->header()->restoreState(treeData); - } - } - - ~BaseDetailView() - { - // Save out whatever data we want to save out. - auto pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (pState) - { - pState->CaptureGeometry(this); - } - - auto splitterState = AZ::UserSettings::CreateFind(m_splitterStateCRC, AZ::UserSettings::CT_GLOBAL); - if (splitterState) - { - QByteArray qba = m_gui->splitter->saveState(); - splitterState->m_splitterStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - - auto treeState = AZ::UserSettings::CreateFind(m_treeStateCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - if (m_gui->treeView && m_gui->treeView->header()) - { - QByteArray qba = m_gui->treeView->header()->saveState(); - treeState->m_treeColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - if (m_replicaDataView) - { - m_replicaDataView->SignalDialogClosed(this); - } - - azdestroy(m_gui); - } - - void RedrawGraph() - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - switch (m_displayMode) - { - case DisplayMode::Active: - DrawActiveGraph(); - break; - case DisplayMode::Aggregate: - DrawAggregateGraph(); - break; - default: - AZ_Error("BaseDetailView", false, "Trying to display unknown graph configuration."); - } - } - - void SetupTreeView() - { - m_gui->treeView->reset(); - - m_gui->treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); - m_gui->treeView->setExpandsOnDoubleClick(false); - - - m_gui->treeView->header()->setSectionResizeMode(QHeaderView::Interactive); - m_gui->treeView->header()->setStretchLastSection(false); - - OnSetupTreeView(); - SetupTreeViewSignals(m_gui->treeView); - } - - public: - virtual const typename ReplicaBandwidthChartData::FrameMap & GetFrameData() const = 0; - virtual BaseDetailDisplayHelper* FindDetailDisplay(const Key& id) = 0; - virtual const BaseDetailDisplayHelper* FindDetailDisplay(const Key& id) const = 0; - - virtual BaseDetailDisplayHelper* FindAggregateDisplay() { return nullptr; } - virtual Key FindAggregateID() const { return Key(); } - - protected: - void OnDataRangeChanged() override - { - InitializeDisplayData(); - RedrawGraph(); - ShowTreeFrame(m_replicaDataView->GetCurrentFrame()); - } - - void SetAllEnabled(bool enabled) override - { - BaseDetailDisplayHelper* aggregateDisplay = FindAggregateDisplay(); - - if (aggregateDisplay) - { - aggregateDisplay->m_graphEnabled = enabled; - - BaseDisplayHelper* displayHelper = aggregateDisplay->GetDataSetDisplayHelper(); - displayHelper->m_graphEnabled = false; - - const AZStd::vector< BaseDisplayHelper* >& dataSets = displayHelper->GetChildren(); - - for (BaseDisplayHelper* dataSet : dataSets) - { - dataSet->m_graphEnabled = enabled; - } - - displayHelper = aggregateDisplay->GetRPCDisplayHelper(); - displayHelper->m_graphEnabled = false; - - const AZStd::vector< BaseDisplayHelper* >& rpcs = displayHelper->GetChildren(); - - for (BaseDisplayHelper* rpc : rpcs) - { - rpc->m_graphEnabled = enabled; - } - } - - for (Key& currentId : m_activeIds) - { - BaseDetailDisplayHelper* detailHelper = FindDetailDisplay(currentId); - detailHelper->m_graphEnabled = enabled; - - BaseDisplayHelper* displayHelper = detailHelper->GetDataSetDisplayHelper(); - displayHelper->m_graphEnabled = enabled; - - const AZStd::vector< BaseDisplayHelper* >& dataSets = displayHelper->GetChildren(); - - for (BaseDisplayHelper* dataSet : dataSets) - { - dataSet->m_graphEnabled = enabled; - } - - displayHelper = detailHelper->GetRPCDisplayHelper(); - displayHelper->m_graphEnabled = enabled; - - const AZStd::vector< BaseDisplayHelper* >& rpcs = displayHelper->GetChildren(); - - for (BaseDisplayHelper* rpc : rpcs) - { - rpc->m_graphEnabled = enabled; - } - } - - LayoutChanged(); - RedrawGraph(); - } - - void SetSelectedEnabled(bool enabled) override - { - QModelIndexList selection = m_gui->treeView->selectionModel()->selectedIndexes(); - - for (QModelIndex& index : selection) - { - static_cast(index.internalPointer())->m_graphEnabled = enabled; - } - - LayoutChanged(); - RedrawGraph(); - } - - void OnCollapseAll() override - { - m_gui->treeView->collapseAll(); - } - - void OnExpandAll() override - { - m_gui->treeView->expandAll(); - } - - void OnDoubleClicked(const QModelIndex& clickedIndex) override - { - if (!clickedIndex.isValid()) - { - return; - } - - BaseDisplayHelper* displayHelper = static_cast(clickedIndex.internalPointer()); - - displayHelper->m_graphEnabled = !displayHelper->m_graphEnabled; - - LayoutChanged(); - RedrawGraph(); - } - - void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override - { - for (const QModelIndex& selectedIndex : selected.indexes()) - { - BaseDisplayHelper* displayHelper = static_cast(selectedIndex.internalPointer()); - - displayHelper->m_selected = true; - displayHelper->m_areaGraphPlotHelper.SetHighlighted(displayHelper->m_selected); - } - - for (const QModelIndex& deselectedIndex : deselected.indexes()) - { - BaseDisplayHelper* displayHelper = static_cast(deselectedIndex.internalPointer()); - - displayHelper->m_selected = false; - displayHelper->m_areaGraphPlotHelper.SetHighlighted(displayHelper->m_selected); - } - } - - void OnUpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex) override - { - (void)startIndex; - (void)endIndex; - - RedrawGraph(); - } - - void OnDisplayModeChanged(int displayMode) override - { - if (displayMode > static_cast(DisplayMode::Start) && displayMode < static_cast(DisplayMode::End)) - { - if (m_displayMode != static_cast(displayMode)) - { - m_displayMode = static_cast(displayMode); - - InitializeDisplayData(); - SetupTreeView(); - RedrawGraph(); - } - } - } - - void OnGraphDetailChanged(int graphDetail) override - { - if (graphDetail > static_cast(DetailMode::Start) && graphDetail < static_cast(DetailMode::End)) - { - if (m_detailMode != static_cast(graphDetail)) - { - m_detailMode = static_cast(graphDetail); - RedrawGraph(); - } - } - } - - void OnBandwidthDisplayUsageTypeChanged(int bandwidthUsageType) - { - if (bandwidthUsageType > ReplicaDisplayTypes::BUDT_START && bandwidthUsageType < ReplicaDisplayTypes::BUDT_END) - { - if (m_bandwidthUsageDisplayType != static_cast(bandwidthUsageType)) - { - m_bandwidthUsageDisplayType = static_cast(bandwidthUsageType); - RedrawGraph(); - } - } - } - - void OnInspectedSeries(size_t seriesId) - { - (void)seriesId; - - // Nothing to see here - } - - void OnSelectedSeries(size_t seriesId, int position) - { - (void)seriesId; - - EBUS_EVENT_ID(m_replicaDataView->GetCaptureWindowIdentity(), DrillerCaptureWindowRequestBus, ScrubToFrameRequest, position); - } - - bool IsInDisplayMode(DisplayMode displayMode) - { - return m_displayMode == displayMode; - } - - protected: - - void SignalDataViewDestroyed(ReplicaDataView* dataView) - { - if (dataView == m_replicaDataView) - { - m_replicaDataView = nullptr; - } - - close(); - } - - virtual void InitializeDisplayData() = 0; - virtual void LayoutChanged() = 0; - virtual void OnSetupTreeView() = 0; - virtual void ShowTreeFrame(FrameNumberType frameId) = 0; - - virtual AZ::u32 CreateWindowGeometryCRC() = 0; - virtual AZ::u32 CreateSplitterStateCRC() = 0; - virtual AZ::u32 CreateTreeStateCRC() = 0; - - DisplayMode m_displayMode; - DetailMode m_detailMode; - - ReplicaDisplayTypes::BandwidthUsageDisplayType m_bandwidthUsageDisplayType; - - AZ::u32 m_windowStateCRC; - AZ::u32 m_splitterStateCRC; - AZ::u32 m_treeStateCRC; - - ReplicaDataView* m_replicaDataView; - IdSet m_activeIds; - IdSet m_activeInspectedIds; - Ui::BaseDetailView* m_gui; - - private: - void DrawActiveGraph(); - void DrawHighDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId); - void DrawMediumDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId); - void DrawLowDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId); - - void DrawAggregateGraph(); - - void PlotBatchedGraphData(AreaGraphPlotHelper& areaPlotHelper, FrameNumberType frameId, const BandwidthUsageAggregator& usageAggregator) - { - switch (m_bandwidthUsageDisplayType) - { - case ReplicaDisplayTypes::BUDT_COMBINED: - areaPlotHelper.PlotBatchedData(frameId, static_cast(usageAggregator.m_bytesSent + usageAggregator.m_bytesReceived)); - break; - case ReplicaDisplayTypes::BUDT_SENT: - areaPlotHelper.PlotBatchedData(frameId, static_cast(usageAggregator.m_bytesSent)); - break; - case ReplicaDisplayTypes::BUDT_RECEIVED: - areaPlotHelper.PlotBatchedData(frameId, static_cast(usageAggregator.m_bytesReceived)); - break; - default: - AZ_Error("BaseDetailView", false, "Unknown bandwidth usage display type."); - } - } - - void ConfigureBaseDetailDisplayHelper(BaseDetailDisplayHelper* detailDisplayHelper); - - void ConfigureGraphAxis() - { - const QColor markerColor(Qt::red); - m_gui->areaChart->ResetChart(); - m_gui->areaChart->ConfigureVerticalAxis("Bandwidth Usage", m_replicaDataView->GetAverageFrameBandwidthBudget()); - m_gui->areaChart->ConfigureHorizontalAxis("Frame", static_cast(m_replicaDataView->GetAxisStartFrame()), static_cast(m_replicaDataView->GetAxisEndFrame())); - m_gui->areaChart->AddMarker(Charts::AxisType::Horizontal, static_cast(m_replicaDataView->GetCurrentFrame()), markerColor); - } - }; - - template - class BaseDetailTreeViewModel - : public ReplicaTreeViewModel - { - typedef ReplicaBandwidthChartData BandwidthChartData; - public: - AZ_CLASS_ALLOCATOR(BaseDetailTreeViewModel, AZ::SystemAllocator, 0); - BaseDetailTreeViewModel(BaseDetailView* detailView) - : ReplicaTreeViewModel(nullptr) - , m_baseDetailView(detailView) - { - } - - void RefreshView(FrameNumberType frameId) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - AZStd::unordered_set< Key > discoveredSet; - - m_tableViewOrdering.clear(); - - if (m_baseDetailView->IsInDisplayMode(BaseDetailView::DisplayMode::Active)) - { - if (m_baseDetailView->m_replicaDataView->HideInactiveInspectedElements()) - { - m_tableViewOrdering.insert(m_tableViewOrdering.begin(), m_baseDetailView->m_activeInspectedIds.begin(), m_baseDetailView->m_activeInspectedIds.end()); - } - else - { - m_tableViewOrdering.insert(m_tableViewOrdering.begin(), m_baseDetailView->m_activeIds.begin(), m_baseDetailView->m_activeIds.end()); - } - - } - - const typename BandwidthChartData::FrameMap& frameMap = m_baseDetailView->GetFrameData(); - auto frameIter = frameMap.find(frameId); - - BaseDetailDisplayHelper* aggregateDisplayHelper = m_baseDetailView->FindAggregateDisplay(); - - if (aggregateDisplayHelper && m_baseDetailView->IsInDisplayMode(BaseDetailView::DisplayMode::Aggregate)) - { - aggregateDisplayHelper->ResetBandwidthUsage(); - - if (m_baseDetailView->m_replicaDataView->HideInactiveInspectedElements()) - { - if (frameIter != frameMap.end()) - { - m_tableViewOrdering.push_back(m_baseDetailView->FindAggregateID()); - } - } - else - { - m_tableViewOrdering.push_back(m_baseDetailView->FindAggregateID()); - } - } - else - { - aggregateDisplayHelper = nullptr; - } - - if (frameIter != frameMap.end()) - { - const typename BandwidthChartData::BandwidthUsageMap* usageMap = frameIter->second; - - for (typename BandwidthChartData::BandwidthUsageMap::const_iterator usageIter = usageMap->begin(); - usageIter != usageMap->end(); - ++usageIter) - { - const BandwidthUsageContainer* usageContainer = usageIter->second; - - const Key& idKey = usageIter->first; - - BaseDetailDisplayHelper* detailHelper = m_baseDetailView->FindDetailDisplay(idKey); - - if (detailHelper) - { - auto insert = discoveredSet.insert(idKey); - - if (insert.second) - { - detailHelper->ResetBandwidthUsage(); - } - - DataSetDisplayFilter* dataSetDisplayFilter = detailHelper->GetDataSetDisplayHelper(); - - if (dataSetDisplayFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& dataSetUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - - for (const auto& usagePair : dataSetUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - - detailHelper->AddDataSetUsage(currentUsage); - - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->AddDataSetUsage(currentUsage); - } - } - } - - RPCDisplayFilter* rpcDisplayFilter = detailHelper->GetRPCDisplayHelper(); - - if (rpcDisplayFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& rpcUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - for (const auto& usagePair : rpcUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - - detailHelper->AddRPCUsage(currentUsage); - - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->AddRPCUsage(currentUsage); - } - } - } - } - } - } - else - { - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->ResetBandwidthUsage(); - } - - for (Key& currentId : m_tableViewOrdering) - { - BaseDetailDisplayHelper* detailDisplayHelper = m_baseDetailView->FindDetailDisplay(currentId); - - if (detailDisplayHelper) - { - detailDisplayHelper->ResetBandwidthUsage(); - } - } - } - - AZStd::sort(m_tableViewOrdering.begin(), m_tableViewOrdering.end(), AZStd::less()); - - layoutChanged(); - } - - protected: - - int GetRootRowCount() const override - { - return static_cast(m_tableViewOrdering.size()); - } - - const BaseDisplayHelper* FindDisplayHelperAtRoot(int row) const override - { - if (row < 0 || row >= m_tableViewOrdering.size()) - { - return nullptr; - } - - return m_baseDetailView->FindDetailDisplay(m_tableViewOrdering[row]); - } - - BaseDetailView* m_baseDetailView; - AZStd::vector< Key > m_tableViewOrdering; - }; -} - -#include "BaseDetailView.inl" -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.inl b/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.inl deleted file mode 100644 index 07aaff4ba3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailView.inl +++ /dev/null @@ -1,456 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -namespace Driller -{ - template - void BaseDetailView::DrawActiveGraph() - { - const BandwidthUsageContainer emptyContainer; - const typename ReplicaBandwidthChartData::BandwidthUsageMap s_emptyMap; - - ConfigureGraphAxis(); - - for (const Key& currentId : m_activeIds) - { - BaseDetailDisplayHelper* detailDisplayHelper = FindDetailDisplay(currentId); - - ConfigureBaseDetailDisplayHelper(detailDisplayHelper); - } - - const typename ReplicaBandwidthChartData::FrameMap& frameMap = GetFrameData(); - - for (FrameNumberType frameId = m_replicaDataView->GetStartFrame(); frameId <= m_replicaDataView->GetEndFrame(); ++frameId) - { - typename ReplicaBandwidthChartData::FrameMap::const_iterator frameIter = frameMap.find(frameId); - const typename ReplicaBandwidthChartData::BandwidthUsageMap* usageMap = nullptr; - - if (frameIter != frameMap.end()) - { - usageMap = frameIter->second; - } - else - { - usageMap = &s_emptyMap; - } - - AZ_Assert(usageMap != nullptr,"Null pointer added to data map"); - if (usageMap == nullptr) - { - continue; - } - - for (const Key& currentId : m_activeIds) - { - const BandwidthUsageContainer* usageContainer = &emptyContainer; - typename ReplicaBandwidthChartData::BandwidthUsageMap::const_iterator usageIter = usageMap->find(currentId); - - if (usageIter != usageMap->end()) - { - usageContainer = usageIter->second; - } - else - { - usageContainer = &emptyContainer; - } - - BaseDetailDisplayHelper* detailDisplayHelper = FindDetailDisplay(currentId); - - switch (m_detailMode) - { - case DetailMode::Low: - DrawLowDetailActiveGraph(detailDisplayHelper,usageContainer,frameId); - break; - case DetailMode::Medium: - DrawMediumDetailActiveGraph(detailDisplayHelper, usageContainer, frameId); - break; - case DetailMode::High: - DrawHighDetailActiveGraph(detailDisplayHelper, usageContainer, frameId); - break; - default: - break; - } - } - } - } - - template - void BaseDetailView::DrawLowDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId) - { - if (detailDisplayHelper->m_graphEnabled) - { - BandwidthUsageAggregator usageAggregator; - usageAggregator.m_bytesSent = usageContainer->GetTotalBytesSent(); - usageAggregator.m_bytesReceived = usageContainer->GetTotalBytesReceived(); - - PlotBatchedGraphData(detailDisplayHelper->m_areaGraphPlotHelper, frameId, usageAggregator); - } - } - - template - void BaseDetailView::DrawMediumDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId) - { - DataSetDisplayFilter* dataSetFilter = detailDisplayHelper->GetDataSetDisplayHelper(); - - if (dataSetFilter && dataSetFilter->m_graphEnabled) - { - BandwidthUsageAggregator overallDataSetUsage; - const BandwidthUsageContainer::UsageAggregationMap& dataSetUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - - const AZStd::vector< BaseDisplayHelper* >& dataSets = dataSetFilter->GetChildren(); - - for (BaseDisplayHelper* helper : dataSets) - { - KeyedDisplayHelper* dataSet = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageIter = dataSetUsage.find(dataSet->GetKey()); - - if (usageIter != dataSetUsage.end()) - { - const BandwidthUsage& currentUsage = usageIter->second; - overallDataSetUsage.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - overallDataSetUsage.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - } - } - - PlotBatchedGraphData(dataSetFilter->m_areaGraphPlotHelper, frameId, overallDataSetUsage); - } - - RPCDisplayFilter* rpcFilter = detailDisplayHelper->GetRPCDisplayHelper(); - - if (rpcFilter && rpcFilter->m_graphEnabled) - { - BandwidthUsageAggregator overallRPCUsage; - const BandwidthUsageContainer::UsageAggregationMap& rpcUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - const AZStd::vector< BaseDisplayHelper* >& rpcs = rpcFilter->GetChildren(); - - for (BaseDisplayHelper* helper : rpcs) - { - KeyedDisplayHelper* rpc = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageIter = rpcUsage.find(rpc->GetKey()); - - if (usageIter != rpcUsage.end()) - { - const BandwidthUsage& currentUsage = usageIter->second; - - overallRPCUsage.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - overallRPCUsage.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - } - } - - PlotBatchedGraphData(rpcFilter->m_areaGraphPlotHelper, frameId, overallRPCUsage); - } - } - - template - void BaseDetailView::DrawHighDetailActiveGraph(BaseDetailDisplayHelper* detailDisplayHelper, const BandwidthUsageContainer* usageContainer, FrameNumberType frameId) - { - DataSetDisplayFilter* dataSetFilter = detailDisplayHelper->GetDataSetDisplayHelper(); - - if (dataSetFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& dataSetUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - const AZStd::vector< BaseDisplayHelper* >& dataSets = dataSetFilter->GetChildren(); - - for (BaseDisplayHelper* helper : dataSets) - { - if (helper->m_graphEnabled) - { - KeyedDisplayHelper* dataSet = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageIter = dataSetUsage.find(dataSet->GetKey()); - - if (usageIter == dataSetUsage.end()) - { - const BandwidthUsageAggregator emptyUsage; - PlotBatchedGraphData(dataSet->m_areaGraphPlotHelper, frameId, emptyUsage); - } - else - { - const BandwidthUsage& currentUsage = usageIter->second; - PlotBatchedGraphData(dataSet->m_areaGraphPlotHelper, frameId, currentUsage.m_usageAggregator); - } - } - } - } - - RPCDisplayFilter* rpcFilter = detailDisplayHelper->GetRPCDisplayHelper(); - - if (rpcFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& rpcUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - const AZStd::vector< BaseDisplayHelper* >& rpcs = rpcFilter->GetChildren(); - - for (BaseDisplayHelper* helper : rpcs) - { - if (helper->m_graphEnabled) - { - KeyedDisplayHelper* rpc = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageIter = rpcUsage.find(rpc->GetKey()); - - if (usageIter == rpcUsage.end()) - { - const BandwidthUsageAggregator emptyUsage; - PlotBatchedGraphData(rpc->m_areaGraphPlotHelper, frameId, emptyUsage); - } - else - { - const BandwidthUsage& currentUsage = usageIter->second; - PlotBatchedGraphData(rpc->m_areaGraphPlotHelper, frameId, currentUsage.m_usageAggregator); - } - } - } - } - } - - // GRAPHCHANGE - template - void BaseDetailView::DrawAggregateGraph() - { - BandwidthUsageContainer emptyContainer; - - ConfigureGraphAxis(); - - BaseDetailDisplayHelper* aggregateDisplayHelper = FindAggregateDisplay(); - - ConfigureBaseDetailDisplayHelper(aggregateDisplayHelper); - - const typename ReplicaBandwidthChartData::FrameMap& frameMap = GetFrameData(); - - for (FrameNumberType frameId = m_replicaDataView->GetStartFrame(); frameId <= m_replicaDataView->GetEndFrame(); ++frameId) - { - typename ReplicaBandwidthChartData::FrameMap::const_iterator frameIter = frameMap.find(frameId); - const typename ReplicaBandwidthChartData::BandwidthUsageMap* usageMap = nullptr; - - if (frameIter != frameMap.end()) - { - usageMap = frameIter->second; - } - else - { - static typename ReplicaBandwidthChartData::BandwidthUsageMap s_emptyMap; - usageMap = &s_emptyMap; - } - - AZ_Assert(usageMap != nullptr,"Null pointer added to data map"); - if (usageMap == nullptr) - { - continue; - } - - BandwidthUsageAggregator overallUsageAggregator; - - BandwidthUsageAggregator overallDataSetUsage; - AZStd::unordered_map dataSetAggregators; - DataSetDisplayFilter* dataSetFilter = aggregateDisplayHelper->GetDataSetDisplayHelper(); - - BandwidthUsageAggregator overallRPCUsage; - AZStd::unordered_map rpcAggregators; - RPCDisplayFilter* rpcFilter = aggregateDisplayHelper->GetRPCDisplayHelper(); - - for (const Key& currentId : m_activeIds) - { - const BandwidthUsageContainer* usageContainer = nullptr; - typename ReplicaBandwidthChartData::BandwidthUsageMap::const_iterator usageIter = usageMap->find(currentId); - - if (usageIter != usageMap->end()) - { - usageContainer = usageIter->second; - - overallUsageAggregator.m_bytesSent += usageContainer->GetTotalBytesSent(); - overallUsageAggregator.m_bytesReceived += usageContainer->GetTotalBytesReceived(); - } - else - { - usageContainer = &emptyContainer; - } - - if (dataSetFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& dataSetUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - - const AZStd::vector< BaseDisplayHelper* >& dataSets = dataSetFilter->GetChildren(); - - for (BaseDisplayHelper* helper : dataSets) - { - KeyedDisplayHelper* dataSet = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageAggIter = dataSetUsage.find(dataSet->GetKey()); - - if (usageAggIter != dataSetUsage.end()) - { - const BandwidthUsage& currentUsage = usageAggIter->second; - - overallDataSetUsage.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - overallDataSetUsage.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - - if (helper->m_graphEnabled) - { - BandwidthUsageAggregator& dataSetAggregator = dataSetAggregators[dataSet->GetKey()]; - dataSetAggregator.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - dataSetAggregator.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - } - } - } - } - - if (rpcFilter) - { - const BandwidthUsageContainer::UsageAggregationMap& rpcUsage = usageContainer->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - const AZStd::vector< BaseDisplayHelper* >& rpcs = rpcFilter->GetChildren(); - - for (BaseDisplayHelper* helper : rpcs) - { - KeyedDisplayHelper* rpc = static_cast*>(helper); - const BandwidthUsageContainer::UsageAggregationMap::const_iterator usageAggIter = rpcUsage.find(rpc->GetKey()); - - if (usageAggIter != rpcUsage.end()) - { - const BandwidthUsage& currentUsage = usageAggIter->second; - - overallRPCUsage.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - overallRPCUsage.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - - if (helper->m_graphEnabled) - { - BandwidthUsageAggregator& rpcAggregator = rpcAggregators[rpc->GetKey()]; - rpcAggregator.m_bytesSent += currentUsage.m_usageAggregator.m_bytesSent; - rpcAggregator.m_bytesReceived += currentUsage.m_usageAggregator.m_bytesReceived; - } - } - } - } - } - - if (m_detailMode == DetailMode::Low) - { - if (aggregateDisplayHelper->m_graphEnabled) - { - PlotBatchedGraphData(aggregateDisplayHelper->m_areaGraphPlotHelper, frameId, overallUsageAggregator); - } - } - else if (m_detailMode == DetailMode::Medium) - { - if (dataSetFilter && dataSetFilter->m_graphEnabled) - { - PlotBatchedGraphData(dataSetFilter->m_areaGraphPlotHelper, frameId, overallDataSetUsage); - } - - if (rpcFilter && rpcFilter->m_graphEnabled) - { - PlotBatchedGraphData(rpcFilter->m_areaGraphPlotHelper, frameId, overallRPCUsage); - } - } - else if (m_detailMode == DetailMode::High) - { - if (dataSetFilter) - { - const AZStd::vector< BaseDisplayHelper* >& dataSets = dataSetFilter->GetChildren(); - for (BaseDisplayHelper* helper : dataSets) - { - if (!helper->m_graphEnabled) - { - continue; - } - - KeyedDisplayHelper* dataSet = static_cast*>(helper); - BandwidthUsageAggregator& dataSetAggregator = dataSetAggregators[dataSet->GetKey()]; - - PlotBatchedGraphData(helper->m_areaGraphPlotHelper, frameId, dataSetAggregator); - } - } - - if (rpcFilter) - { - const AZStd::vector< BaseDisplayHelper* >& rpcs = rpcFilter->GetChildren(); - for (BaseDisplayHelper* helper : rpcs) - { - if (!helper->m_graphEnabled) - { - continue; - } - - KeyedDisplayHelper* rpc = static_cast*>(helper); - BandwidthUsageAggregator& rpcAggregator = rpcAggregators[rpc->GetKey()]; - - PlotBatchedGraphData(helper->m_areaGraphPlotHelper, frameId, rpcAggregator); - } - } - } - } - } - - template - void BaseDetailView::ConfigureBaseDetailDisplayHelper(BaseDetailDisplayHelper* detailDisplayHelper) - { - detailDisplayHelper->ResetGraphConfiguration(); - - if (detailDisplayHelper->m_graphEnabled && m_detailMode == DetailMode::Low) - { - detailDisplayHelper->m_areaGraphPlotHelper.SetupPlotHelper(m_gui->areaChart, detailDisplayHelper->GetDisplayName(), m_replicaDataView->GetActiveFrameCount()); - detailDisplayHelper->m_areaGraphPlotHelper.SetHighlighted(detailDisplayHelper->m_selected); - } - - if (m_detailMode == DetailMode::Medium || m_detailMode == DetailMode::High) - { - RPCDisplayFilter* rpcFilter = detailDisplayHelper->GetRPCDisplayHelper(); - - if (rpcFilter) - { - if (m_detailMode == DetailMode::Medium) - { - if (rpcFilter->m_graphEnabled) - { - rpcFilter->m_areaGraphPlotHelper.SetupPlotHelper(m_gui->areaChart, rpcFilter->GetDisplayName(), m_replicaDataView->GetActiveFrameCount()); - rpcFilter->m_areaGraphPlotHelper.SetHighlighted(rpcFilter->m_selected); - } - } - else if (m_detailMode == DetailMode::High) - { - const AZStd::vector< BaseDisplayHelper* >& rpcs = rpcFilter->GetChildren(); - - for (BaseDisplayHelper* helper : rpcs) - { - if (helper->m_graphEnabled) - { - helper->m_areaGraphPlotHelper.SetupPlotHelper(m_gui->areaChart, helper->GetDisplayName(), m_replicaDataView->GetActiveFrameCount()); - helper->m_areaGraphPlotHelper.SetHighlighted(helper->m_selected); - } - } - } - } - - DataSetDisplayFilter* dataSetFilter = detailDisplayHelper->GetDataSetDisplayHelper(); - - if (dataSetFilter) - { - if (m_detailMode == DetailMode::Medium) - { - if (dataSetFilter->m_graphEnabled) - { - dataSetFilter->m_areaGraphPlotHelper.SetupPlotHelper(m_gui->areaChart, dataSetFilter->GetDisplayName(), m_replicaDataView->GetActiveFrameCount()); - dataSetFilter->m_areaGraphPlotHelper.SetHighlighted(dataSetFilter->m_selected); - } - } - else if (m_detailMode == DetailMode::High) - { - const AZStd::vector< BaseDisplayHelper* >& dataSets = dataSetFilter->GetChildren(); - - for (BaseDisplayHelper* helper : dataSets) - { - if (helper->m_graphEnabled) - { - helper->m_areaGraphPlotHelper.SetupPlotHelper(m_gui->areaChart, dataSetFilter->GetDisplayName(), m_replicaDataView->GetActiveFrameCount()); - helper->m_areaGraphPlotHelper.SetHighlighted(helper->m_selected); - } - } - } - } - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.cpp b/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.cpp deleted file mode 100644 index 4c71c2bf57..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "BaseDetailViewQObject.hxx" -#include -#include - -#include "Source/Driller/AreaChart.hxx" -#include "Source/Driller/Replica/ReplicaDataView.hxx" - -namespace Driller -{ - BaseDetailViewQObject::BaseDetailViewQObject(QWidget* parent) - : QDialog(parent) - { - } - - void BaseDetailViewQObject::SetupSignals(ReplicaDataView* dataView, Ui::BaseDetailView* detailView) - { - QObject::connect(dataView,SIGNAL(DataRangeChanged()),this,SLOT(DataRangeChanged())); - QObject::connect(detailView->treeView,SIGNAL(doubleClicked(const QModelIndex&)),this,SLOT(DoubleClicked(const QModelIndex&))); - QObject::connect(detailView->bandwidthUsageDisplayType, SIGNAL(currentIndexChanged(int)), this, SLOT(BandwidthDisplayUsageTypeChanged(int))); - QObject::connect(detailView->graphDetailType, SIGNAL(currentIndexChanged(int)), this, SLOT(GraphDetailChanged(int))); - - detailView->areaChart->EnableMouseInspection(true); - - QObject::connect(detailView->areaChart, SIGNAL(InspectedSeries(size_t)), this, SLOT(InspectedSeries(size_t))); - QObject::connect(detailView->areaChart, SIGNAL(SelectedSeries(size_t, int)), this, SLOT(SelectedSeries(size_t, int))); - - QObject::connect(detailView->configToolbar,SIGNAL(hideAll()),this,SLOT(HideAll())); - QObject::connect(detailView->configToolbar,SIGNAL(hideSelected()),this,SLOT(HideSelected())); - QObject::connect(detailView->configToolbar,SIGNAL(showAll()),this,SLOT(ShowAll())); - QObject::connect(detailView->configToolbar,SIGNAL(showSelected()),this,SLOT(ShowSelected())); - QObject::connect(detailView->configToolbar,SIGNAL(collapseAll()),this,SLOT(CollapseAll())); - QObject::connect(detailView->configToolbar,SIGNAL(expandAll()),this,SLOT(ExpandAll())); - } - - void BaseDetailViewQObject::SetupTreeViewSignals(QTreeView* treeView) - { - QObject::connect(treeView->selectionModel(),SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)),this, SLOT(SelectionChanged(const QItemSelection&, const QItemSelection&))); - } - - void BaseDetailViewQObject::DataRangeChanged() - { - OnDataRangeChanged(); - } - - void BaseDetailViewQObject::HideAll() - { - SetAllEnabled(false); - } - - void BaseDetailViewQObject::ShowAll() - { - SetAllEnabled(true); - } - - void BaseDetailViewQObject::HideSelected() - { - SetSelectedEnabled(false); - } - - void BaseDetailViewQObject::ShowSelected() - { - SetSelectedEnabled(true); - } - - void BaseDetailViewQObject::CollapseAll() - { - OnCollapseAll(); - } - - void BaseDetailViewQObject::ExpandAll() - { - OnExpandAll(); - } - - void BaseDetailViewQObject::DoubleClicked(const QModelIndex& index) - { - OnDoubleClicked(index); - } - - void BaseDetailViewQObject::SelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) - { - OnSelectionChanged(selected,deselected); - } - - void BaseDetailViewQObject::UpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex) - { - OnUpdateDisplay(startIndex,endIndex); - } - - void BaseDetailViewQObject::DisplayModeChanged(int aggregationType) - { - OnDisplayModeChanged(aggregationType); - } - - void BaseDetailViewQObject::GraphDetailChanged(int graphDetailType) - { - OnGraphDetailChanged(graphDetailType); - } - - void BaseDetailViewQObject::BandwidthDisplayUsageTypeChanged(int bandwidthUsageType) - { - OnBandwidthDisplayUsageTypeChanged(bandwidthUsageType); - } - - void BaseDetailViewQObject::InspectedSeries(size_t seriesId) - { - OnInspectedSeries(seriesId); - } - - void BaseDetailViewQObject::SelectedSeries(size_t seriesId, int position) - { - OnSelectedSeries(seriesId, position); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.hxx b/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.hxx deleted file mode 100644 index 16dbaed6fa..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewQObject.hxx +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_BASEDETAILVIEWQOBJECT_H -#define DRILLER_REPLICA_BASEDETAILVIEWQOBJECT_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#include -#endif - -namespace Ui -{ - class BaseDetailView; -} - -namespace Driller -{ - class ReplicaDataView; - - // This class is a work around because QT does not play nicely with templates. - // So I'm going to do all of my Qt related signalling here and just pass it along - // to a virtual function. - class BaseDetailViewQObject : public QDialog - { - Q_OBJECT - public: - - AZ_CLASS_ALLOCATOR(BaseDetailViewQObject, AZ::SystemAllocator,0); - - BaseDetailViewQObject(QWidget* parent = nullptr); - - void SetupSignals(ReplicaDataView* dataView, Ui::BaseDetailView* detailView); - void SetupTreeViewSignals(QTreeView* treeView); - - public slots: - void DataRangeChanged(); - void HideAll(); - void ShowAll(); - - void HideSelected(); - void ShowSelected(); - - void CollapseAll(); - void ExpandAll(); - - void DoubleClicked(const QModelIndex& index); - void SelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void UpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex); - - void DisplayModeChanged(int); - void GraphDetailChanged(int); - void BandwidthDisplayUsageTypeChanged(int); - - void InspectedSeries(size_t seriesId); - void SelectedSeries(size_t seriesId, int position); - - protected: - virtual void OnDataRangeChanged() = 0; - - virtual void SetAllEnabled(bool enabled) = 0; - virtual void SetSelectedEnabled(bool enabled) = 0; - - virtual void OnCollapseAll() = 0; - virtual void OnExpandAll() = 0; - - virtual void OnDoubleClicked(const QModelIndex& index) = 0; - virtual void OnSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) = 0; - virtual void OnUpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex) = 0; - - virtual void OnDisplayModeChanged(int) = 0; - virtual void OnGraphDetailChanged(int) = 0; - virtual void OnBandwidthDisplayUsageTypeChanged(int) = 0; - - virtual void OnInspectedSeries(size_t seriesId) = 0; - virtual void OnSelectedSeries(size_t seriesId, int position) = 0; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewSavedState.h b/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewSavedState.h deleted file mode 100644 index 8c16507c42..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/BaseDetailViewSavedState.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_BASEDETAILVIEWSAVEDSTATE_H -#define DRILLER_REPLICA_BASEDETAILVIEWSAVEDSTATE_H - -#include -#include -#include - -namespace Driller -{ - class BaseDetailViewSplitterSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(BaseDetailViewSplitterSavedState, "{280A523E-9A7F-4E23-BAF8-1F6084AB77D6}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(BaseDetailViewSplitterSavedState, AZ::SystemAllocator, 0); - - AZStd::vector< AZ::u8 > m_splitterStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Field("m_splitterStorage", &BaseDetailViewSplitterSavedState::m_splitterStorage) - ->Version(1); - ; - } - } - }; - - class BaseDetailViewTreeSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(BaseDetailViewTreeSavedState, "{4B3ED3CE-5446-4DCD-98D3-62B577A75786}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(BaseDetailViewTreeSavedState, AZ::SystemAllocator, 0); - - AZStd::vector m_treeColumnStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Field("m_treeColumnStorage", &BaseDetailViewTreeSavedState::m_treeColumnStorage) - ->Version(1); - } - } - }; -} -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.cpp b/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.cpp deleted file mode 100644 index 54bdf1a77e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.cpp +++ /dev/null @@ -1,746 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include - -#include -#include - -#include "OverallReplicaDetailView.hxx" -#include -#include - -#include "ReplicaChunkUsageDataContainers.h" -#include "ReplicaDataAggregator.hxx" -#include "ReplicaDataEvents.h" -#include "ReplicaUsageDataContainers.h" - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" -#include "Source/Driller/Replica/ReplicaDataView.hxx" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Workspaces/Workspace.h" - -namespace Driller -{ - //////////////////////// - // TreeModelSavedState - //////////////////////// - class TreeModelSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(TreeModelSavedState, "{36103E46-2503-4EEE-BA4B-2650E25A5B26}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(TreeModelSavedState, AZ::SystemAllocator, 0); - - AZStd::vector m_treeColumnStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Field("m_treeColumnStorage", &TreeModelSavedState::m_treeColumnStorage) - ->Version(1); - } - } - }; - - //////////////////////////////// - // OverallReplicaTreeViewModel - //////////////////////////////// - - OverallReplicaTreeViewModel::OverallReplicaTreeViewModel(AbstractOverallReplicaDetailView* overallDetailView) - : BaseOverallTreeViewModel(overallDetailView) - { - } - - int OverallReplicaTreeViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return CD_COUNT; - } - - QVariant OverallReplicaTreeViewModel::data(const QModelIndex& index, int role) const - { - const bool relativeValue = true; - const bool absoluteValue = false; - - const BaseDisplayHelper* baseDisplay = static_cast(index.internalPointer()); - - switch (index.column()) - { - case CD_DISPLAY_NAME: - return displayNameData(baseDisplay, role); - case CD_REPLICA_ID: - { - if (role == Qt::DisplayRole || role == Qt::UserRole) - { - AZ::u64 replicaId = 0; - - const BaseDisplayHelper* currentDisplay = baseDisplay; - - while (currentDisplay != nullptr && !azrtti_istypeof(currentDisplay)) - { - currentDisplay = currentDisplay->GetParent(); - } - - if (currentDisplay) - { - const OverallReplicaDetailDisplayHelper* replicaDisplay = static_cast(currentDisplay); - replicaId = replicaDisplay->GetReplicaId(); - } - - if (role == Qt::DisplayRole) - { - return FormattingHelper::ReplicaID(replicaId); - } - else - { - return QVariant(replicaId); - } - } - } - break; - case CD_TOTAL_SENT: - return totalSentData(baseDisplay, role); - case CD_AVG_SENT_FRAME: - return avgSentPerFrameData(baseDisplay, role); - case CD_AVG_SENT_SECOND: - return avgSentPerSecondData(baseDisplay, role); - case CD_PARENT_PERCENT_SENT: - return percentOfSentData(baseDisplay, role, relativeValue); - case CD_TOTAL_PERCENT_SENT: - return percentOfSentData(baseDisplay, role, absoluteValue); - case CD_TOTAL_RECEIVED: - return totalReceivedData(baseDisplay, role); - case CD_AVG_RECEIVED_FRAME: - return avgReceivedPerFrameData(baseDisplay, role); - case CD_AVG_RECEIVED_SECOND: - return avgReceivedPerSecondData(baseDisplay, role); - case CD_PARENT_PERCENT_RECEIVED: - return percentOfReceivedData(baseDisplay, role, relativeValue); - case CD_TOTAL_PERCENT_RECEIVED: - return percentOfReceivedData(baseDisplay, role, absoluteValue); - default: - AZ_Warning("OverallReplicaTreeViewModel", false, "Unknown Column"); - break; - } - - return QVariant(); - } - - QVariant OverallReplicaTreeViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_DISPLAY_NAME: - return QString("Name"); - case CD_REPLICA_ID: - return QString("ReplicaId"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_AVG_SENT_FRAME: - return QString("Sent Bytes/Frame"); - case CD_AVG_SENT_SECOND: - return QString("Sent Bytes/Second"); - case CD_PARENT_PERCENT_SENT: - return QString("% of Parent Sent"); - case CD_TOTAL_PERCENT_SENT: - return QString("% of Total Sent"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_AVG_RECEIVED_FRAME: - return QString("Received Bytes/Frame"); - case CD_AVG_RECEIVED_SECOND: - return QString("Received Bytes/Second"); - case CD_PARENT_PERCENT_RECEIVED: - return QString("% of Parent Received"); - case CD_TOTAL_PERCENT_RECEIVED: - return QString("% of Total Received"); - } - } - } - - return QVariant(); - } - - const BaseDisplayHelper* OverallReplicaTreeViewModel::FindDisplayHelperAtRoot(int row) const - { - if (row < 0 || row >= m_tableViewOrdering.size()) - { - return nullptr; - } - - return m_overallReplicaDetailView->FindReplicaDisplayHelper(m_tableViewOrdering[row]); - } - - ///////////////////////////////////////// - // OverallReplicaChunkTypeTreeViewModel - ///////////////////////////////////////// - - OverallReplicaChunkTypeTreeViewModel::OverallReplicaChunkTypeTreeViewModel(AbstractOverallReplicaDetailView* overallDetailView) - : BaseOverallTreeViewModel(overallDetailView) - { - } - - int OverallReplicaChunkTypeTreeViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return CD_COUNT; - } - - QVariant OverallReplicaChunkTypeTreeViewModel::data(const QModelIndex& index, int role) const - { - const bool relativeValue = true; - const bool absoluteValue = false; - - const BaseDisplayHelper* baseDisplay = static_cast(index.internalPointer()); - - switch (index.column()) - { - case CD_DISPLAY_NAME: - return displayNameData(baseDisplay, role); - case CD_TOTAL_SENT: - return totalSentData(baseDisplay, role); - case CD_AVG_SENT_FRAME: - return avgSentPerFrameData(baseDisplay, role); - case CD_AVG_SENT_SECOND: - return avgSentPerSecondData(baseDisplay, role); - case CD_PARENT_PERCENT_SENT: - return percentOfSentData(baseDisplay, role, relativeValue); - case CD_TOTAL_PERCENT_SENT: - return percentOfSentData(baseDisplay, role, absoluteValue); - case CD_TOTAL_RECEIVED: - return totalReceivedData(baseDisplay, role); - case CD_AVG_RECEIVED_FRAME: - return avgReceivedPerFrameData(baseDisplay, role); - case CD_AVG_RECEIVED_SECOND: - return avgReceivedPerSecondData(baseDisplay, role); - case CD_PARENT_PERCENT_RECEIVED: - return percentOfReceivedData(baseDisplay, role, relativeValue); - case CD_TOTAL_PERCENT_RECEIVED: - return percentOfReceivedData(baseDisplay, role, absoluteValue); - default: - AZ_Warning("OverallReplicaTreeViewModel", false, "Unknown Column"); - break; - } - - return QVariant(); - } - - QVariant OverallReplicaChunkTypeTreeViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_DISPLAY_NAME: - return QString("Name"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_AVG_SENT_FRAME: - return QString("Sent Bytes/Frame"); - case CD_AVG_SENT_SECOND: - return QString("Sent Bytes/Second"); - case CD_PARENT_PERCENT_SENT: - return QString("% of Parent Sent"); - case CD_TOTAL_PERCENT_SENT: - return QString("% of Total Sent"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_AVG_RECEIVED_FRAME: - return QString("Received Bytes/Frame"); - case CD_AVG_RECEIVED_SECOND: - return QString("Received Bytes/Second"); - case CD_PARENT_PERCENT_RECEIVED: - return QString("% of Parent Received"); - case CD_TOTAL_PERCENT_RECEIVED: - return QString("% of Total Received"); - } - } - } - - return QVariant(); - } - - const BaseDisplayHelper* OverallReplicaChunkTypeTreeViewModel::FindDisplayHelperAtRoot(int row) const - { - if (row < 0 || row >= m_tableViewOrdering.size()) - { - return nullptr; - } - - return m_overallReplicaDetailView->FindReplicaChunkTypeDisplayHelper(m_tableViewOrdering[row]); - } - - ///////////////////////////// - // OverallReplicaDetailView - ///////////////////////////// - - const char* OverallReplicaDetailView::WINDOW_STATE_FORMAT = "OVERALL_REPLICA_DETAIL_VIEW_WINDOW_STATE"; - const char* OverallReplicaDetailView::REPLICA_TREE_STATE_FORMAT = "OVERALL_REPLICA_DETAIL_VIEW_TREE_STATE"; - const char* OverallReplicaDetailView::REPLICA_CHUNK_TREE_STATE_FORMAT = "OVERALL_REPLICA_CHUNK_DETAIL_VIEW_TREE_STATE"; - - OverallReplicaDetailView::OverallReplicaDetailView(ReplicaDataView* dataView, const ReplicaDataAggregator& dataAggregator) - : AbstractOverallReplicaDetailView() - , m_lifespanTelemetry("OverallReplicaDetailView") - , m_replicaDataView(dataView) - , m_windowStateCRC(AZ::Crc32(WINDOW_STATE_FORMAT)) - , m_replicaTreeStateCRC(AZ::Crc32(REPLICA_TREE_STATE_FORMAT)) - , m_replicaChunkTreeStateCRC(AZ::Crc32(REPLICA_CHUNK_TREE_STATE_FORMAT)) - , m_dataAggregator(dataAggregator) - , m_overallReplicaModel(this) - , m_replicaFilterProxyModel(this) - , m_overallChunkTypeModel(this) - , m_replicaChunkTypeFilterProxyModel(this) - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint); - - m_gui = azcreate(Ui::OverallReplicaDetailView, ()); - m_gui->setupUi(this); - - show(); - raise(); - activateWindow(); - setFocus(); - - QString titleName("Overall Replica Usage - %2"); - this->setWindowTitle(titleName.arg(m_dataAggregator.GetInspectionFileName())); - - // Loading up saved state - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (windowState) - { - windowState->RestoreGeometry(this); - } - auto treeState = AZ::UserSettings::Find(m_replicaTreeStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (treeState) - { - QByteArray treeData((const char*)treeState->m_treeColumnStorage.data(), (int)treeState->m_treeColumnStorage.size()); - m_gui->overallReplicaUsage->header()->restoreState(treeData); - } - - treeState = AZ::UserSettings::Find(m_replicaChunkTreeStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (treeState) - { - QByteArray treeData((const char*)treeState->m_treeColumnStorage.data(), (int)treeState->m_treeColumnStorage.size()); - m_gui->overallChunkTypeUsage->header()->restoreState(treeData); - } - - m_gui->startFrame->setMinimum(0); - m_gui->startFrame->setValue(0); - - m_gui->endFrame->setMaximum(static_cast(m_dataAggregator.GetFrameCount()) - 1); - m_gui->endFrame->setValue(static_cast(m_dataAggregator.GetFrameCount() - 1)); - - m_changeTimer.setInterval(500); - m_changeTimer.setSingleShot(true); - - UpdateFrameBoundaries(); - ParseData(); - SetupTreeView(); - UpdateDisplay(); - - QObject::connect(m_gui->startFrame, SIGNAL(valueChanged(int)), this, SLOT(QueueUpdate(int))); - QObject::connect(m_gui->endFrame, SIGNAL(valueChanged(int)), this, SLOT(QueueUpdate(int))); - QObject::connect(m_gui->framesPerSecond, SIGNAL(valueChanged(int)),this,SLOT(OnFPSChanged(int))); - connect(&m_changeTimer, SIGNAL(timeout()), SLOT(OnDataRangeChanged())); - } - - OverallReplicaDetailView::~OverallReplicaDetailView() - { - ClearData(); - - // Save out whatever data we want to save out. - auto pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (pState) - { - pState->CaptureGeometry(this); - } - - auto treeState = AZ::UserSettings::CreateFind(m_replicaTreeStateCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - if (m_gui->overallReplicaUsage && m_gui->overallReplicaUsage->header()) - { - QByteArray qba = m_gui->overallReplicaUsage->header()->saveState(); - treeState->m_treeColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - treeState = AZ::UserSettings::CreateFind(m_replicaChunkTreeStateCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - if (m_gui->overallChunkTypeUsage && m_gui->overallChunkTypeUsage->header()) - { - QByteArray qba = m_gui->overallChunkTypeUsage->header()->saveState(); - treeState->m_treeColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - if (m_replicaDataView) - { - m_replicaDataView->SignalDialogClosed(this); - } - - azdestroy(m_gui); - } - - int OverallReplicaDetailView::GetFrameRange() const - { - return m_frameRange; - } - - int OverallReplicaDetailView::GetFPS() const - { - return m_gui->framesPerSecond->value(); - } - - void OverallReplicaDetailView::SignalDataViewDestroyed(ReplicaDataView* replicaDataView) - { - if (m_replicaDataView == replicaDataView) - { - m_replicaDataView = nullptr; - } - - close(); - } - - void OverallReplicaDetailView::ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) - { - } - - void OverallReplicaDetailView::ActivateWorkspaceSettings(WorkspaceSettingsProvider*) - { - } - - void OverallReplicaDetailView::SaveSettingsToWorkspace(WorkspaceSettingsProvider*) - { - } - - void OverallReplicaDetailView::ApplyPersistentState() - { - } - - void OverallReplicaDetailView::Reflect(AZ::ReflectContext* context) - { - (void)context; - } - - void OverallReplicaDetailView::OnFPSChanged(int fps) - { - (void)fps; - - UpdateDisplay(); - } - - void OverallReplicaDetailView::QueueUpdate(int ignoredFrame) - { - (void)ignoredFrame; - - m_changeTimer.start(); - } - - void OverallReplicaDetailView::OnDataRangeChanged() - { - ParseData(); - UpdateFrameBoundaries(); - UpdateDisplay(); - } - - OverallReplicaDetailDisplayHelper* OverallReplicaDetailView::CreateReplicaDisplayHelper(const char* replicaName, AZ::u64 replicaId) - { - OverallReplicaDetailDisplayHelper* detailDisplay = nullptr; - - ReplicaDisplayHelperMap::iterator displayIter = m_replicaDisplayHelpers.find(replicaId); - - if (displayIter == m_replicaDisplayHelpers.end()) - { - detailDisplay = aznew OverallReplicaDetailDisplayHelper(replicaName, replicaId); - m_replicaDisplayHelpers.insert(ReplicaDisplayHelperMap::value_type(replicaId, detailDisplay)); - - m_overallReplicaModel.m_tableViewOrdering.push_back(replicaId); - } - else - { - detailDisplay = displayIter->second; - } - - return detailDisplay; - } - - OverallReplicaDetailDisplayHelper* OverallReplicaDetailView::FindReplicaDisplayHelper(AZ::u64 replicaId) - { - OverallReplicaDetailDisplayHelper* detailDisplay = nullptr; - - ReplicaDisplayHelperMap::iterator displayIter = m_replicaDisplayHelpers.find(replicaId); - - if (displayIter != m_replicaDisplayHelpers.end()) - { - detailDisplay = displayIter->second; - } - - return detailDisplay; - } - - ReplicaChunkDetailDisplayHelper* OverallReplicaDetailView::CreateReplicaChunkTypeDisplayHelper(const AZStd::string& chunkTypeName, AZ::u32 chunkIndex) - { - ReplicaChunkDetailDisplayHelper* detailDisplay = nullptr; - - ReplicaChunkTypeDisplayHelperMap::iterator displayIter = m_replicaChunkTypeDisplayHelpers.find(chunkTypeName); - - if (displayIter == m_replicaChunkTypeDisplayHelpers.end()) - { - detailDisplay = aznew ReplicaChunkDetailDisplayHelper(chunkTypeName.c_str(), chunkIndex); - m_replicaChunkTypeDisplayHelpers.insert(ReplicaChunkTypeDisplayHelperMap::value_type(chunkTypeName, detailDisplay)); - - m_overallChunkTypeModel.m_tableViewOrdering.push_back(chunkTypeName); - } - else - { - detailDisplay = displayIter->second; - } - - return detailDisplay; - } - - ReplicaChunkDetailDisplayHelper* OverallReplicaDetailView::FindReplicaChunkTypeDisplayHelper(const AZStd::string& chunkTypeName) - { - ReplicaChunkDetailDisplayHelper* detailDisplay = nullptr; - - ReplicaChunkTypeDisplayHelperMap::iterator displayIter = m_replicaChunkTypeDisplayHelpers.find(chunkTypeName); - - if (displayIter != m_replicaChunkTypeDisplayHelpers.end()) - { - detailDisplay = displayIter->second; - } - - return detailDisplay; - } - - void OverallReplicaDetailView::SaveOnExit() - { - } - - void OverallReplicaDetailView::UpdateFrameBoundaries() - { - m_gui->startFrame->setMaximum(m_gui->endFrame->value()); - m_gui->endFrame->setMinimum(m_gui->startFrame->value()); - - m_frameRange = (m_gui->endFrame->value() - m_gui->startFrame->value()) + 1; - - if (m_frameRange <= 0) - { - m_frameRange = 1; - } - } - - void OverallReplicaDetailView::ParseData() - { - // Not the best approach. But this shouldn't update all that frequently. - ClearData(); - - FrameNumberType startFrame = static_cast(m_gui->startFrame->value()); - FrameNumberType endFrame = static_cast(m_gui->endFrame->value()); - - EventNumberType startIndex = m_dataAggregator.GetFirstIndexAtFrame(startFrame); - EventNumberType endIndex = m_dataAggregator.GetFirstIndexAtFrame(endFrame) + m_dataAggregator.NumOfEventsAtFrame(endFrame); - - const Aggregator::EventListType& events = m_dataAggregator.GetEvents(); - - for (EventNumberType currentIndex = startIndex; currentIndex < endIndex; ++currentIndex) - { - ReplicaChunkEvent* chunkEvent = static_cast(events[currentIndex]); - - // Since I process each event twice, I need to do the total aggregation seperately. - if (chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_SENT - || chunkEvent->GetEventType() == Replica::RET_CHUNK_RPC_SENT) - { - m_totalUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - } - else - { - m_totalUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - } - - ProcessForReplica(chunkEvent); - ProcessForReplicaChunk(chunkEvent); - } - } - - void OverallReplicaDetailView::ProcessForReplica(ReplicaChunkEvent* chunkEvent) - { - const char* replicaName = chunkEvent->GetReplicaName(); - AZ::u64 replicaId = chunkEvent->GetReplicaId(); - - OverallReplicaDetailDisplayHelper* replicaDisplayHelper = CreateReplicaDisplayHelper(replicaName, replicaId); - - if (replicaDisplayHelper) - { - if (chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_SENT - || chunkEvent->GetEventType() == Replica::RET_CHUNK_RPC_SENT) - { - replicaDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - } - else if (chunkEvent->GetEventType() == Replica::RET_CHUNK_RPC_RECEIVED - || chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_RECEIVED) - { - replicaDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - } - - ReplicaChunkDetailDisplayHelper* chunkDetailDisplayHelper = replicaDisplayHelper->FindReplicaChunk(chunkEvent->GetReplicaChunkIndex()); - - if (chunkDetailDisplayHelper == nullptr) - { - chunkDetailDisplayHelper = replicaDisplayHelper->CreateReplicaChunkDisplayHelper(chunkEvent->GetChunkTypeName(), chunkEvent->GetReplicaChunkIndex()); - } - - ProcessForBaseDetailDisplayHelper(chunkEvent, chunkDetailDisplayHelper); - } - } - - void OverallReplicaDetailView::ProcessForReplicaChunk(ReplicaChunkEvent* chunkEvent) - { - AZ::u32 chunkId = chunkEvent->GetReplicaChunkIndex(); - AZStd::string chunkTypeName = chunkEvent->GetChunkTypeName(); - - ReplicaChunkDetailDisplayHelper* chunkDisplayHelper = CreateReplicaChunkTypeDisplayHelper(chunkTypeName, chunkId); - - if (chunkDisplayHelper) - { - ProcessForBaseDetailDisplayHelper(chunkEvent, chunkDisplayHelper); - } - } - - void OverallReplicaDetailView::ProcessForBaseDetailDisplayHelper(ReplicaChunkEvent* chunkEvent, BaseDetailDisplayHelper* detailDisplayHelper) - { - if (chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_SENT - || chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_RECEIVED) - { - ReplicaChunkDataSetEvent* dataSetEvent = static_cast(chunkEvent); - - detailDisplayHelper->SetupDataSet(dataSetEvent->GetIndex(), dataSetEvent->GetDataSetName()); - - DataSetDisplayFilter* dataSetDisplayFilter = detailDisplayHelper->GetDataSetDisplayHelper(); - DataSetDisplayHelper* dataSetDisplayHelper = detailDisplayHelper->FindDataSet(dataSetEvent->GetIndex()); - - if (chunkEvent->GetEventType() == Replica::RET_CHUNK_DATASET_SENT) - { - detailDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - dataSetDisplayFilter->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - dataSetDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - } - else - { - detailDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - dataSetDisplayFilter->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - dataSetDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - } - } - else - { - ReplicaChunkRPCEvent* rpcEvent = static_cast(chunkEvent); - - detailDisplayHelper->SetupRPC(rpcEvent->GetIndex(), rpcEvent->GetRPCName()); - - RPCDisplayFilter* rpcDisplayFilter = detailDisplayHelper->GetRPCDisplayHelper(); - RPCDisplayHelper* rpcDisplayHelper = detailDisplayHelper->FindRPC(rpcEvent->GetIndex()); - - if (chunkEvent->GetEventType() == Replica::RET_CHUNK_RPC_SENT) - { - detailDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - rpcDisplayFilter->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - rpcDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += chunkEvent->GetUsageBytes(); - } - else - { - detailDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - rpcDisplayFilter->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - rpcDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += chunkEvent->GetUsageBytes(); - } - } - } - - void OverallReplicaDetailView::ClearData() - { - for (auto& mapPair : m_replicaDisplayHelpers) - { - delete mapPair.second; - } - m_replicaDisplayHelpers.clear(); - m_overallReplicaModel.m_tableViewOrdering.clear(); - - for (auto& mapPair : m_replicaChunkTypeDisplayHelpers) - { - delete mapPair.second; - } - m_replicaChunkTypeDisplayHelpers.clear(); - m_overallChunkTypeModel.m_tableViewOrdering.clear(); - - m_totalUsageAggregator.m_bytesSent = 0; - m_totalUsageAggregator.m_bytesReceived = 0; - } - - void OverallReplicaDetailView::UpdateDisplay() - { - int frameRange = GetFrameRange(); - - // Sent Total - m_gui->totalBytesSent->setText(QString::number(m_totalUsageAggregator.m_bytesSent)); - - size_t avgBytesPerFrame = m_totalUsageAggregator.m_bytesSent / frameRange; - m_gui->avgBytesSentFrame->setText(QString::number(avgBytesPerFrame)); - m_gui->avgBytesSentSecond->setText(QString::number(avgBytesPerFrame * GetFPS())); - - // Received Total - m_gui->totalBytesReceived->setText(QString::number(m_totalUsageAggregator.m_bytesReceived)); - - avgBytesPerFrame = m_totalUsageAggregator.m_bytesReceived / frameRange; - m_gui->avgBytesReceivedFrame->setText(QString::number(avgBytesPerFrame)); - m_gui->avgBytesReceivedSecond->setText(QString::number(avgBytesPerFrame * GetFPS())); - - m_overallChunkTypeModel.layoutChanged(); - m_overallReplicaModel.layoutChanged(); - } - - void OverallReplicaDetailView::SetupTreeView() - { - SetupReplicaTreeView(); - SetupReplicaChunkTypeTreeView(); - } - - void OverallReplicaDetailView::SetupReplicaTreeView() - { - m_replicaFilterProxyModel.setSortRole(Qt::UserRole); - m_replicaFilterProxyModel.setSourceModel(&m_overallReplicaModel); - - m_gui->overallReplicaUsage->setModel(&m_replicaFilterProxyModel); - } - - void OverallReplicaDetailView::SetupReplicaChunkTypeTreeView() - { - m_replicaChunkTypeFilterProxyModel.setSortRole(Qt::UserRole); - m_replicaChunkTypeFilterProxyModel.setSourceModel(&m_overallChunkTypeModel); - - m_gui->overallChunkTypeUsage->setModel(&m_replicaChunkTypeFilterProxyModel); - } -}; diff --git a/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.hxx b/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.hxx deleted file mode 100644 index 9232f678d7..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/OverallReplicaDetailView.hxx +++ /dev/null @@ -1,470 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef PROFILER_REPLICA_OVERALLDETAILVIEW_H -#define PROFILER_REPLICA_OVERALLDETAILVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -#include "Source/Driller/DrillerDataTypes.h" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Replica/ReplicaTreeViewModel.hxx" - -#include "ReplicaBandwidthChartData.h" -#endif - -namespace Ui -{ - class OverallReplicaDetailView; -} - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class OverallReplicaDetailView; - class ReplicaDataView; - - class ReplicaDataAggregator; - - class ReplicaChunkDataEvent; - class ReplicaChunkReceivedDataEvent; - class ReplicaChunkSentDataEvent; - - class AbstractOverallReplicaDetailView - : public QDialog - { - template - friend class BaseOverallTreeViewModel; - - friend class OverallReplicaTreeViewModel; - friend class OverallReplicaChunkTypeTreeViewModel; - - Q_OBJECT - public: - virtual int GetFrameRange() const = 0; - virtual int GetFPS() const = 0; - - protected: - virtual OverallReplicaDetailDisplayHelper* FindReplicaDisplayHelper(AZ::u64 replicaId) = 0; - virtual ReplicaChunkDetailDisplayHelper* FindReplicaChunkTypeDisplayHelper(const AZStd::string& chunkTypeName) = 0; - - BandwidthUsageAggregator m_totalUsageAggregator; - }; - - template - class BaseOverallTreeViewModel : public ReplicaTreeViewModel - { - public: - AZ_CLASS_ALLOCATOR(BaseOverallTreeViewModel, AZ::SystemAllocator,0); - BaseOverallTreeViewModel(AbstractOverallReplicaDetailView* overallDetailView) - : m_overallReplicaDetailView(overallDetailView) - { - } - - AZStd::vector< Key > m_tableViewOrdering; - - protected: - - int GetRootRowCount() const override - { - return static_cast(m_tableViewOrdering.size()); - } - - QVariant displayNameData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole || role == Qt::UserRole) - { - QString displayName = baseDisplay->GetDisplayName(); - - if (displayName.isEmpty()) - { - return QString(""); - } - else - { - return displayName; - } - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignVCenter); - } - - return QVariant(); - } - - QVariant totalSentData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesSent); - } - else if (role == Qt::UserRole) - { - return baseDisplay->m_bandwidthUsageAggregator.m_bytesSent; - } - - return QVariant(); - } - - QVariant totalReceivedData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived); - } - else if (role == Qt::UserRole) - { - return baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived; - } - - return QVariant(); - } - - QVariant avgSentPerFrameData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesSent/m_overallReplicaDetailView->GetFrameRange()); - } - else if (role == Qt::UserRole) - { - return baseDisplay->m_bandwidthUsageAggregator.m_bytesSent/m_overallReplicaDetailView->GetFrameRange(); - } - - return QVariant(); - } - - QVariant avgReceivedPerFrameData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived/m_overallReplicaDetailView->GetFrameRange()); - } - else if (role == Qt::UserRole) - { - return baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived/m_overallReplicaDetailView->GetFrameRange(); - } - - return QVariant(); - } - - QVariant avgSentPerSecondData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number((baseDisplay->m_bandwidthUsageAggregator.m_bytesSent/m_overallReplicaDetailView->GetFrameRange()) * m_overallReplicaDetailView->GetFPS()); - } - else if (role == Qt::UserRole) - { - return (baseDisplay->m_bandwidthUsageAggregator.m_bytesSent/m_overallReplicaDetailView->GetFrameRange()) * m_overallReplicaDetailView->GetFPS(); - } - - return QVariant(); - } - - QVariant avgReceivedPerSecondData(const BaseDisplayHelper* baseDisplay, int role) const - { - if (role == Qt::DisplayRole) - { - return QString::number((baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived/m_overallReplicaDetailView->GetFrameRange()) * m_overallReplicaDetailView->GetFPS()); - } - else if (role == Qt::UserRole) - { - return (baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived/m_overallReplicaDetailView->GetFrameRange()) * m_overallReplicaDetailView->GetFPS(); - } - - return QVariant(); - } - - QVariant percentOfSentData(const BaseDisplayHelper* baseDisplay, int role, bool isRelative) const - { - if (role == Qt::DisplayRole || role == Qt::UserRole) - { - size_t denominator = m_overallReplicaDetailView->m_totalUsageAggregator.m_bytesSent; - - if (isRelative) - { - const BaseDisplayHelper* parentHelper = baseDisplay->GetParent(); - if (parentHelper) - { - denominator = parentHelper->m_bandwidthUsageAggregator.m_bytesSent; - } - } - - if (denominator == 0) - { - if (role == Qt::DisplayRole) - { - return QString::number(0,'f',3); - } - else - { - return QVariant(0.0f); - } - } - else - { - float value = static_cast(baseDisplay->m_bandwidthUsageAggregator.m_bytesSent)/static_cast(denominator)*100.0f; - - if (role == Qt::DisplayRole) - { - return QString::number(value,'f',3); - } - else - { - return QVariant(value); - } - } - } - - return QVariant(); - } - - QVariant percentOfReceivedData(const BaseDisplayHelper* baseDisplay, int role, bool isRelative) const - { - if (role == Qt::DisplayRole || role == Qt::UserRole) - { - size_t denominator = m_overallReplicaDetailView->m_totalUsageAggregator.m_bytesReceived; - - if (isRelative) - { - const BaseDisplayHelper* parentHelper = baseDisplay->GetParent(); - if (parentHelper) - { - denominator = parentHelper->m_bandwidthUsageAggregator.m_bytesReceived; - } - } - - if (denominator == 0) - { - if (role == Qt::DisplayRole) - { - return QString::number(0,'f',3); - } - else - { - return QVariant(0.0f); - } - } - else - { - float value = static_cast(baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived)/static_cast(denominator)*100.0f; - - if (role == Qt::DisplayRole) - { - return QString::number(value,'f',3); - } - else - { - return QVariant(value); - } - } - } - - return QVariant(); - } - - AbstractOverallReplicaDetailView* m_overallReplicaDetailView; - }; - - class OverallReplicaTreeViewModel : public BaseOverallTreeViewModel - { - public: - enum ColumnDescriptor - { - // Forcing the index to start at 0 - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order in the tree - CD_DISPLAY_NAME, - CD_REPLICA_ID, - - CD_TOTAL_SENT, - CD_AVG_SENT_FRAME, - CD_AVG_SENT_SECOND, - CD_PARENT_PERCENT_SENT, - CD_TOTAL_PERCENT_SENT, - - CD_TOTAL_RECEIVED, - CD_AVG_RECEIVED_FRAME, - CD_AVG_RECEIVED_SECOND, - CD_PARENT_PERCENT_RECEIVED, - CD_TOTAL_PERCENT_RECEIVED, - - // Used for sizing of the TableView. Anything after this won't be displayed. - CD_COUNT - }; - - AZ_CLASS_ALLOCATOR(OverallReplicaTreeViewModel, AZ::SystemAllocator,0); - OverallReplicaTreeViewModel(AbstractOverallReplicaDetailView* overallDetailView); - - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - - protected: - const BaseDisplayHelper* FindDisplayHelperAtRoot(int row) const; - }; - - class OverallReplicaChunkTypeTreeViewModel : public BaseOverallTreeViewModel - { - public: - enum ColumnDescriptor - { - // Forcing the index to start at 0 - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order in the tree - CD_DISPLAY_NAME, - - CD_TOTAL_SENT, - CD_AVG_SENT_FRAME, - CD_AVG_SENT_SECOND, - CD_PARENT_PERCENT_SENT, - CD_TOTAL_PERCENT_SENT, - - CD_TOTAL_RECEIVED, - CD_AVG_RECEIVED_FRAME, - CD_AVG_RECEIVED_SECOND, - CD_PARENT_PERCENT_RECEIVED, - CD_TOTAL_PERCENT_RECEIVED, - - // Used for sizing of the TableView. Anything after this won't be displayed. - CD_COUNT - }; - - AZ_CLASS_ALLOCATOR(OverallReplicaChunkTypeTreeViewModel, AZ::SystemAllocator,0); - OverallReplicaChunkTypeTreeViewModel(AbstractOverallReplicaDetailView* overallDetailView); - - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - - protected: - const BaseDisplayHelper* FindDisplayHelperAtRoot(int row) const; - }; - - class OverallReplicaDetailView - : public AbstractOverallReplicaDetailView - { - private: - - Q_OBJECT - - template - friend class BaseOverallTreeViewModel; - - friend class OverallReplicaTreeViewModel; - friend class OverallReplicaChunkTypeTreeViewModel; - - typedef AZStd::unordered_map ReplicaDisplayHelperMap; - typedef AZStd::unordered_map ReplicaChunkTypeDisplayHelperMap; - - static const char* WINDOW_STATE_FORMAT; - static const char* REPLICA_TREE_STATE_FORMAT; - static const char* REPLICA_CHUNK_TREE_STATE_FORMAT; - - public: - AZ_CLASS_ALLOCATOR(OverallReplicaDetailView, AZ::SystemAllocator, 0); - - OverallReplicaDetailView(ReplicaDataView* dataView, const ReplicaDataAggregator& dataAggregator); - ~OverallReplicaDetailView(); - - int GetFrameRange() const override; - int GetFPS() const override; - - void SignalDataViewDestroyed(ReplicaDataView* replicaDataView); - - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - void ApplyPersistentState(); - - static void Reflect(AZ::ReflectContext* context); - - public slots: - - void OnFPSChanged(int); - - void QueueUpdate(int); - void OnDataRangeChanged(); - - private: - - OverallReplicaDetailDisplayHelper* CreateReplicaDisplayHelper(const char* replicaName, AZ::u64 replicaId); - OverallReplicaDetailDisplayHelper* FindReplicaDisplayHelper(AZ::u64 replicaId); - - ReplicaChunkDetailDisplayHelper* CreateReplicaChunkTypeDisplayHelper(const AZStd::string& chunkTypeName, AZ::u32 chunkIndex); - ReplicaChunkDetailDisplayHelper* FindReplicaChunkTypeDisplayHelper(const AZStd::string& chunkTypeName); - - void SaveOnExit(); - void UpdateFrameBoundaries(); - - void ParseData(); - void ProcessForReplica(ReplicaChunkEvent* chunkEvent); - void ProcessForReplicaChunk(ReplicaChunkEvent* chunkEvent); - void ProcessForBaseDetailDisplayHelper(ReplicaChunkEvent* chunkEvent, BaseDetailDisplayHelper* baseDetailDisplayHelper); - - void ClearData(); - - void UpdateDisplay(); - - void SetupTreeView(); - void SetupReplicaTreeView(); - void SetupReplicaChunkTypeTreeView(); - - // Window Telemetry - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - - ReplicaDataView* m_replicaDataView; - - // Window Saved State - AZ::Crc32 m_windowStateCRC; - AZ::Crc32 m_replicaTreeStateCRC; - AZ::Crc32 m_replicaChunkTreeStateCRC; - - // General Data Source - const ReplicaDataAggregator& m_dataAggregator; - - // Cached data - int m_frameRange; - - // UX niceties - QTimer m_changeTimer; - - // Display features for the Replica usage table - OverallReplicaTreeViewModel m_overallReplicaModel; - QSortFilterProxyModel m_replicaFilterProxyModel; - ReplicaDisplayHelperMap m_replicaDisplayHelpers; - - // Display features for the ReplicaChunkType usage table - OverallReplicaChunkTypeTreeViewModel m_overallChunkTypeModel; - QSortFilterProxyModel m_replicaChunkTypeFilterProxyModel; - ReplicaChunkTypeDisplayHelperMap m_replicaChunkTypeDisplayHelpers; - - Ui::OverallReplicaDetailView* m_gui; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.cpp deleted file mode 100644 index d455f8ae29..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.cpp +++ /dev/null @@ -1,397 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -#include "ReplicaBandwidthChartData.h" - -namespace Driller -{ - //////////////////// - // GraphPlotHelper - //////////////////// - - GraphPlotHelper::GraphPlotHelper(const QColor& displayColor) - : m_color(displayColor) - , m_channelId(StripChart::DataStrip::s_invalidChannelId) - , m_zeroOutLine(false) - , m_initializeLine(false) - , m_lastHorizontalValue(0.0f) - { - } - - void GraphPlotHelper::Reset() - { - m_initializeLine = true; - m_zeroOutLine = false; - m_channelId = StripChart::DataStrip::s_invalidChannelId; - m_lastHorizontalValue = 0.0f; - } - - bool GraphPlotHelper::IsSetup() const - { - return m_channelId != StripChart::DataStrip::s_invalidChannelId; - } - - void GraphPlotHelper::SetupPlotHelper(StripChart::DataStrip* chart, const char* channelName, float startValue) - { - if (chart == nullptr) - { - return; - } - - AZ_Assert(m_channelId == StripChart::DataStrip::s_invalidChannelId, "Double registering the GraphPlotHelper"); - - m_channelId = chart->AddChannel(channelName); - chart->SetChannelStyle(m_channelId, StripChart::Channel::STYLE_CONNECTED_LINE); - chart->SetChannelColor(m_channelId, m_color); - - m_lastHorizontalValue = startValue; - } - - void GraphPlotHelper::PlotData(StripChart::DataStrip* chart, float tickSize, float horizontalValue, float verticalValue, bool forceDraw) - { - if (chart == nullptr) - { - return; - } - - if (!IsSetup()) - { - SetupPlotHelper(chart, "", horizontalValue); - } - - bool hasData = !AZ::IsClose(verticalValue, 0.0f, 0.001f); - - float stepDifference = horizontalValue - m_lastHorizontalValue; - - if (m_zeroOutLine || hasData || forceDraw || m_initializeLine) - { - if (!hasData) - { - if (m_zeroOutLine) - { - chart->AddData(m_channelId, 0, m_lastHorizontalValue + tickSize, 0.0f); - } - else if (m_initializeLine) - { - chart->AddData(m_channelId, 0, m_lastHorizontalValue, 0.0f); - } - } - - if (stepDifference > tickSize + 0.001f) - { - chart->AddData(m_channelId, 0, horizontalValue - tickSize, 0.0f); - } - - m_initializeLine = false; - m_zeroOutLine = hasData; - m_lastHorizontalValue = horizontalValue; - - chart->AddData(m_channelId, 0, horizontalValue, verticalValue); - } - } - - void GraphPlotHelper::PlotBatchedData(StripChart::DataStrip* chart, float tickSize, float horizontalValue, float verticalValue, bool forceDraw) - { - bool hasData = !AZ::IsClose(verticalValue, 0.0f, 0.001f); - - float stepDifference = horizontalValue - m_lastHorizontalValue; - - if (m_zeroOutLine || hasData || forceDraw || m_initializeLine) - { - if (!hasData) - { - if (m_zeroOutLine) - { - chart->AddBatchedData(m_channelId, 0, m_lastHorizontalValue + tickSize, 0.0f); - } - else if (m_initializeLine) - { - chart->AddBatchedData(m_channelId, 0, m_lastHorizontalValue, 0.0f); - } - } - - if (stepDifference > tickSize + 0.001f) - { - chart->AddBatchedData(m_channelId, 0, horizontalValue - tickSize, 0.0f); - } - - m_initializeLine = false; - m_zeroOutLine = hasData; - m_lastHorizontalValue = horizontalValue; - - chart->AddBatchedData(m_channelId, 0, horizontalValue, verticalValue); - } - } - - void GraphPlotHelper::SetHighlight(StripChart::DataStrip* chart, bool highlight) - { - if (chart == nullptr || m_channelId == StripChart::DataStrip::s_invalidChannelId) - { - return; - } - - chart->SetChannelHighlight(m_channelId, highlight); - } - - void GraphPlotHelper::ZeroOutLine(float lastHorizontalValue, float tickSize, StripChart::DataStrip* chart) - { - if (m_zeroOutLine && !AZ::IsClose(lastHorizontalValue, m_lastHorizontalValue, 0.001f)) - { - chart->AddData(m_channelId, 0, m_lastHorizontalValue + tickSize, 0.0f); - } - } - - //////////////////////// - // AreaGraphPlotHelper - //////////////////////// - - AreaGraphPlotHelper::AreaGraphPlotHelper(const QColor& displayColor) - : m_color(displayColor) - , m_areaChart(nullptr) - , m_seriesId(AreaChart::AreaChart::k_invalidSeriesId) - { - } - - bool AreaGraphPlotHelper::IsSetup() const - { - return m_areaChart != nullptr && m_seriesId != AreaChart::AreaChart::k_invalidSeriesId; - } - - void AreaGraphPlotHelper::Reset() - { - m_areaChart = nullptr; - m_seriesId = AreaChart::AreaChart::k_invalidSeriesId; - } - - void AreaGraphPlotHelper::SetupPlotHelper(AreaChart::AreaChart* chart, const char* channelName, size_t seriesSize) - { - AZ_Error("AreaGraphPlotHelper", !IsSetup(), "Plot Helper is already setup."); - if (IsSetup()) - { - Reset(); - } - - QString name(channelName); - - m_areaChart = chart; - m_seriesId = m_areaChart->CreateSeries(name, m_color,seriesSize); - } - - void AreaGraphPlotHelper::PlotData(int position, unsigned int value) - { - if (IsSetup()) - { - m_areaChart->AddPoint(m_seriesId, position, value); - } - } - - void AreaGraphPlotHelper::PlotBatchedData(int position, unsigned int value) - { - m_areaChart->AddPoint(m_seriesId, position, value); - } - - void AreaGraphPlotHelper::SetHighlighted(bool highlighted) - { - if (IsSetup()) - { - m_areaChart->SetSeriesHighlight(m_seriesId, highlighted); - } - } - - void AreaGraphPlotHelper::SetEnabled(bool enabled) - { - if (IsSetup()) - { - m_areaChart->SetSeriesEnabled(m_seriesId, enabled); - } - } - - bool AreaGraphPlotHelper::IsSeries(size_t seriesId) const - { - if (m_seriesId == AreaChart::AreaChart::k_invalidSeriesId) - { - return false; - } - else - { - return m_seriesId == seriesId; - } - } - - ////////////////////////////// - // BandwidthUsageAggregator - ////////////////////////////// - - BandwidthUsageAggregator::BandwidthUsageAggregator() - : m_bytesSent(0) - , m_bytesReceived(0) - { - } - - void BandwidthUsageAggregator::Reset() - { - m_bytesSent = 0; - m_bytesReceived = 0; - } - - //////////////////////////// - // BandwidthUsageContainer - //////////////////////////// - - BandwidthUsageContainer::BandwidthUsageContainer() - { - m_dataTypeAggregationMap.insert(DataTypeAggreationMap::value_type(BandwidthUsage::DataType::DATA_SET, UsageAggregationMap())); - m_dataTypeAggregationMap.insert(DataTypeAggreationMap::value_type(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL, UsageAggregationMap())); - } - - BandwidthUsageContainer::~BandwidthUsageContainer() - { - } - - void BandwidthUsageContainer::ProcessChunkEvent(const ReplicaChunkEvent* chunkEvent) - { - BandwidthUsage* bandwidthUsage = nullptr; - - if (azrtti_istypeof(chunkEvent)) - { - const ReplicaChunkDataSetEvent* dataSetEvent = static_cast(chunkEvent); - - size_t index = dataSetEvent->GetIndex(); - - UsageAggregationMap& dataSetAggregationMap = m_dataTypeAggregationMap[BandwidthUsage::DataType::DATA_SET]; - - UsageAggregationMap::iterator usageIter = dataSetAggregationMap.find(index); - - if (usageIter == dataSetAggregationMap.end()) - { - BandwidthUsage usage; - - usage.m_dataType = BandwidthUsage::DataType::DATA_SET; - usage.m_identifier = dataSetEvent->GetDataSetName(); - usage.m_index = dataSetEvent->GetIndex(); - - usageIter = dataSetAggregationMap.insert(UsageAggregationMap::value_type(index, usage)).first; - } - - bandwidthUsage = (&usageIter->second); - - if (azrtti_istypeof(dataSetEvent)) - { - m_totalUsageAggregator.m_bytesSent += dataSetEvent->GetUsageBytes(); - bandwidthUsage->m_usageAggregator.m_bytesSent += dataSetEvent->GetUsageBytes(); - OnProcessSentDataSet(static_cast(dataSetEvent)); - } - else if (azrtti_istypeof(dataSetEvent)) - { - m_totalUsageAggregator.m_bytesReceived += dataSetEvent->GetUsageBytes(); - bandwidthUsage->m_usageAggregator.m_bytesReceived += dataSetEvent->GetUsageBytes(); - OnProcessReceivedDataSet(static_cast(dataSetEvent)); - } - else - { - AZ_Error("Standalone Tools", false, "Unknown event type in BadnwidthUsageContainer::ProcessChunkEvent."); - } - } - else if (azrtti_istypeof(chunkEvent)) - { - const ReplicaChunkRPCEvent* rpcEvent = static_cast(chunkEvent); - - size_t index = rpcEvent->GetIndex(); - - UsageAggregationMap& rpcUsageAggregationMap = m_dataTypeAggregationMap[BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL]; - - UsageAggregationMap::iterator usageIter = rpcUsageAggregationMap.find(index); - - if (usageIter == rpcUsageAggregationMap.end()) - { - BandwidthUsage usage; - - usage.m_dataType = BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL; - usage.m_identifier = rpcEvent->GetRPCName(); - usage.m_index = rpcEvent->GetIndex(); - - usageIter = rpcUsageAggregationMap.insert(UsageAggregationMap::value_type(index, usage)).first; - } - - bandwidthUsage = (&usageIter->second); - - if (azrtti_istypeof(rpcEvent)) - { - m_totalUsageAggregator.m_bytesSent += rpcEvent->GetUsageBytes(); - bandwidthUsage->m_usageAggregator.m_bytesSent += rpcEvent->GetUsageBytes(); - OnProcessSentRPC(static_cast(rpcEvent)); - } - else if (azrtti_istypeof(rpcEvent)) - { - m_totalUsageAggregator.m_bytesReceived += rpcEvent->GetUsageBytes(); - bandwidthUsage->m_usageAggregator.m_bytesReceived += rpcEvent->GetUsageBytes(); - OnProcessReceivedRPC(static_cast(rpcEvent)); - } - else - { - AZ_Error("Standalone Tools", false, "Unknown event type in BadnwidthUsageContainer::ProcessChunkEvent."); - } - } - else - { - AZ_Error("Standalone Tools", false, "Unknown event type in BadnwidthUsageContainer::ProcessChunkEvent."); - } - } - - size_t BandwidthUsageContainer::GetTotalBytesSent() const - { - return m_totalUsageAggregator.m_bytesSent; - } - - size_t BandwidthUsageContainer::GetTotalBytesReceived() const - { - return m_totalUsageAggregator.m_bytesReceived; - } - - size_t BandwidthUsageContainer::GetTotalBandwidthUsage() const - { - return GetTotalBytesSent() + GetTotalBytesReceived(); - } - - const BandwidthUsageContainer::UsageAggregationMap& BandwidthUsageContainer::GetDataTypeUsageAggregation(BandwidthUsage::DataType dataType) const - { - static UsageAggregationMap s_emptyMap; - - DataTypeAggreationMap::const_iterator dataTypeIterator = m_dataTypeAggregationMap.find(dataType); - - AZ_Error("Standalone Tools", dataTypeIterator != m_dataTypeAggregationMap.end(), "Use of Unknown DataType inside of GetDataTypeUsageAggreation"); - if (dataTypeIterator != m_dataTypeAggregationMap.end()) - { - return dataTypeIterator->second; - } - - return s_emptyMap; - } - - void BandwidthUsageContainer::OnProcessSentDataSet(const ReplicaChunkSentDataSetEvent* sentData) - { - (void)sentData; - } - - void BandwidthUsageContainer::OnProcessReceivedDataSet(const ReplicaChunkReceivedDataSetEvent* receivedData) - { - (void)receivedData; - } - - void BandwidthUsageContainer::OnProcessSentRPC(const ReplicaChunkSentRPCEvent* sentData) - { - (void)sentData; - } - - void BandwidthUsageContainer::OnProcessReceivedRPC(const ReplicaChunkReceivedRPCEvent* receivedData) - { - (void)receivedData; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.h deleted file mode 100644 index 618dd54a89..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaBandwidthChartData.h +++ /dev/null @@ -1,401 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_BANDWIDTHCHARTDATA_H -#define DRILLER_REPLICA_BANDWIDTHCHARTDATA_H - -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "ReplicaDataEvents.h" -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/AreaChart.hxx" - -#include "Source/Driller/DrillerDataTypes.h" - -#include - -namespace Driller -{ - // Graph Helper - class GraphPlotHelper - { - public: - GraphPlotHelper(const QColor& displayColor); - - void Reset(); - bool IsSetup() const; - void SetupPlotHelper(StripChart::DataStrip* chart, const char* channelName, float startValue); - void PlotData(StripChart::DataStrip* chart, float tickSize, float horizontalValue, float verticalValue, bool forceDraw); - - // Call this if you are going to do safety checks and don't want the GraphPlotHelper to do that. - // i.e. if your adding a bunch of data in a row, you'll want to safety check once, then add all the data here. - void PlotBatchedData(StripChart::DataStrip* chart, float tickSize, float horizontalValue, float verticalValue, bool forceDraw); - - void SetHighlight(StripChart::DataStrip* chart, bool highlight); - void ZeroOutLine(float lastHorizontalValue, float tickSize, StripChart::DataStrip* chart); - - private: - QColor m_color; - int m_channelId; - bool m_zeroOutLine; - bool m_initializeLine; - float m_lastHorizontalValue; - }; - - class AreaGraphPlotHelper - { - public: - AreaGraphPlotHelper(const QColor& displayColor); - - bool IsSetup() const; - void Reset(); - - void SetupPlotHelper(AreaChart::AreaChart* chart, const char* channelName, size_t seriesSize = 0); - - void PlotData(int position, unsigned int value); - void PlotBatchedData(int position, unsigned int value); - - void SetHighlighted(bool highlighted); - void SetEnabled(bool enabled); - - bool IsSeries(size_t seriesId) const; - - private: - - QColor m_color; - - AreaChart::AreaChart* m_areaChart; - size_t m_seriesId; - }; - - struct BandwidthUsageAggregator - { - BandwidthUsageAggregator(); - - void Reset(); - - quint64 m_bytesSent; - quint64 m_bytesReceived; - }; - - struct BandwidthUsage - { - enum class DataType - { - UNKNOWN, - DATA_SET, - REMOTE_PROCEDURE_CALL - }; - - DataType m_dataType = DataType::UNKNOWN; - BandwidthUsageAggregator m_usageAggregator; - - size_t m_index; - AZStd::string m_identifier; - }; - - class BandwidthUsageContainer - { - public: - typedef AZStd::unordered_map UsageAggregationMap; - typedef AZStd::unordered_map DataTypeAggreationMap; - - AZ_CLASS_ALLOCATOR(BandwidthUsageContainer, AZ::SystemAllocator, 0); - - BandwidthUsageContainer(); - virtual ~BandwidthUsageContainer(); - - void ProcessChunkEvent(const ReplicaChunkEvent* chunkEvent); - - size_t GetTotalBytesSent() const; - size_t GetTotalBytesReceived() const; - size_t GetTotalBandwidthUsage() const; - - const UsageAggregationMap& GetDataTypeUsageAggregation(BandwidthUsage::DataType dataType) const; - - protected: - virtual void OnProcessSentDataSet(const ReplicaChunkSentDataSetEvent* sentData); - virtual void OnProcessReceivedDataSet(const ReplicaChunkReceivedDataSetEvent* receivedData); - - virtual void OnProcessSentRPC(const ReplicaChunkSentRPCEvent* sentData); - virtual void OnProcessReceivedRPC(const ReplicaChunkReceivedRPCEvent* receivedData); - - private: - DataTypeAggreationMap m_dataTypeAggregationMap; - - BandwidthUsageAggregator m_totalUsageAggregator; - }; - - template - class ReplicaBandwidthChartData - { - public: - typedef AZStd::unordered_map BandwidthUsageMap; - typedef AZStd::unordered_map FrameMap; - - public: - AZ_CLASS_ALLOCATOR(ReplicaBandwidthChartData, AZ::SystemAllocator, 0); - - ReplicaBandwidthChartData(const QColor& color) - : m_color(color) - , m_enabled(true) - , m_selected(false) - , m_inspected(false) - , m_areaGraphPlotHelper(color) - { - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(m_color); - painter.drawRect(0, 0, 16, 16); - - m_icon.addPixmap(pixmap); - } - - virtual ~ReplicaBandwidthChartData() - { - for (typename FrameMap::iterator frameIter = m_frameMapping.begin(); - frameIter != m_frameMapping.end(); - ++frameIter) - { - BandwidthUsageMap* bandwidthUsageMap = frameIter->second; - - for (typename BandwidthUsageMap::iterator usageIter = bandwidthUsageMap->begin(); - usageIter != bandwidthUsageMap->end(); - ++usageIter) - { - delete usageIter->second; - } - - azdestroy(bandwidthUsageMap); - } - } - - virtual const char* GetAxisName() const = 0; - - const QColor& GetColor() const - { - return m_color; - } - - const QIcon& GetIcon() const - { - if (m_enabled) - { - return m_icon; - } - else - { - static bool s_doOnce = true; - static QIcon s_blackIcon; - - if (s_doOnce) - { - s_doOnce = false; - - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(Qt::black); - painter.drawRect(0, 0, 16, 16); - - s_blackIcon.addPixmap(pixmap); - } - - return s_blackIcon; - } - } - - bool HasUsageForFrame(FrameNumberType frame) const - { - return m_frameMapping.find(frame) != m_frameMapping.end(); - } - - const BandwidthUsageMap& FindUsageForFrame(FrameNumberType frameId) const - { - static const BandwidthUsageMap emptyMap; - - typename FrameMap::const_iterator frameIter = m_frameMapping.find(frameId); - - if (frameIter == m_frameMapping.end()) - { - return emptyMap; - } - else - { - return (*frameIter->second); - } - } - - const FrameMap& GetUsageForAllFrames() const - { - return m_frameMapping; - } - - size_t GetSentUsageForFrame(FrameNumberType frameId) const - { - size_t totalSentUsage = 0; - const BandwidthUsageMap& frameMap = FindUsageForFrame(frameId); - - for (auto frameIter = frameMap.begin(); - frameIter != frameMap.end(); - ++frameIter) - { - totalSentUsage += frameIter->second->GetTotalBytesSent(); - } - - return totalSentUsage; - } - - size_t GetReceivedUsageForFrame(FrameNumberType frameId) const - { - size_t totalReceivedUsage = 0; - - const BandwidthUsageMap& frameMap = FindUsageForFrame(frameId); - - for (auto frameIter = frameMap.begin(); - frameIter != frameMap.end(); - ++frameIter) - { - totalReceivedUsage += frameIter->second->GetTotalBytesReceived(); - } - - return totalReceivedUsage; - } - - const FrameMap& GetAllFrames() const - { - return m_frameMapping; - } - - AZ::s64 GetActiveFrameCount() const - { - return m_frameMapping.size(); - } - - void SetEnabled(bool enabled) - { - m_enabled = enabled; - } - - bool IsEnabled() const - { - return m_enabled; - } - - void SetSelected(bool selected) - { - m_selected = selected; - } - - bool IsSelected() const - { - return m_selected; - } - - void SetInspected(bool inspected) - { - m_inspected = inspected; - } - - bool IsInspected() const - { - return m_inspected; - } - - AreaGraphPlotHelper& GetAreaGraphPlotHelper() - { - return m_areaGraphPlotHelper; - } - - void ProcessReplicaChunkEvent(FrameNumberType frameId, const ReplicaChunkEvent* chunkEvent) - { - BandwidthUsageContainer* container = GetUsageForFrame(frameId, chunkEvent); - - if (container) - { - container->ProcessChunkEvent(chunkEvent); - } - } - - protected: - - BandwidthUsageMap* GetUsageForFrame(FrameNumberType frameId) - { - BandwidthUsageMap* retVal = nullptr; - - typename FrameMap::iterator frameIter = m_frameMapping.find(frameId); - - if (frameIter == m_frameMapping.end()) - { - retVal = azcreate(BandwidthUsageMap, ()); - - if (retVal) - { - m_frameMapping.insert(typename FrameMap::value_type(frameId, retVal)); - } - } - else - { - retVal = frameIter->second; - } - - return retVal; - } - - BandwidthUsageContainer* GetUsageForFrame(FrameNumberType frameId, const ReplicaChunkEvent* chunkEvent) - { - BandwidthUsageContainer* chunkContainer = nullptr; - BandwidthUsageMap* usageMap = GetUsageForFrame(frameId); - - if (usageMap) - { - T usageKey = GetKeyFromEvent(chunkEvent); - typename BandwidthUsageMap::iterator chunkIter = usageMap->find(usageKey); - - if (chunkIter == usageMap->end()) - { - chunkContainer = CreateBandwidthUsage(chunkEvent); - - if (chunkContainer) - { - usageMap->insert(typename BandwidthUsageMap::value_type(usageKey, chunkContainer)); - } - } - else - { - chunkContainer = static_cast(chunkIter->second); - } - } - - return chunkContainer; - } - - virtual BandwidthUsageContainer* CreateBandwidthUsage(const ReplicaChunkEvent* chunkEvent) = 0; - virtual T GetKeyFromEvent(const ReplicaChunkEvent* chunkEvent) const = 0; - - private: - - QIcon m_icon; - QColor m_color; - - FrameMap m_frameMapping; - bool m_enabled; - bool m_selected; - bool m_inspected; - - AreaGraphPlotHelper m_areaGraphPlotHelper; - }; -} -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.cpp deleted file mode 100644 index 5a35b095e3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.cpp +++ /dev/null @@ -1,430 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -#include "ReplicaChunkTypeDetailView.h" - -#include - -#include "ReplicaChunkUsageDataContainers.h" -#include "ReplicaDataAggregator.hxx" - -namespace Driller -{ - //////////////////////////////////// - // ReplicaChunkTypeDetailViewModel - //////////////////////////////////// - - ReplicaChunkTypeDetailViewModel::ReplicaChunkTypeDetailViewModel(ReplicaChunkTypeDetailView* chunkDetailView) - : BaseDetailTreeViewModel(chunkDetailView) - { - } - - int ReplicaChunkTypeDetailViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return static_cast(CD_COUNT); - } - - QVariant ReplicaChunkTypeDetailViewModel::data(const QModelIndex& index, int role) const - { - const BaseDisplayHelper* baseDisplay = static_cast(index.internalPointer()); - - if (role == Qt::BackgroundRole) - { - if (baseDisplay->m_inspected) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - else - { - switch (index.column()) - { - case CD_DISPLAY_NAME: - if (role == Qt::DecorationRole) - { - if (baseDisplay->HasIcon()) - { - return baseDisplay->GetIcon(); - } - } - else if (role == Qt::DisplayRole) - { - QString displayName = baseDisplay->GetDisplayName(); - - if (displayName.isEmpty()) - { - return QString(""); - } - else - { - return displayName; - } - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignVCenter); - } - - break; - case CD_REPLICA_ID: - { - if (role == Qt::DisplayRole) - { - AZ::u64 replicaId = 0; - - const BaseDisplayHelper* currentDisplay = baseDisplay; - - while (currentDisplay != nullptr && !azrtti_istypeof(currentDisplay)) - { - currentDisplay = currentDisplay->GetParent(); - } - - if (currentDisplay) - { - const ReplicaDetailDisplayHelper* replicaDisplay = static_cast(currentDisplay); - replicaId = replicaDisplay->GetReplicaId(); - } - - return FormattingHelper::ReplicaID(replicaId); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - } - break; - case CD_TOTAL_SENT: - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesSent); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_RECEIVED: - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_RPC_COUNT: - if (role == Qt::DisplayRole) - { - if (azrtti_istypeof(baseDisplay)) - { - size_t count = 0; - - for (BaseDisplayHelper* displayHelper : baseDisplay->GetChildren()) - { - count += displayHelper->GetChildren().size(); - } - - return QString::number(count); - } - else if (azrtti_istypeof(baseDisplay)) - { - return QString::number(baseDisplay->GetChildren().size()); - } - } - break; - default: - AZ_Assert(false,"Unknown column index %i",index.column()); - break; - } - } - - return QVariant(); - } - - QVariant ReplicaChunkTypeDetailViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_DISPLAY_NAME: - return QString("Name"); - case CD_REPLICA_ID: - return QString("ReplicaId"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_RPC_COUNT: - return QString("RPC Count"); - default: - AZ_Assert(false, "Unknown section index %i", section); - break; - } - } - } - - return QVariant(); - } - - /////////////////////////////// - // ReplicaChunkTypeDetailView - /////////////////////////////// - ReplicaChunkTypeDetailView::ReplicaChunkTypeDetailView(ReplicaDataView* replicaDataView, ReplicaChunkTypeDataContainer* chunkTypeDataContainer) - : BaseDetailView(replicaDataView) - , m_inspectedSeries(AreaChart::AreaChart::k_invalidSeriesId) - , m_aggregateDisplayHelper(nullptr) - , m_replicaChunkData(chunkTypeDataContainer) - , m_chunkTypeDetailView(this) - , m_lifespanTelemetry("ReplicaChunkTypeDetailView") - { - QString replicaChunkType = QString("%1").arg(chunkTypeDataContainer->GetChunkType()); - - show(); - raise(); - activateWindow(); - setFocus(); - - setWindowTitle(QString("%1's breakdown - %2").arg(replicaChunkType).arg(replicaDataView->m_aggregator->GetInspectionFileName())); - - m_gui->replicaName->setText(replicaChunkType); - - // Ordering here needs to match ordering in BaseDetailView.h - m_gui->aggregationTypeComboBox->addItem(QString("Replica")); - m_gui->aggregationTypeComboBox->addItem(QString("Combined")); - - if (m_gui->aggregationTypeComboBox->count() == 1) - { - m_gui->aggregationTypeComboBox->setEditable(false); - m_gui->aggregationTypeComboBox->setEnabled(false); - } - - QObject::connect((&m_chunkTypeDetailView), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(UpdateDisplay(const QModelIndex&, const QModelIndex&))); - QObject::connect(m_gui->aggregationTypeComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(DisplayModeChanged(int))); - - m_gui->aggregationTypeComboBox->setCurrentIndex(static_cast(DisplayMode::Aggregate)); - } - - ReplicaChunkTypeDetailView::~ReplicaChunkTypeDetailView() - { - for (ReplicaDetailDisplayMap::iterator displayIter = m_replicaDisplayMapping.begin(); - displayIter != m_replicaDisplayMapping.end(); - ++displayIter) - { - delete displayIter->second; - } - } - - const ReplicaBandwidthChartData::FrameMap& ReplicaChunkTypeDetailView::GetFrameData() const - { - return m_replicaChunkData->GetAllFrames(); - } - - BaseDetailDisplayHelper* ReplicaChunkTypeDetailView::FindDetailDisplay(const AZ::u64& replicaId) - { - BaseDetailDisplayHelper* retVal = nullptr; - - ReplicaDetailDisplayMap::iterator displayIter = m_replicaDisplayMapping.find(replicaId); - - if (displayIter != m_replicaDisplayMapping.end()) - { - retVal = displayIter->second; - } - - return retVal; - } - - const BaseDetailDisplayHelper* ReplicaChunkTypeDetailView::FindDetailDisplay(const AZ::u64& replicaId) const - { - const BaseDetailDisplayHelper* retVal = nullptr; - - ReplicaDetailDisplayMap::const_iterator displayIter = m_replicaDisplayMapping.find(replicaId); - - if (displayIter != m_replicaDisplayMapping.end()) - { - retVal = displayIter->second; - } - - return retVal; - } - - void ReplicaChunkTypeDetailView::InitializeDisplayData() - { - m_activeIds.clear(); - m_activeInspectedIds.clear(); - - BaseDetailDisplayHelper* aggregateDisplayHelper = FindAggregateDisplay(); - - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->GetDataSetDisplayHelper()->ClearActiveDisplay(); - aggregateDisplayHelper->GetRPCDisplayHelper()->ClearActiveDisplay(); - } - - const ReplicaChunkTypeDataContainer::FrameMap& frameMap = m_replicaChunkData->GetAllFrames(); - - for (FrameNumberType currentFrame = m_replicaDataView->GetStartFrame(); currentFrame <= m_replicaDataView->GetEndFrame(); ++currentFrame) - { - ReplicaChunkTypeDataContainer::FrameMap::const_iterator frameIter = frameMap.find(currentFrame); - - if (frameIter == frameMap.end()) - { - continue; - } - - const ReplicaChunkTypeDataContainer::BandwidthUsageMap* usageMap = frameIter->second; - - for (ReplicaChunkTypeDataContainer::BandwidthUsageMap::const_iterator usageIter = usageMap->begin(); - usageIter != usageMap->end(); - ++usageIter) - { - ReplicaBandwidthUsage* bandwidthUsage = static_cast(usageIter->second); - - ReplicaDetailDisplayMap::iterator displayIter = m_replicaDisplayMapping.find(bandwidthUsage->GetReplicaId()); - ReplicaDetailDisplayHelper* replicaDisplay = nullptr; - - if (displayIter == m_replicaDisplayMapping.end()) - { - replicaDisplay = aznew ReplicaDetailDisplayHelper(bandwidthUsage->GetReplicaName(), bandwidthUsage->GetReplicaId()); - - if (replicaDisplay) - { - m_replicaDisplayMapping.insert(AZStd::make_pair(replicaDisplay->GetReplicaId(), replicaDisplay)); - } - } - else - { - replicaDisplay = displayIter->second; - } - - // Consider sending along an overall descriptor of the replcia so we can easily setup the display instead - // of iterating blindly over our detail information trying to get a sense of what the thing is. - if (replicaDisplay) - { - if (currentFrame == m_replicaDataView->GetCurrentFrame()) - { - m_activeInspectedIds.insert(replicaDisplay->GetReplicaId()); - } - - // First time we add an object in we want to reset it's display. - if (m_activeIds.insert(replicaDisplay->GetReplicaId()).second) - { - replicaDisplay->GetDataSetDisplayHelper()->ClearActiveDisplay(); - replicaDisplay->GetRPCDisplayHelper()->ClearActiveDisplay(); - } - - const ReplicaBandwidthUsage::UsageAggregationMap& dataSetBandwidthUsage = bandwidthUsage->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - - for (const auto& usagePair : dataSetBandwidthUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - - replicaDisplay->SetupDataSet(currentUsage.m_index, currentUsage.m_identifier.c_str()); - - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->SetupDataSet(currentUsage.m_index, currentUsage.m_identifier.c_str()); - } - } - - const ReplicaBandwidthUsage::UsageAggregationMap& rpcBandwidthUsage = bandwidthUsage->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - for (const auto& usagePair : rpcBandwidthUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - - replicaDisplay->SetupRPC(currentUsage.m_index, currentUsage.m_identifier.c_str()); - - if (aggregateDisplayHelper) - { - aggregateDisplayHelper->SetupRPC(currentUsage.m_index, currentUsage.m_identifier.c_str()); - } - } - } - } - } - } - - BaseDetailDisplayHelper* ReplicaChunkTypeDetailView::FindAggregateDisplay() - { - if (m_aggregateDisplayHelper == nullptr) - { - m_aggregateDisplayHelper = aznew ReplicaDetailDisplayHelper("Combined Usage", FindAggregateID()); - m_replicaDisplayMapping.insert(AZStd::make_pair(m_aggregateDisplayHelper->GetReplicaId(), m_aggregateDisplayHelper)); - } - - return m_aggregateDisplayHelper; - } - - AZ::u64 ReplicaChunkTypeDetailView::FindAggregateID() const - { - return 0; - } - - void ReplicaChunkTypeDetailView::LayoutChanged() - { - m_chunkTypeDetailView.layoutChanged(); - } - - void ReplicaChunkTypeDetailView::OnSetupTreeView() - { - m_gui->treeView->setModel(&m_chunkTypeDetailView); - ShowTreeFrame(m_replicaDataView->GetCurrentFrame()); - } - - void ReplicaChunkTypeDetailView::ShowTreeFrame(FrameNumberType frameId) - { - m_chunkTypeDetailView.RefreshView(frameId); - } - - AZ::u32 ReplicaChunkTypeDetailView::CreateWindowGeometryCRC() - { - return AZ::Crc32("REPLICA_CHUNK_DETAIL_VIEW_WINDOW_STATE"); - } - - AZ::u32 ReplicaChunkTypeDetailView::CreateSplitterStateCRC() - { - return AZ::Crc32("REPLICA_CHUNK_DETAIL_VIEW_SPLITTER_STATE"); - } - - AZ::u32 ReplicaChunkTypeDetailView::CreateTreeStateCRC() - { - return AZ::Crc32("REPLICA_CHUNK_DETAIL_VIEW_TREE_STATE"); - } - - void ReplicaChunkTypeDetailView::OnInspectedSeries(size_t seriesId) - { - if (m_inspectedSeries != seriesId) - { - m_inspectedSeries = seriesId; - - // TODO: Handle expanding the tree and scrolling to the selected value. - for (auto& mapPair : m_replicaDisplayMapping) - { - BaseDetailDisplayHelper* displayHelper = mapPair.second; - - displayHelper->InspectSeries(m_inspectedSeries); - } - - if (m_aggregateDisplayHelper) - { - m_aggregateDisplayHelper->InspectSeries(m_inspectedSeries); - } - - m_chunkTypeDetailView.layoutChanged(); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.h deleted file mode 100644 index 16b2ba7cba..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkTypeDetailView.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_REPLICACHUNKTYPEDETAILVIEW_H -#define DRILLER_REPLICA_REPLICACHUNKTYPEDETAILVIEW_H - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Replica/ReplicaDataView.hxx" - -#include "Source/Driller/Replica/BaseDetailView.h" - -namespace Ui -{ - class ReplicaDetailView; -} - -namespace Driller -{ - class ReplicaBandwidthUsage; - class ReplicaChunkTypeDetailView; - - class ReplicaChunkTypeDetailViewModel - : public BaseDetailTreeViewModel - { - public: - enum ColumnDescriptor - { - // Forcing the index to start at 0 - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order - CD_DISPLAY_NAME, - CD_REPLICA_ID, - CD_TOTAL_SENT, - CD_TOTAL_RECEIVED, - CD_RPC_COUNT, - - // Used for sizing of the TableView. Anything after this won't be displayed. - CD_COUNT - }; - - AZ_CLASS_ALLOCATOR(ReplicaChunkTypeDetailViewModel, AZ::SystemAllocator, 0); - ReplicaChunkTypeDetailViewModel(ReplicaChunkTypeDetailView* detailView); - - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - }; - - class ReplicaChunkTypeDetailView - : public BaseDetailView - { - typedef AZStd::unordered_map ReplicaDetailDisplayMap; - - friend class ReplicaChunkTypeDetailViewModel; - - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkTypeDetailView, AZ::SystemAllocator, 0); - - ReplicaChunkTypeDetailView(ReplicaDataView* replicaDataView, ReplicaChunkTypeDataContainer* chunkTypeDataContainer); - ~ReplicaChunkTypeDetailView(); - - const ReplicaBandwidthChartData::FrameMap& GetFrameData() const override; - BaseDetailDisplayHelper* FindDetailDisplay(const AZ::u64& replicaId) override; - const BaseDetailDisplayHelper* FindDetailDisplay(const AZ::u64& replicaId) const override; - - BaseDetailDisplayHelper* FindAggregateDisplay() override; - AZ::u64 FindAggregateID() const override; - - protected: - - void InitializeDisplayData() override; - - void LayoutChanged() override; - void OnSetupTreeView() override; - void ShowTreeFrame(FrameNumberType frameId) override; - - AZ::u32 CreateWindowGeometryCRC() override; - AZ::u32 CreateSplitterStateCRC() override; - AZ::u32 CreateTreeStateCRC() override; - - void OnInspectedSeries(size_t seriesId); - - private: - - size_t m_inspectedSeries; - - ReplicaDetailDisplayHelper* m_aggregateDisplayHelper; - - ReplicaDetailDisplayMap m_replicaDisplayMapping; - ReplicaChunkTypeDataContainer* m_replicaChunkData; - - ReplicaChunkTypeDetailViewModel m_chunkTypeDetailView; - - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.cpp deleted file mode 100644 index 28bcf29daa..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ReplicaChunkUsageDataContainers.h" - -#include "Source/Driller/StripChart.hxx" -#include "ReplicaDataEvents.h" - -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" - -namespace Driller -{ - ////////////////////////// - // ReplicaBandwidthUsage - ////////////////////////// - - ReplicaBandwidthUsage::ReplicaBandwidthUsage(const char* replicaName, AZ::u64 replicaId) - : m_replicaName(replicaName) - , m_replicaId(replicaId) - { - } - - AZ::u64 ReplicaBandwidthUsage::GetReplicaId() const - { - return m_replicaId; - } - - const char* ReplicaBandwidthUsage::GetReplicaName() const - { - return m_replicaName.c_str(); - } - - ////////////////////////////////// - // ReplicaChunkTypeDataContainer - ////////////////////////////////// - - ReplicaChunkTypeDataContainer::ReplicaChunkTypeDataContainer(const char* replicaType, const QColor& displayColor) - : ReplicaBandwidthChartData(displayColor) - , m_replicaType(replicaType) - { - } - - const char* ReplicaChunkTypeDataContainer::GetChunkType() const - { - return m_replicaType.c_str(); - } - - const char* ReplicaChunkTypeDataContainer::GetAxisName() const - { - return GetChunkType(); - } - - BandwidthUsageContainer* ReplicaChunkTypeDataContainer::CreateBandwidthUsage(const ReplicaChunkEvent* dataEvent) - { - return aznew ReplicaBandwidthUsage(dataEvent->GetReplicaName(), dataEvent->GetReplicaId()); - } - - AZ::u64 ReplicaChunkTypeDataContainer::GetKeyFromEvent(const ReplicaChunkEvent* dataEvent) const - { - return dataEvent->GetReplicaId(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.h deleted file mode 100644 index 946359b006..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaChunkUsageDataContainers.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_CHUNK_USAGE_DATA_CONTAINER_H -#define DRILLER_REPLICA_CHUNK_USAGE_DATA_CONTAINER_H - -#include -#include -#include -#include -#include -#include - -#include - -#include "ReplicaBandwidthChartData.h" - -namespace Driller -{ - class ReplicaDataAggregator; - class ReplicaChunkEvent; - class ReplicaDataView; - - class BaseDetailDisplayHelper; - - class ReplicaBandwidthUsage - : public BandwidthUsageContainer - { - public: - AZ_CLASS_ALLOCATOR(ReplicaBandwidthUsage, AZ::SystemAllocator, 0); - ReplicaBandwidthUsage(const char* replicaName, AZ::u64 replicaId); - - AZ::u64 GetReplicaId() const; - const char* GetReplicaName() const; - - private: - AZStd::string m_replicaName; - AZ::u64 m_replicaId; - }; - - class ReplicaChunkTypeDataContainer - : public ReplicaBandwidthChartData - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkTypeDataContainer, AZ::SystemAllocator, 0); - - ReplicaChunkTypeDataContainer(const char* replicaType, const QColor& displayColor); - - const char* GetChunkType() const; - const char* GetAxisName() const override; - - protected: - BandwidthUsageContainer* CreateBandwidthUsage(const ReplicaChunkEvent* dataEvent) override; - AZ::u64 GetKeyFromEvent(const ReplicaChunkEvent* dataEvent) const override; - - private: - - ReplicaBandwidthUsage* GetReplicaForFrame(AZ::u64 frameId, const ReplicaChunkEvent* dataEvent); - - AZStd::string m_replicaType; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.cpp deleted file mode 100644 index 9cc2c9ae10..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.cpp +++ /dev/null @@ -1,690 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include - -#include "ReplicaDataAggregator.hxx" -#include - -#include "ReplicaDataEvents.h" -#include "ReplicaDataView.hxx" - -#include "Source/Driller/Workspaces/Workspace.h" -#include "Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.hxx" -#include "Source/Driller/ChannelDataView.hxx" - -namespace Driller -{ - //////////////////////////////////// - // ReplicaDataAggregatorSavedState - //////////////////////////////////// - - class ReplicaDataAggregatorSavedState : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaDataAggregatorSavedState, "{599BCB69-C521-4EFD-9D79-C09790907F81}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaDataAggregatorSavedState, AZ::SystemAllocator, 0); - - ReplicaDataAggregatorSavedState() - { - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Version(1) - ->Field("FrameBudget", &ReplicaDataConfigurationSettings::m_averageFrameBudget) - ->Field("DisplayType", &ReplicaDataConfigurationSettings::m_configurationDisplay) - ->Field("FrameRate", &ReplicaDataConfigurationSettings::m_frameRate) - ; - - serialize->Class() - ->Version(2) - ->Field("ConfigurationSettings",&ReplicaDataAggregatorSavedState::m_configurationSettings) - ; - } - } - - ReplicaDataConfigurationSettings m_configurationSettings; - }; - - /////////////////////////////////// - // ReplicaDataAggregatorWorkspace - /////////////////////////////////// - - class ReplicaDataAggregatorWorkspace : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaDataAggregatorWorkspace, "{EF501646-46BB-4C20-83C9-4C6816294448}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaDataAggregatorWorkspace,AZ::SystemAllocator,0); - - AZStd::vector m_activeViewIndexes; - - ReplicaDataAggregatorWorkspace() - { - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewIndexes",&ReplicaDataAggregatorWorkspace::m_activeViewIndexes) - ->Version(1); - } - } - }; - - //////////////////////////////////// - // ReplicaExportSettingsSavedState - //////////////////////////////////// - - class ReplicaExportSettingsSavedState : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaExportSettingsSavedState,"{5CE5D03E-04A9-4D28-91D4-5587E0643E84}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaExportSettingsSavedState,AZ::SystemAllocator,0); - - bool m_exportColumnDescriptors; - AZStd::vector< int > m_exportOrdering; - - ReplicaExportSettingsSavedState() - : m_exportColumnDescriptors(true) - { - } - - void Init() - { - m_exportOrdering = - { - static_cast(ReplicaExportSettings::ExportField::Name), - static_cast(ReplicaExportSettings::ExportField::Id), - static_cast(ReplicaExportSettings::ExportField::ChunkType), - static_cast(ReplicaExportSettings::ExportField::UsageType), - static_cast(ReplicaExportSettings::ExportField::UsageIdentifier), - static_cast(ReplicaExportSettings::ExportField::Bytes_Sent), - static_cast(ReplicaExportSettings::ExportField::Bytes_Received), - }; - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_exportColumnDescriptors",&ReplicaExportSettingsSavedState::m_exportColumnDescriptors) - ->Field("m_exportOrdering",&ReplicaExportSettingsSavedState::m_exportOrdering) - ->Version(1); - } - } - }; - - ////////////////////////// - // ReplicaExportSettings - ////////////////////////// - - const char* ReplicaExportSettings::REPLICA_CSV_EXPORT_SETTINGS = "REPLICA_CSV_EXPORT_SETTINGS"; - - ReplicaExportSettings::ReplicaExportSettings() - { - m_columnDescriptors = - { - { ExportField::Name, "Replica Name"}, - { ExportField::Id, "Replica Id"}, - { ExportField::ChunkType,"ReplicaChunk Type"}, - { ExportField::UsageType,"Usage Type"}, - { ExportField::UsageIdentifier,"Usage Identifier"}, - { ExportField::Bytes_Sent,"Data Sent(Bytes)"}, - { ExportField::Bytes_Received,"Data Received(Bytes)"}, - }; - - for (const AZStd::pair< ExportField, AZStd::string >& item : m_columnDescriptors) - { - m_stringToExportEnum[item.second] = item.first; - } - } - - void ReplicaExportSettings::LoadSettings() - { - m_persistentState = AZ::UserSettings::Find(AZ_CRC(REPLICA_CSV_EXPORT_SETTINGS), AZ::UserSettings::CT_GLOBAL); - - if (m_persistentState == nullptr) - { - m_persistentState = AZ::UserSettings::CreateFind(AZ_CRC(REPLICA_CSV_EXPORT_SETTINGS), AZ::UserSettings::CT_GLOBAL); - m_persistentState->Init(); - } - } - - void ReplicaExportSettings::GetExportItems(QStringList& items) const - { - for (const AZStd::pair< ReplicaExportField, AZStd::string>& item : m_columnDescriptors) - { - items.push_back(QString(item.second.c_str())); - } - } - - void ReplicaExportSettings::GetActiveExportItems(QStringList& items) const - { - for (unsigned int i=0; i < m_persistentState->m_exportOrdering.size(); ++i) - { - ReplicaExportField currentField = static_cast(m_persistentState->m_exportOrdering[i]); - - if (currentField != ReplicaExportField::UNKNOWN) - { - items.push_back(QString(FindColumnDescriptor(currentField).c_str())); - } - } - } - - void ReplicaExportSettings::UpdateExportOrdering(const QStringList& activeItems) - { - m_persistentState->m_exportOrdering.clear(); - - for (const QString& activeItem : activeItems) - { - ExportField field = FindExportFieldFromDescriptor(activeItem.toStdString().c_str()); - - AZ_Warning("Standalone Tools",field != ExportField::UNKNOWN,"Unknown descriptor %s",activeItem.toStdString().c_str()); - if (field != ExportField::UNKNOWN) - { - m_persistentState->m_exportOrdering.push_back(static_cast(field)); - } - } - - m_persistentState->m_exportColumnDescriptors = this->ShouldExportColumnDescriptors(); - } - - const AZStd::vector< int >& ReplicaExportSettings::GetExportOrder() const - { - return m_persistentState->m_exportOrdering; - } - - const AZStd::string& ReplicaExportSettings::FindColumnDescriptor(ExportField exportField) const - { - static const AZStd::string emptyDescriptor; - - AZStd::unordered_map::const_iterator descriptorIter = m_columnDescriptors.find(exportField); - - if (descriptorIter == m_columnDescriptors.end()) - { - AZ_Warning("Standalone Tools",false,"Unknown column descriptor in Carrier CSV Export"); - return emptyDescriptor; - } - else - { - return descriptorIter->second; - } - } - - ReplicaExportField ReplicaExportSettings::FindExportFieldFromDescriptor(const char* columnDescriptor) const - { - AZStd::unordered_map::const_iterator exportIter = m_stringToExportEnum.find(columnDescriptor); - - ExportField retVal = ExportField::UNKNOWN; - - if (exportIter != m_stringToExportEnum.end()) - { - retVal = exportIter->second; - } - - return retVal; - } - - ////////////////////////// - // ReplicaDataAggregator - ////////////////////////// - - const char* ReplicaDataAggregator::REPLICA_AGGREGATOR_SAVED_STATE = "REPLICA_DATA_AGGREGATOR_SAVED_STATE"; - const char* ReplicaDataAggregator::REPLICA_AGGREGATOR_WORKSPACE = "REPLICA_DATA_AGGREGATOR_WORKSPACE"; - - ReplicaDataAggregator::ReplicaDataAggregator(int identity) - : Aggregator(identity) - , m_parser(this) - , m_budgetMarkerTicket(0) - , m_processingFrame(0) - , m_currentFrameUsage(0.0f) - , m_maxFrameUsage(0.0f) - , m_normalizingValue(1.0f) - { - // find state and restore it - m_persistentState = AZ::UserSettings::CreateFind(AZ_CRC(REPLICA_AGGREGATOR_SAVED_STATE), AZ::UserSettings::CT_GLOBAL); - m_csvExportSettings.LoadSettings(); - - OnConfigurationChanged(); - - connect(this, SIGNAL(OnEventFinalized(DrillerEvent*)), SLOT(ProcessDrillerEvent(DrillerEvent*))); - } - - ReplicaDataAggregator::~ReplicaDataAggregator() - { - // Clear out our open data views - while (!m_openDataViews.empty()) - { - delete m_openDataViews.front(); - } - } - - CustomizeCSVExportWidget* ReplicaDataAggregator::CreateCSVExportCustomizationWidget() - { - return aznew GenericCustomizeCSVExportWidget(m_csvExportSettings); - } - - bool ReplicaDataAggregator::HasConfigurations() const - { - return true; - } - - ChannelConfigurationWidget* ReplicaDataAggregator::CreateConfigurationWidget() - { - return aznew ReplicaDataAggregatorConfigurationPanel(m_persistentState->m_configurationSettings); - } - - void ReplicaDataAggregator::OnConfigurationChanged() - { - // Adding a bit of fluff room into average frame budget in order to give it a bit of extra space above it - // so the line is really clear. - float normalizingValue = m_normalizingValue; - - // Only allow the maximum usage to double our specified budget to avoid losing too much fidelity - // for outlier data. - float maxUsage = AZ::GetMin(m_maxFrameUsage,m_persistentState->m_configurationSettings.m_averageFrameBudget * 2.0f); - - m_normalizingValue = AZStd::max(maxUsage, m_persistentState->m_configurationSettings.m_averageFrameBudget); - m_normalizingValue = AZStd::GetMax(1.0f, m_normalizingValue); - - if (!AZ::IsClose(normalizingValue,m_normalizingValue,0.001f)) - { - emit NormalizedRangeChanged(); - } - } - - void ReplicaDataAggregator::AnnotateChannelView(ChannelDataView* channelDataView) - { - RemoveChannelAnnotation(channelDataView); - - float budgetMarker = (2.0f * (m_persistentState->m_configurationSettings.m_averageFrameBudget / m_normalizingValue) - 1.0f); - - QColor color = GetColor(); - color.setRed(AZStd::min(color.red() + 50, 255)); - color.setGreen(AZStd::min(color.green() + 50, 255)); - color.setBlue(AZStd::min(color.blue() + 50, 255)); - - m_budgetMarkerTicket = channelDataView->AddBudgetMarker(budgetMarker, color); - } - - void ReplicaDataAggregator::RemoveChannelAnnotation(ChannelDataView* channelDataView) - { - if (m_budgetMarkerTicket != 0) - { - channelDataView->RemoveBudgetMarker(m_budgetMarkerTicket); - m_budgetMarkerTicket = 0; - } - } - - float ReplicaDataAggregator::ValueAtFrame(FrameNumberType frame) - { - size_t totalChunkBandwidth = 0; - - const EventListType& eventList = GetEvents(); - - // If we have an event, do some fancy color coding. - AZ::s64 numEvents = NumOfEventsAtFrame(frame); - AZ::s64 startIndex = GetFirstIndexAtFrame(frame); - - for (AZ::s64 i = 0; i < numEvents; ++i) - { - ReplicaChunkEvent* replicaChunkEvent = static_cast(eventList[startIndex + i]); - - totalChunkBandwidth += replicaChunkEvent->GetUsageBytes(); - } - - return AZStd::min(1.0f, static_cast(totalChunkBandwidth) / m_normalizingValue)*2.0f - 1.0f; - } - - void ReplicaDataAggregator::OnDataViewDestroyed(QObject* object) - { - for (AZStd::vector::iterator dataViewIter = m_openDataViews.begin(); - dataViewIter != m_openDataViews.end(); - ++dataViewIter) - { - if ((*dataViewIter) == object) - { - m_openDataViews.erase(dataViewIter); - break; - } - } - } - - void ReplicaDataAggregator::ProcessDrillerEvent(DrillerEvent* drillerEvent) - { - size_t currentFrame = GetFrameCount(); - - if (currentFrame != m_processingFrame) - { - m_processingFrame = currentFrame; - m_currentFrameUsage = 0; - } - - ReplicaChunkEvent* replicaChunkEvent = static_cast(drillerEvent); - m_currentFrameUsage += replicaChunkEvent->GetUsageBytes(); - - if (m_currentFrameUsage > m_maxFrameUsage) - { - m_maxFrameUsage = m_currentFrameUsage; - OnConfigurationChanged(); - } - } - - void ReplicaDataAggregator::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* settingsProvider) - { - (void)settingsProvider; - } - - void ReplicaDataAggregator::ActivateWorkspaceSettings(WorkspaceSettingsProvider* settingsProvider) - { - ReplicaDataAggregatorWorkspace* workspace = settingsProvider->FindSetting(AZ_CRC(REPLICA_AGGREGATOR_WORKSPACE)); - - if (workspace) - { - // Clear out our open data views - while (!m_openDataViews.empty()) - { - delete m_openDataViews.front(); - } - - for (int i=0; i < workspace->m_activeViewIndexes.size(); ++i) - { - ReplicaDataView* dataView = aznew ReplicaDataView(workspace->m_activeViewIndexes[i],1,this); - RegisterReplicaDataView(dataView); - - dataView->ApplySettingsFromWorkspace(settingsProvider); - dataView->ActivateWorkspaceSettings(settingsProvider); - } - } - } - - void ReplicaDataAggregator::SaveSettingsToWorkspace(WorkspaceSettingsProvider* settingsProvider) - { - ReplicaDataAggregatorWorkspace* workspace = settingsProvider->CreateSetting(AZ_CRC(REPLICA_AGGREGATOR_WORKSPACE)); - - if (workspace) - { - workspace->m_activeViewIndexes.clear(); - - for (ReplicaDataView* dataView : m_openDataViews) - { - workspace->m_activeViewIndexes.push_back(dataView->GetDataViewIndex()); - dataView->SaveSettingsToWorkspace(settingsProvider); - } - } - } - - unsigned int ReplicaDataAggregator::GetAverageFrameBandwidthBudget() const - { - return static_cast(m_persistentState->m_configurationSettings.m_averageFrameBudget); - } - - QColor ReplicaDataAggregator::GetColor() const - { - return QColor(0, 0, 255); - } - - QString ReplicaDataAggregator::GetName() const - { - return QString("Replica activity"); - } - - QString ReplicaDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString ReplicaDataAggregator::GetDescription() const - { - return QString("GridMate Replica Usage Per Frame"); - } - - QString ReplicaDataAggregator::GetToolTip() const - { - return QString("Information about Replica's, DataSet's, and RPC's"); - } - - AZ::Uuid ReplicaDataAggregator::GetID() const - { - return AZ::Uuid("{1252CBE9-111B-4CD3-AF10-FFAE9566B2FF}"); - } - - QWidget* ReplicaDataAggregator::DrillDownRequest(FrameNumberType frame) - { - unsigned int replicaDataViewIndex = static_cast(m_openDataViews.size()); - - // We only push to the back, so the list will be ordered with the highest index - // being at the back. - // Not exactly bulletproof, but simple(and if they want to open 4 billion windows to cause a slight error, more power to them). - if (!m_openDataViews.empty()) - { - replicaDataViewIndex = m_openDataViews.back()->GetDataViewIndex() + 1; - } - - ReplicaDataView* retVal = aznew ReplicaDataView(replicaDataViewIndex, frame, this); - RegisterReplicaDataView(retVal); - - return retVal; - } - - void ReplicaDataAggregator::OptionsRequest() - { - } - - void ReplicaDataAggregator::ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file, CSVExportSettings* exportSettings) - { - ReplicaExportSettings* replicaExportSettings = static_cast(exportSettings); - const AZStd::vector< int >& exportOrdering = replicaExportSettings->GetExportOrder(); - - bool addComma = false; - - for (int fieldId : exportOrdering) - { - ReplicaExportField currentField = static_cast(fieldId); - - if (addComma) - { - file.Write(",",1); - } - - const AZStd::string& columnDescriptor = replicaExportSettings->FindColumnDescriptor(currentField); - file.Write(columnDescriptor.c_str(),columnDescriptor.size()); - addComma = true; - } - - file.Write("\n",1); - } - - void ReplicaDataAggregator::ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent, CSVExportSettings* exportSettings) - { - AZ_Assert(azrtti_istypeof(drillerEvent),"Invalid Event"); - const ReplicaChunkEvent* replicaChunkEvent = static_cast(drillerEvent); - - ReplicaExportSettings* replicaExportSettings = static_cast(exportSettings); - - const AZStd::vector< int >& exportOrdering = replicaExportSettings->GetExportOrder(); - bool addComma = false; - - AZStd::string field; - - for (int fieldId : exportOrdering) - { - ReplicaExportField currentField = static_cast(fieldId); - - if (addComma) - { - file.Write(",",1); - } - - switch (currentField) - { - case ReplicaExportField::Name: - { - field = replicaChunkEvent->GetReplicaName(); - break; - } - case ReplicaExportField::Id: - { - AZStd::to_string(field,replicaChunkEvent->GetReplicaId()); - break; - } - case ReplicaExportField::ChunkType: - { - field = replicaChunkEvent->GetChunkTypeName(); - break; - } - case ReplicaExportField::UsageType: - { - switch (replicaChunkEvent->GetEventType()) - { - case Replica::RET_CHUNK_DATASET_SENT: - case Replica::RET_CHUNK_DATASET_RECEIVED: - { - field = "DataSet"; - break; - } - case Replica::RET_CHUNK_RPC_SENT: - case Replica::RET_CHUNK_RPC_RECEIVED: - { - field = "RPC"; - break; - } - default: - AZ_Warning("Standalone Tools",false,"Unknown Event Type for Replica Event"); - break; - } - break; - } - case ReplicaExportField::UsageIdentifier: - { - if (azrtti_istypeof(replicaChunkEvent)) - { - const ReplicaChunkSentDataSetEvent* dataSetEvent = static_cast(replicaChunkEvent); - field = dataSetEvent->GetDataSetName(); - } - else if (azrtti_istypeof(replicaChunkEvent)) - { - const ReplicaChunkReceivedDataSetEvent* dataSetEvent = static_cast(replicaChunkEvent); - field = dataSetEvent->GetDataSetName(); - } - else if (azrtti_istypeof(replicaChunkEvent)) - { - const ReplicaChunkSentRPCEvent* rpcEvent = static_cast(replicaChunkEvent); - field = rpcEvent->GetRPCName(); - } - else if (azrtti_istypeof(replicaChunkEvent)) - { - const ReplicaChunkReceivedRPCEvent* rpcEvent = static_cast(replicaChunkEvent); - field = rpcEvent->GetRPCName(); - } - else - { - AZ_Warning("Standalone Tools",false,"Invalid ReplicaEvent Type Usage"); - } - - break; - } - case ReplicaExportField::Bytes_Sent: - { - switch (replicaChunkEvent->GetEventType()) - { - case Replica::RET_CHUNK_RPC_SENT: - case Replica::RET_CHUNK_DATASET_SENT: - { - field = AZStd::to_string(static_cast(replicaChunkEvent->GetUsageBytes())); - break; - } - case Replica::RET_CHUNK_RPC_RECEIVED: - case Replica::RET_CHUNK_DATASET_RECEIVED: - { - field = "0"; - break; - } - default: - AZ_Warning("Standalone Tools",false,"Unknown EventType for ReplicaEvent"); - break; - } - break; - } - case ReplicaExportField::Bytes_Received: - { - switch (replicaChunkEvent->GetEventType()) - { - case Replica::RET_CHUNK_RPC_SENT: - case Replica::RET_CHUNK_DATASET_SENT: - { - field = "0"; - break; - } - case Replica::RET_CHUNK_RPC_RECEIVED: - case Replica::RET_CHUNK_DATASET_RECEIVED: - { - field = AZStd::to_string(static_cast(replicaChunkEvent->GetUsageBytes())); - break; - } - default: - AZ_Warning("Standalone Tools",false,"Unknown EventType for ReplicaEvent"); - break; - } - break; - } - default: - AZ_Warning("Standalone Tools",false,"Unknown Export Field for ReplicaDataAggreagtor"); - break; - } - - file.Write(field.c_str(),field.length()); - addComma = true; - } - - file.Write("\n",1); - } - - void ReplicaDataAggregator::RegisterReplicaDataView(ReplicaDataView* replicaDataView) - { - if (replicaDataView) - { - m_openDataViews.push_back(replicaDataView); - - connect(replicaDataView,SIGNAL(destroyed(QObject*)),this,SLOT(OnDataViewDestroyed(QObject*))); - } - } - - void ReplicaDataAggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - ReplicaDataView::Reflect(context); - - ReplicaExportSettingsSavedState::Reflect(context); - ReplicaDataAggregatorSavedState::Reflect(context); - ReplicaDataAggregatorWorkspace::Reflect(context); - - serialize->Class() - ->Version(1) - ->SerializeWithNoData(); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.hxx deleted file mode 100644 index 66c0b9d179..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregator.hxx +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_DATAAGGREGATOR_H -#define DRILLER_REPLICA_DATAAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "ReplicaDataParser.h" - -#include "GridMate/Drillers/ReplicaDriller.h" - -#include "Source/Driller/GenericCustomizeCSVExportWidget.hxx" -#include -#endif - -namespace Driller -{ - class ReplicaDataView; - class ReplicaDataAggregatorSavedState; - class ReplicaExportSettingsSavedState; - - class ReplicaExportSettings - : public GenericCSVExportSettings - { - // Serialization Keys - static const char* REPLICA_CSV_EXPORT_SETTINGS; - - public: - enum class ExportField - { - Name = 0, - Id, - ChunkType, - UsageType, - UsageIdentifier, - Bytes_Sent, - Bytes_Received, - UNKNOWN - }; - - private: - AZStd::unordered_map< ExportField, AZStd::string > m_columnDescriptors; - AZStd::unordered_map< AZStd::string, ExportField > m_stringToExportEnum; - - AZStd::intrusive_ptr m_persistentState; - - public: - AZ_CLASS_ALLOCATOR(ReplicaExportSettings, AZ::SystemAllocator, 0); - - ReplicaExportSettings(); - - void LoadSettings(); - - void GetExportItems(QStringList& items) const override; - void GetActiveExportItems(QStringList& items) const override; - - const AZStd::vector< int >& GetExportOrder() const; - const AZStd::string& FindColumnDescriptor(ExportField exportField) const; - protected: - void UpdateExportOrdering(const QStringList& activeItems) override; - - private: - ExportField FindExportFieldFromDescriptor(const char* descriptor) const; - }; - - struct ReplicaDataConfigurationSettings - { - public: - enum ConfigurationDisplayType - { - CDT_Start = -1, - - CDT_Frame, - CDT_Second, - CDT_Minute, - - CDT_Max - }; - - AZ_TYPE_INFO(ReplicaDataConfigurationSettings, "{7A075B8E-DCAF-47A1-96CF-2CA3A44F38EF}"); - - ReplicaDataConfigurationSettings() - : m_averageFrameBudget(1024.0f * 10.0f) - , m_configurationDisplay(CDT_Frame) - , m_frameRate(60) - { - } - - // Actual data to be used in the display settings - float m_averageFrameBudget; - - // Information needed purely for the display - ConfigurationDisplayType m_configurationDisplay; - unsigned int m_frameRate; - }; - - typedef ReplicaExportSettings::ExportField ReplicaExportField; - - class ReplicaDataAggregator : public Aggregator - { - Q_OBJECT - - // Serialization Keys - static const char* REPLICA_AGGREGATOR_SAVED_STATE; - static const char* REPLICA_AGGREGATOR_WORKSPACE; - public: - AZ_RTTI(ReplicaDataAggregator, "{764A4084-E579-4811-89D5-3ADA0632358D}"); - AZ_CLASS_ALLOCATOR(ReplicaDataAggregator, AZ::SystemAllocator, 0); - - ReplicaDataAggregator(int identity = 0); - ~ReplicaDataAggregator(); - - static AZ::u32 DrillerId() { return GridMate::Debug::ReplicaDriller::Tags::REPLICA_DRILLER; } - - AZ::u32 GetDrillerId() const override - { - return ReplicaDataAggregator::DrillerId(); - } - - static const char* ChannelName() { return "GridMate"; } - - AZ::Crc32 GetChannelId() const override - { - return AZ::Crc32(ChannelName()); - } - - AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() override - { - return &m_parser; - } - - bool CanExportToCSV() const override - { - return true; - } - - CustomizeCSVExportWidget* CreateCSVExportCustomizationWidget() override; - - bool HasConfigurations() const; - ChannelConfigurationWidget* CreateConfigurationWidget() override; - void OnConfigurationChanged() override; - - void AnnotateChannelView(ChannelDataView* channelDataView) override; - void RemoveChannelAnnotation(ChannelDataView* channelDataView) override; - - // Driller::Aggregator. - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*) override; - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*) override; - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*) override; - - static void Reflect(AZ::ReflectContext* context); - - // ReplicaDataAggregator - unsigned int GetAverageFrameBandwidthBudget() const; - - public slots: - // Driller::Aggregator - float ValueAtFrame(FrameNumberType frame) override; - QColor GetColor() const override; - QString GetName() const override; - QString GetChannelName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - void OptionsRequest() override; - void OnDataViewDestroyed(QObject* object); - - void ProcessDrillerEvent(DrillerEvent* drillerEvent); - - protected: - void ExportColumnDescriptorToCSV(AZ::IO::SystemFile& file,CSVExportSettings* exportSettings) override; - void ExportEventToCSV(AZ::IO::SystemFile& file, const DrillerEvent* drillerEvent,CSVExportSettings* exportSettings) override; - - private: - ReplicaDataAggregator(const ReplicaDataAggregator&) = delete; - void RegisterReplicaDataView(ReplicaDataView* replicaDataView); - - ReplicaExportSettings m_csvExportSettings; - ReplicaDataParser m_parser; - - unsigned int m_budgetMarkerTicket; - - size_t m_processingFrame; - - float m_currentFrameUsage; - float m_maxFrameUsage; - - float m_normalizingValue; - - AZStd::vector< ReplicaDataView* > m_openDataViews; - - AZStd::intrusive_ptr m_persistentState; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.cpp deleted file mode 100644 index 91098eab54..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.cpp +++ /dev/null @@ -1,171 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include -#include - -namespace Driller -{ - //////////////////////////////////////////// - // ReplicaDataAggregatorConfigurationPanel - //////////////////////////////////////////// - - ReplicaDataAggregatorConfigurationPanel::ReplicaDataAggregatorConfigurationPanel(ReplicaDataConfigurationSettings& configurationSettings) - : m_configurationSettings(configurationSettings) - { - setupUi(this); - - InitUI(); - - connect(fpsSpinBox, SIGNAL(valueChanged(int)), SLOT(OnFPSChanged(int))); - connect(unitSelector, SIGNAL(currentIndexChanged(int)), SLOT(OnTypeChanged(int))); - connect(budgetSpinBox, SIGNAL(valueChanged(int)), SLOT(OnBudgetChanged(int))); - - m_changeTimer.setInterval(500); - m_changeTimer.setSingleShot(true); - - connect(&m_changeTimer, SIGNAL(timeout()), SLOT(OnTimeout())); - } - - ReplicaDataAggregatorConfigurationPanel::~ReplicaDataAggregatorConfigurationPanel() - { - } - - void ReplicaDataAggregatorConfigurationPanel::InitUI() - { - fpsSpinBox->setValue(m_configurationSettings.m_frameRate); - - for (unsigned int i = 0; i < static_cast(ReplicaDataConfigurationSettings::CDT_Max); ++i) - { - switch (static_cast(i)) - { - case ReplicaDataConfigurationSettings::CDT_Frame: - unitSelector->addItem("Bytes per Frame"); - break; - case ReplicaDataConfigurationSettings::CDT_Second: - unitSelector->addItem("Bytes per Second"); - break; - case ReplicaDataConfigurationSettings::CDT_Minute: - unitSelector->addItem("Bytes per Minute"); - break; - default: - unitSelector->addItem("???"); - AZ_Error("ReplicaDataAggregatorConfigurationPanel", false, "Unhandled unit given to ReplicaDataConfigurationSettings."); - break; - } - } - - int displayConfiguration = static_cast(m_configurationSettings.m_configurationDisplay); - - if (displayConfiguration >= 0 && displayConfiguration < static_cast(ReplicaDataConfigurationSettings::CDT_Max)) - { - unitSelector->setCurrentIndex(displayConfiguration); - } - - DisplayTypeDescriptor(); - UpdateBudgetDisplay(); - } - - void ReplicaDataAggregatorConfigurationPanel::OnBudgetChanged(int value) - { - float budget = static_cast(value); - switch (m_configurationSettings.m_configurationDisplay) - { - case ReplicaDataConfigurationSettings::CDT_Frame: - // Don't need to do anything on Seconds - break; - case ReplicaDataConfigurationSettings::CDT_Minute: - budget = budget / 60.0f; - // Fall through to the seconds. - case ReplicaDataConfigurationSettings::CDT_Second: - budget = budget / static_cast(m_configurationSettings.m_frameRate); - break; - default: - AZ_Error("ReplicaDataAggregatorConfigurationPanel", false, "Unknown configuraiton display given."); - break; - } - - m_configurationSettings.m_averageFrameBudget = static_cast(budget); - - m_changeTimer.start(); - } - - void ReplicaDataAggregatorConfigurationPanel::OnTypeChanged(int type) - { - if (type >= 0 && type < static_cast(ReplicaDataConfigurationSettings::CDT_Max)) - { - m_configurationSettings.m_configurationDisplay = static_cast(type); - - DisplayTypeDescriptor(); - UpdateBudgetDisplay(); - } - } - - void ReplicaDataAggregatorConfigurationPanel::OnFPSChanged(int fps) - { - // We don't want the budget to change when we switch FPS - // but we may need to update the value we actually store. - // so we'll store the original value - int budget = budgetSpinBox->value(); - - m_configurationSettings.m_frameRate = fps; - - // Then fake setting that value to recalculate using the - // new frame rate correctly. - OnBudgetChanged(budget); - } - - void ReplicaDataAggregatorConfigurationPanel::OnTimeout() - { - emit ConfigurationChanged(); - } - - void ReplicaDataAggregatorConfigurationPanel::DisplayTypeDescriptor() - { - switch (m_configurationSettings.m_configurationDisplay) - { - case ReplicaDataConfigurationSettings::CDT_Frame: - unitLabel->setText("Frame"); - break; - case ReplicaDataConfigurationSettings::CDT_Second: - unitLabel->setText("Second"); - break; - case ReplicaDataConfigurationSettings::CDT_Minute: - unitLabel->setText("Minute"); - break; - default: - unitLabel->setText("???"); - AZ_Error("ReplicaDataAggregatorCOnfigurationPanel", false, "Unknown unit configuration."); - } - } - - void ReplicaDataAggregatorConfigurationPanel::UpdateBudgetDisplay() - { - float displayValue = m_configurationSettings.m_averageFrameBudget; - - switch (m_configurationSettings.m_configurationDisplay) - { - case ReplicaDataConfigurationSettings::CDT_Frame: - // Frame is good as is. - break; - case ReplicaDataConfigurationSettings::CDT_Minute: - // Multiply by 60 then let it fall through into the conversion to seconds. - displayValue *= 60; - case ReplicaDataConfigurationSettings::CDT_Second: - // For seconds, multiply the average frame budget, by the frame rate. - displayValue *= m_configurationSettings.m_frameRate; - break; - default: - AZ_Error("ReplicaDataAggregationConfigurationPanel", false, "Unknown configuration type given."); - } - - budgetSpinBox->setValue(static_cast(displayValue)); - } - - -#undef TOSTRING -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.hxx b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.hxx deleted file mode 100644 index 9293c7ed39..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.hxx +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#pragma once - -#ifndef DRILLER_REPLICA_REPLICADATAAGGREGATORCONFIGURATIONPANEL_H -#define DRILLER_REPLICA_REPLICADATAAGGREGATORCONFIGURATIONPANEL_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#include -#include - -// Generated File -#include - -#include -#include -#endif - -namespace Driller -{ - class ReplicaDataAggregatorConfigurationPanel - : public ChannelConfigurationWidget - , private Ui::ReplicaDataAggregatorConfigurationPanel - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(ReplicaDataAggregatorConfigurationPanel, AZ::SystemAllocator, 0); - - ReplicaDataAggregatorConfigurationPanel(ReplicaDataConfigurationSettings& configurationSettings); - ~ReplicaDataAggregatorConfigurationPanel(); - - public slots: - void OnBudgetChanged(int budget); - void OnTypeChanged(int type); - void OnFPSChanged(int fps); - - void OnTimeout(); - - private: - - void InitUI(); - - void DisplayTypeDescriptor(); - void UpdateBudgetDisplay(); - - ReplicaDataConfigurationSettings& m_configurationSettings; - QTimer m_changeTimer; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.ui b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.ui deleted file mode 100644 index f0eff2308d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.ui +++ /dev/null @@ -1,345 +0,0 @@ - - - ReplicaDataAggregatorConfigurationPanel - - - - 0 - 0 - 354 - 127 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Replica Data Aggregator Configuration - - - - 5 - - - 10 - - - 5 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 120 - 0 - - - - Qt::LeftToRight - - - Unit of Measure - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 115 - 0 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 120 - 0 - - - - Bandwidth Usage Budget - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 115 - 0 - - - - 999999999 - - - - - - - - 0 - 0 - - - - bytes per - - - - - - - Frame - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Horizontal - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 120 - 0 - - - - FPS - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 0 - - - - - - - - 115 - 0 - - - - 1 - - - 240 - - - 60 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataEvents.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataEvents.h deleted file mode 100644 index 18e325435a..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataEvents.h +++ /dev/null @@ -1,291 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_DATAEVENTS_H -#define DRILLER_REPLICA_DATAEVENTS_H - -#include -#include -#include -#include -#include - -#include "Source/Driller/DrillerEvent.h" - -namespace Driller -{ - namespace Replica - { - enum ReplicaEventType - { - RET_CHUNK_DATASET_SENT = 0, - RET_CHUNK_DATASET_RECEIVED, - RET_CHUNK_RPC_SENT, - RET_CHUNK_RPC_RECEIVED - }; - } - - class ReplicaChunkEvent - : public DrillerEvent - { - protected: - ReplicaChunkEvent(Replica::ReplicaEventType eventType) - : DrillerEvent(static_cast(eventType)) - , m_replicaId(0) - , m_replicaChunkId(0) - , m_replicaChunkIndex(std::numeric_limits::max()) - , m_timeProcessed(0) - , m_usageBytes(0) - { - } - - public: - - AZ_CLASS_ALLOCATOR(ReplicaChunkEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkEvent, "{76B2DCFB-2D63-4B11-AD18-48843209FF26}", DrillerEvent); - - void SetReplicaName(const char* replicaName) - { - m_replicaName = replicaName; - } - - const char* GetReplicaName() const - { - return m_replicaName.c_str(); - } - - void SetReplicaChunkIndex(AZ::u32 index) - { - m_replicaChunkIndex = index; - } - - AZ::u32 GetReplicaChunkIndex() const - { - return m_replicaChunkIndex; - } - - void SetChunkTypeName(const char* chunkTypeName) - { - m_chunkTypeName = chunkTypeName; - - // Temporary measure to maintain data integrity - if (m_replicaChunkIndex == std::numeric_limits::max()) - { - m_replicaChunkIndex = static_cast(AZ::Crc32(chunkTypeName)); - } - } - - const char* GetChunkTypeName() const - { - return m_chunkTypeName.c_str(); - } - - void SetUsageBytes(size_t usageBytes) - { - m_usageBytes = usageBytes; - } - - size_t GetUsageBytes() const - { - return m_usageBytes; - } - - void SetReplicaId(AZ::u64 replicaId) - { - m_replicaId = replicaId; - } - - AZ::u64 GetReplicaId() const - { - return m_replicaId; - } - - void SetReplicaChunkId(AZ::u64 replicaChunkId) - { - m_replicaChunkId = replicaChunkId; - } - - AZ::u64 GetReplicaChunkId() const - { - return m_replicaChunkId; - } - - void SetTimeProcssed(const AZStd::chrono::milliseconds& timeProcessed) - { - m_timeProcessed = timeProcessed; - } - - AZStd::chrono::milliseconds GetTimeProcessed() const - { - return m_timeProcessed; - } - - void StepForward(Aggregator* data) override { (void)data; }; - void StepBackward(Aggregator* data) override { (void)data; }; - - private: - AZStd::string m_replicaName; - AZStd::string m_chunkTypeName; - - AZ::u64 m_replicaId; - AZ::u64 m_replicaChunkId; - - AZ::u32 m_replicaChunkIndex; - - AZStd::chrono::milliseconds m_timeProcessed; - - size_t m_usageBytes; - }; - - class ReplicaChunkDataSetEvent - : public ReplicaChunkEvent - { - protected: - ReplicaChunkDataSetEvent(Replica::ReplicaEventType eventType) - : ReplicaChunkEvent(eventType) - , m_hasIndex(false) - , m_index(0) - { - } - - public: - AZ_RTTI(ReplicaChunkDataSetEvent, "{39D9C3E7-B119-4C9C-BC70-DB4890A131FD}", ReplicaChunkEvent); - - void SetDataSetName(const char* dataSetName) - { - m_dataSetName = dataSetName; - } - - const char* GetDataSetName() const - { - return m_dataSetName.c_str(); - } - - void SetIndex(size_t dataSetIndex) - { - m_hasIndex = true; - m_index = dataSetIndex; - } - - size_t GetIndex() const - { - return m_index; - } - - bool HasIndex() const - { - return m_hasIndex; - } - - private: - AZStd::string m_dataSetName; - bool m_hasIndex; - size_t m_index; - }; - - class ReplicaChunkRPCEvent - : public ReplicaChunkEvent - { - protected: - ReplicaChunkRPCEvent(Replica::ReplicaEventType eventType) - : ReplicaChunkEvent(eventType) - , m_hasIndex(false) - , m_index(0) - { - } - - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkDataSetEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkRPCEvent, "{27213952-E66A-4DE7-A60D-683895A5A973}", ReplicaChunkEvent); - - void SetRPCName(const char* rpcName) - { - m_RPCName = rpcName; - } - - const char* GetRPCName() const - { - return m_RPCName.c_str(); - } - - void SetIndex(size_t rpcIndex) - { - m_hasIndex = true; - m_index = rpcIndex; - } - - size_t GetIndex() const - { - return m_index; - } - - bool HasIndex() const - { - return m_hasIndex; - } - - private: - AZStd::string m_RPCName; - bool m_hasIndex; - size_t m_index; - }; - - class ReplicaChunkSentDataSetEvent - : public ReplicaChunkDataSetEvent - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkSentDataSetEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkSentDataSetEvent, "{2B6BDB9C-4465-4BC6-BB80-73CD85A0B818}", ReplicaChunkDataSetEvent); - - ReplicaChunkSentDataSetEvent() - : ReplicaChunkDataSetEvent(Replica::RET_CHUNK_DATASET_SENT) - { - } - }; - - class ReplicaChunkReceivedDataSetEvent - : public ReplicaChunkDataSetEvent - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkReceivedDataSetEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkReceivedDataSetEvent, "{138F7C4A-3727-4565-9395-673E43BC325C}", ReplicaChunkDataSetEvent); - - ReplicaChunkReceivedDataSetEvent() - : ReplicaChunkDataSetEvent(Replica::RET_CHUNK_DATASET_RECEIVED) - { - } - }; - - class ReplicaChunkSentRPCEvent - : public ReplicaChunkRPCEvent - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkSentRPCEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkSentRPCEvent, "{04E9EE7E-5F41-4566-B584-0C671B2E09DE}", ReplicaChunkRPCEvent); - - ReplicaChunkSentRPCEvent() - : ReplicaChunkRPCEvent(Replica::RET_CHUNK_RPC_SENT) - { - } - }; - - class ReplicaChunkReceivedRPCEvent - : public ReplicaChunkRPCEvent - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkReceivedRPCEvent, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkReceivedRPCEvent, "{68482B1F-8A70-4152-9014-714B46641A12}", ReplicaChunkRPCEvent); - - ReplicaChunkReceivedRPCEvent() - : ReplicaChunkRPCEvent(Replica::RET_CHUNK_RPC_RECEIVED) - { - } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.cpp deleted file mode 100644 index 26a40f46c3..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ReplicaDataParser.h" - -#include "ReplicaDataAggregator.hxx" -#include "ReplicaDataEvents.h" - -#include "GridMate/Drillers/ReplicaDriller.h" - -namespace Driller -{ - ////////////////////// - // ReplicaDataParser - ////////////////////// - - ReplicaDataParser::ReplicaDataParser(ReplicaDataAggregator* aggregator) - : DrillerHandlerParser(false) - , m_currentType(Replica::DataType::NONE) - , m_aggregator(aggregator) - { - } - - AZ::Debug::DrillerHandlerParser* ReplicaDataParser::OnEnterTag(AZ::u32 tagName) - { - if (tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_SEND_DATASET) - { - AZ_Assert(m_currentType == Replica::DataType::NONE, "ERROR: Bad flow received."); - - ReplicaChunkSentDataSetEvent* newEvent = aznew ReplicaChunkSentDataSetEvent; - - if (newEvent) - { - m_currentType = Replica::DataType::SENT_REPLICA_CHUNK; - m_aggregator->AddEvent(newEvent); - return this; - } - } - else if (tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_RECEIVE_DATASET) - { - AZ_Assert(m_currentType == Replica::DataType::NONE, "ERROR: Bad flow received."); - - ReplicaChunkReceivedDataSetEvent* newEvent = aznew ReplicaChunkReceivedDataSetEvent; - - if (newEvent) - { - m_currentType = Replica::DataType::RECEIVED_REPLICA_CHUNK; - m_aggregator->AddEvent(newEvent); - return this; - } - } - else if (tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_SEND_RPC) - { - AZ_Assert(m_currentType == Replica::DataType::NONE, "ERROR: Bad flow received."); - - ReplicaChunkSentRPCEvent* newEvent = aznew ReplicaChunkSentRPCEvent; - - if (newEvent) - { - m_currentType = Replica::DataType::SENT_REPLICA_CHUNK; - m_aggregator->AddEvent(newEvent); - return this; - } - } - else if (tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_RECEIVE_RPC) - { - AZ_Assert(m_currentType == Replica::DataType::NONE, "ERROR: Bad flow received."); - - ReplicaChunkReceivedRPCEvent* newEvent = aznew ReplicaChunkReceivedRPCEvent; - - if (newEvent) - { - m_currentType = Replica::DataType::RECEIVED_REPLICA_CHUNK; - m_aggregator->AddEvent(newEvent); - return this; - } - } - - return nullptr; - } - - void ReplicaDataParser::OnExitTag(AZ::Debug::DrillerHandlerParser* handler, AZ::u32 tagName) - { - (void)handler; - - if (tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_SEND_DATASET - || tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_RECEIVE_DATASET - || tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_SEND_RPC - || tagName == GridMate::Debug::ReplicaDriller::Tags::CHUNK_RECEIVE_RPC) - { - m_currentType = Replica::DataType::NONE; - m_aggregator->FinalizeEvent(); - } - } - - void ReplicaDataParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - if (m_currentType == Replica::DataType::NONE - || m_aggregator->GetEvents().empty()) - { - return; - } - - ProcessReplicaChunk(dataNode); - - switch (m_currentType) - { - case Replica::DataType::SENT_REPLICA_CHUNK: - ProcessSentReplicaChunk(dataNode); - break; - case Replica::DataType::RECEIVED_REPLICA_CHUNK: - ProcessReceivedReplicaChunk(dataNode); - break; - default: - break; - } - } - - void ReplicaDataParser::ProcessReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - ReplicaChunkEvent* receivedEvent = static_cast(m_aggregator->GetEvents().back()); - - if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::CHUNK_TYPE) - { - AZStd::string chunkType; - dataNode.Read(chunkType); - - receivedEvent->SetChunkTypeName(chunkType.c_str()); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::CHUNK_INDEX) - { - AZ::u32 chunkIndex; - dataNode.Read(chunkIndex); - - receivedEvent->SetReplicaChunkIndex(chunkIndex); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::SIZE) - { - size_t usageBytes; - dataNode.Read(usageBytes); - - receivedEvent->SetUsageBytes(usageBytes); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::REPLICA_ID) - { - AZ::u32 replicaId; - dataNode.Read(replicaId); - - receivedEvent->SetReplicaId(replicaId); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::REPLICA_NAME) - { - AZStd::string replicaName; - dataNode.Read(replicaName); - - receivedEvent->SetReplicaName(replicaName.c_str()); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::TIME_PROCESSED_MILLISEC) - { - AZStd::sys_time_t time; - dataNode.Read(time); - - AZStd::chrono::milliseconds timeMS(time); - receivedEvent->SetTimeProcssed(timeMS); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::DATA_SET_NAME) - { - AZStd::string dataSetName; - dataNode.Read(dataSetName); - - ReplicaChunkDataSetEvent* dataSetEvent = static_cast(receivedEvent); - - dataSetEvent->SetDataSetName(dataSetName.c_str()); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::DATA_SET_INDEX) - { - size_t dataSetIndex; - dataNode.Read(dataSetIndex); - - ReplicaChunkDataSetEvent* dataSetEvent = static_cast(receivedEvent); - - dataSetEvent->SetIndex(dataSetIndex); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::RPC_NAME) - { - AZStd::string rpcName; - dataNode.Read(rpcName); - - ReplicaChunkRPCEvent* rpcEvent = static_cast(receivedEvent); - - rpcEvent->SetRPCName(rpcName.c_str()); - } - else if (dataNode.m_name == GridMate::Debug::ReplicaDriller::Tags::RPC_INDEX) - { - size_t rpcIndex; - dataNode.Read(rpcIndex); - - ReplicaChunkRPCEvent* rpcEvent = static_cast(receivedEvent); - rpcEvent->SetIndex(rpcIndex); - } - } - - void ReplicaDataParser::ProcessSentReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - (void)dataNode; - } - - void ReplicaDataParser::ProcessReceivedReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - (void)dataNode; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.h deleted file mode 100644 index 0b6e6c6347..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataParser.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_DATAPARSER_H -#define DRILLER_REPLICA_DATAPARSER_H - -#include - -namespace Driller -{ - class ReplicaDataAggregator; - - namespace Replica - { - enum class DataType - { - NONE, - SENT_REPLICA_CHUNK, - RECEIVED_REPLICA_CHUNK - }; - } - - class ReplicaDataParser - : public AZ::Debug::DrillerHandlerParser - { - public: - ReplicaDataParser(ReplicaDataAggregator* aggregator); - - AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName) override; - void OnExitTag(AZ::Debug::DrillerHandlerParser* handler, AZ::u32 tagName) override; - void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) override; - - private: - - void ProcessReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode); - void ProcessSentReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode); - void ProcessReceivedReplicaChunk(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - Replica::DataType m_currentType; - - ReplicaDataAggregator* m_aggregator; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.cpp deleted file mode 100644 index be4c7d14ff..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.cpp +++ /dev/null @@ -1,1808 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -#include "ReplicaDataView.hxx" -#include - -#include "BaseDetailView.h" -#include "ReplicaChunkTypeDetailView.h" -#include "ReplicaChunkUsageDataContainers.h" -#include "ReplicaDataAggregator.hxx" -#include "ReplicaDataEvents.h" -#include "ReplicaDetailView.h" -#include "ReplicaOperationTelemetryEvent.h" -#include "ReplicaUsageDataContainers.h" - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" -#include "Source/Driller/Replica/OverallReplicaDetailView.hxx" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Workspaces/Workspace.h" - -namespace Driller -{ - ////////////////////////////// - // ReplicaDataViewSavedState - ////////////////////////////// - - class ReplicaDataViewSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaDataViewSavedState, "{8C5CA0D3-CD56-4972-83E5-2A7D3217E8FE}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaDataViewSavedState, AZ::SystemAllocator, 0); - - int m_displayTimeType; - int m_displayDataType; - int m_displayRange; - int m_bandwidthUsageDisplayType; - int m_tableFilterType; - - ReplicaDataViewSavedState() - : m_displayDataType(ReplicaDataView::DDT_START + 1) - , m_displayRange(30) - , m_bandwidthUsageDisplayType(ReplicaDisplayTypes::BUDT_START + 1) - , m_tableFilterType(ReplicaDataView::TFT_START + 1) - { - } - - void CopyStateFrom(const ReplicaDataViewSavedState* source) - { - m_displayTimeType = source->m_displayTimeType; - m_displayDataType = source->m_displayDataType; - m_displayRange = source->m_displayRange; - m_bandwidthUsageDisplayType = source->m_bandwidthUsageDisplayType; - m_tableFilterType = source->m_tableFilterType; - } - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_displayDataType", &ReplicaDataViewSavedState::m_displayDataType) - ->Field("m_displayRange", &ReplicaDataViewSavedState::m_displayRange) - ->Field("m_bandwidthUsageDisplayType",&ReplicaDataViewSavedState::m_bandwidthUsageDisplayType) - ->Field("m_tableFilterType", &ReplicaDataViewSavedState::m_tableFilterType) - ->Version(4); - } - } - }; - - //////////////////////////////////////// - // ReplicaDataViewTableModelSavedState - //////////////////////////////////////// - - class ReplicaDataViewTableModelSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaDataViewTableModelSavedState, "{36103E46-2503-4EEE-BA4B-2650E25A5B26}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaDataViewTableModelSavedState, AZ::SystemAllocator, 0); - - AZStd::vector m_treeColumnStorage; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Field("m_treeColumnStorage", &ReplicaDataViewTableModelSavedState::m_treeColumnStorage) - ->Version(1); - } - } - }; - - ////////////////////////////////////// - // ReplicaDataViewSplitterSavedState - ////////////////////////////////////// - - class ReplicaDataViewSplitterSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(ReplicaDataViewSplitterSavedState, "{E698D9E8-D8E9-4115-87E7-2BEEBE5F7FB3}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(ReplicaDataViewSplitterSavedState, AZ::SystemAllocator, 0); - - AZStd::vector m_splitterSavedState; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - - if (serialize) - { - serialize->Class() - ->Field("m_splitterSavedState", &ReplicaDataViewSplitterSavedState::m_splitterSavedState) - ->Version(1) - ; - } - } - }; - - ////////////////////////// - // ReplicaTableViewModel - ////////////////////////// - - ReplicaTableViewModel::ReplicaTableViewModel(ReplicaDataView* replicaDataView) - : QAbstractTableModel(replicaDataView) - , m_replicaDataView(replicaDataView) - { - } - - void ReplicaTableViewModel::RefreshView() - { - m_replicaIds.clear(); - - if (m_replicaDataView->HideInactiveInspectedElements()) - { - m_replicaIds.insert(m_replicaIds.begin(), m_replicaDataView->m_activeInspectedReplicaIds.begin(), m_replicaDataView->m_activeInspectedReplicaIds.end()); - } - else - { - m_replicaIds.insert(m_replicaIds.begin(), m_replicaDataView->m_activeReplicaIds.begin(), m_replicaDataView->m_activeReplicaIds.end()); - } - - AZStd::sort(m_replicaIds.begin(), m_replicaIds.end(), AZStd::less()); - - layoutChanged(); - } - - int ReplicaTableViewModel::rowCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return static_cast(m_replicaIds.size()); - } - - int ReplicaTableViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return CD_COUNT; - } - - Qt::ItemFlags ReplicaTableViewModel::flags(const QModelIndex& index) const - { - Qt::ItemFlags flags = QAbstractTableModel::flags(index); - - switch (index.column()) - { - case CD_INSPECT: - flags &= ~(Qt::ItemIsSelectable); - break; - default: - break; - } - - return flags; - } - - - QVariant ReplicaTableViewModel::data(const QModelIndex& index, int role) const - { - AZ::u64 replicaId = GetReplicaIdFromIndex(index); - - ReplicaDataContainer* replicaContainer = m_replicaDataView->FindReplicaData(replicaId); - - - if (replicaContainer != nullptr) - { - if (role == Qt::BackgroundRole) - { - if (replicaContainer->IsInspected()) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - else - { - switch (index.column()) - { - case CD_REPLICA_ID: - if (role == Qt::DisplayRole) - { - return FormattingHelper::ReplicaID(replicaContainer->GetReplicaId()); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_SENT: - if (role == Qt::DisplayRole) - { - return QString::number(replicaContainer->GetSentUsageForFrame(m_replicaDataView->GetCurrentFrame())); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_RECEIVED: - if (role == Qt::DisplayRole) - { - return QString::number(replicaContainer->GetReceivedUsageForFrame(m_replicaDataView->GetCurrentFrame())); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_REPLICA_NAME: - if (role == Qt::DecorationRole) - { - return replicaContainer->GetIcon(); - } - else if (role == Qt::DisplayRole) - { - AZStd::string replicaName = replicaContainer->GetReplicaName(); - return QString(replicaName.empty() ? "" : replicaName.c_str()); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignLeft | Qt::AlignVCenter); - } - break; - case CD_INSPECT: - if (role == Qt::DecorationRole || role == Qt::SizeHintRole) - { - QPixmap pixmap = QPixmap(":/general/inspect_icon"); - - if (role == Qt::DecorationRole) - { - return pixmap; - } - else if (role == Qt::SizeHintRole) - { - return pixmap.size(); - } - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - default: - AZ_Assert(false,"Unknown column index %i",index.column()); - break; - } - } - } - - return QVariant(); - } - - QVariant ReplicaTableViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_REPLICA_ID: - return QString("Replica ID"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_REPLICA_NAME: - return QString("Replica Name"); - case CD_INSPECT: - return QString(""); - default: - AZ_Assert(false, "Unknown section index %i", section); - break; - } - } - } - - return QVariant(); - } - - AZ::u64 ReplicaTableViewModel::GetReplicaIdFromIndex(const QModelIndex& index) const - { - return GetReplicaIdForRow(index.row()); - } - - AZ::u64 ReplicaTableViewModel::GetReplicaIdForRow(int row) const - { - if (row < 0 || row >= m_replicaIds.size()) - { - return 0; - } - - return m_replicaIds[row]; - } - - /////////////////////////////////// - // ReplicaChunkTypeTableViewModel - /////////////////////////////////// - - ReplicaChunkTypeTableViewModel::ReplicaChunkTypeTableViewModel(ReplicaDataView* replicaDataView) - : QAbstractTableModel(replicaDataView) - , m_replicaDataView(replicaDataView) - { - } - - void ReplicaChunkTypeTableViewModel::RefreshView() - { - m_replicaChunkTypes.clear(); - - if (m_replicaDataView->HideInactiveInspectedElements()) - { - m_replicaChunkTypes.insert(m_replicaChunkTypes.begin(), m_replicaDataView->m_activeInspectedChunkTypes.begin(), m_replicaDataView->m_activeInspectedChunkTypes.end()); - } - else - { - m_replicaChunkTypes.insert(m_replicaChunkTypes.begin(), m_replicaDataView->m_activeChunkTypes.begin(), m_replicaDataView->m_activeChunkTypes.end()); - } - - AZStd::sort(m_replicaChunkTypes.begin(), m_replicaChunkTypes.end(), AZStd::less()); - layoutChanged(); - } - - int ReplicaChunkTypeTableViewModel::rowCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return static_cast(m_replicaChunkTypes.size()); - } - - int ReplicaChunkTypeTableViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return CD_COUNT; - } - - Qt::ItemFlags ReplicaChunkTypeTableViewModel::flags(const QModelIndex& index) const - { - Qt::ItemFlags flags = QAbstractTableModel::flags(index); - - switch (index.column()) - { - case CD_INSPECT: - flags &= ~(Qt::ItemIsSelectable); - break; - default: - break; - } - - return flags; - } - - QVariant ReplicaChunkTypeTableViewModel::data(const QModelIndex& index, int role) const - { - const char* chunkType = GetReplicaChunkTypeFromIndex(index); - ReplicaChunkTypeDataContainer* replicaChunkTypeContainer = m_replicaDataView->FindReplicaChunkTypeData(chunkType); - - if (replicaChunkTypeContainer != nullptr) - { - if (role == Qt::BackgroundRole) - { - if (replicaChunkTypeContainer->IsInspected()) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - else - { - switch (index.column()) - { - case CD_CHUNK_TYPE: - if (role == Qt::DecorationRole) - { - return replicaChunkTypeContainer->GetIcon(); - } - else if (role == Qt::DisplayRole) - { - AZStd::string chunkTypeString = replicaChunkTypeContainer->GetChunkType(); - return QString(chunkTypeString.empty() ? "" : chunkTypeString.c_str()); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_SENT: - if (role == Qt::DisplayRole) - { - return QString::number(replicaChunkTypeContainer->GetSentUsageForFrame(m_replicaDataView->GetCurrentFrame())); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_RECEIVED: - if (role == Qt::DisplayRole) - { - return QString::number(replicaChunkTypeContainer->GetReceivedUsageForFrame(m_replicaDataView->GetCurrentFrame())); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_INSPECT: - if (role == Qt::DecorationRole || role == Qt::SizeHintRole) - { - QPixmap pixmap = QPixmap(":/general/inspect_icon"); - - if (role == Qt::DecorationRole) - { - return pixmap; - } - else if (role == Qt::SizeHintRole) - { - return pixmap.size(); - } - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - default: - AZ_Assert(false,"Unknown column index %i",index.column()); - break; - } - } - } - - return QVariant(); - } - - QVariant ReplicaChunkTypeTableViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_CHUNK_TYPE: - return QString("Chunk Type"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_INSPECT: - return QString(""); - default: - AZ_Assert(false, "Unknown section index %i", section); - break; - } - } - } - - return QVariant(); - } - - const char* ReplicaChunkTypeTableViewModel::GetReplicaChunkTypeFromIndex(const QModelIndex& index) const - { - return GetReplicaChunkTypeForRow(index.row()); - } - - const char* ReplicaChunkTypeTableViewModel::GetReplicaChunkTypeForRow(int row) const - { - const char* retVal = nullptr; - - if (row < 0 || row >= m_replicaChunkTypes.size()) - { - return retVal; - } - - retVal = m_replicaChunkTypes[row].c_str(); - - return retVal; - } - - //////////////////////// - // ChartZoomMaintainer - //////////////////////// - - ReplicaDataView::ChartZoomMaintainer::ChartZoomMaintainer() - : m_axis(Charts::AxisType::Horizontal) - , m_minValue(0.0f) - , m_maxValue(1.0f) - { - } - - void ReplicaDataView::ChartZoomMaintainer::GetZoomFromChart(StripChart::DataStrip& chart, Charts::AxisType axis) - { - m_axis = axis; - - bool gotWindowRange = chart.GetWindowRange(axis, m_minValue, m_maxValue); - - float minRange; - float maxRange; - - bool gotAxisRange = chart.GetAxisRange(axis, minRange, maxRange); - - if (gotWindowRange && gotAxisRange) - { - float range = maxRange - minRange; - - if (AZ::IsClose(maxRange, minRange, 0.01f)) - { - range = 1.0f; - } - - m_minValue /= range; - m_maxValue /= range; - } - else - { - m_minValue = 0.0f; - m_maxValue = 1.0f; - } - } - - void ReplicaDataView::ChartZoomMaintainer::SetZoomOnChart(StripChart::DataStrip& chart, Charts::AxisType axis) - { - AZ_Assert(axis == m_axis, "Warning: Manipulating different axis from when zoom was set"); - - float minRange; - float maxRange; - - bool gotRange = chart.GetAxisRange(axis, minRange, maxRange); - - if (gotRange) - { - float range = maxRange - minRange; - - if (AZ::IsClose(maxRange, minRange, 0.01f)) - { - range = 1.0f; - } - - chart.ZoomManual(axis, range * m_minValue, range * m_maxValue); - } - } - - //////////////////// - // ReplicaDataView - //////////////////// - const char* ReplicaDataView::DDT_REPLICA_NAME = "Replica"; - const char* ReplicaDataView::DDT_CHUNK_NAME = "Chunk Type"; - - const char* ReplicaDataView::WINDOW_STATE_FORMAT = "REPLICA_DATA_VIEW_WINDOW_STATE_%u"; - const char* ReplicaDataView::SPLITTER_STATE_FORMAT = "REPLICA_DATA_VIEW_SPLITTER_STATE_%u"; - const char* ReplicaDataView::TABLE_STATE_FORMAT = "REPLICA_DATA_VIEW_TABLE_STATE_%u"; - const char* ReplicaDataView::DATA_VIEW_STATE_FORMAT = "REPLICA_DATA_VIEW_DATA_VIEW_STATE_%u"; - const char* ReplicaDataView::DATA_VIEW_WORKSPACE_FORMAT = "REPLICA_DATA_VIEW_WORKSPACE_%u"; - - const int ReplicaDataView::INSPECT_ICON_COLUMN_SIZE = 32; - - ReplicaDataView::ReplicaDataView(unsigned int dataViewIndex, FrameNumberType currentFrame, const ReplicaDataAggregator* aggregator) - : QDialog() - , m_dataViewIndex(dataViewIndex) - , m_inspectedSeries(AreaChart::AreaChart::k_invalidSeriesId) - , m_windowStateCRC(0) - , m_splitterStateCRC(0) - , m_tableViewCRC(0) - , m_dataViewCRC(0) - , m_aggregatorIdentity(aggregator->GetIdentity()) - , m_aggregator(aggregator) - , m_currentFrame(currentFrame) - , m_startFrame(0) - , m_endFrame(0) - , m_overallReplicaDetailView(nullptr) - , m_replicaTypeTableView(this) - , m_replicaChunkTypeTableView(this) - , m_lifespanTelemetry("ReplicaDataView") - { - setAttribute(Qt::WA_DeleteOnClose, true); - setWindowFlags(windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint); - - // Create a window defined in CarrierDataView.ui. - m_gui = azcreate(Ui::ReplicaDataView, ()); - m_gui->setupUi(this); - - show(); - raise(); - activateWindow(); - setFocus(); - - m_gui->areaChart->ConfigureVerticalAxis("Bandwidth Usage", GetAverageFrameBandwidthBudget()); - m_gui->areaChart->EnableMouseInspection(true); - - this->setWindowTitle(m_aggregator->GetDialogTitle()); - - for (int i = DDT_START + 1; i < DDT_END; ++i) - { - switch (i) - { - case DDT_REPLICA: - m_gui->dataSelectionComboBox->addItem(QString(DDT_REPLICA_NAME)); - break; - case DDT_CHUNK: - m_gui->dataSelectionComboBox->addItem(QString(DDT_CHUNK_NAME)); - break; - default: - break; - } - } - - if (m_gui->dataSelectionComboBox->count() == 1) - { - m_gui->dataSelectionComboBox->setEditable(false); - m_gui->dataSelectionComboBox->setEnabled(false); - } - - for (int i = ReplicaDisplayTypes::BUDT_START + 1; i < ReplicaDisplayTypes::BUDT_END; ++i) - { - switch (i) - { - case ReplicaDisplayTypes::BUDT_COMBINED: - m_gui->bandwidthUsageComboBox->addItem(QString(ReplicaDisplayTypes::DisplayNames::BUDT_COMBINED_NAME)); - break; - case ReplicaDisplayTypes::BUDT_SENT: - m_gui->bandwidthUsageComboBox->addItem(QString(ReplicaDisplayTypes::DisplayNames::BUDT_SENT_NAME)); - break; - case ReplicaDisplayTypes::BUDT_RECEIVED: - m_gui->bandwidthUsageComboBox->addItem(QString(ReplicaDisplayTypes::DisplayNames::BUDT_RECEIVED_NAME)); - break; - default: - break; - } - } - - if (m_gui->bandwidthUsageComboBox->count() == 1) - { - m_gui->dataSelectionComboBox->setEditable(false); - m_gui->dataSelectionComboBox->setEnabled(false); - } - - for (int i = TFT_START + 1; i < TFT_END; ++i) - { - switch (i) - { - case TFT_NONE: - m_gui->tableFilterComboBox->addItem("No Filter"); - break; - case TFT_ACTIVE_ONLY: - m_gui->tableFilterComboBox->addItem("Active Types"); - break; - } - } - - if (m_gui->tableFilterComboBox->count() == 1) - { - m_gui->tableFilterComboBox->setEditable(false); - m_gui->tableFilterComboBox->setEnabled(false); - } - - m_gui->drillerConfigToolbar->enableTreeCommands(false); - - AZStd::string serializationString = AZStd::string::format(WINDOW_STATE_FORMAT, m_dataViewIndex); - m_windowStateCRC = AZ::Crc32(serializationString.c_str()); - - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - - if (windowState) - { - windowState->RestoreGeometry(this); - } - - serializationString = AZStd::string::format(DATA_VIEW_STATE_FORMAT, m_dataViewIndex); - m_dataViewCRC = AZ::Crc32(serializationString.c_str()); - m_persistentState = AZ::UserSettings::CreateFind(m_dataViewCRC, AZ::UserSettings::CT_GLOBAL); - - ApplyPersistentState(); - - // do the table state formatting - serializationString = AZStd::string::format(TABLE_STATE_FORMAT, m_dataViewIndex); - m_tableViewCRC = AZ::Crc32(serializationString.c_str()); - auto treeState = AZ::UserSettings::Find(m_tableViewCRC, AZ::UserSettings::CT_GLOBAL); - - if (treeState) - { - QByteArray treeData((const char*)treeState->m_treeColumnStorage.data(), (int)treeState->m_treeColumnStorage.size()); - m_gui->tableView->horizontalHeader()->restoreState(treeData); - } - - serializationString = AZStd::string::format(SPLITTER_STATE_FORMAT, m_dataViewIndex); - m_splitterStateCRC = AZ::Crc32(serializationString.c_str()); - auto splitterState = AZ::UserSettings::Find(m_splitterStateCRC,AZ::UserSettings::CT_GLOBAL); - - if (splitterState) - { - QByteArray splitterData((const char*)splitterState->m_splitterSavedState.data(), (int)splitterState->m_splitterSavedState.size()); - m_gui->splitter->restoreState(splitterData); - } - - DrillerMainWindowMessages::Handler::BusConnect(m_aggregatorIdentity); - DrillerEventWindowMessages::Handler::BusConnect(m_aggregatorIdentity); - - QObject::connect((&m_replicaTypeTableView), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(UpdateDisplay(const QModelIndex&, const QModelIndex&))); - QObject::connect((&m_replicaChunkTypeTableView), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(UpdateDisplay(const QModelIndex&, const QModelIndex&))); - - QObject::connect(m_gui->tableView, SIGNAL(clicked(const QModelIndex&)), this, SLOT(OnCellClicked(const QModelIndex&))); - QObject::connect(m_gui->tableView, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(OnDoubleClicked(const QModelIndex&))); - - QObject::connect(m_gui->drillerConfigToolbar, SIGNAL(hideAll()), this, SLOT(HideAll())); - QObject::connect(m_gui->drillerConfigToolbar, SIGNAL(hideSelected()), this, SLOT(HideSelected())); - QObject::connect(m_gui->drillerConfigToolbar, SIGNAL(showAll()), this, SLOT(ShowAll())); - QObject::connect(m_gui->drillerConfigToolbar, SIGNAL(showSelected()), this, SLOT(ShowSelected())); - - QObject::connect(m_gui->showOverallStatistics,SIGNAL(clicked()),this,SLOT(OnShowOverallStatistics())); - QObject::connect(m_gui->displayRange, SIGNAL(valueChanged(int)), this, SLOT(OnDisplayRangeChanged(int))); - QObject::connect(m_gui->dataSelectionComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(OnDataTypeChanged(int))); - QObject::connect(m_gui->bandwidthUsageComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnBandwidthUsageDisplayTypeChanged(int))); - QObject::connect(m_gui->tableFilterComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(OnTableFilterTypeChanged(int))); - - QObject::connect(m_gui->areaChart, SIGNAL(InspectedSeries(size_t)), this, SLOT(OnInspectedSeries(size_t))); - QObject::connect(m_gui->areaChart, SIGNAL(SelectedSeries(size_t,int)), this, SLOT(OnSelectedSeries(size_t, int))); - } - - ReplicaDataView::~ReplicaDataView() - { - DrillerEventWindowMessages::Handler::BusDisconnect(m_aggregatorIdentity); - DrillerMainWindowMessages::Handler::BusDisconnect(m_aggregatorIdentity); - - // Save out whatever data we want to save out. - auto pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (pState) - { - pState->CaptureGeometry(this); - } - - auto splitterState = AZ::UserSettings::CreateFind(m_splitterStateCRC, AZ::UserSettings::CT_GLOBAL); - if (splitterState) - { - QByteArray qba = m_gui->splitter->saveState(); - splitterState->m_splitterSavedState.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - - auto treeState = AZ::UserSettings::CreateFind(m_tableViewCRC, AZ::UserSettings::CT_GLOBAL); - if (treeState) - { - if (m_gui->tableView && m_gui->tableView->horizontalHeader()) - { - QByteArray qba = m_gui->tableView->horizontalHeader()->saveState(); - treeState->m_treeColumnStorage.assign((AZ::u8*)qba.begin(), (AZ::u8*)qba.end()); - } - } - - for (ReplicaDataMap::iterator replicaIter = m_replicaData.begin(); - replicaIter != m_replicaData.end(); - ++replicaIter) - { - delete replicaIter->second; - } - - m_replicaData.clear(); - - for (ReplicaChunkTypeDataMap::iterator chunkIter = m_replicaChunkTypeData.begin(); - chunkIter != m_replicaChunkTypeData.end(); - ++chunkIter) - { - delete chunkIter->second; - } - m_replicaChunkTypeData.clear(); - - for (ReplicaDetailView* view : m_spawnedReplicaDetailViews) - { - view->SignalDataViewDestroyed(this); - view->close(); - } - - for (ReplicaChunkTypeDetailView* view : m_spawnedChunkDetailViews) - { - view->SignalDataViewDestroyed(this); - view->close(); - } - - if (m_overallReplicaDetailView) - { - m_overallReplicaDetailView->SignalDataViewDestroyed(this); - m_overallReplicaDetailView->close(); - m_overallReplicaDetailView = nullptr; - } - - azdestroy(m_gui); - } - - void ReplicaDataView::FrameChanged(FrameNumberType frame) - { - int displayRange = GetDisplayRange(); - int halfRange = displayRange / 2; - - m_currentFrame = frame; - - m_startFrame = AZStd::GetMax(m_currentFrame - halfRange, 0); - - if (m_startFrame == 0) - { - m_endFrame = AZStd::GetMin(m_startFrame + displayRange, static_cast(m_aggregator->GetFrameCount())); - } - else - { - m_endFrame = AZStd::GetMin(m_currentFrame + halfRange, static_cast(m_aggregator->GetFrameCount())); - } - - if (m_endFrame == m_aggregator->GetFrameCount()) - { - m_startFrame = AZStd::GetMax(m_endFrame - displayRange, 0); - } - - UpdateData(); - - RefreshGraph(); - RefreshTableView(); - - emit DataRangeChanged(); - } - - void ReplicaDataView::EventFocusChanged(EventNumberType eventIndex) - { - (void)eventIndex; - } - - void ReplicaDataView::EventChanged(EventNumberType eventIndex) - { - (void)eventIndex; - } - - float ReplicaDataView::GetAxisStartFrame() const - { - return static_cast(m_startFrame); - } - - FrameNumberType ReplicaDataView::GetStartFrame() const - { - return m_startFrame; - } - - float ReplicaDataView::GetAxisEndFrame() const - { - return static_cast(AZStd::GetMax(m_endFrame, GetDisplayRange())); - } - - FrameNumberType ReplicaDataView::GetEndFrame() const - { - return m_endFrame; - } - - FrameNumberType ReplicaDataView::GetActiveFrameCount() const - { - return GetDisplayRange(); - } - - FrameNumberType ReplicaDataView::GetCurrentFrame() const - { - return m_currentFrame; - } - - bool ReplicaDataView::HideInactiveInspectedElements() const - { - return m_persistentState->m_tableFilterType == TFT_ACTIVE_ONLY; - } - - int ReplicaDataView::GetCaptureWindowIdentity() const - { - return m_aggregator->GetIdentity(); - } - - unsigned int ReplicaDataView::GetAverageFrameBandwidthBudget() const - { - return m_aggregator->GetAverageFrameBandwidthBudget(); - } - - void ReplicaDataView::DrawFrameGraph() - { - const QColor markerColor(Qt::red); - BandwidthUsageAggregator maximumUsageAggregator; - - m_gui->areaChart->ResetChart(); - m_gui->areaChart->ConfigureHorizontalAxis("Frame", static_cast(GetAxisStartFrame()), static_cast(GetAxisEndFrame())); - - m_gui->areaChart->AddMarker(Charts::AxisType::Horizontal, static_cast(GetCurrentFrame()), markerColor); - - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - for (auto replicaIter = m_replicaData.begin(); - replicaIter != m_replicaData.end(); - ++replicaIter) - { - ReplicaDataContainer* container = replicaIter->second; - - container->GetAreaGraphPlotHelper().Reset(); - PlotChartDataForFrames(container); - } - break; - case DDT_CHUNK: - for (auto chunkIter = m_replicaChunkTypeData.begin(); - chunkIter != m_replicaChunkTypeData.end(); - ++chunkIter) - { - ReplicaChunkTypeDataContainer* container = chunkIter->second; - - container->GetAreaGraphPlotHelper().Reset(); - PlotChartDataForFrames(container); - } - break; - default: - AZ_Assert(false,"ERROR: Unknown display data type"); - break; - } - } - - void ReplicaDataView::SignalDialogClosed(QDialog* dialog) - { - if (dialog == m_overallReplicaDetailView) - { - m_overallReplicaDetailView = nullptr; - return; - } - - for (AZStd::vector< ReplicaDetailView* >::iterator dialogIter = m_spawnedReplicaDetailViews.begin(); - dialogIter != m_spawnedReplicaDetailViews.end(); - ++dialogIter) - { - if ((*dialogIter) == dialog) - { - m_spawnedReplicaDetailViews.erase(dialogIter); - return; - } - } - - for (AZStd::vector< ReplicaChunkTypeDetailView* >::iterator dialogIter = m_spawnedChunkDetailViews.begin(); - dialogIter != m_spawnedChunkDetailViews.end(); - ++dialogIter) - { - if ((*dialogIter) == dialog) - { - m_spawnedChunkDetailViews.erase(dialogIter); - return; - } - } - } - - unsigned int ReplicaDataView::GetDataViewIndex() const - { - return m_dataViewIndex; - } - - void ReplicaDataView::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* settingsProvider) - { - AZStd::string workspaceStateStr = AZStd::string::format(DATA_VIEW_WORKSPACE_FORMAT, GetDataViewIndex()); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - ReplicaDataViewSavedState* workspace = settingsProvider->FindSetting(workspaceStateCRC); - - if (workspace) - { - m_persistentState->CopyStateFrom(workspace); - } - } - } - - void ReplicaDataView::ActivateWorkspaceSettings(WorkspaceSettingsProvider* settingsProvider) - { - (void)settingsProvider; - - ApplyPersistentState(); - } - - void ReplicaDataView::SaveSettingsToWorkspace(WorkspaceSettingsProvider* settingsProvider) - { - AZStd::string workspaceStateStr = AZStd::string::format(DATA_VIEW_WORKSPACE_FORMAT, GetDataViewIndex()); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - ReplicaDataViewSavedState* workspace = settingsProvider->CreateSetting(workspaceStateCRC); - - if (workspace) - { - workspace->CopyStateFrom(m_persistentState.get()); - } - } - } - - void ReplicaDataView::ApplyPersistentState() - { - if (m_persistentState) - { - m_gui->dataSelectionComboBox->setCurrentIndex(m_persistentState->m_displayDataType); - m_gui->bandwidthUsageComboBox->setCurrentIndex(m_persistentState->m_bandwidthUsageDisplayType); - m_gui->tableFilterComboBox->setCurrentIndex(m_persistentState->m_tableFilterType); - - m_gui->displayRange->setValue(m_persistentState->m_displayRange); - - SetupTableView(); - FrameChanged(GetCurrentFrame()); - } - } - - void ReplicaDataView::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - ReplicaDataViewSavedState::Reflect(context); - ReplicaDataViewTableModelSavedState::Reflect(context); - ReplicaDataViewSplitterSavedState::Reflect(context); - - BaseDetailViewSplitterSavedState::Reflect(context); - BaseDetailViewTreeSavedState::Reflect(context); - } - } - - void ReplicaDataView::ReplicaSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) - { - if (GetDisplayDataType() != DDT_REPLICA) - { - return; - } - - if (!selected.indexes().empty()) - { - for (const QModelIndex& selectedIndex : selected.indexes()) - { - AZ::u64 replicaId = m_replicaTypeTableView.GetReplicaIdFromIndex(selectedIndex); - ReplicaDataContainer* container = FindReplicaData(replicaId); - - if (container != nullptr) - { - container->SetSelected(true); - - const bool isHighlighted = true; - container->GetAreaGraphPlotHelper().SetHighlighted(isHighlighted); - } - } - } - - if (!deselected.empty()) - { - for (const QModelIndex& deselectedIndex : deselected.indexes()) - { - AZ::u64 replicaId = m_replicaTypeTableView.GetReplicaIdFromIndex(deselectedIndex); - ReplicaDataContainer* container = FindReplicaData(replicaId); - - if (container != nullptr) - { - container->SetSelected(false); - - const bool isHighlighted = false; - container->GetAreaGraphPlotHelper().SetHighlighted(isHighlighted); - } - } - } - } - - void ReplicaDataView::ChunkSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected) - { - if (GetDisplayDataType() != DDT_CHUNK) - { - return; - } - - if (!selected.indexes().empty()) - { - for (const QModelIndex& selectedIndex : selected.indexes()) - { - const char* chunkType = m_replicaChunkTypeTableView.GetReplicaChunkTypeFromIndex(selectedIndex); - ReplicaChunkTypeDataContainer* container = FindReplicaChunkTypeData(chunkType); - - if (container != nullptr) - { - container->SetSelected(true); - - const bool isHighlighted = true; - container->GetAreaGraphPlotHelper().SetHighlighted(isHighlighted); - } - } - } - - if (!deselected.empty()) - { - AZStd::unordered_set rowSets; - for (const QModelIndex& deselectedIndex : deselected.indexes()) - { - const char* chunkType = m_replicaChunkTypeTableView.GetReplicaChunkTypeFromIndex(deselectedIndex); - ReplicaChunkTypeDataContainer* container = FindReplicaChunkTypeData(chunkType); - - if (container != nullptr) - { - container->SetSelected(false); - - const bool isHighlighted = false; - container->GetAreaGraphPlotHelper().SetHighlighted(isHighlighted); - } - } - } - } - - void ReplicaDataView::OnDisplayRangeChanged(int displayRange) - { - ReplicaOperationTelemetryEvent displayRangeEvent; - displayRangeEvent.SetMetric("DisplayRange", displayRange); - displayRangeEvent.Log(); - - m_persistentState->m_displayRange = displayRange; - FrameChanged(GetCurrentFrame()); - } - - void ReplicaDataView::HideAll() - { - SetAllEnabled(false); - } - - void ReplicaDataView::ShowAll() - { - SetAllEnabled(true); - } - - void ReplicaDataView::SetAllEnabled(bool enabled) - { - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - { - for (AZ::u64 replicaId : m_activeReplicaIds) - { - ReplicaDataContainer* dataContainer = m_replicaData[replicaId]; - dataContainer->SetEnabled(enabled); - dataContainer->GetAreaGraphPlotHelper().SetEnabled(enabled); - } - - m_replicaTypeTableView.layoutChanged(); - break; - } - case DDT_CHUNK: - { - for (AZStd::string chunkType : m_activeChunkTypes) - { - ReplicaChunkTypeDataContainer* dataContainer = m_replicaChunkTypeData[chunkType]; - dataContainer->SetEnabled(enabled); - dataContainer->GetAreaGraphPlotHelper().SetEnabled(enabled); - } - - m_replicaChunkTypeTableView.layoutChanged(); - break; - } - default: - AZ_Assert(false, "Unknown Display Data Type"); - break; - } - } - - void ReplicaDataView::HideSelected() - { - SetSelectedEnabled(false); - } - - void ReplicaDataView::ShowSelected() - { - SetSelectedEnabled(true); - } - - void ReplicaDataView::SetSelectedEnabled(bool enabled) - { - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - { - for (AZ::u64 replicaId : m_activeReplicaIds) - { - ReplicaDataContainer* dataContainer = m_replicaData[replicaId]; - - if (dataContainer->IsSelected()) - { - dataContainer->SetEnabled(enabled); - } - } - - m_replicaTypeTableView.layoutChanged(); - break; - } - case DDT_CHUNK: - { - for (AZStd::string chunkType : m_activeChunkTypes) - { - ReplicaChunkTypeDataContainer* dataContainer = m_replicaChunkTypeData[chunkType]; - - if (dataContainer->IsSelected()) - { - dataContainer->SetEnabled(enabled); - } - } - - m_replicaChunkTypeTableView.layoutChanged(); - break; - } - default: - AZ_Assert(false, "Unknown Data Display Type"); - break; - } - - m_replicaChunkTypeTableView.layoutChanged(); - RefreshGraph(); - } - - void ReplicaDataView::UpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex) - { - (void)startIndex; - (void)endIndex; - - RefreshGraph(); - } - - void ReplicaDataView::RefreshGraph() - { - DrawFrameGraph(); - } - - void ReplicaDataView::OnCellClicked(const QModelIndex& index) - { - if (!index.isValid()) - { - return; - } - - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - if (index.column() == ReplicaTableViewModel::CD_INSPECT) - { - InspectReplica(index.row()); - } - break; - case DDT_CHUNK: - if (index.column() == ReplicaChunkTypeTableViewModel::CD_INSPECT) - { - InspectChunkType(index.row()); - } - break; - default: - AZ_Assert(false, "ERROR: Unknown Display Data Type"); - break; - } - } - - void ReplicaDataView::OnDoubleClicked(const QModelIndex& index) - { - if (!index.isValid()) - { - return; - } - - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - { - if (index.column() != ReplicaTableViewModel::CD_INSPECT) - { - AZ::u64 replicaId = m_replicaTypeTableView.GetReplicaIdFromIndex(index); - - ReplicaDataContainer* dataContainer = FindReplicaData(replicaId); - dataContainer->SetEnabled(!dataContainer->IsEnabled()); - dataContainer->GetAreaGraphPlotHelper().SetEnabled(dataContainer->IsEnabled()); - } - break; - } - case DDT_CHUNK: - { - if (index.column() != ReplicaChunkTypeTableViewModel::CD_INSPECT) - { - const char* chunkType = m_replicaChunkTypeTableView.GetReplicaChunkTypeFromIndex(index); - - ReplicaChunkTypeDataContainer* dataContainer = FindReplicaChunkTypeData(chunkType); - dataContainer->SetEnabled(!dataContainer->IsEnabled()); - dataContainer->GetAreaGraphPlotHelper().SetEnabled(dataContainer->IsEnabled()); - } - break; - } - default: - AZ_Assert(false, "ERROR: Unknown Display Data Type"); - break; - } - } - - void ReplicaDataView::OnDataTypeChanged(int selectedIndex) - { - AZ_Error("StandaloneTools", selectedIndex > DDT_START && selectedIndex < DDT_END, "selectedIndex for DataType is out of enum range."); - - if (selectedIndex > DDT_START && selectedIndex < DDT_END) - { - m_persistentState->m_displayDataType = static_cast(selectedIndex); - ParseActiveItems(); - SetupTableView(); - RefreshGraph(); - - ReplicaOperationTelemetryEvent dataTypeChanged; - - switch (m_persistentState->m_displayDataType) - { - case DDT_CHUNK: - { - dataTypeChanged.SetAttribute("DisplayDataType", DDT_CHUNK_NAME); - break; - } - case DDT_REPLICA: - { - dataTypeChanged.SetAttribute("DisplayDataType", DDT_REPLICA_NAME); - break; - } - default: - { - dataTypeChanged.SetAttribute("Change Display Data Type", "Unknown"); - } - } - - dataTypeChanged.Log(); - } - } - - void ReplicaDataView::OnBandwidthUsageDisplayTypeChanged(int selectedIndex) - { - AZ_Error("StandaloneTools", selectedIndex > ReplicaDisplayTypes::BUDT_START && selectedIndex < ReplicaDisplayTypes::BUDT_END, "Invalid index for BandwidthUsageDisplay"); - - if (selectedIndex > ReplicaDisplayTypes::BUDT_START && selectedIndex < ReplicaDisplayTypes::BUDT_END) - { - m_persistentState->m_bandwidthUsageDisplayType = static_cast(selectedIndex); - - RefreshGraph(); - - ReplicaOperationTelemetryEvent bandwidthDisplayChanged; - - switch (m_persistentState->m_displayDataType) - { - case ReplicaDisplayTypes::BUDT_COMBINED: - { - bandwidthDisplayChanged.SetAttribute("BandwidthUsageDisplayType", ReplicaDisplayTypes::DisplayNames::BUDT_COMBINED_NAME); - break; - } - case ReplicaDisplayTypes::BUDT_SENT: - { - bandwidthDisplayChanged.SetAttribute("BandwidthUsageDisplayType", ReplicaDisplayTypes::DisplayNames::BUDT_SENT_NAME); - break; - } - case ReplicaDisplayTypes::BUDT_RECEIVED: - { - bandwidthDisplayChanged.SetAttribute("BandwidthUsageDisplayType", ReplicaDisplayTypes::DisplayNames::BUDT_RECEIVED_NAME); - break; - } - default: - { - bandwidthDisplayChanged.SetAttribute("Change Display Data Type", "Unknown"); - } - } - - bandwidthDisplayChanged.Log(); - } - } - - void ReplicaDataView::OnTableFilterTypeChanged(int selectedIndex) - { - AZ_Error("StandaloneTools", selectedIndex > TFT_START && selectedIndex < TFT_END, "Invalid index for TableFilterType"); - - if (selectedIndex > TFT_START && selectedIndex < TFT_END) - { - m_persistentState->m_tableFilterType = static_cast(selectedIndex); - RefreshTableView(); - - ReplicaOperationTelemetryEvent displayFilterChangedEvent; - - switch (m_persistentState->m_tableFilterType) - { - case TFT_NONE: - { - displayFilterChangedEvent.SetAttribute("TableFilterType", "None"); - break; - } - case TFT_ACTIVE_ONLY: - { - displayFilterChangedEvent.SetAttribute("TableFilterType", "Active Only"); - break; - } - default: - { - displayFilterChangedEvent.SetAttribute("TableFilterType", "Unknown"); - } - } - - displayFilterChangedEvent.Log(); - } - } - - void ReplicaDataView::OnShowOverallStatistics() - { - if (m_overallReplicaDetailView == nullptr) - { - m_overallReplicaDetailView = aznew OverallReplicaDetailView(this, (*m_aggregator)); - } - else - { - if (m_overallReplicaDetailView->isMinimized()) - { - m_overallReplicaDetailView->showNormal(); - } - - m_overallReplicaDetailView->raise(); - m_overallReplicaDetailView->activateWindow(); - } - } - - void ReplicaDataView::OnInspectedSeries(size_t seriesId) - { - if (m_inspectedSeries != seriesId) - { - m_inspectedSeries = seriesId; - - // This could be improved by using a map. But might not be necessary. - if (GetDisplayDataType() == DDT_REPLICA) - { - for (auto& mapPair : m_replicaData) - { - ReplicaDataContainer* container = mapPair.second; - - container->SetInspected(container->GetAreaGraphPlotHelper().IsSeries(seriesId)); - } - - m_replicaTypeTableView.layoutChanged(); - } - else if (GetDisplayDataType() == DDT_CHUNK) - { - for (auto& mapPair : m_replicaChunkTypeData) - { - ReplicaChunkTypeDataContainer* container = mapPair.second; - - container->SetInspected(container->GetAreaGraphPlotHelper().IsSeries(seriesId)); - } - - m_replicaChunkTypeTableView.layoutChanged(); - } - } - } - - void ReplicaDataView::OnSelectedSeries(size_t seriesId, int position) - { - (void)seriesId; - - EBUS_EVENT_ID(GetCaptureWindowIdentity(), DrillerCaptureWindowRequestBus, ScrubToFrameRequest, position); - } - - void ReplicaDataView::InspectReplica(int tableRow) - { - AZ::u64 replicaId = m_replicaTypeTableView.GetReplicaIdForRow(tableRow); - ReplicaDataContainer* replicaContainer = FindReplicaData(replicaId); - - ReplicaDetailView* replicaDetailView = aznew ReplicaDetailView(this, replicaContainer); - replicaDetailView->LoadSavedState(); - m_spawnedReplicaDetailViews.push_back(replicaDetailView); - } - - void ReplicaDataView::InspectChunkType(int tableRow) - { - const char* chunkType = m_replicaChunkTypeTableView.GetReplicaChunkTypeForRow(tableRow); - ReplicaChunkTypeDataContainer* chunkContainer = FindReplicaChunkTypeData(chunkType); - - ReplicaChunkTypeDetailView* replicaDetailView = aznew ReplicaChunkTypeDetailView(this, chunkContainer); - replicaDetailView->LoadSavedState(); - m_spawnedChunkDetailViews.push_back(replicaDetailView); - } - - void ReplicaDataView::RefreshTableView() - { - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - m_replicaTypeTableView.RefreshView(); - break; - case DDT_CHUNK: - m_replicaChunkTypeTableView.RefreshView(); - break; - default: - break; - } - } - - void ReplicaDataView::SetupTableView() - { - m_gui->tableView->reset(); - - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - SetupReplicaTableView(); - break; - case DDT_CHUNK: - SetupChunkTableView(); - break; - default: - break; - } - - RefreshTableView(); - } - - void ReplicaDataView::SetupReplicaTableView() - { - m_gui->tableView->setModel(&m_replicaTypeTableView); - m_gui->tableView->verticalHeader()->hide(); - - m_gui->tableView->horizontalHeader()->reset(); - - // I think this will fix the sizing issue, but until we update to 5.6 we don't get it! AWESOME - //m_gui->tableView->horizontalHeader()->resetDefaultSectionSize(); - - for (int i = 0; i < m_replicaTypeTableView.columnCount(); ++i) - { - m_gui->tableView->horizontalHeader()->resizeSection(i, m_gui->tableView->horizontalHeader()->defaultSectionSize()); - } - - // QT Persists the section resize mode after you call reset on the table, and on the column header. - // It's pretty special. - // Going to manually remove the information to avoid something looking really stupid. - if (ReplicaChunkTypeTableViewModel::CD_INSPECT < m_replicaTypeTableView.columnCount()) - { - m_gui->tableView->horizontalHeader()->setSectionResizeMode(ReplicaChunkTypeTableViewModel::CD_INSPECT, QHeaderView::Interactive); - } - - m_gui->tableView->horizontalHeader()->setSectionsClickable(false); - m_gui->tableView->horizontalHeader()->setSectionResizeMode(ReplicaTableViewModel::CD_INSPECT, QHeaderView::Fixed); - m_gui->tableView->horizontalHeader()->resizeSection(ReplicaTableViewModel::CD_INSPECT, INSPECT_ICON_COLUMN_SIZE); - - m_gui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_gui->tableView->setAlternatingRowColors(true); - - m_gui->tableView->setItemDelegateForColumn(ReplicaTableViewModel::CD_INSPECT, new InspectIconItemDelegate(Qt::AlignCenter, m_gui->tableView)); - - QObject::connect(m_gui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(ReplicaSelectionChanged(const QItemSelection&, const QItemSelection&))); - } - - void ReplicaDataView::SetupChunkTableView() - { - m_gui->tableView->setModel(&m_replicaChunkTypeTableView); - m_gui->tableView->verticalHeader()->hide(); - - m_gui->tableView->horizontalHeader()->reset(); - - // I think this will fix the sizing issue, but until we update to 5.6 we don't get it! AWESOME - //m_gui->tableView->horizontalHeader()->resetDefaultSectionSize(); - - for (int i = 0; i < m_replicaChunkTypeTableView.columnCount(); ++i) - { - m_gui->tableView->horizontalHeader()->resizeSection(i, m_gui->tableView->horizontalHeader()->defaultSectionSize()); - } - - // QT Persists the section resize mode after you call reset on the table, and on the column header. - // It's pretty special. - // Going to manually remove the information to avoid something looking really stupid. - if (ReplicaTableViewModel::CD_INSPECT < m_replicaChunkTypeTableView.columnCount()) - { - m_gui->tableView->horizontalHeader()->setSectionResizeMode(ReplicaTableViewModel::CD_INSPECT, QHeaderView::Interactive); - } - - m_gui->tableView->horizontalHeader()->setSectionsClickable(false); - m_gui->tableView->horizontalHeader()->setSectionResizeMode(ReplicaChunkTypeTableViewModel::CD_INSPECT, QHeaderView::Fixed); - m_gui->tableView->horizontalHeader()->resizeSection(ReplicaChunkTypeTableViewModel::CD_INSPECT, INSPECT_ICON_COLUMN_SIZE); - - m_gui->tableView->setSelectionBehavior(QAbstractItemView::SelectRows); - m_gui->tableView->setAlternatingRowColors(true); - - m_gui->tableView->setItemDelegateForColumn(ReplicaChunkTypeTableViewModel::CD_INSPECT, new InspectIconItemDelegate(Qt::AlignCenter, m_gui->tableView)); - - QObject::connect(m_gui->tableView->selectionModel(), SIGNAL(selectionChanged(const QItemSelection&, const QItemSelection&)), this, SLOT(ChunkSelectionChanged(const QItemSelection&, const QItemSelection&))); - } - - void ReplicaDataView::UpdateData() - { - for (FrameNumberType frameId = GetStartFrame(); frameId <= GetEndFrame(); ++frameId) - { - ParseFrameData(frameId); - } - - ParseActiveItems(); - } - - void ReplicaDataView::ParseFrameData(FrameNumberType frameId) - { - AZ_PROFILE_FUNCTION(AzToolsFramework); - if (frameId < 0 || frameId >= m_aggregator->GetFrameCount() || m_parsedFrames.find(frameId) != m_parsedFrames.end()) - { - return; - } - - m_parsedFrames.insert(frameId); - - size_t numEvents = m_aggregator->NumOfEventsAtFrame(frameId); - - if (numEvents > 0) - { - const ReplicaDataAggregator::EventListType& events = m_aggregator->GetEvents(); - - EventNumberType startIndex = m_aggregator->GetFirstIndexAtFrame(frameId); - for (EventNumberType eventId = startIndex; eventId < static_cast(startIndex + numEvents); ++eventId) - { - const ReplicaChunkEvent* replicaChunkEvent = static_cast(events[eventId]); - - // Parsing events by ReplicaId - AZ::u64 replicaId = replicaChunkEvent->GetReplicaId(); - ReplicaDataMap::iterator replicaIter = m_replicaData.find(replicaId); - ReplicaDataContainer* replicaDataContainer = nullptr; - - if (replicaIter == m_replicaData.end()) - { - replicaDataContainer = aznew ReplicaDataContainer(replicaChunkEvent->GetReplicaName(), replicaId, GetRandomDisplayColor()); - - if (replicaDataContainer) - { - m_replicaData.insert(ReplicaDataMap::value_type(replicaId, replicaDataContainer)); - } - } - else - { - replicaDataContainer = replicaIter->second; - } - - // Parsing events by ReplicaChunkType - const AZStd::string& replicaChunkType = replicaChunkEvent->GetChunkTypeName(); - ReplicaChunkTypeDataMap::iterator replicaChunkIter = m_replicaChunkTypeData.find(replicaChunkType); - ReplicaChunkTypeDataContainer* replicaChunkDataContainer = nullptr; - - if (replicaChunkIter == m_replicaChunkTypeData.end()) - { - replicaChunkDataContainer = aznew ReplicaChunkTypeDataContainer(replicaChunkType.c_str(), GetRandomDisplayColor()); - - if (replicaChunkDataContainer) - { - m_replicaChunkTypeData.insert(ReplicaChunkTypeDataMap::value_type(replicaChunkType, replicaChunkDataContainer)); - } - } - else - { - replicaChunkDataContainer = replicaChunkIter->second; - } - - if (replicaDataContainer) - { - replicaDataContainer->ProcessReplicaChunkEvent(frameId, replicaChunkEvent); - } - - if (replicaChunkDataContainer) - { - replicaChunkDataContainer->ProcessReplicaChunkEvent(frameId, replicaChunkEvent); - } - } - } - } - - - void ReplicaDataView::ParseActiveItems() - { - switch (GetDisplayDataType()) - { - case DDT_REPLICA: - m_activeReplicaIds.clear(); - m_activeInspectedReplicaIds.clear(); - - for (AZStd::pair& replicaItem : m_replicaData) - { - ReplicaDataContainer* dataContainer = replicaItem.second; - - for (FrameNumberType frameId = GetStartFrame(); frameId <= GetEndFrame(); ++frameId) - { - if (dataContainer->HasUsageForFrame(frameId)) - { - m_activeReplicaIds.insert(replicaItem.first); - - if (dataContainer->HasUsageForFrame(GetCurrentFrame())) - { - m_activeInspectedReplicaIds.insert(replicaItem.first); - } - - break; - } - } - } - break; - case DDT_CHUNK: - m_activeChunkTypes.clear(); - m_activeInspectedChunkTypes.clear(); - - for (AZStd::pair& chunkItem : m_replicaChunkTypeData) - { - ReplicaChunkTypeDataContainer* dataContainer = chunkItem.second; - - for (FrameNumberType frameId = GetStartFrame(); frameId <= GetEndFrame(); ++frameId) - { - if (dataContainer->HasUsageForFrame(frameId)) - { - m_activeChunkTypes.insert(chunkItem.first); - - if (dataContainer->HasUsageForFrame(GetCurrentFrame())) - { - m_activeInspectedChunkTypes.insert(chunkItem.first); - } - - break; - } - } - } - break; - default: - AZ_Assert(false, "Unknown Display Data Type"); - break; - } - } - - int ReplicaDataView::GetDisplayRange() const - { - return m_persistentState->m_displayRange; - } - - ReplicaDataView::DisplayDataType ReplicaDataView::GetDisplayDataType() const - { - return static_cast(m_persistentState->m_displayDataType); - } - - ReplicaDisplayTypes::BandwidthUsageDisplayType ReplicaDataView::GetBandwidthUsageDisplayType() const - { - return static_cast(m_persistentState->m_bandwidthUsageDisplayType); - } - - ReplicaDataContainer* ReplicaDataView::FindReplicaData(AZ::u64 replicaId) const - { - ReplicaDataContainer* retVal = nullptr; - - ReplicaDataMap::const_iterator replicaIter = m_replicaData.find(replicaId); - - if (replicaIter != m_replicaData.end()) - { - retVal = replicaIter->second; - } - - return retVal; - } - - ReplicaChunkTypeDataContainer* ReplicaDataView::FindReplicaChunkTypeData(const char* chunkType) const - { - ReplicaChunkTypeDataContainer* retVal = nullptr; - - if (chunkType == nullptr) - { - return retVal; - } - - ReplicaChunkTypeDataMap::const_iterator chunkTypeIter = m_replicaChunkTypeData.find(AZStd::string(chunkType)); - - if (chunkTypeIter != m_replicaChunkTypeData.end()) - { - retVal = chunkTypeIter->second; - } - - return retVal; - } -} - diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.hxx b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.hxx deleted file mode 100644 index 20833fe4e5..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataView.hxx +++ /dev/null @@ -1,438 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef REPLICADATAVIEW_H -#define REPLICADATAVIEW_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" - -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/AreaChart.hxx" -#include "Source/Driller/DrillerDataTypes.h" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#include "Source/Driller/Replica/ReplicaDisplayTypes.h" -#include "Source/Driller/Replica/ReplicaTreeViewModel.hxx" - -#include -#include - -#include "ReplicaBandwidthChartData.h" -#endif - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class ReplicaDataAggregator; - - class ReplicaChunkDataEvent; - class ReplicaChunkReceivedDataEvent; - class ReplicaChunkSentDataEvent; - class ReplicaDataView; - class ReplicaTableViewModel; - class ReplicaDataContainer; - class ReplicaChunkTypeDataContainer; - - class ReplicaDetailView; - class ReplicaChunkTypeDetailView; - - class ReplicaDataViewSavedState; - - class OverallReplicaDetailView; - - class FormattingHelper - { - public: - static QString ReplicaID(AZ::u64 replicaId) - { - return QString("0x%1").arg(QString::number(replicaId,16).toUpper()); - } - }; - - // Icon Item Delegate - class InspectIconItemDelegate : public QStyledItemDelegate - { - Q_OBJECT - public: - explicit InspectIconItemDelegate(Qt::Alignment alignment, QObject* parent = 0) - : QStyledItemDelegate(parent) - , m_alignment(alignment) - { - - } - - void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override - { - auto opt = option; - opt.decorationAlignment = m_alignment; - QStyledItemDelegate::paint(painter,opt,index); - } - - private: - Qt::Alignment m_alignment; - }; - - // Should be a private class, but Q_OBJECT doesn't support it. - class ReplicaTableViewModel : public QAbstractTableModel - { - Q_OBJECT - - public: - - enum ColumnDescriptor - { - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order. - CD_REPLICA_NAME, - CD_REPLICA_ID, - CD_TOTAL_SENT, - CD_TOTAL_RECEIVED, - CD_INSPECT, - - // Used for sizing of the TableView. Anything after this won't be displayed. - CD_COUNT, - - }; - - AZ_CLASS_ALLOCATOR(ReplicaTableViewModel, AZ::SystemAllocator, 0); - ReplicaTableViewModel(ReplicaDataView* replicaDataView); - - void RefreshView(); - - int rowCount(const QModelIndex& parentIndex = QModelIndex()) const override; - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - - Qt::ItemFlags flags(const QModelIndex& index) const override; - - AZ::u64 GetReplicaIdFromIndex(const QModelIndex& index) const; - AZ::u64 GetReplicaIdForRow(int row) const; - - private: - - ReplicaDataView* m_replicaDataView; - AZStd::vector m_replicaIds; - }; - - class ReplicaChunkTypeTableViewModel : public QAbstractTableModel - { - Q_OBJECT - - public: - - enum ColumnDescriptor - { - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order. - CD_CHUNK_TYPE, - CD_TOTAL_SENT, - CD_TOTAL_RECEIVED, - CD_INSPECT, - - CD_COUNT - }; - - AZ_CLASS_ALLOCATOR(ReplicaChunkTypeTableViewModel, AZ::SystemAllocator, 0); - - ReplicaChunkTypeTableViewModel(ReplicaDataView* replicaDataView); - - void RefreshView(); - - int rowCount(const QModelIndex& parentIndex = QModelIndex()) const override; - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - - Qt::ItemFlags flags(const QModelIndex& index) const override; - - const char* GetReplicaChunkTypeFromIndex(const QModelIndex& index) const; - const char* GetReplicaChunkTypeForRow(int row) const; - - private: - - ReplicaDataView* m_replicaDataView; - AZStd::vector m_replicaChunkTypes; - }; - - class ReplicaDataView - : public QDialog - , public Driller::DrillerMainWindowMessages::Bus::Handler - , public Driller::DrillerEventWindowMessages::Bus::Handler - { - Q_OBJECT - - private: - - friend class ReplicaDataViewSavedState; - friend class ReplicaDataViewConfigurationDialog; - - friend class ReplicaChunkTypeTableViewModel; - friend class ReplicaChunkTypeDetailView; - - friend class ReplicaTableViewModel; - friend class ReplicaDetailView; - - enum DisplayDataType - { - DDT_START = -1, - - DDT_REPLICA, - DDT_CHUNK, - - DDT_END - }; - - enum TableFilterType - { - TFT_START = -1, - - TFT_NONE, - TFT_ACTIVE_ONLY, - - TFT_END - }; - - static const char* DDT_REPLICA_NAME; - static const char* DDT_CHUNK_NAME; - - // Serialization Keys - static const char* WINDOW_STATE_FORMAT; - static const char* SPLITTER_STATE_FORMAT; - static const char* TABLE_STATE_FORMAT; - static const char* DATA_VIEW_STATE_FORMAT; - - static const char* DATA_VIEW_WORKSPACE_FORMAT; - - // Sizing keys - static const int INSPECT_ICON_COLUMN_SIZE; - - public: - - struct ChartZoomMaintainer - { - public: - ChartZoomMaintainer(); - - void GetZoomFromChart(StripChart::DataStrip& chart, Charts::AxisType axis); - void SetZoomOnChart(StripChart::DataStrip& chart, Charts::AxisType axis); - - private: - - Charts::AxisType m_axis; - float m_minValue; - float m_maxValue; - }; - - public: - - AZ_CLASS_ALLOCATOR(ReplicaDataView, AZ::SystemAllocator, 0); - - ReplicaDataView(unsigned int dataViewIndex, FrameNumberType currentFrame, const ReplicaDataAggregator* aggr); - virtual ~ReplicaDataView(); - - // MainWindow Bus Commands - void FrameChanged(FrameNumberType frame) override; - void EventFocusChanged(EventNumberType eventIndex) override; - void EventChanged(EventNumberType eventIndex) override; - - float GetAxisStartFrame() const; - FrameNumberType GetStartFrame() const; - - float GetAxisEndFrame() const; - FrameNumberType GetEndFrame() const; - - FrameNumberType GetActiveFrameCount() const; - FrameNumberType GetCurrentFrame() const; - - bool HideInactiveInspectedElements() const; - - int GetCaptureWindowIdentity() const; - unsigned int GetAverageFrameBandwidthBudget() const; - - void SignalDialogClosed(QDialog* dialog); - - unsigned int GetDataViewIndex() const; - - // Mimicing the workspace bus, but these need to be invoked manually - // by the object that creates these windows(since it creates these in response - // to these events). - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - void ApplyPersistentState(); - - static void Reflect(AZ::ReflectContext* context); - - public slots: - - void UpdateDisplay(const QModelIndex& startIndex, const QModelIndex& endIndex); - - void RefreshGraph(); - void ReplicaSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void ChunkSelectionChanged(const QItemSelection& selected, const QItemSelection& deselected); - void OnDisplayRangeChanged(int); - - void HideAll(); - void ShowAll(); - void SetAllEnabled(bool enabled); - - void HideSelected(); - void ShowSelected(); - void SetSelectedEnabled(bool enabled); - - void OnCellClicked(const QModelIndex& index); - void OnDoubleClicked(const QModelIndex& idnex); - - void OnDataTypeChanged(int selectedIndex); - void OnBandwidthUsageDisplayTypeChanged(int selectedIndex); - void OnTableFilterTypeChanged(int selectedIndex); - - void OnShowOverallStatistics(); - - void OnInspectedSeries(size_t seriesId); - void OnSelectedSeries(size_t seriesId, int position); - - signals: - - void DataRangeChanged(); - - private: - - void SaveOnExit(); - - void InspectReplica(int tableRow); - void InspectChunkType(int tableRow); - - void RefreshTableView(); - void SetupTableView(); - void SetupReplicaTableView(); - void SetupChunkTableView(); - - void DrawFrameGraph(); - - template - void PlotChartDataForFrames(ReplicaBandwidthChartData* chartData) - { - AreaGraphPlotHelper& areaPlotHelper = chartData->GetAreaGraphPlotHelper(); - areaPlotHelper.SetupPlotHelper(m_gui->areaChart, chartData->GetAxisName(),chartData->GetAllFrames().size()); - - if (!areaPlotHelper.IsSetup()) - { - return; - } - - areaPlotHelper.SetHighlighted(chartData->IsSelected()); - areaPlotHelper.SetEnabled(chartData->IsEnabled()); - - ReplicaDisplayTypes::BandwidthUsageDisplayType bandwidthDisplayType = GetBandwidthUsageDisplayType(); - - for (FrameNumberType frameId = GetStartFrame(); frameId <= GetEndFrame(); ++frameId) - { - size_t sentDataUsage = chartData->GetSentUsageForFrame(frameId); - size_t receivedDataUsage = chartData->GetReceivedUsageForFrame(frameId); - - switch (bandwidthDisplayType) - { - case ReplicaDisplayTypes::BUDT_COMBINED: - areaPlotHelper.PlotBatchedData(frameId, static_cast(sentDataUsage + receivedDataUsage)); - break; - case ReplicaDisplayTypes::BUDT_SENT: - areaPlotHelper.PlotBatchedData(frameId, static_cast(sentDataUsage)); - break; - case ReplicaDisplayTypes::BUDT_RECEIVED: - areaPlotHelper.PlotBatchedData(frameId, static_cast(receivedDataUsage)); - break; - default: - AZ_Error("Standalone Tools", false, "Unknown bandwidth display type."); - break; - } - } - } - - void InitializeData(); - void UpdateData(); - void ParseFrameData(FrameNumberType frameId); - void ParseActiveItems(); - - int GetDisplayRange() const; - DisplayDataType GetDisplayDataType() const; - ReplicaDisplayTypes::BandwidthUsageDisplayType GetBandwidthUsageDisplayType() const; - - ReplicaDataContainer* FindReplicaData(AZ::u64 replicaId) const; - ReplicaChunkTypeDataContainer* FindReplicaChunkTypeData(const char* chunkType) const; - - typedef AZStd::unordered_map ReplicaDataMap; - typedef AZStd::unordered_set ReplicaIdSet; - - typedef AZStd::unordered_map ReplicaChunkTypeDataMap; - typedef AZStd::unordered_set ReplicaChunkTypeSet; - - // Used for ordering in the table view/quick mapping of Row -> ReplicaID - ReplicaDataMap m_replicaData; - ReplicaIdSet m_activeReplicaIds; - ReplicaIdSet m_activeInspectedReplicaIds; - ReplicaTableViewModel m_replicaTypeTableView; - - ReplicaChunkTypeDataMap m_replicaChunkTypeData; - ReplicaChunkTypeSet m_activeChunkTypes; - ReplicaChunkTypeSet m_activeInspectedChunkTypes; - ReplicaChunkTypeTableViewModel m_replicaChunkTypeTableView; - - unsigned int m_dataViewIndex; - size_t m_inspectedSeries; - - AZ::u32 m_windowStateCRC; - AZ::u32 m_splitterStateCRC; - AZ::u32 m_tableViewCRC; - AZ::u32 m_dataViewCRC; - - int m_aggregatorIdentity; - const ReplicaDataAggregator* m_aggregator; - - FrameNumberType m_startFrame; - FrameNumberType m_endFrame; - FrameNumberType m_currentFrame; - - AZStd::unordered_set< FrameNumberType > m_parsedFrames; - - OverallReplicaDetailView* m_overallReplicaDetailView; - AZStd::vector< ReplicaDetailView* > m_spawnedReplicaDetailViews; - AZStd::vector< ReplicaChunkTypeDetailView* > m_spawnedChunkDetailViews; - - // Information about the window that we might want to save out - AZStd::intrusive_ptr m_persistentState; - - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - - Ui::ReplicaDataView* m_gui; - }; -} - -#endif // REPLICADATAVIEW_H diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataViewConfigDialog.ui b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataViewConfigDialog.ui deleted file mode 100644 index 567eed74e4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDataViewConfigDialog.ui +++ /dev/null @@ -1,106 +0,0 @@ - - - ReplicaDataViewConfigDialog - - - - 0 - 0 - 322 - 89 - - - - Replica Data View Configuration - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 5 - - - 0 - - - 5 - - - 0 - - - - - Controls the number of frames displayed on the Replica Data View and Replica Detail View. - - - Display Range - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - 99999 - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - Remove Inactive Replica's From Inspected Frame View - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.cpp deleted file mode 100644 index 0e653e982b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include - -#include "ReplicaDetailView.h" -#include - -#include "ReplicaDataAggregator.hxx" -#include "ReplicaUsageDataContainers.h" - - -namespace Driller -{ - /////////////////////////// - // ReplicaDetailViewModel - /////////////////////////// - - ReplicaDetailViewModel::ReplicaDetailViewModel(ReplicaDetailView* detailView) - : BaseDetailTreeViewModel(detailView) - { - } - - int ReplicaDetailViewModel::columnCount(const QModelIndex& parentIndex) const - { - (void)parentIndex; - - return static_cast(CD_COUNT); - } - - QVariant ReplicaDetailViewModel::data(const QModelIndex& index, int role) const - { - const BaseDisplayHelper* baseDisplay = static_cast(index.internalPointer()); - - if (role == Qt::BackgroundRole) - { - if (baseDisplay->m_inspected) - { - return QVariant::fromValue(QColor(94, 94, 178, 255)); - } - } - else - { - switch (index.column()) - { - case CD_DISPLAY_NAME: - if (role == Qt::DecorationRole) - { - if (baseDisplay->HasIcon()) - { - return baseDisplay->GetIcon(); - } - } - else if (role == Qt::DisplayRole) - { - return baseDisplay->GetDisplayName(); - } - break; - case CD_TOTAL_SENT: - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesSent); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_TOTAL_RECEIVED: - if (role == Qt::DisplayRole) - { - return QString::number(baseDisplay->m_bandwidthUsageAggregator.m_bytesReceived); - } - else if (role == Qt::TextAlignmentRole) - { - return QVariant(Qt::AlignCenter); - } - break; - case CD_RPC_COUNT: - if (role == Qt::DisplayRole) - { - if (azrtti_istypeof(baseDisplay)) - { - size_t count = 0; - - for (BaseDisplayHelper* displayHelper : baseDisplay->GetChildren()) - { - count += displayHelper->GetChildren().size(); - } - - return QString::number(count); - } - else if (azrtti_istypeof(baseDisplay)) - { - return QString::number(baseDisplay->GetChildren().size()); - } - } - break; - default: - AZ_Assert(false,"Unknown column index %i",index.column()); - break; - } - } - - return QVariant(); - } - - - QVariant ReplicaDetailViewModel::headerData(int section, Qt::Orientation orientation, int role) const - { - if (role == Qt::DisplayRole) - { - if (orientation == Qt::Horizontal) - { - switch (section) - { - case CD_DISPLAY_NAME: - return QString("Display Name"); - case CD_TOTAL_SENT: - return QString("Sent Bytes"); - case CD_TOTAL_RECEIVED: - return QString("Received Bytes"); - case CD_RPC_COUNT: - return QString("RPC Count"); - default: - AZ_Assert(false, "Unknown section index %i", section); - break; - } - } - } - - return QVariant(); - } - - ////////////////////// - // ReplicaDetailView - ////////////////////// - ReplicaDetailView::ReplicaDetailView(ReplicaDataView* replicaDataView, ReplicaDataContainer* dataContainer) - : BaseDetailView(replicaDataView) - , m_inspectedSeries(AreaChart::AreaChart::k_invalidSeriesId) - , m_replicaData(dataContainer) - , m_replicaDetailView(this) - , m_lifespanTelemetry("ReplicaDetailView") - { - QString replicaName = QString("%1 (%2)").arg(QString(dataContainer->GetReplicaName())).arg(FormattingHelper::ReplicaID(dataContainer->GetReplicaId())); - - show(); - raise(); - activateWindow(); - setFocus(); - - setWindowTitle(QString("%1's ReplicaChunk Breakdown - %2").arg(replicaName).arg(replicaDataView->m_aggregator->GetInspectionFileName())); - - m_gui->replicaName->setText(replicaName); - - m_gui->aggregationTypeComboBox->addItem(QString("Replica Chunk")); - - if (m_gui->aggregationTypeComboBox->count() == 1) - { - m_gui->aggregationTypeComboBox->setEditable(false); - m_gui->aggregationTypeComboBox->setEnabled(false); - } - - QObject::connect((&m_replicaDetailView), SIGNAL(dataChanged(const QModelIndex&, const QModelIndex&)), this, SLOT(UpdateDisplay(const QModelIndex&, const QModelIndex&))); - QObject::connect(m_gui->aggregationTypeComboBox,SIGNAL(currentIndexChanged(int)),this,SLOT(DisplayModeChanged(int))); - QObject::connect(m_gui->bandwidthUsageDisplayType, SIGNAL(currentIndexChanged(int)), this, SLOT(BandwidthDisplayUsageTypeChanged(int))); - QObject::connect(m_gui->graphDetailType, SIGNAL(currentIndexChanged(int)), this, SLOT(GraphDetailChanged(int))); - - DisplayModeChanged(static_cast(DisplayMode::Active)); - } - - ReplicaDetailView::~ReplicaDetailView() - { - for (ChunkDetailDisplayMap::iterator displayIter = m_typeDisplayMapping.begin(); - displayIter != m_typeDisplayMapping.end(); - ++displayIter) - { - delete displayIter->second; - } - } - - const ReplicaBandwidthChartData::FrameMap& ReplicaDetailView::GetFrameData() const - { - return m_replicaData->GetAllFrames(); - } - - BaseDetailDisplayHelper* ReplicaDetailView::FindDetailDisplay(const AZ::u32& chunkIndex) - { - BaseDetailDisplayHelper* retVal = nullptr; - - ChunkDetailDisplayMap::iterator displayIter = m_typeDisplayMapping.find(chunkIndex); - - if (displayIter != m_typeDisplayMapping.end()) - { - retVal = displayIter->second; - } - - return retVal; - } - - const BaseDetailDisplayHelper* ReplicaDetailView::FindDetailDisplay(const AZ::u32& chunkIndex) const - { - const BaseDetailDisplayHelper* retVal = nullptr; - - ChunkDetailDisplayMap::const_iterator displayIter = m_typeDisplayMapping.find(chunkIndex); - - if (displayIter != m_typeDisplayMapping.end()) - { - retVal = displayIter->second; - } - - return retVal; - } - - void ReplicaDetailView::InitializeDisplayData() - { - m_activeIds.clear(); - m_activeInspectedIds.clear(); - - const ReplicaDataContainer::FrameMap& frameMap = m_replicaData->GetAllFrames(); - - for (FrameNumberType currentFrame = m_replicaDataView->GetStartFrame(); currentFrame <= m_replicaDataView->GetEndFrame(); ++currentFrame) - { - ReplicaDataContainer::FrameMap::const_iterator frameIter = frameMap.find(currentFrame); - - if (frameIter == frameMap.end()) - { - continue; - } - - const ReplicaDataContainer::BandwidthUsageMap* usageMap = frameIter->second; - - for (ReplicaDataContainer::BandwidthUsageMap::const_iterator usageIter = usageMap->begin(); - usageIter != usageMap->end(); - ++usageIter) - { - ReplicaChunkBandwidthUsage* bandwidthUsage = static_cast(usageIter->second); - - ChunkDetailDisplayMap::iterator displayIter = m_typeDisplayMapping.find(bandwidthUsage->GetChunkIndex()); - - ReplicaChunkDetailDisplayHelper* chunkTypeDisplay = nullptr; - - if (displayIter == m_typeDisplayMapping.end()) - { - chunkTypeDisplay = aznew ReplicaChunkDetailDisplayHelper(bandwidthUsage->GetChunkTypeName(), bandwidthUsage->GetChunkIndex()); - - if (chunkTypeDisplay) - { - m_typeDisplayMapping.insert(AZStd::make_pair(bandwidthUsage->GetChunkIndex(), chunkTypeDisplay)); - } - } - else - { - chunkTypeDisplay = displayIter->second; - } - - // Consider sending along an overall descriptor of the replcia so we can easily setup the display instead - // of iterating blindly over our detail information trying to get a sense of what the thing is. - if (chunkTypeDisplay) - { - if (currentFrame == m_replicaDataView->GetCurrentFrame()) - { - m_activeInspectedIds.insert(chunkTypeDisplay->GetChunkIndex()); - } - - if (m_activeIds.insert(chunkTypeDisplay->GetChunkIndex()).second) - { - chunkTypeDisplay->GetDataSetDisplayHelper()->ClearActiveDisplay(); - chunkTypeDisplay->GetRPCDisplayHelper()->ClearActiveDisplay(); - } - - const ReplicaChunkBandwidthUsage::UsageAggregationMap& dataSetUsage = bandwidthUsage->GetDataTypeUsageAggregation(BandwidthUsage::DataType::DATA_SET); - - for (const auto& usagePair : dataSetUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - chunkTypeDisplay->SetupDataSet(currentUsage.m_index, currentUsage.m_identifier.c_str()); - } - - const ReplicaChunkBandwidthUsage::UsageAggregationMap& rpcUsage = bandwidthUsage->GetDataTypeUsageAggregation(BandwidthUsage::DataType::REMOTE_PROCEDURE_CALL); - - for (const auto& usagePair : rpcUsage) - { - const BandwidthUsage& currentUsage = usagePair.second; - chunkTypeDisplay->SetupRPC(currentUsage.m_index, currentUsage.m_identifier.c_str()); - } - } - } - } - } - - void ReplicaDetailView::LayoutChanged() - { - m_replicaDetailView.layoutChanged(); - } - - void ReplicaDetailView::OnSetupTreeView() - { - m_gui->treeView->setModel(&m_replicaDetailView); - ShowTreeFrame(m_replicaDataView->GetCurrentFrame()); - } - - void ReplicaDetailView::ShowTreeFrame(FrameNumberType frameId) - { - m_replicaDetailView.RefreshView(frameId); - } - - AZ::u32 ReplicaDetailView::CreateWindowGeometryCRC() - { - return AZ::Crc32("REPLICA_DETAIL_VIEW_WINDOW_STATE"); - } - - AZ::u32 ReplicaDetailView::CreateSplitterStateCRC() - { - return AZ::Crc32("REPLICA_DETAIL_VIEW_SPLITTER_STATE"); - } - - AZ::u32 ReplicaDetailView::CreateTreeStateCRC() - { - return AZ::Crc32("REPLICA_DETAIL_VIEW_TREE_STATE"); - } - - void ReplicaDetailView::OnInspectedSeries(size_t seriesId) - { - if (m_inspectedSeries != seriesId) - { - m_inspectedSeries = seriesId; - - // TODO: Handle expanding the tree and scrolling to the selected value. - for (auto& mapPair : m_typeDisplayMapping) - { - BaseDetailDisplayHelper* displayHelper = mapPair.second; - - displayHelper->m_inspected = displayHelper->m_areaGraphPlotHelper.IsSeries(m_inspectedSeries); - } - - m_replicaDetailView.layoutChanged(); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.h deleted file mode 100644 index 136da9003c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDetailView.h +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_REPLICADETAILVIEW_H -#define DRILLER_REPLICA_REPLICADETAILVIEW_H - -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/StripChart.hxx" -#include "Source/Driller/Replica/ReplicaDataView.hxx" -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" - -#include "Source/Driller/Replica/BaseDetailView.h" - -namespace Ui -{ - class ReplicaDetailView; -} - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class ReplicaDetailView; - class ReplicaChunkBandwidthUsage; - - class ReplicaDetailViewModel - : public BaseDetailTreeViewModel - { - public: - enum ColumnDescriptor - { - CD_INDEX_FORCE = -1, - - // Ordering of this enum determines the display order - CD_DISPLAY_NAME, - CD_TOTAL_SENT, - CD_TOTAL_RECEIVED, - CD_RPC_COUNT, - - // Used for sizing of the TableView. Anything after this won't be displayed. - CD_COUNT - }; - - AZ_CLASS_ALLOCATOR(ReplicaDetailViewModel, AZ::SystemAllocator, 0); - ReplicaDetailViewModel(ReplicaDetailView* detailView); - - int columnCount(const QModelIndex& parentIndex = QModelIndex()) const override; - - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - QVariant headerData(int section, Qt::Orientation orientation, int role) const override; - }; - - class ReplicaDetailView - : public BaseDetailView - { - typedef AZStd::unordered_map ChunkDetailDisplayMap; - - friend class ReplicaDetailViewModel; - - public: - AZ_CLASS_ALLOCATOR(ReplicaDetailView, AZ::SystemAllocator, 0); - - ReplicaDetailView(ReplicaDataView* replicaDataView, ReplicaDataContainer* dataContainer); - ~ReplicaDetailView(); - - const ReplicaBandwidthChartData::FrameMap& GetFrameData() const override; - BaseDetailDisplayHelper* FindDetailDisplay(const AZ::u32& chunkIndex) override; - const BaseDetailDisplayHelper* FindDetailDisplay(const AZ::u32& chunkIndex) const override; - - protected: - - void InitializeDisplayData() override; - - void LayoutChanged() override; - void OnSetupTreeView() override; - void ShowTreeFrame(FrameNumberType frameId) override; - - AZ::u32 CreateWindowGeometryCRC() override; - AZ::u32 CreateSplitterStateCRC() override; - AZ::u32 CreateTreeStateCRC() override; - - void OnInspectedSeries(size_t seriesId) override; - - private: - - size_t m_inspectedSeries; - - ChunkDetailDisplayMap m_typeDisplayMapping; - ReplicaDataContainer* m_replicaData; - - ReplicaDetailViewModel m_replicaDetailView; - - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.cpp deleted file mode 100644 index 0fad38a2ea..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.cpp +++ /dev/null @@ -1,568 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include - -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" - -#include "Source/Driller/StripChart.hxx" - -#include -#include - -namespace Driller -{ - QColor GetRandomDisplayColor() - { - static AZ::SimpleLcgRandom s_randomGenerator(AZStd::chrono::system_clock::now().time_since_epoch().count()); - // Narrowing the range to avoid excessively dark colors - return QColor(50 + s_randomGenerator.GetRandom() % 206, 50 + s_randomGenerator.GetRandom() % 206, 50 + s_randomGenerator.GetRandom() % 206); - } - - ////////////////////// - // BaseDisplayHelper - ////////////////////// - - BaseDisplayHelper::BaseDisplayHelper() - : m_graphEnabled(true) - , m_selected(false) - , m_inspected(false) - , m_color(GetRandomDisplayColor()) - , m_areaGraphPlotHelper(m_color) - , m_sentGraphPlot(m_color) - , m_iconEnabled(true) - , m_parent(nullptr) - { - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(m_color); - painter.drawRect(0, 0, 16, 16); - - m_icon.addPixmap(pixmap); - } - - BaseDisplayHelper::~BaseDisplayHelper() - { - for (BaseDisplayHelper* helper : m_children) - { - // Can't remove objects from the tree display since it messes with the - // index ordering. So if we get into this error, just keep it there, but we won't delete it. - if (helper->m_parent == this) - { - delete helper; - } - } - - m_children.clear(); - } - - void BaseDisplayHelper::Reset() - { - m_graphEnabled = true; - m_selected = false; - - for (BaseDisplayHelper* helper : m_children) - { - helper->Reset(); - } - - OnReset(); - ResetGraphConfiguration(); - ResetBandwidthUsage(); - } - - void BaseDisplayHelper::ResetGraphConfiguration() - { - m_areaGraphPlotHelper.Reset(); - - for (BaseDisplayHelper* helper : m_children) - { - helper->ResetGraphConfiguration(); - } - - OnResetGraphConfiguration(); - } - - void BaseDisplayHelper::ResetBandwidthUsage() - { - m_bandwidthUsageAggregator.Reset(); - - for (BaseDisplayHelper* helper : m_children) - { - helper->ResetBandwidthUsage(); - } - - OnResetBandwidthUsage(); - } - - int BaseDisplayHelper::AddChild(BaseDisplayHelper* baseDisplayHelper) - { - if (baseDisplayHelper == nullptr) - { - return -1; - } - - AZ_Assert(baseDisplayHelper->m_parent == nullptr, "Adding Leaf node to two parents in tree."); - - int index = static_cast(m_children.size()); - m_children.push_back(baseDisplayHelper); - - baseDisplayHelper->m_parent = this; - - return index; - } - - void BaseDisplayHelper::DetachChild(BaseDisplayHelper* baseDisplayHelper) - { - if (baseDisplayHelper == nullptr) - { - return; - } - - AZ_Error("BaseDisplayHelper", baseDisplayHelper->m_parent == this, "Detaching a leaf node from the wrong parent."); - - if (baseDisplayHelper->m_parent == this) - { - for (AZStd::vector< BaseDisplayHelper* >::iterator displayIter = m_children.begin(); - displayIter != m_children.end(); - ++displayIter) - { - if ((*displayIter) == baseDisplayHelper) - { - baseDisplayHelper->m_parent = nullptr; - m_children.erase(displayIter); - break; - } - } - } - } - - void BaseDisplayHelper::InspectSeries(size_t seriesId) - { - m_inspected = m_areaGraphPlotHelper.IsSeries(seriesId); - - for (BaseDisplayHelper* child : m_children) - { - child->InspectSeries(seriesId); - } - } - - BaseDisplayHelper* BaseDisplayHelper::FindChildByRow(int row) - { - BaseDisplayHelper* retVal = nullptr; - - if (row >= 0 && row < m_children.size()) - { - retVal = m_children[row]; - } - - return retVal; - } - - const BaseDisplayHelper* BaseDisplayHelper::FindChildByRow(int row) const - { - const BaseDisplayHelper* retVal = nullptr; - - if (row >= 0 && row < m_children.size()) - { - retVal = m_children[row]; - } - - return retVal; - } - - size_t BaseDisplayHelper::GetTreeRowCount() const - { - return m_children.size(); - } - - int BaseDisplayHelper::GetChildIndex(const BaseDisplayHelper* helper) const - { - int index = -1; - - for (size_t i = 0; i < m_children.size(); ++i) - { - if (m_children[i] == helper) - { - index = static_cast(i); - break; - } - } - - return index; - } - - void BaseDisplayHelper::SetIconEnabled(bool iconEnabled) - { - m_iconEnabled = iconEnabled; - } - - bool BaseDisplayHelper::HasIcon() const - { - return m_iconEnabled; - } - - const QIcon& BaseDisplayHelper::GetIcon() const - { - if (m_graphEnabled) - { - return m_icon; - } - else - { - static QIcon s_blackIcon; - static bool s_doOnce = true; - - if (s_doOnce) - { - s_doOnce = false; - - QPixmap pixmap(16, 16); - QPainter painter(&pixmap); - painter.setBrush(Qt::black); - painter.drawRect(0, 0, 16, 16); - - s_blackIcon.addPixmap(pixmap); - } - - return s_blackIcon; - } - } - - const AZStd::vector< BaseDisplayHelper* >& BaseDisplayHelper::GetChildren() const - { - return m_children; - } - - const BaseDisplayHelper* BaseDisplayHelper::GetParent() const - { - return m_parent; - } - - void BaseDisplayHelper::DetachAllChildren() - { - for (BaseDisplayHelper* helper : m_children) - { - helper->m_parent = nullptr; - } - - m_children.clear(); - } - - void BaseDisplayHelper::OnReset() - { - } - - void BaseDisplayHelper::OnResetGraphConfiguration() - { - } - - void BaseDisplayHelper::OnResetBandwidthUsage() - { - } - - ///////////////////////// - // DataSetDisplayHelper - ///////////////////////// - - DataSetDisplayHelper::DataSetDisplayHelper(size_t dataSetIndex) - : KeyedDisplayHelper(dataSetIndex) - { - } - - void DataSetDisplayHelper::SetDisplayName(const char* displayName) - { - if (displayName) - { - m_dataSetName = displayName; - } - else - { - m_dataSetName.clear(); - } - } - - const char* DataSetDisplayHelper::GetDisplayName() const - { - return m_dataSetName.c_str(); - } - - ///////////////////// - // RPCDisplayHelper - ///////////////////// - - /////////////////////////////// - // RPCInvokationDisplayHelper - /////////////////////////////// - - RPCDisplayHelper::RPCInvokationDisplayHelper::RPCInvokationDisplayHelper(const AZStd::string& rpcName, int counter) - { - SetIconEnabled(false); - m_rpcName = AZStd::string::format("%s_%i",rpcName.c_str(),counter); - } - - const char* RPCDisplayHelper::RPCInvokationDisplayHelper::GetDisplayName() const - { - return m_rpcName.c_str(); - } - - RPCDisplayHelper::RPCDisplayHelper(size_t rpcIndex) - : KeyedDisplayHelper(rpcIndex) - { - } - - void RPCDisplayHelper::AddInvokation(const BandwidthUsage& bandwidthUsage) - { - m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - RPCInvokationDisplayHelper* invokationDisplayHelper = aznew RPCInvokationDisplayHelper(m_rpcName,static_cast(GetChildren().size())); - - invokationDisplayHelper->m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - invokationDisplayHelper->m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - AddChild(invokationDisplayHelper); - } - - void RPCDisplayHelper::SetDisplayName(const char* displayName) - { - m_rpcName = displayName; - } - - const char* RPCDisplayHelper::GetDisplayName() const - { - return m_rpcName.c_str(); - } - - void RPCDisplayHelper::OnResetBandwidthUsage() - { - DetachAllChildren(); - } - - //////////////////////////// - // BaseDetailDisplayHelper - //////////////////////////// - - BaseDetailDisplayHelper::BaseDetailDisplayHelper() - : m_rpcDisplayFilter(aznew RPCDisplayFilter()) - , m_dataSetDisplayFilter(aznew DataSetDisplayFilter()) - { - AddChild(m_rpcDisplayFilter); - AddChild(m_dataSetDisplayFilter); - } - - BaseDetailDisplayHelper::~BaseDetailDisplayHelper() - { - m_rpcDisplayFilter = nullptr; - m_dataSetDisplayFilter = nullptr; - } - - RPCDisplayHelper* BaseDetailDisplayHelper::FindRPC(size_t rpcIndex) - { - AZ_Error("BaseDetailDisplayHelper", m_rpcDisplayFilter->HasDisplayHelperForKey(rpcIndex), "Invalid RPC Index"); - return m_rpcDisplayFilter->FindDisplayHelperFromKey(rpcIndex); - } - - const RPCDisplayHelper* BaseDetailDisplayHelper::FindRPC(size_t rpcIndex) const - { - return m_rpcDisplayFilter->FindDisplayHelperFromKey(rpcIndex); - } - - void BaseDetailDisplayHelper::SetupRPC(size_t index, const char* rpcName) - { - if (!m_rpcDisplayFilter->HasDisplayHelperForKey(index)) - { - RPCDisplayHelper* rpcDisplayHelper = m_rpcDisplayFilter->CreateDisplayHelperFromKey(index); - rpcDisplayHelper->SetDisplayName(rpcName); - } - } - - void BaseDetailDisplayHelper::AddRPCUsage(const BandwidthUsage& bandwidthUsage) - { - m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - m_rpcDisplayFilter->m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - m_rpcDisplayFilter->m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - RPCDisplayHelper* rpcDisplay = FindRPC(bandwidthUsage.m_index); - - if (rpcDisplay) - { - rpcDisplay->AddInvokation(bandwidthUsage); - } - } - - RPCDisplayFilter* BaseDetailDisplayHelper::GetRPCDisplayHelper() - { - return m_rpcDisplayFilter; - } - - DataSetDisplayHelper* BaseDetailDisplayHelper::FindDataSet(size_t dataSetIndex) - { - AZ_Error("BaseDetailDisplayHelper", m_dataSetDisplayFilter->HasDisplayHelperForKey(dataSetIndex), "Invalid DataSetIndex"); - return m_dataSetDisplayFilter->FindDisplayHelperFromKey(dataSetIndex); - } - - const DataSetDisplayHelper* BaseDetailDisplayHelper::FindDataSet(size_t dataSetIndex) const - { - return m_dataSetDisplayFilter->FindDisplayHelperFromKey(dataSetIndex); - } - - void BaseDetailDisplayHelper::SetupDataSet(size_t dataSetIndex, const char* dataSetName) - { - if (!m_dataSetDisplayFilter->HasDisplayHelperForKey(dataSetIndex)) - { - DataSetDisplayHelper* displayHelper = m_dataSetDisplayFilter->CreateDisplayHelperFromKey(dataSetIndex); - displayHelper->SetDisplayName(dataSetName); - } - } - - void BaseDetailDisplayHelper::AddDataSetUsage(const BandwidthUsage& bandwidthUsage) - { - m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - m_dataSetDisplayFilter->m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - m_dataSetDisplayFilter->m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - - DataSetDisplayHelper* dataSetDisplay = FindDataSet(bandwidthUsage.m_index); - - if (dataSetDisplay) - { - dataSetDisplay->m_bandwidthUsageAggregator.m_bytesSent += bandwidthUsage.m_usageAggregator.m_bytesSent; - dataSetDisplay->m_bandwidthUsageAggregator.m_bytesReceived += bandwidthUsage.m_usageAggregator.m_bytesReceived; - } - } - - DataSetDisplayFilter* BaseDetailDisplayHelper::GetDataSetDisplayHelper() - { - return m_dataSetDisplayFilter; - } - - - //////////////////////////////////// - // ReplicaChunkDetailDisplayHelper - //////////////////////////////////// - - ReplicaChunkDetailDisplayHelper::ReplicaChunkDetailDisplayHelper(const char* chunkTypeName, AZ::u32 chunkIndex) - : m_chunkTypeName(chunkTypeName) - , m_chunkIndex(chunkIndex) - { - } - - AZ::u32 ReplicaChunkDetailDisplayHelper::GetChunkIndex() const - { - return m_chunkIndex; - } - - const char* ReplicaChunkDetailDisplayHelper::GetChunkTypeName() const - { - return m_chunkTypeName.c_str(); - } - - const char* ReplicaChunkDetailDisplayHelper::GetDisplayName() const - { - return GetChunkTypeName(); - } - - /////////////////////////////// - // ReplicaDetailDisplayHelper - /////////////////////////////// - - ReplicaDetailDisplayHelper::ReplicaDetailDisplayHelper(const char* replicaName, AZ::u64 replicaId) - : m_replicaName(replicaName) - , m_replicaId(replicaId) - { - } - - AZ::u64 ReplicaDetailDisplayHelper::GetReplicaId() const - { - return m_replicaId; - } - - const char* ReplicaDetailDisplayHelper::GetReplicaName() const - { - return m_replicaName.c_str(); - } - - const char* ReplicaDetailDisplayHelper::GetDisplayName() const - { - return GetReplicaName(); - } - - ////////////////////////////////////// - // OverallReplicaDetailDisplayHelper - ////////////////////////////////////// - - OverallReplicaDetailDisplayHelper::OverallReplicaDetailDisplayHelper(const char* replicaName, AZ::u64 replicaId) - : m_replicaName(replicaName) - , m_replicaId(replicaId) - { - } - - OverallReplicaDetailDisplayHelper::~OverallReplicaDetailDisplayHelper() - { - DetachAllChildren(); - - for (auto& mapPair : m_replicaChunks) - { - delete mapPair.second; - } - } - - AZ::u64 OverallReplicaDetailDisplayHelper::GetReplicaId() const - { - return m_replicaId; - } - - const char* OverallReplicaDetailDisplayHelper::GetReplicaName() const - { - return m_replicaName.c_str(); - } - - const char* OverallReplicaDetailDisplayHelper::GetDisplayName() const - { - return GetReplicaName(); - } - - ReplicaChunkDetailDisplayHelper* OverallReplicaDetailDisplayHelper::CreateReplicaChunkDisplayHelper(const AZStd::string& chunkName, AZ::u32 chunkIndex) - { - ReplicaChunkDetailDisplayHelper* displayHelper = nullptr; - - auto chunkIter = m_replicaChunks.find(chunkIndex); - - AZ_Error("OverallReplicaDetailDisplayHelper", chunkIter == m_replicaChunks.end(), "Trying to create two replica chunks with the same chunk index for a given replica."); - - if (chunkIter == m_replicaChunks.end()) - { - displayHelper = aznew ReplicaChunkDetailDisplayHelper(chunkName.c_str(), chunkIndex); - m_replicaChunks.emplace(chunkIndex, displayHelper); - - AddChild(displayHelper); - } - - return displayHelper; - } - - ReplicaChunkDetailDisplayHelper* OverallReplicaDetailDisplayHelper::FindReplicaChunk(AZ::u32 chunkIndex) - { - ReplicaChunkDetailDisplayHelper* detailDisplayHelper = nullptr; - - auto chunkIter = m_replicaChunks.find(chunkIndex); - if (chunkIter != m_replicaChunks.end()) - { - detailDisplayHelper = chunkIter->second; - } - - return detailDisplayHelper; - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.h deleted file mode 100644 index 61407bd208..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayHelpers.h +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_REPLICADISPLAYHELPERS_H -#define DRILLER_REPLICA_REPLICADISPLAYHELPERS_H - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -// QModelIndex -#include - -#include "Source/Driller/DrillerDataTypes.h" -#include "Source/Driller/Replica/ReplicaBandwidthChartData.h" - -namespace StripChart -{ - class DataStrip; -} - -namespace Driller -{ - QColor GetRandomDisplayColor(); - - // Combo TreeView/Graph Display - class BaseDisplayHelper; - - class BaseDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(BaseDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(BaseDisplayHelper, "{8F84783A-B924-4081-9F6E-51524071B7BB}"); - - BaseDisplayHelper(); - virtual ~BaseDisplayHelper(); - - void Reset(); - void ResetGraphConfiguration(); - void ResetBandwidthUsage(); - - virtual int AddChild(BaseDisplayHelper* baseDisplayHelper); - virtual void DetachChild(BaseDisplayHelper* baseDisplayHelper); - - void InspectSeries(size_t seriesId); - - virtual BaseDisplayHelper* FindChildByRow(int row); - virtual const BaseDisplayHelper* FindChildByRow(int row) const; - virtual size_t GetTreeRowCount() const; - - virtual int GetChildIndex(const BaseDisplayHelper* helper) const; - - virtual const char* GetDisplayName() const = 0; - - void SetIconEnabled(bool iconEnabled); - bool HasIcon() const; - const QIcon& GetIcon() const; - - const AZStd::vector< BaseDisplayHelper* >& GetChildren() const; - - const BaseDisplayHelper* GetParent() const; - - // Information needed for graphing - bool m_graphEnabled; - bool m_selected; - bool m_inspected; - - QColor m_color; - - BandwidthUsageAggregator m_bandwidthUsageAggregator; - AreaGraphPlotHelper m_areaGraphPlotHelper; - - GraphPlotHelper m_sentGraphPlot; - - protected: - - virtual void DetachAllChildren(); - - virtual void OnReset(); - virtual void OnResetGraphConfiguration(); - virtual void OnResetBandwidthUsage(); - - private: - - bool m_iconEnabled; - QIcon m_icon; - - BaseDisplayHelper* m_parent; - - AZStd::vector< BaseDisplayHelper* > m_children; - }; - - template - class KeyedDisplayHelper - : public BaseDisplayHelper - { - public: - KeyedDisplayHelper(Key key) - : m_key(key) - {} - - const Key& GetKey() const - { - return m_key; - } - - private: - Key m_key; - }; - - template - class FilteredDisplayHelper - : public BaseDisplayHelper - { - typedef AZStd::unordered_map< Key, int > KeyToIndexMapping; - public: - AZ_CLASS_ALLOCATOR(FilteredDisplayHelper, AZ::SystemAllocator, 0); - - FilteredDisplayHelper(const char* displayName) - : m_displayName(displayName) - { - } - - virtual ~FilteredDisplayHelper() - { - DetachAllChildren(); - - for (auto& mapPair : m_displayHelperMap) - { - delete mapPair.second; - } - } - - const char* GetDisplayName() const override - { - return m_displayName.c_str(); - } - - int AddChild(BaseDisplayHelper* baseDisplayHelper) override - { - AZ_Assert(false, "Unsupported behavior"); - (void)baseDisplayHelper; - return -1; - } - - int GetChildIndex(const BaseDisplayHelper* helper) const override - { - const KeyedDisplayHelper* keyedHelper = static_cast*>(helper); - - const Key& key = keyedHelper->GetKey(); - - int foundIndex = -1; - - for (size_t i = 0; i < m_displayOrdering.size(); ++i) - { - if (m_displayOrdering[i] == key) - { - foundIndex = static_cast(i); - break; - } - } - - return foundIndex; - } - - bool HasDisplayHelperForKey(const Key& key) const - { - return m_keyMapping.find(key) != m_keyMapping.end(); - } - - DisplayType* CreateDisplayHelperFromKey(const Key& key) - { - DisplayType* retVal = nullptr; - - typename AZStd::unordered_map< Key, DisplayType* >::iterator helperIter = m_displayHelperMap.find(key); - - if (helperIter == m_displayHelperMap.end()) - { - retVal = aznew DisplayType(key); - m_displayHelperMap[key] = retVal; - } - else - { - retVal = m_displayHelperMap[key]; - } - - typename KeyToIndexMapping::iterator indexIter = m_keyMapping.find(key); - - if (indexIter == m_keyMapping.end()) - { - if (retVal) - { - int index = BaseDisplayHelper::AddChild(retVal); - m_keyMapping[key] = index; - } - } - - if (m_activeDisplay.insert(key).second) - { - m_displayOrdering.push_back(key); - } - - return retVal; - } - - DisplayType* FindDisplayHelperFromKey(const Key& key) - { - DisplayType* retVal = nullptr; - - typename KeyToIndexMapping::iterator indexIter = m_keyMapping.find(key); - - if (indexIter != m_keyMapping.end()) - { - retVal = static_cast(BaseDisplayHelper::FindChildByRow(indexIter->second)); - } - - return retVal; - } - - const DisplayType* FindDisplayHelperFromKey(const Key& key) const - { - const DisplayType* retVal = nullptr; - - typename KeyToIndexMapping::const_iterator indexIter = m_keyMapping.find(key); - - if (indexIter != m_keyMapping.end()) - { - retVal = static_cast(BaseDisplayHelper::FindChildByRow(indexIter->second)); - } - - return retVal; - } - - BaseDisplayHelper* FindChildByRow(int row) override - { - DisplayType* retVal = nullptr; - - if (row >= 0 && row < m_displayOrdering.size()) - { - Key key = m_displayOrdering[row]; - retVal = FindDisplayHelperFromKey(key); - } - - return retVal; - } - - const DisplayType* FindChildByRow(int row) const override - { - const DisplayType* retVal = nullptr; - - if (row >= 0 && row < m_displayOrdering.size()) - { - Key key = m_displayOrdering[row]; - retVal = FindDisplayHelperFromKey(key); - } - - return retVal; - } - - size_t GetTreeRowCount() const override - { - return m_displayOrdering.size(); - } - - void ClearActiveDisplay() - { - DetachAllChildren(); - - m_activeDisplay.clear(); - m_keyMapping.clear(); - m_displayOrdering.clear(); - } - - protected: - void OnChildActivated(BaseDisplayHelper* helper, int index) - { - const KeyedDisplayHelper* keyedHelper = static_cast*>(helper); - const Key& key = keyedHelper->GetKey(); - - m_keyMapping[key] = index; - - if (m_activeDisplay.insert(key).second) - { - m_displayOrdering.push_back(key); - } - } - - void OnChildDeactivated(BaseDisplayHelper* helper) - { - const KeyedDisplayHelper* keyedHelper = static_cast*>(helper); - const Key& key = keyedHelper->GetKey(); - - m_displayOrdering.erase(m_displayOrdering.begin() + m_keyMapping[key]); - m_keyMapping.erase(key); - m_activeDisplay.erase(key); - } - - private: - - void OnReset() override - { - m_keyMapping.clear(); - m_activeDisplay.clear(); - m_displayOrdering.clear(); - } - - void OnResetGraphConfiguration() override - { - } - - AZStd::string m_displayName; - - KeyToIndexMapping m_keyMapping; - AZStd::unordered_set< Key > m_activeDisplay; - AZStd::vector< Key > m_displayOrdering; - - AZStd::unordered_map< Key, DisplayType* > m_displayHelperMap; - }; - - class DataSetDisplayHelper - : public KeyedDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(DataSetDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(DataSetDisplayHelper, "{74A47E69-1DF5-40E7-A471-BF84B62182A8}", BaseDisplayHelper); - - DataSetDisplayHelper(size_t dataSetIndex); - - void SetDisplayName(const char* displayName); - const char* GetDisplayName() const override; - - private: - - AZStd::string m_dataSetName; - }; - - class DataSetDisplayFilter - : public FilteredDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(DataSetDisplayFilter, AZ::SystemAllocator, 0); - AZ_RTTI(DataSetDisplayFilter, "{C0B802CD-5551-48C0-95C2-41607D42A2E1}", BaseDisplayHelper); - - DataSetDisplayFilter() - : FilteredDisplayHelper("DataSets") - { - } - }; - - class RPCDisplayHelper - : public KeyedDisplayHelper - { - private: - class RPCInvokationDisplayHelper - : public BaseDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(RPCInvokationDisplayHelper, AZ::SystemAllocator, 0); - - RPCInvokationDisplayHelper(const AZStd::string& name, int count); - - const char* GetDisplayName() const override; - - private: - - AZStd::string m_rpcName; - }; - - public: - AZ_CLASS_ALLOCATOR(RPCDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(RPCDisplayHelper, "{564003A2-7880-441A-AC51-5397730C2E31}", BaseDisplayHelper); - - RPCDisplayHelper(size_t rpcName); - - void AddInvokation(const BandwidthUsage& bandwidthUsage); - - void SetDisplayName(const char* displayName); - const char* GetDisplayName() const override; - - protected: - - void OnResetBandwidthUsage() override; - - private: - - AZStd::string m_rpcName; - }; - - class RPCDisplayFilter - : public FilteredDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(DataSetDisplayFilter, AZ::SystemAllocator, 0); - AZ_RTTI(RPCDisplayFilter, "{1AF8368E-C5AF-4936-85C5-BA67E62FF871}", BaseDisplayHelper); - - RPCDisplayFilter() - : FilteredDisplayHelper("RPCs") - { - } - }; - - class BaseDetailDisplayHelper - : public BaseDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(BaseDetailDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(BaseDetailDisplayHelper, "{22B3809C-20A5-407B-9302-7890CEF4821D}", BaseDisplayHelper); - - BaseDetailDisplayHelper(); - virtual ~BaseDetailDisplayHelper(); - - RPCDisplayHelper* FindRPC(size_t rpcIndex); - const RPCDisplayHelper* FindRPC(size_t rpcIndex) const; - void SetupRPC(size_t rpcIndex, const char* rpcName); - void AddRPCUsage(const BandwidthUsage& currentUsage); - - RPCDisplayFilter* GetRPCDisplayHelper(); - - DataSetDisplayHelper* FindDataSet(size_t dataSetIndex); - const DataSetDisplayHelper* FindDataSet(size_t dataSetIndex) const; - void SetupDataSet(size_t dataSetIndex, const char* dataSetName); - void AddDataSetUsage(const BandwidthUsage& currentUsage); - - DataSetDisplayFilter* GetDataSetDisplayHelper(); - - protected: - - RPCDisplayFilter* m_rpcDisplayFilter; - DataSetDisplayFilter* m_dataSetDisplayFilter; - }; - - class ReplicaChunkDetailDisplayHelper - : public BaseDetailDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkDetailDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaChunkDetailDisplayHelper, "{9DBE2EFE-AA89-4527-A003-1EE08B9E3DB7}", BaseDetailDisplayHelper); - - ReplicaChunkDetailDisplayHelper(const char* chunkTypeName, AZ::u32 chunkIndex); - - AZ::u32 GetChunkIndex() const; - const char* GetChunkTypeName() const; - - const char* GetDisplayName() const override; - private: - - AZStd::string m_chunkTypeName; - int m_chunkIndex; - }; - - class ReplicaDetailDisplayHelper - : public BaseDetailDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(ReplicaDetailDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(ReplicaDetailDisplayHelper, "{9DBE2EFE-AA89-4527-A003-1EE08B9E3DB7}", BaseDetailDisplayHelper); - - ReplicaDetailDisplayHelper(const char* replicaName, AZ::u64 replicaId); - - AZ::u64 GetReplicaId() const; - const char* GetReplicaName() const; - - const char* GetDisplayName() const override; - - private: - - AZStd::string m_replicaName; - AZ::u64 m_replicaId; - }; - - class OverallReplicaDetailDisplayHelper - : public BaseDisplayHelper - { - public: - AZ_CLASS_ALLOCATOR(OverallReplicaDetailDisplayHelper, AZ::SystemAllocator, 0); - AZ_RTTI(OverallReplicaDetailDisplayHelper, "{1CE46BA7-DA92-4C4E-8294-F5E096D14622}", BaseDisplayHelper); - - OverallReplicaDetailDisplayHelper(const char* replicaName, AZ::u64 replicaId); - ~OverallReplicaDetailDisplayHelper(); - - AZ::u64 GetReplicaId() const; - const char* GetReplicaName() const; - - const char* GetDisplayName() const override; - - bool HasReplicaChunk(int chunkIndex); - ReplicaChunkDetailDisplayHelper* CreateReplicaChunkDisplayHelper(const AZStd::string& chunkName, AZ::u32 chunkIndex); - ReplicaChunkDetailDisplayHelper* FindReplicaChunk(AZ::u32 chunkIndex); - - private: - - AZStd::string m_replicaName; - AZ::u64 m_replicaId; - - AZStd::unordered_map m_replicaChunks; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.cpp deleted file mode 100644 index fcd4a3e237..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#include "Source/Driller/Replica/ReplicaDisplayTypes.h" - -namespace ReplicaDisplayTypes -{ - ///////////////// - // DisplayNames - ///////////////// - const char* DisplayNames::BUDT_SENT_NAME = "Sent"; - const char* DisplayNames::BUDT_RECEIVED_NAME = "Received"; - const char* DisplayNames::BUDT_COMBINED_NAME = "Combined"; -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.h deleted file mode 100644 index 1fdbc8651b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDisplayTypes.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -namespace ReplicaDisplayTypes -{ - enum BandwidthUsageDisplayType - { - BUDT_START = -1, - - BUDT_COMBINED, - BUDT_SENT, - BUDT_RECEIVED, - - BUDT_END - }; - - class DisplayNames - { - public: - static const char* BUDT_SENT_NAME; - static const char* BUDT_RECEIVED_NAME; - static const char* BUDT_COMBINED_NAME; - }; -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.cpp deleted file mode 100644 index aca8deb616..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ReplicaDrillerConfigToolbar.hxx" -#include -#include - -namespace Driller -{ - ReplicaDrillerConfigToolbar::ReplicaDrillerConfigToolbar(QWidget* parent) - : QWidget(parent) - , m_gui(new Ui::ReplicaDrillerConfigToolbar) - { - m_gui->setupUi(this); - - m_gui->hideAll->setAutoDefault(false); - m_gui->hideSelected->setAutoDefault(false); - m_gui->showAll->setAutoDefault(false); - m_gui->showSelected->setAutoDefault(false); - m_gui->collapseAll->setAutoDefault(false); - m_gui->expandAll->setAutoDefault(false); - - QObject::connect(m_gui->hideAll, SIGNAL(clicked()), this, SIGNAL(hideAll())); - QObject::connect(m_gui->hideSelected, SIGNAL(clicked()), this, SIGNAL(hideSelected())); - QObject::connect(m_gui->showAll, SIGNAL(clicked()), this, SIGNAL(showAll())); - QObject::connect(m_gui->showSelected, SIGNAL(clicked()), this, SIGNAL(showSelected())); - QObject::connect(m_gui->collapseAll, SIGNAL(clicked()), this, SIGNAL(collapseAll())); - QObject::connect(m_gui->expandAll, SIGNAL(clicked()), this, SIGNAL(expandAll())); - } - - ReplicaDrillerConfigToolbar::~ReplicaDrillerConfigToolbar() - { - delete m_gui; - } - - void ReplicaDrillerConfigToolbar::enableTreeCommands(bool enabled) - { - m_gui->collapseAll->setVisible(enabled); - m_gui->expandAll->setVisible(enabled); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx deleted file mode 100644 index 92501b1ebe..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_REPLICADRILLERCONFIGTOOLBAR_H -#define DRILLER_REPLICA_REPLICADRILLERCONFIGTOOLBAR_H - -#if !defined(Q_MOC_RUN) -#include -#include - -#pragma once - -#include -#endif - -namespace Ui -{ - class ReplicaDrillerConfigToolbar; -} - -namespace Driller -{ - class ReplicaDrillerConfigToolbar - : public QWidget - { - Q_OBJECT - - public: - AZ_CLASS_ALLOCATOR(ReplicaDrillerConfigToolbar, AZ::SystemAllocator,0); - - explicit ReplicaDrillerConfigToolbar(QWidget* parent = nullptr); - ~ReplicaDrillerConfigToolbar(); - - void enableTreeCommands(bool enabled); - - public: - signals: - void hideSelected(); - void showSelected(); - - void hideAll(); - void showAll(); - - void collapseAll(); - void expandAll(); - - private: - - Ui::ReplicaDrillerConfigToolbar* m_gui; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.ui b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.ui deleted file mode 100644 index 1ebeb59bd4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaDrillerConfigToolbar.ui +++ /dev/null @@ -1,158 +0,0 @@ - - - ReplicaDrillerConfigToolbar - - - - 0 - 0 - 871 - 60 - - - - - 0 - 0 - - - - Form - - - - 2 - - - 2 - - - 2 - - - 2 - - - - - 0 - - - 8 - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Hide Selected - - - - - - - - 0 - 0 - - - - Show Selected - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - Hide All - - - - - - - - 0 - 0 - - - - - 1 - 0 - - - - Show All - - - - - - - - 0 - 0 - - - - Collapse All - - - - - - - - 0 - 0 - - - - Expand Alll - - - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaOperationTelemetryEvent.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaOperationTelemetryEvent.h deleted file mode 100644 index 3eb78a8b10..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaOperationTelemetryEvent.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef DRILLER_REPLICA_REPLICAOPERATIONTELEMETRYEVENT_H -#define DRILLER_REPLICA_REPLICAOPERATIONTELEMETRYEVENT_H - -#include "Source/Telemetry/TelemetryEvent.h" - -namespace Driller -{ - class ReplicaOperationTelemetryEvent - : public Telemetry::TelemetryEvent - { - public: - ReplicaOperationTelemetryEvent() - : Telemetry::TelemetryEvent("ReplicaDataViewOperation") - { - } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.cpp deleted file mode 100644 index 0321a64f62..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "Source/Driller/Replica/ReplicaTreeViewModel.hxx" -#include - -namespace Driller -{ - ReplicaTreeViewModel::ReplicaTreeViewModel(QObject* parent) - : QAbstractItemModel(parent) - { - } - - ReplicaTreeViewModel::~ReplicaTreeViewModel() - { - } - - int ReplicaTreeViewModel::rowCount(const QModelIndex& parentIndex) const - { - int rowCount = 0; - - if (!parentIndex.isValid()) - { - rowCount = GetRootRowCount(); - } - else - { - const BaseDisplayHelper* displayHelper = static_cast(parentIndex.internalPointer()); - rowCount = static_cast(displayHelper->GetTreeRowCount()); - } - - return rowCount; - } - - QModelIndex ReplicaTreeViewModel::index(int row, int column, const QModelIndex& parent) const - { - if (!parent.isValid()) - { - const BaseDisplayHelper* baseDisplayHelper = FindDisplayHelperAtRoot(row); - - if (baseDisplayHelper) - { - return createIndex(row, column, (void*)(baseDisplayHelper)); - } - else - { - return QModelIndex(); - } - } - else - { - const BaseDisplayHelper* parentHelper = static_cast(parent.internalPointer()); - const BaseDisplayHelper* displayHelper = parentHelper->FindChildByRow(row); - - if (displayHelper) - { - return createIndex(row, column, (void*)(displayHelper)); - } - else - { - AZ_Assert(false, "Invalid Tree Structure"); - } - } - - return QModelIndex(); - } - - QModelIndex ReplicaTreeViewModel::parent(const QModelIndex& index) const - { - if (index.isValid()) - { - const BaseDisplayHelper* displayHelper = static_cast(index.internalPointer()); - const BaseDisplayHelper* parent = displayHelper->GetParent(); - - if (parent) - { - return createIndex(parent->GetChildIndex(displayHelper), 0, (void*)(parent)); - } - } - - return QModelIndex(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.hxx b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.hxx deleted file mode 100644 index 743af15f53..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaTreeViewModel.hxx +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_REPLICATREEVIEWMODELS_H -#define DRILLER_REPLICA_REPLICATREEVIEWMODELS_H - -#if !defined(Q_MOC_RUN) -#include - -#include "Source/Driller/Replica/ReplicaDisplayHelpers.h" -#endif - -namespace Driller -{ - - class ReplicaTreeViewModel - : public QAbstractItemModel - { - Q_OBJECT - - protected: - ReplicaTreeViewModel(QObject* parent = nullptr); - - public: - AZ_CLASS_ALLOCATOR(ReplicaTreeViewModel,AZ::SystemAllocator,0); - - virtual ~ReplicaTreeViewModel(); - - int rowCount(const QModelIndex& parentIndex = QModelIndex()) const override; - QModelIndex index(int row, int column, const QModelIndex& parent) const; - QModelIndex parent(const QModelIndex& index) const; - - protected: - - virtual int GetRootRowCount() const = 0; - virtual const BaseDisplayHelper* FindDisplayHelperAtRoot(int row) const = 0; - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.cpp b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.cpp deleted file mode 100644 index 929fb85d2c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ReplicaUsageDataContainers.h" - -#include "Source/Driller/StripChart.hxx" -#include "ReplicaDataEvents.h" - -namespace Driller -{ - /////////////////////////////// - // ReplicaChunkBandwidthUsage - /////////////////////////////// - - ReplicaChunkBandwidthUsage::ReplicaChunkBandwidthUsage(const char* chunkTypeName, AZ::u32 chunkIndex) - : m_chunkIndex(chunkIndex) - , m_chunkTypeName(chunkTypeName) - { - } - - AZ::u32 ReplicaChunkBandwidthUsage::GetChunkIndex() const - { - return m_chunkIndex; - } - - const char* ReplicaChunkBandwidthUsage::GetChunkTypeName() const - { - return m_chunkTypeName.c_str(); - } - - ///////////////////////// - // ReplicaDataContainer - ///////////////////////// - - ReplicaDataContainer::ReplicaDataContainer(const char* replicaName, AZ::u64 replicaId, const QColor& displayColor) - : ReplicaBandwidthChartData(displayColor) - , m_replicaName(replicaName) - , m_replicaId(replicaId) - { - } - - const char* ReplicaDataContainer::GetReplicaName() const - { - return m_replicaName.c_str(); - } - - AZ::u64 ReplicaDataContainer::GetReplicaId() const - { - return m_replicaId; - } - - const char* ReplicaDataContainer::GetAxisName() const - { - return GetReplicaName(); - } - - BandwidthUsageContainer* ReplicaDataContainer::CreateBandwidthUsage(const ReplicaChunkEvent* chunkEvent) - { - return aznew ReplicaChunkBandwidthUsage(chunkEvent->GetChunkTypeName(), chunkEvent->GetReplicaChunkIndex()); - } - - AZ::u32 ReplicaDataContainer::GetKeyFromEvent(const ReplicaChunkEvent* chunkEvent) const - { - return chunkEvent->GetReplicaChunkIndex(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.h b/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.h deleted file mode 100644 index 46f653792b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/ReplicaUsageDataContainers.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_REPLICA_USAGE_DATA_CONTAINER_H -#define DRILLER_REPLICA_USAGE_DATA_CONTAINER_H - -#include -#include -#include -#include -#include - -#include - -#include "ReplicaBandwidthChartData.h" - -namespace Driller -{ - class ReplicaDataAggregator; - class ReplicaDataView; - - class ReplicaChunkBandwidthUsage - : public BandwidthUsageContainer - { - public: - AZ_CLASS_ALLOCATOR(ReplicaChunkBandwidthUsage, AZ::SystemAllocator, 0); - - ReplicaChunkBandwidthUsage(const char* chunkTypeName, AZ::u32 chunkIndex); - - AZ::u32 GetChunkIndex() const; - const char* GetChunkTypeName() const; - - private: - AZStd::string m_chunkTypeName; - AZ::u32 m_chunkIndex; - }; - - class ReplicaDataContainer - : public ReplicaBandwidthChartData - { - public: - AZ_CLASS_ALLOCATOR(ReplicaDataContainer, AZ::SystemAllocator, 0); - - ReplicaDataContainer(const char* replicaName, AZ::u64 replicaId, const QColor& displayColor); - - const char* GetReplicaName() const; - AZ::u64 GetReplicaId() const; - - const char* GetAxisName() const override; - - protected: - BandwidthUsageContainer* CreateBandwidthUsage(const ReplicaChunkEvent* dataEvent) override; - AZ::u32 GetKeyFromEvent(const ReplicaChunkEvent* dataEvent) const override; - - private: - - AZStd::string m_replicaName; - AZ::u64 m_replicaId; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Replica/basedetailview.ui b/Code/Tools/Standalone/Source/Driller/Replica/basedetailview.ui deleted file mode 100644 index dbd5cc1912..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/basedetailview.ui +++ /dev/null @@ -1,504 +0,0 @@ - - - BaseDetailView - - - - 0 - 0 - 659 - 756 - - - - Form - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::Vertical - - - 3 - - - false - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 2 - - - 2 - - - 2 - - - 3 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 5 - - - 0 - - - 5 - - - - - - 0 - 0 - - - - - 15 - 50 - false - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - - - - 0 - 0 - - - - - 0 - 100 - - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 2 - - - 3 - - - 2 - - - 2 - - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Display Mode - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Usage Display - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Graph Detail - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 255 - 50 - - - - - 16777215 - 55 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - QAbstractItemView::ExtendedSelection - - - true - - - true - - - false - - - - - - - - - - - - AreaChart::AreaChart - QWidget -
Source/Driller/AreaChart.hxx
- 1 -
- - Driller::ReplicaDrillerConfigToolbar - QWidget -
Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx
- 1 -
-
- - -
diff --git a/Code/Tools/Standalone/Source/Driller/Replica/overallreplicadetailview.ui b/Code/Tools/Standalone/Source/Driller/Replica/overallreplicadetailview.ui deleted file mode 100644 index 5368dfe2a2..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/overallreplicadetailview.ui +++ /dev/null @@ -1,718 +0,0 @@ - - - OverallReplicaDetailView - - - - 0 - 0 - 667 - 708 - - - - Form - - - - - - - 22 - - - - Overall Replica Statistics - - - Qt::AlignCenter - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Start Frame - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - 99 - - - - - - - End Frame - - - - - - - - 0 - 0 - - - - - 60 - 0 - - - - - 60 - 16777215 - - - - 0 - - - 99 - - - 0 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - FPS - - - - - - - 60 - - - - - - - - - - Qt::Horizontal - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 16777215 - 16777215 - - - - Total Bytes Sent - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 125 - 0 - - - - Avg Bytes Sent/Frame - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - 0 - 0 - - - - - 125 - 0 - - - - Avg Bytes Sent/Second - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - - 90 - 0 - - - - - 16777215 - 16777215 - - - - Total Bytes Recv'd - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 20 - 20 - - - - - - - - - 0 - 0 - - - - - 125 - 0 - - - - Avg Bytes Recv'd/Frame - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 5 - 20 - - - - - - - - - 0 - 0 - - - - - 125 - 0 - - - - Avg Bytes Recv'd/Second - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 80 - 16777215 - - - - true - - - - - - - Qt::Horizontal - - - - 153 - 20 - - - - - - - - - - - - - - - 0 - 0 - - - - Replica Chunk Type - - - - 4 - - - 5 - - - 4 - - - 4 - - - - - - 0 - 250 - - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - true - - - false - - - - - - - - - - - 0 - 0 - - - - Replica - - - - 4 - - - 5 - - - 4 - - - 4 - - - - - - 0 - 250 - - - - true - - - true - - - true - - - false - - - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Replica/replicadataview.ui b/Code/Tools/Standalone/Source/Driller/Replica/replicadataview.ui deleted file mode 100644 index 3bc5729b7f..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Replica/replicadataview.ui +++ /dev/null @@ -1,558 +0,0 @@ - - - ReplicaDataView - - - - 0 - 0 - 766 - 752 - - - - - 0 - 0 - - - - Replica Data View - - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 0 - 0 - - - - Qt::Vertical - - - true - - - 3 - - - false - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 5 - - - - - - 0 - 0 - - - - - 0 - 100 - - - - - - - - - - 0 - 0 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Qt::NoFocus - - - Show total bandwidth usage statistics for the capture - - - false - - - Overall Statistics - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Top Level Type - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 95 - 0 - - - - false - - - - - - - - - - - 0 - 0 - - - - - 0 - 50 - - - - - 16777215 - 50 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 13 - - - 0 - - - 0 - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Usage Graph Type - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 95 - 0 - - - - false - - - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Table Filter - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 95 - 0 - - - - - - - - - - - - 0 - 0 - - - - - 0 - 55 - - - - - 16777215 - 55 - - - - Display Range - - - - 0 - - - 5 - - - 5 - - - 5 - - - 5 - - - - - - 0 - 0 - - - - - 95 - 0 - - - - 0 - - - 99999 - - - - - - - - - - - 0 - 0 - - - - - 175 - 0 - - - - - 16777215 - 55 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Expanding - - - - 0 - 20 - - - - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - - - - - - - - - - AreaChart::AreaChart - QWidget -
Source/Driller/AreaChart.hxx
- 1 -
- - Driller::ReplicaDrillerConfigToolbar - QWidget -
Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx
- 1 -
-
- - - - -
diff --git a/Code/Tools/Standalone/Source/Driller/StripChart.cpp b/Code/Tools/Standalone/Source/Driller/StripChart.cpp deleted file mode 100644 index 56bc15af39..0000000000 --- a/Code/Tools/Standalone/Source/Driller/StripChart.cpp +++ /dev/null @@ -1,991 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include - -#include "StripChart.hxx" -#include -#include "DrillerMainWindowMessages.h" - -#include "ChartNumberFormats.h" -#include - -#include -#include -#include -#include - -namespace StripChart -{ - int DataStrip::s_invalidChannelId = -1; - - ////////////////////////////////////////////////////////////////////////// - DataStrip::DataStrip(QWidget* parent, Qt::WindowFlags flags) - : QWidget(parent, flags) - , m_Axis(nullptr) - , m_DependentAxis(nullptr) - , m_InsetL(56) - , m_InsetR(16) - , m_InsetT(16) - , m_InsetB(24) - , m_IsDragging(false) - , m_InBatchMode(false) - , m_ZoomLimit(15) - , m_MarkerPosition(0) - , m_MarkerColor(Qt::white) - , m_ptrFormatter(nullptr) - , m_MouseWasDragged(false) - , m_bLeftDown(false) - , m_isDataDirty(true) - { - this->setStyleSheet(QString("QToolTip { border: 1px solid white; padding: 1px; background: black; color: white; }")); - setMouseTracking(true); - } - - DataStrip::~DataStrip() - { - delete m_Axis; - delete m_DependentAxis; - } - - void DataStrip::SetAxisTextFormatter(Charts::QAbstractAxisFormatter* target) - { - if (m_ptrFormatter) - { - disconnect(m_ptrFormatter, SIGNAL(destroyed(QObject*)), this, SLOT(OnDestroyAxisFormatter(QObject*))); - } - - m_ptrFormatter = target; - if (m_ptrFormatter) - { - connect(m_ptrFormatter, SIGNAL(destroyed(QObject*)), this, SLOT(OnDestroyAxisFormatter(QObject*))); - } - } - - void DataStrip::OnDestroyAxisFormatter(QObject* pDestroyed) - { - if ((QObject*)pDestroyed == (QObject*)m_ptrFormatter) - { - m_ptrFormatter = nullptr; // signals will disconnect automatically. - } - } - - void DataStrip::Reset() - { - delete m_Axis; - m_Axis = nullptr; - - delete m_DependentAxis; - m_DependentAxis = nullptr; - - m_Channels.clear(); - } - - void DataStrip::SetDataDirty() - { - m_isDataDirty = true; - update(); - } - - void DataStrip::SetZoomLimit(float limit) - { - m_ZoomLimit = limit; - } - - int DataStrip::AddChannel(QString name) - { - int id = (int)m_Channels.size(); - m_Channels.push_back(); - m_Channels[id].SetName(name); - m_Channels[id].SetID(id); - m_Channels[id].m_Data.reserve(65536); - - return id; - } - - void DataStrip::SetChannelColor(int channelID, QColor color) - { - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].SetColor(color); - } - } - void DataStrip::SetChannelStyle(int channelID, Channel::ChannelStyle style) - { - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].SetStyle(style); - } - } - - void DataStrip::SetChannelHighlight(int channelID, bool highlight) - { - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].SetHighlight(highlight); - update(); - } - } - - void DataStrip::SetChannelSampleHighlight(int channelID, AZ::u64 sampleID, bool highlight) - { - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].SetHighlightedSample(highlight, sampleID); - update(); - } - } - - void DataStrip::SetViewFull() - { - m_Axis->SetViewFull(); - m_DependentAxis->SetViewFull(); - update(); - } - - void DataStrip::SetLockRight(bool tf) - { - if (m_Axis) - { - m_Axis->SetLockedRight(tf); - } - update(); - } - void DataStrip::SetMarkerColor(QColor qc) - { - m_MarkerColor = qc; - update(); - } - void DataStrip::SetMarkerPosition(float qposn) - { - m_MarkerPosition = qposn; - update(); - } - - void DataStrip::AddData(int channelID, AZ::u64 sampleID, float h, float v) - { - AZ_Error("Standalone Tools", !m_InBatchMode, "AddData should not called during a BatchData session."); - - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].m_Data.push_back(Channel::Sample(sampleID, h, v)); - - m_Axis->AddAxisRange(h); - if (m_DependentAxis) - { - m_DependentAxis->AddAxisRange(v); - } - update(); - } - } - - void DataStrip::StartBatchDataAdd() - { - m_InBatchMode = true; - } - - void DataStrip::AddBatchedData(int channelId, AZ::u64 sampleId, float h, float v) - { - AZ_Error("StandaloneTools", m_InBatchMode, "AddBatchedData should only be called during a BatchData session."); - - if (IsValidChannelId(channelId)) - { - m_Channels[channelId].m_Data.push_back(Channel::Sample(sampleId, h, v)); - } - } - - void DataStrip::EndBatchDataAdd() - { - if (m_InBatchMode) - { - m_InBatchMode = false; - update(); - } - } - - void DataStrip::ClearData(int channelID) - { - if (IsValidChannelId(channelID)) - { - m_Channels[channelID].m_Data.clear(); - } - } - - void DataStrip::ClearAxisRange() - { - m_Axis->Clear(); - if (m_DependentAxis) - { - m_DependentAxis->Clear(); - } - } - - bool DataStrip::AddAxis(QString label, float minimum, float maximum, bool lockedZoom, bool lockedRange) - { - Charts::Axis* a = nullptr; - - if (!m_Axis) - { - a = m_Axis = aznew Charts::Axis(); - } - else if (!m_DependentAxis) - { - a = m_DependentAxis = aznew Charts::Axis(); - } - else - { - AZ_Assert(false, "ERROR: Creating 3 axis's for a single graph."); - } - - if (a) - { - a->SetLabel(label); - a->SetLockedZoom(lockedZoom); - a->SetAxisRange(minimum, maximum); - a->SetWindowMin(minimum); - a->SetWindowMax(maximum); - a->SetLockedRange(lockedRange); - update(); - } - - return a != nullptr; - } - - bool DataStrip::GetAxisRange(Charts::AxisType whichAxis, float& minValue, float& maxValue) - { - bool foundAxis = false; - - Charts::Axis* axis = nullptr; - switch (whichAxis) - { - case Charts::AxisType::Horizontal: - axis = m_Axis; - break; - case Charts::AxisType::Vertical: - axis = m_DependentAxis; - break; - default: - AZ_Assert(false, "ERROR: Invalid Axis(%i) given to GetAxisRange", whichAxis); - break; - } - - - - if (axis) - { - foundAxis = true; - minValue = axis->GetRangeMin(); - maxValue = axis->GetRangeMax(); - } - - return foundAxis; - } - - bool DataStrip::GetWindowRange(Charts::AxisType whichAxis, float& minValue, float& maxValue) - { - bool foundAxis = false; - - Charts::Axis* axis = nullptr; - switch (whichAxis) - { - - case Charts::AxisType::Horizontal: - axis = m_Axis; - break; - case Charts::AxisType::Vertical: - axis = m_DependentAxis; - break; - default: - AZ_Assert(false, "ERROR: Invalid Axis(%i) given to GetWindowRange", whichAxis); - break; - } - - if (axis) - { - foundAxis = true; - minValue = axis->GetWindowMin(); - maxValue = axis->GetWindowMax(); - } - - return foundAxis; - } - - void DataStrip::SetWindowRange(Charts::AxisType whichAxis, float minValue, float maxValue) - { - Charts::Axis* axis = nullptr; - switch (whichAxis) - { - case Charts::AxisType::Horizontal: - axis = m_Axis; - break; - case Charts::AxisType::Vertical: - axis = m_DependentAxis; - break; - default: - AZ_Assert(false, "ERROR: Invalid Axis(%i) given to SetWindowRange", whichAxis); - break; - } - - if (axis) - { - axis->SetAxisRange(minValue, maxValue); - } - } - - void DataStrip::AddWindowRange(Charts::AxisType whichAxis, float minValue, float maxValue) - { - Charts::Axis* axis = nullptr; - switch (whichAxis) - { - case Charts::AxisType::Horizontal: - axis = m_Axis; - break; - case Charts::AxisType::Vertical: - axis = m_DependentAxis; - break; - default: - AZ_Assert(false, "ERROR: Invalid Axis(%i) given to SetWindowRange", whichAxis); - break; - } - - if (axis) - { - axis->AddAxisRange(minValue); - axis->AddAxisRange(maxValue); - } - } - - void DataStrip::Drag(Charts::Axis* axis, int deltaX, int deltaY) - { - if (!axis->GetLockedRange() && !axis->GetLockedRight()) - { - if (axis->GetWindowMin() + deltaX > axis->GetRangeMin() && axis->GetWindowMax() + deltaX < axis->GetRangeMax()) - { - axis->SetAutoWindow(false); - axis->UpdateWindowRange((float)deltaX); - } - } - - Drag(m_DependentAxis, deltaY); - } - - void DataStrip::Drag(Charts::Axis* axis, int deltaY) - { - if (!axis->GetLockedRange() && !axis->GetLockedRight()) - { - axis->SetAutoWindow(false); - axis->UpdateWindowRange((float)deltaY); - } - } - - QPoint DataStrip::TransformHoriz(Charts::Axis* axis, float h) - { - QPoint pt(0, 0); - - if (axis) - { - //if ((v >= axis->m_WindowMin) && (v <= axis->m_WindowMax)) - { - float fullRange = fabs(axis->GetWindowRange()); - - float ratio = float(h - axis->GetWindowMin()) / fullRange; - pt.setX(m_Inset.left() + int((float(m_Inset.width()) * ratio))); - } - } - - return pt; - } - - QPoint DataStrip::TransformVert(Charts::Axis* axis, float v) - { - QPoint pt(0, 0); - - if (axis) - { - //if ((v >= axis->m_WindowMin) && (v <= axis->m_WindowMax)) - { - float fullRange = fabs(axis->GetWindowRange()); - - float ratio = float(v - axis->GetWindowMin()) / fullRange; - pt.setY(m_Inset.bottom() - int((float(m_Inset.height()) * ratio))); - } - } - - return pt; - } - - TransformResult DataStrip::Transform(Charts::Axis* axis, float h, float v, QPoint& outPt) - { - TransformResult tr = INVALID_RANGE; - QPoint pt(0, 0); - - if (axis) - { - if (h < axis->GetWindowMin()) - { - tr = OUTSIDE_LEFT; - pt.setX(m_Inset.left()); - } - else if (h > axis->GetWindowMax()) - { - tr = OUTSIDE_RIGHT; - pt.setX(m_Inset.right()); - } - else - { - tr = INSIDE_RANGE; - - if (axis->GetWindowMax() != axis->GetWindowMin()) - { - float fullRange = fabs(axis->GetWindowMax() - axis->GetWindowMin()); - float ratio = float(h - axis->GetWindowMin()) / fullRange; - pt.setX(m_Inset.left() + int((float(m_Inset.width()) * ratio))); - pt += TransformVert(m_DependentAxis, v); - } - else - { - pt.setX(m_Inset.left() + m_Inset.width() / 2); - } - } - } - - outPt = pt; - return tr; - } - - void DataStrip::wheelEvent(QWheelEvent* event) - { - int numDegrees = event->angleDelta().y() / 8; - int numSteps = numDegrees / 15; - // +step := zoom IN - // -step := zoom OUT - QPoint zoomPt = event->position().toPoint() - m_Inset.topLeft(); - - float zoomRatioX = (float)zoomPt.x() / (float)m_Inset.width(); - float zoomRatioY = (1.0f - ((float)zoomPt.y() / (float)m_Inset.height())); // because up is higher - - // give it some grace area. This makes it so if your mouse is "close" to the edge, its basically at the edge. - if (zoomRatioX < 0.1f) - { - zoomRatioX = 0.0f; - } - - if (zoomRatioX > 0.9f) - { - zoomRatioX = 1.0f; - } - - if (zoomRatioY < 0.1f) - { - zoomRatioY = 0.0f; - } - - if (zoomRatioY > 0.9f) - { - zoomRatioY = 1.0f; - } - - // the zoom limit is the smallest possible range you'd like to represent. - - m_Axis->Zoom(zoomRatioX, (float)numSteps, m_ZoomLimit); - m_DependentAxis->Zoom(zoomRatioY, (float)numSteps, 1.0f); - - update(); - - event->accept(); - } - void DataStrip::mouseMoveEvent(QMouseEvent* event) - { - if (m_IsDragging) - { - m_MouseWasDragged = true; - - float pixelWidth = (float)m_Inset.width(); - float pixelHeight = (float)m_Inset.height(); - float domainWidth = m_Axis->GetWindowRange(); - float domainHeight = m_DependentAxis->GetWindowRange(); - float domainPerPixelX = domainWidth / pixelWidth; - float domainPerPixelY = domainHeight / pixelHeight; - - QPoint deltaPoint = event->pos() - m_DragTracker; - - float deltaInDomainX = -domainPerPixelX * (float)(deltaPoint.x()); - float deltaInDomainY = domainPerPixelY * (float)(deltaPoint.y()); - - m_Axis->Drag(deltaInDomainX); - m_DependentAxis->Drag(deltaInDomainY); - - m_DragTracker = event->pos(); - update(); - } - else if (m_bLeftDown) - { - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = (float)(event->pos().x() - m_InsetL) / (float)(width() - m_InsetL - m_InsetR); - float localValue = (fullRange * ratio) + m_Axis->GetWindowMin(); - emit onMouseLeftDragDomainValue(localValue); - } - else - { - // mouse move with no buttons -- tooltip event - bool hitsomething = false; - HitArea closestHitArea; - int minimumDistance = 10; - - for (auto iter = m_hitAreas.begin(); iter != m_hitAreas.end(); ++iter) - { - QPoint hitboxCenter = iter->m_hitBoxCenter; - - int distance = (hitboxCenter - event->pos()).manhattanLength(); - if (distance < minimumDistance) - { - closestHitArea = *iter; - hitsomething = true; - minimumDistance = distance; - } - } - - if (hitsomething) - { - emit onMouseOverDataPoint(closestHitArea.m_ptrChannel->m_channelID, closestHitArea.m_sampleID, closestHitArea.m_primaryAxisValue, closestHitArea.m_dependentAxisValue); - } - else - { - // transform the point into the window range: - QPoint localPt = event->pos() - m_Inset.topLeft(); - localPt -= m_Inset.topLeft(); - float ratioX = (float)localPt.x() / (float)m_Inset.width(); - float ratioY = (1.0f - ((float)localPt.y() / (float)m_Inset.height())); - emit onMouseOverNothing((ratioX * m_Axis->GetWindowRange()) + m_Axis->GetWindowMin(), (ratioY * m_DependentAxis->GetWindowRange()) + m_DependentAxis->GetWindowMin()); - } - } - } - void DataStrip::mousePressEvent(QMouseEvent* event) - { - if (event->button() == Qt::RightButton) - { - m_MouseWasDragged = false; - m_IsDragging = true; - m_DragTracker = event->pos(); - update(); - } - else if (event->button() == Qt::LeftButton) - { - m_bLeftDown = true; - - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = (float)(event->pos().x() - m_InsetL) / (float)(width() - m_InsetL - m_InsetR); - float localValue = (fullRange * ratio) + m_Axis->GetWindowMin(); - emit onMouseLeftDownDomainValue(localValue); - } - - event->accept(); - } - void DataStrip::mouseReleaseEvent(QMouseEvent* event) - { - if (event->button() == Qt::RightButton) - { - m_IsDragging = false; - } - else if (event->button() == Qt::LeftButton) - { - if (m_bLeftDown) - { - m_bLeftDown = false; - float fullRange = fabs(m_Axis->GetWindowMax() - m_Axis->GetWindowMin()); - float ratio = (float)(event->pos().x() - m_InsetL) / (float)(width() - m_InsetL - m_InsetR); - float localValue = (fullRange * ratio) + m_Axis->GetWindowMin(); - emit onMouseLeftUpDomainValue(localValue); - } - } - - update(); - event->accept(); - } - void DataStrip::resizeEvent(QResizeEvent* event) - { - RecalculateInset(); - event->ignore(); - } - - void DataStrip::RecalculateInset() - { - m_Inset = QRect(m_InsetL, m_InsetT, rect().width() - m_InsetL - m_InsetR, rect().height() - m_InsetT - m_InsetB); - } - - void DataStrip::AttachDataSourceWidget(QWidget* widget) - { - connect(this, SIGNAL(ProcureData(StripChart::DataStrip*)), widget, SLOT(ProvideData(StripChart::DataStrip*))); - } - - void DataStrip::paintEvent(QPaintEvent* event) - { - (void)event; - - // - // pull data from owner - // e.g. in the profiler case the ChartTimeHistory() with cached parameters should end up getting called - // ChartTimeHistory( m_cachedChart, m_cachedFrame, m_cachedFar, m_cachedColumn ); - // - if (m_isDataDirty) - { - emit ProcureData(this); - m_isDataDirty = false; - } - - QPen pen; - pen.setWidth(1); - QBrush brush; - brush.setStyle(Qt::SolidPattern); - pen.setBrush(brush); - - QPainter p(this); - p.setPen(pen); - - QFont currentFont = p.font(); - - p.fillRect(rect(), QColor(32, 32, 32, 255)); - p.fillRect(m_Inset, Qt::black); - - brush.setColor(QColor(255, 255, 0, 255)); - pen.setColor(QColor(0, 255, 255, 255)); - p.setPen(pen); - - m_hitAreas.clear(); - // HORIZ - if (m_Axis) - { - m_Axis->PaintAxis(Charts::AxisType::Horizontal, &p, rect(), m_Inset, m_ptrFormatter); - - // VERT - if (m_DependentAxis) - { - m_DependentAxis->PaintAxis(Charts::AxisType::Vertical, &p, rect(), m_Inset, m_ptrFormatter); - } - - // +-1 allows data at the outer envelope to render - p.setClipRect(m_InsetL, m_InsetT - 1, rect().width() - m_InsetR - m_InsetL, rect().height() - m_InsetB - m_InsetT + 1); - - for (Channels::iterator chiter = m_Channels.begin(); chiter != m_Channels.end(); ++chiter) - { - Channel& cptr = *chiter; - - pen.setStyle(Qt::SolidLine); - brush.setColor(chiter->m_Color); - pen.setColor(chiter->m_Color); - if (chiter->m_highlighted) - { - pen.setWidth(3); - } - else - { - pen.setWidth(1); - } - p.setPen(pen); - - switch (chiter->m_Style) - { - case Channel::STYLE_POINT: - { - auto datiter = cptr.m_Data.begin(); - while (datiter != cptr.m_Data.end()) - { - QPoint pt; - if (Transform(m_Axis, datiter->m_domainValue, datiter->m_dependentValue, pt) == INSIDE_RANGE) - { - if ((chiter->m_highlightSample) && (chiter->m_highlightedSampleID == datiter->m_sampleID)) - { - // if the channel itself wasn't highlighte we need to set the pen - if (!chiter->m_highlighted) - { - pen.setWidth(3); - p.setPen(pen); - } - - p.drawEllipse(pt, 5, 5); - - if (!chiter->m_highlighted) - { - // if the channel itself wasn't highlighted we need to restore the pen - p.setPen(pen); - pen.setWidth(1); - } - } - else - { - p.drawEllipse(pt, 3, 3); - } - - m_hitAreas.push_back(HitArea(datiter->m_domainValue, datiter->m_dependentValue, pt, &cptr, datiter->m_sampleID)); - } - ++datiter; - } - } - break; - case Channel::STYLE_PLUSMINUS: - { - auto datiter = cptr.m_Data.begin(); - while (datiter != cptr.m_Data.end()) - { - QPoint pt; - if (Transform(m_Axis, datiter->m_domainValue, datiter->m_dependentValue, pt) == INSIDE_RANGE) - { - m_hitAreas.push_back(HitArea(datiter->m_domainValue, datiter->m_dependentValue, pt, &cptr, datiter->m_sampleID)); - - int plussize = 3; - - if ((chiter->m_highlightSample) && (chiter->m_highlightedSampleID == datiter->m_sampleID)) - { - if (!chiter->m_highlighted) - { - // if the channel itself wasn't highlighte we need to set the pen - pen.setWidth(3); - p.setPen(pen); - } - plussize = 5; - } - - p.drawLine(pt.x() - plussize, pt.y(), pt.x() + plussize, pt.y()); - if (datiter->m_dependentValue > 0.0f) - { - p.drawLine(pt.x(), pt.y() - plussize, pt.x(), pt.y() + plussize); - } - - if ((chiter->m_highlightSample) && (chiter->m_highlightedSampleID == datiter->m_sampleID)) - { - if (!chiter->m_highlighted) - { - // restore pen - pen.setWidth(1); - p.setPen(pen); - } - } - } - ++datiter; - } - } - break; - case Channel::STYLE_CONNECTED_LINE: - { - auto datiter = cptr.m_Data.begin(); - auto onebehind = cptr.m_Data.begin(); - if (datiter != cptr.m_Data.end()) - { - ++datiter; - } - while (datiter != cptr.m_Data.end()) - { - QPoint pt1; - TransformResult tr1 = Transform(m_Axis, onebehind->m_domainValue, onebehind->m_dependentValue, pt1); - QPoint pt2; - TransformResult tr2 = Transform(m_Axis, datiter->m_domainValue, datiter->m_dependentValue, pt2); - - if (tr1 == INSIDE_RANGE && tr2 == INSIDE_RANGE) - { - m_hitAreas.push_back(HitArea(datiter->m_domainValue, datiter->m_dependentValue, pt2, &cptr, datiter->m_sampleID)); - - - if ((chiter->m_highlightSample) && (chiter->m_highlightedSampleID == datiter->m_sampleID)) - { - if (!chiter->m_highlighted) - { - // if the channel itself wasn't highlighted we need to set the pen - pen.setWidth(3); - p.setPen(pen); - } - - p.drawLine(pt1, pt2); - p.drawEllipse(pt2, 3, 3); - if (!chiter->m_highlighted) - { - // restore the pen - pen.setWidth(1); - p.setPen(pen); - } - } - else - { - // not highlighted.. - p.drawLine(pt1, pt2); // just draw a line - } - } - ++onebehind; - ++datiter; - } - } - break; - } - } - - pen.setStyle(Qt::SolidLine); - brush.setStyle(Qt::Dense2Pattern); - brush.setColor(m_MarkerColor); - pen.setColor(m_MarkerColor); - p.setPen(pen); - QPoint markerPt; - if (Transform(m_Axis, m_MarkerPosition, 0.0f, markerPt) == INSIDE_RANGE) - { - p.drawLine(markerPt.x(), 0, markerPt.x(), m_Inset.y() + m_Inset.height()); - } - } - } - - void DataStrip::RenderHorizCallouts(QPainter* painter) - { - float textSpaceRequired = (float)painter->fontMetrics().horizontalAdvance("9,999,999.99"); - int fontH = painter->fontMetrics().height(); - - AZStd::vector divisions; - divisions.reserve(10); - float divisionSize = m_Axis->ComputeAxisDivisions((float)m_Inset.width(), divisions, textSpaceRequired, textSpaceRequired); - - QPen dottedPen; - dottedPen.setStyle(Qt::DotLine); - dottedPen.setColor(QColor(64, 64, 64, 255)); - dottedPen.setWidth(1); - QBrush solidBrush; - QPen solidPen; - solidPen.setStyle(Qt::SolidLine); - solidPen.setColor(QColor(0, 255, 255, 255)); - solidPen.setWidth(1); - - for (auto it = divisions.begin(); it != divisions.end(); ++it) - { - float currentUnit = *it; - QPoint leftEdge = TransformHoriz(m_Axis, currentUnit); - - QPoint leftline((int)leftEdge.x(), m_Inset.bottom()); - QPoint leftend = leftline - QPoint(0, m_Inset.height()); - painter->setPen(dottedPen); - painter->drawLine(leftline, leftend); - - QString text; - if (m_ptrFormatter) - { - text = m_ptrFormatter->convertAxisValueToText(Charts::AxisType::Horizontal, currentUnit, divisions.front(), divisions.back(), divisionSize); - } - else - { - text = QString("%1").arg((AZ::s64)currentUnit); - } - - int textW = painter->fontMetrics().horizontalAdvance(text); - - painter->setPen(solidPen); - painter->drawText((int)leftEdge.x() - textW / 2, m_Inset.bottom() + fontH, text); - } - } - - void DataStrip::RenderVertCallouts(QPainter* painter) - { - if (!m_DependentAxis) - { - return; - } - - int fontH = painter->fontMetrics().height(); - - - QPen dottedPen; - dottedPen.setStyle(Qt::DotLine); - dottedPen.setColor(QColor(64, 64, 64, 255)); - dottedPen.setWidth(1); - QBrush solidBrush; - QPen solidPen; - solidPen.setStyle(Qt::SolidLine); - solidPen.setColor(QColor(0, 255, 255, 255)); - solidPen.setWidth(1); - AZStd::vector divisions; - divisions.reserve(10); - float divisionSize = m_DependentAxis->ComputeAxisDivisions((float)m_Inset.height(), divisions, fontH * 2.0f, fontH * 2.0f); - - for (auto it = divisions.begin(); it != divisions.end(); ++it) - { - float currentUnit = *it; - - // where is that in the inset? - QPoint leftEdge = TransformVert(m_DependentAxis, currentUnit); - - painter->setPen(dottedPen); - QPoint leftline(m_Inset.left(), leftEdge.y()); - QPoint leftend = leftline + QPoint(m_Inset.width(), 0); - painter->drawLine(leftline, leftend); - - QString text; - if (m_ptrFormatter) - { - text = m_ptrFormatter->convertAxisValueToText(Charts::AxisType::Vertical, currentUnit, divisions.front(), divisions.back(), divisionSize); - } - else - { - text = QString("%1").arg((AZ::s64)currentUnit); - } - - int textW = painter->fontMetrics().horizontalAdvance(text); - painter->setPen(solidPen); - painter->drawText(m_Inset.left() - textW - 2, (int)leftEdge.y() + fontH / 2, text); - } - } - - void DataStrip::DrawRotatedText(QString text, QPainter* painter, float degrees, int x, int y, float scale) - { - painter->save(); - painter->translate(x, y); - painter->scale(scale, scale); - painter->rotate(degrees); - painter->drawText(0, 0, text); - painter->restore(); - } - - void DataStrip::ZoomExtents(Charts::AxisType axis) - { - switch (axis) - { - case Charts::AxisType::Horizontal: - if (m_Axis) - { - m_Axis->SetViewFull(); - } - break; - case Charts::AxisType::Vertical: - if (m_DependentAxis) - { - m_DependentAxis->SetViewFull(); - } - break; - default: - AZ_Assert(false, "ERROR: Unkown axis(%i) in ZoomExtents", axis); - } - } - - void DataStrip::ZoomManual(Charts::AxisType axis, float minValue, float maxValue) - { - switch (axis) - { - case Charts::AxisType::Horizontal: - if (m_Axis) - { - m_Axis->ZoomToRange(minValue, maxValue, false); - } - break; - case Charts::AxisType::Vertical: - if (m_DependentAxis) - { - m_DependentAxis->ZoomToRange(minValue, maxValue, false); - } - break; - default: - AZ_Assert(false, "ERROR: Unkown axis(%i) in ZoomExtents", axis); - } - } - - bool DataStrip::IsValidChannelId(int channelId) const - { - return channelId >= 0 && channelId < m_Channels.size(); - } -} diff --git a/Code/Tools/Standalone/Source/Driller/StripChart.hxx b/Code/Tools/Standalone/Source/Driller/StripChart.hxx deleted file mode 100644 index d6f9bc24c1..0000000000 --- a/Code/Tools/Standalone/Source/Driller/StripChart.hxx +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef AZ_STRIPCHART_H -#define AZ_STRIPCHART_H - -#if !defined(Q_MOC_RUN) -#include -#include -#include -#include - -#include -#endif - -namespace Charts -{ - class Axis; -} - -namespace StripChart -{ - enum TransformResult - { - OUTSIDE_LEFT = -1, - INSIDE_RANGE = 0, - OUTSIDE_RIGHT = 1, - INVALID_RANGE = 2 - }; - - struct Channel - { - AZ_CLASS_ALLOCATOR(Channel,AZ::SystemAllocator,0); - Channel() : m_Color(QColor(255,255,0,255)), m_Style(STYLE_POINT), m_channelID(0), m_highlighted(false), m_highlightSample(false), m_highlightedSampleID(0) {} - - enum ChannelStyle - { - STYLE_POINT = 0, - STYLE_CONNECTED_LINE, - STYLE_VERTICAL_LINE, - STYLE_BAR, - STYLE_PLUSMINUS - }; - - void SetName(QString name) { m_Name = name; } - void SetColor(QColor &color) { m_Color = color; } - void SetStyle(ChannelStyle style) { m_Style = style; } - void SetHighlight(bool highlight) { m_highlighted = highlight; } - void SetHighlightedSample(bool highlight, AZ::u64 sampleID) { m_highlightedSampleID = sampleID; m_highlightSample = highlight; } - void SetID(int id) { m_channelID = id; } - - struct Sample - { - float m_domainValue; - float m_dependentValue; - AZ::u64 m_sampleID; - - Sample() : m_domainValue(0.0f), m_dependentValue(0.0f), m_sampleID(0) {} - Sample(AZ::u64 sampleID, float domain, float dependent) : - m_sampleID(sampleID), - m_domainValue(domain), - m_dependentValue(dependent) {} - }; - - int m_channelID; - QString m_Name; - AZStd::vector< Sample > m_Data; - QColor m_Color; - ChannelStyle m_Style; - bool m_highlighted; - AZ::u64 m_highlightedSampleID; - bool m_highlightSample; - }; - - class DataStrip - : public QWidget - { - Q_OBJECT; - public: - static int s_invalidChannelId; - - AZ_CLASS_ALLOCATOR(DataStrip,AZ::SystemAllocator,0); - DataStrip(QWidget* parent = NULL, Qt::WindowFlags flags = Qt::WindowFlags()); - virtual ~DataStrip(void); - - void Reset(); - - void SetChannelHighlight(int channelID, bool highlight); - void SetChannelSampleHighlight( int channelID, AZ::u64 sampleID, bool highlight); - - bool AddAxis(QString label, float minimum, float maximum, bool lockedZoom = true, bool lockedRange = false); - - void ZoomExtents(Charts::AxisType axis); - void ZoomManual(Charts::AxisType axis, float minValue, float maxValue); - - int AddChannel(QString name); - - // Use AddData when just adding a random point to the graph. This will keep all of - // the axis's in order. - void AddData(int channelID, AZ::u64 sampleID, float h, float v = 0.0f); - - // Use AddDataBatch when adding lots of data all at once, this will ignore some calls. - void StartBatchDataAdd(); - void AddBatchedData(int channelID, AZ::u64 sampleID, float h, float v = 0.0f); - void EndBatchDataAdd(); - - void ClearData(int channelID); - void ClearAxisRange(); - void SetChannelColor(int channelID, QColor color); - - void SetChannelStyle(int channelID, Channel::ChannelStyle style); - void SetViewFull(); - void SetLockRight(bool tf); - void SetZoomLimit(float limit); - - void SetMarkerColor(QColor qc); - void SetMarkerPosition(float qposn); - - bool GetAxisRange(Charts::AxisType whichAxis, float& minValue, float& maxValue); - bool GetWindowRange(Charts::AxisType whichAxis, float &minValue, float &maxValue); - // override for knowledgeable outsiders who want a different range than from the data provided via AddData(...) - void SetWindowRange(Charts::AxisType whichAxis, float minValue, float maxValue); - void AddWindowRange(Charts::AxisType whichAxis, float minValue, float maxValue); - - // you may set it to null to clear it. - // the chart will automatically uninstall the text formatter if it is destroyed - // it DOES NOT TAKE OWNERSHIP of the formatter. - void SetAxisTextFormatter(Charts::QAbstractAxisFormatter* target); - void AttachDataSourceWidget(QWidget *widget); - - void SetDataDirty(); - bool IsValidChannelId(int channelId) const; - -signals: - void onMouseOverDataPoint(int channelID, AZ::u64 sampleID, float primaryAxisValue, float dependentAxisValue); - void onMouseOverNothing(float primaryAxisValue, float dependentAxisValue); - void onMouseLeftDownDomainValue(float domainValue); - void onMouseLeftDragDomainValue(float domainValue); - void onMouseLeftUpDomainValue(float domainValue); - void ProcureData(StripChart::DataStrip*); - - protected: - virtual void wheelEvent(QWheelEvent * event); - virtual void mouseMoveEvent(QMouseEvent * event); - virtual void mousePressEvent(QMouseEvent * event); - virtual void mouseReleaseEvent(QMouseEvent * event); - virtual void resizeEvent(QResizeEvent * event); - - protected slots: - void OnDestroyAxisFormatter(QObject *pDestroyed); - - protected: - - int m_InsetL; - int m_InsetR; - int m_InsetT; - int m_InsetB; - QRect m_Inset; - float m_ZoomLimit; - bool m_bLeftDown; - bool m_isDataDirty; - - typedef AZStd::vector Channels; - Channels m_Channels; - QPoint m_DragTracker; - bool m_MouseWasDragged; - - Charts::QAbstractAxisFormatter* m_ptrFormatter; - - bool m_IsDragging; - bool m_InBatchMode; - - // axes dealt with internally as follows: - Charts::Axis* m_Axis; - Charts::Axis* m_DependentAxis; // vertical axis - // first submission = horizontal, for binary state data points - // second submission = vertical, for state with value data points - // third submission = depth, for data grids with value - - QColor m_MarkerColor; - float m_MarkerPosition; - - // internal ops - virtual void paintEvent(QPaintEvent *event); - void DrawRotatedText(QString text, QPainter *painter, float degrees, int x, int y, float scale = 1.0f); - void RenderVertCallouts(QPainter *painter); - void RenderHorizCallouts(QPainter *painter); - void RecalculateInset(); - void Drag(Charts::Axis *axis, int deltaY); - void Drag(Charts::Axis *axis, int deltaX, int deltaY); - QPoint TransformVert(Charts::Axis *axis, float v); - QPoint TransformHoriz(Charts::Axis *axis, float h); - TransformResult Transform(Charts::Axis *axis, float h, float v, QPoint &outQPoint); - - class HitArea - { - public: - AZ_CLASS_ALLOCATOR(HitArea, AZ::SystemAllocator, 0); - Channel *m_ptrChannel; - AZ::u64 m_sampleID; - float m_primaryAxisValue; - float m_dependentAxisValue; - QPoint m_hitBoxCenter; - HitArea() : m_ptrChannel(NULL), m_primaryAxisValue(0.0f), m_dependentAxisValue(0.0f) {} - HitArea(float x, float y, QPoint hitBoxCenter, Channel* pChannel, AZ::u64 sampleID) : - m_hitBoxCenter(hitBoxCenter), m_primaryAxisValue(x), m_dependentAxisValue(y), m_ptrChannel(pChannel), m_sampleID(sampleID) {} - }; - - typedef AZStd::vector HitAreaContainer; - HitAreaContainer m_hitAreas; - }; - -} - -#endif //AZ_STRIPCHART_H diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.cpp b/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.cpp deleted file mode 100644 index 63e9de9b1e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.cpp +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "TraceDrillerDialog.hxx" -#include "TraceMessageDataAggregator.hxx" -#include -#include "TraceMessageEvents.h" - -#include -#include -#include -#include -#include - -#include -#include -#include - -namespace Driller -{ - class TraceDrillerDialogSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(TraceDrillerDialogSavedState, "{81955B84-077D-4A87-B562-7A9633736BE4}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(TraceDrillerDialogSavedState, AZ::SystemAllocator, 0); - - AZStd::string m_windowFilter; - AZStd::string m_textFilter; - - TraceDrillerDialogSavedState() {} - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_windowFilter", &TraceDrillerDialogSavedState::m_windowFilter) - ->Field("m_textFilter", &TraceDrillerDialogSavedState::m_textFilter) - ->Version(1); - } - } - }; - - // Qt supports A "filter proxy model" - // you have a normal model - // and then you wrap that model in a filter proxy model. - // this allows you to filter the inner model and feed the outer (filtered) model to the view. - - // this particular filter model lets you specify search criteria in the Window or the Message field - class TraceFilterModel - : public QSortFilterProxyModel - { - public: - AZ_CLASS_ALLOCATOR(TraceFilterModel, AZ::SystemAllocator, 0); - int m_windowColumn; - int m_messageColumn; - - QString m_currentWindowFilter; - QString m_currentMessageFilter; - - TraceFilterModel(int windowColumn, int messageColumn, QObject* pParent) - : QSortFilterProxyModel(pParent) - { - m_windowColumn = windowColumn; - m_messageColumn = messageColumn; - } - - void UpdateWindowFilter(const QString& newFilter) - { - if (newFilter.compare(m_currentWindowFilter) != 0) - { - if (m_windowColumn >= 0) - { - m_currentWindowFilter = newFilter; - invalidateFilter(); - } - } - } - - void UpdateMessageFilter(const QString& newFilter) - { - if (newFilter.compare(m_currentMessageFilter) != 0) - { - if (m_messageColumn >= 0) - { - m_currentMessageFilter = newFilter; - invalidateFilter(); - } - } - } - - - protected: - virtual bool filterAcceptsRow(int source_row, const QModelIndex& /*source parent*/) const - { - QAbstractItemModel* ptrModel = sourceModel(); - - if (!ptrModel) - { - return true; - } - - if (m_currentWindowFilter.size() > 0) - { - QString sourceData = ptrModel->data(ptrModel->index(source_row, m_windowColumn), Qt::DisplayRole).toString(); - if (!sourceData.contains(m_currentWindowFilter, Qt::CaseInsensitive)) - { - return false; - } - } - - if (m_currentMessageFilter.size() > 0) - { - QString sourceData = ptrModel->data(ptrModel->index(source_row, m_messageColumn), Qt::DisplayRole).toString(); - if (!sourceData.contains(m_currentMessageFilter, Qt::CaseInsensitive)) - { - return false; - } - } - - return true; - } - }; - - TraceDrillerDialog::TraceDrillerDialog(TraceMessageDataAggregator* data, int profilerIndex, QWidget* pParent) - : QDialog(pParent) - , m_viewIndex(profilerIndex) - , m_lifespanTelemetry("TraceDataView") - { - setAttribute(Qt::WA_DeleteOnClose, true); - - m_uiLoaded = azcreate(Ui::TraceDrillerDialog, ()); - m_uiLoaded->setupUi(this); - setWindowFlags((this->windowFlags() | Qt::WindowMaximizeButtonHint | Qt::WindowMinimizeButtonHint) & ~(Qt::WindowContextHelpButtonHint)); - - setWindowTitle(data->GetDialogTitle()); - - TraceDrillerLogTab* tabView = aznew TraceDrillerLogTab(this); - - this->layout()->addWidget(tabView); - - m_ptrOriginalModel = aznew TraceDrillerLogModel(data, this); - m_ptrFilter = aznew TraceFilterModel(tabView->GetWindowColumn(), tabView->GetMessageColumn(), this); - m_ptrFilter->setSourceModel(m_ptrOriginalModel); - tabView->ConnectModelToView(m_ptrFilter); - - connect(data, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataDestroyed())); - - connect(m_ptrFilter, SIGNAL(rowsAboutToBeInserted(const QModelIndex &, int, int)), tabView, SLOT(rowsAboutToBeInserted())); - connect(m_ptrFilter, SIGNAL(rowsInserted(const QModelIndex &, int, int)), tabView, SLOT(rowsInserted())); - connect(m_uiLoaded->windowFilterText, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChangeWindowFilter(const QString&))); - connect(m_uiLoaded->messageFilterText, SIGNAL(textChanged(const QString &)), this, SLOT(onTextChangeMessageFilter(const QString&))); - - connect(m_ptrFilter, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrFilter, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrFilter, SIGNAL(modelReset()), this, SLOT(UpdateSummary())); - connect(m_ptrOriginalModel, SIGNAL(rowsInserted(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrOriginalModel, SIGNAL(rowsRemoved(const QModelIndex &, int, int)), this, SLOT(UpdateSummary())); - connect(m_ptrOriginalModel, SIGNAL(modelReset()), this, SLOT(UpdateSummary())); - - AZStd::string windowStateStr = AZStd::string::format("TRACE DRILLER DATA VIEW WINDOW STATE %i", m_viewIndex); - m_windowStateCRC = AZ::Crc32(windowStateStr.c_str()); - AZStd::intrusive_ptr windowState = AZ::UserSettings::Find(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - if (windowState) - { - windowState->RestoreGeometry(this); - } - - AZStd::string filterStateStr = AZStd::string::format("TRACE DRILLER DIALOG SAVED STATE %i", m_viewIndex); - m_filterStateCRC = AZ::Crc32(filterStateStr.c_str()); - m_persistentState = AZ::UserSettings::Find(m_filterStateCRC, AZ::UserSettings::CT_GLOBAL); - ApplyPersistentState(); - UpdateSummary(); - } - - TraceDrillerDialog::~TraceDrillerDialog() - { - SaveOnExit(); - azdestroy(m_uiLoaded); - } - - void TraceDrillerDialog::ApplyPersistentState() - { - if (m_persistentState) - { - // the bridge between our AZStd::string storage and QT's own string type - QString windowFilter(m_persistentState->m_windowFilter.c_str()); - QString textFilter(m_persistentState->m_textFilter.c_str()); - - m_uiLoaded->windowFilterText->setText(windowFilter); - m_uiLoaded->messageFilterText->setText(textFilter); - } - } - - void TraceDrillerDialog::SaveOnExit() - { - AZStd::intrusive_ptr pState = AZ::UserSettings::CreateFind(m_windowStateCRC, AZ::UserSettings::CT_GLOBAL); - pState->CaptureGeometry(this); - - AZStd::intrusive_ptr newState = AZ::UserSettings::CreateFind(m_filterStateCRC, AZ::UserSettings::CT_GLOBAL); - if (newState) - { - newState->m_windowFilter = m_ptrFilter->m_currentWindowFilter.toUtf8().data(); - newState->m_textFilter = m_ptrFilter->m_currentMessageFilter.toUtf8().data(); - } - } - void TraceDrillerDialog::hideEvent(QHideEvent* evt) - { - QDialog::hideEvent(evt); - } - void TraceDrillerDialog::closeEvent(QCloseEvent* evt) - { - QDialog::closeEvent(evt); - } - void TraceDrillerDialog::OnDataDestroyed() - { - deleteLater(); - } - - void TraceDrillerDialog::onTextChangeWindowFilter(const QString& newText) - { - m_ptrFilter->UpdateWindowFilter(newText); - UpdateSummary(); - } - - void TraceDrillerDialog::onTextChangeMessageFilter(const QString& newText) - { - m_ptrFilter->UpdateMessageFilter(newText); - UpdateSummary(); - } - - void TraceDrillerDialog::UpdateSummary() - { - int filterRows = m_ptrFilter->rowCount(); - int originalRows = m_ptrOriginalModel->rowCount(); - - if (!m_uiLoaded->windowFilterText->text().isEmpty() || !m_uiLoaded->messageFilterText->text().isEmpty()) - { - m_uiLoaded->summaryLabel->setText(QString("%1 / %2\nEvent(s)").arg(filterRows).arg(originalRows)); - } - else - { - m_uiLoaded->summaryLabel->setText(QString("%1\nEvent(s)").arg(originalRows)); - } - } - - void TraceDrillerDialog::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("TRACE DRILLER DIALOG WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - TraceDrillerDialogSavedState* workspace = provider->FindSetting(workspaceStateCRC); - if (workspace) - { - m_persistentState->m_windowFilter = workspace->m_windowFilter; - m_persistentState->m_textFilter = workspace->m_textFilter; - } - } - } - void TraceDrillerDialog::ActivateWorkspaceSettings(WorkspaceSettingsProvider*) - { - ApplyPersistentState(); - } - void TraceDrillerDialog::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - AZStd::string workspaceStateStr = AZStd::string::format("TRACE DRILLER DIALOG WORKSPACE STATE %i", m_viewIndex); - AZ::u32 workspaceStateCRC = AZ::Crc32(workspaceStateStr.c_str()); - - if (m_persistentState) - { - TraceDrillerDialogSavedState* workspace = provider->CreateSetting(workspaceStateCRC); - if (workspace) - { - workspace->m_windowFilter = m_ptrFilter->m_currentWindowFilter.toUtf8().data(); - workspace->m_textFilter = m_ptrFilter->m_currentMessageFilter.toUtf8().data(); - } - } - } - - void TraceDrillerDialog::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - TraceDrillerDialogSavedState::Reflect(context); - } - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // TraceDrillerLogTab - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - TraceDrillerLogTab::TraceDrillerLogTab(QWidget* pParent) - : BaseLogView(pParent) - , m_isScrollAfterInsert(true) - { - setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); - } - - TraceDrillerLogTab::~TraceDrillerLogTab() - { - } - - void TraceDrillerLogTab::rowsAboutToBeInserted() - { - m_isScrollAfterInsert = IsAtMaxScroll(); - } - - void TraceDrillerLogTab::rowsInserted() - { - if (m_isScrollAfterInsert) - { - m_ptrLogView->scrollToBottom(); - } - } - - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - // TraceDrillerLogModel - ////////////////////////////////////////////////////////////////////////// - ////////////////////////////////////////////////////////////////////////// - TraceDrillerLogModel::TraceDrillerLogModel(TraceMessageDataAggregator* data, QObject* pParent) - : QAbstractTableModel(pParent) - , m_data(data) - , m_lastShownEvent(-1) - { - connect(data, SIGNAL(OnDataCurrentEventChanged()), this, SLOT(OnDataCurrentEventChanged())); - connect(data, SIGNAL(OnDataAddEvent()), this, SLOT(OnDataAddEvent())); - - // cache Icons! - m_criticalIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); - m_errorIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxCritical); - m_warningIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxWarning); - m_informationIcon = QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation); - - m_lastShownEvent = m_data->GetCurrentEvent(); - } - - TraceDrillerLogModel::~TraceDrillerLogModel() - { - } - - void TraceDrillerLogModel::OnDataCurrentEventChanged() - { - AZ::s64 currentEvent = m_data->GetCurrentEvent(); - // NOTE: we add +1 to all events, because we are EXECUTING the current event (so it must be shown) - if (m_lastShownEvent > currentEvent) - { - // remove rows - beginRemoveRows(QModelIndex(), (int)currentEvent + 1, (int)m_lastShownEvent); - endRemoveRows(); - } - else - { - // add rows - beginInsertRows(QModelIndex(), (int)m_lastShownEvent + 1, (int)currentEvent); - endInsertRows(); - } - m_lastShownEvent = currentEvent; - } - - void TraceDrillerLogModel::OnDataAddEvent() - { - } - - int TraceDrillerLogModel::rowCount(const QModelIndex&) const - { - AZ::s64 currentEvent = m_data->GetCurrentEvent(); - return (int)currentEvent + 1; - } - int TraceDrillerLogModel::columnCount(const QModelIndex&) const - { - return 3; // icon + window + message; - } - Qt::ItemFlags TraceDrillerLogModel::flags(const QModelIndex& index) const - { - if (!index.isValid()) - { - return Qt::ItemIsEnabled; - } - - if (index.column() == 2) // the 3rd column (message) is "editable" - { - return QAbstractItemModel::flags(index) | Qt::ItemIsEditable; - } - - return QAbstractItemModel::flags(index); - } - - QVariant TraceDrillerLogModel::data(const QModelIndex& index, int role) const - { - using namespace AZ::Debug; - - TraceMessageEvent* event = static_cast(m_data->GetEvents().at(index.row())); - if (role == AzToolsFramework::LogPanel::RichTextRole) // the renderer is asking whether this cell is rich text or not. Return a true or false. - { - return /*m_Lines[index.row()].m_bIsRichText*/ false; - } - else if (role == Qt::DecorationRole) // the renderer is asking whether or not we want to display an icon in this cell. Return an icon or null. - { - if (index.column() == 0) - { - switch (event->GetEventType()) - { - case TraceMessageEvent::ET_ASSERT: - return m_criticalIcon; - case TraceMessageEvent::ET_ERROR: - return m_errorIcon; - case TraceMessageEvent::ET_WARNING: - return m_warningIcon; - case TraceMessageEvent::ET_PRINTF: - return m_informationIcon; - case TraceMessageEvent::ET_EXCEPTION: - return QVariant(); - break; - } - } - } - else if (role == Qt::DisplayRole) // the renderer wants to know what text to show in this cell. Return a string or null - { - if (index.column() == 0) // icon has no text - { - return QVariant(QString()); - } - else if (index.column() == 1) // window - { - return QVariant(event->m_window); - } - else if (index.column() == 2) // message - { - return QVariant(QString(event->m_message).trimmed()); - } - } - else if (role == Qt::BackgroundRole) // the renderer wants to know what the background color of this cell should be. REturn a color or null (to use default) - { - switch (event->GetEventType()) - { - case TraceMessageEvent::ET_ASSERT: - return QVariant(QColor::fromRgb(255, 0, 0)); - break; - case TraceMessageEvent::ET_ERROR: - return QVariant(QColor::fromRgb(255, 192, 192)); - break; - case TraceMessageEvent::ET_WARNING: - return QVariant(QColor::fromRgb(255, 255, 192)); - break; - case TraceMessageEvent::ET_PRINTF: - return QVariant(); - break; - case TraceMessageEvent::ET_EXCEPTION: - return QVariant(); - break; - } - } - else if (role == Qt::ForegroundRole) // the renderer wants to know what the text color of this cell should be.REturn a color or null. - { - switch (event->GetEventType()) - { - case TraceMessageEvent::ET_PRINTF: - return QVariant(QColor::fromRgb(0, 0, 0)); - break; - case TraceMessageEvent::ET_ERROR: - return QVariant(QColor::fromRgb(64, 0, 0)); - break; - case TraceMessageEvent::ET_WARNING: - return QVariant(QColor::fromRgb(64, 64, 0)); - break; - case TraceMessageEvent::ET_EXCEPTION: - return QVariant(); - break; - } - } - return QVariant(); - } -} - -#include diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.hxx b/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.hxx deleted file mode 100644 index 36105065a9..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.hxx +++ /dev/null @@ -1,151 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef TRACEDRILLERDIALOG_H -#define TRACEDRILLERDIALOG_H - -#pragma once - -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include - -#include "Source/Driller/DrillerMainWindowMessages.h" -#include "Source/Driller/DrillerOperationTelemetryEvent.h" -#endif - -namespace Ui { - class TraceDrillerDialog; -} // namespace Ui - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class TraceFilterModel; - class TraceMessageDataAggregator; - class TraceDrillerLogModel; - class TraceDrillerDialogSavedState; - - class TraceDrillerDialog - : public QDialog - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(TraceDrillerDialog, AZ::SystemAllocator, 0); - - TraceDrillerDialog(TraceMessageDataAggregator* data, int profilerIndex, QWidget *pParent = NULL); - virtual ~TraceDrillerDialog(); - - // NB: These three methods mimic the workspace bus. - // Because the ProfilerDataAggregator can't know to open these DataView windows - // until after the EBUS message has gone out, the owning aggregator must - // first create these windows and then pass along the provider manually - void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - - void SaveOnExit(); - virtual void closeEvent(QCloseEvent *evt); - virtual void hideEvent(QHideEvent *evt); - - void ApplyPersistentState(); - - AZ::u32 m_windowStateCRC; - AZ::u32 m_filterStateCRC; - int m_viewIndex; - - // persistent state is used as if they were internal variables, - // though they reside in a storage class - // this lasts for the entire lifetime of this object - AZStd::intrusive_ptr m_persistentState; - - public slots: - void OnDataDestroyed(); - void onTextChangeWindowFilter(const QString &); - void onTextChangeMessageFilter(const QString &); - - void UpdateSummary(); - - protected: - DrillerWindowLifepsanTelemetry m_lifespanTelemetry; - - Ui::TraceDrillerDialog* m_uiLoaded; - TraceFilterModel* m_ptrFilter; - TraceDrillerLogModel* m_ptrOriginalModel; - - public: - static void Reflect(AZ::ReflectContext* context); - }; - - class TraceDrillerLogTab : public AzToolsFramework::LogPanel::BaseLogView - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(TraceDrillerLogTab, AZ::SystemAllocator, 0); - - TraceDrillerLogTab(QWidget *pParent = NULL); - virtual ~TraceDrillerLogTab(); - - // return -1 for any of these to indicate that your data has no such column. - // make sure your model has the same semantics! - virtual int GetIconColumn() { return 0; } - virtual int GetWindowColumn() { return 1; } - virtual int GetMessageColumn() { return 2; } // you may not return -1 for this one. - virtual int GetTimeColumn() { return -1; } - - using AzToolsFramework::LogPanel::BaseLogView::rowsInserted; - - public slots: - void rowsAboutToBeInserted(); - void rowsInserted (); - - protected: - - bool m_isScrollAfterInsert; - }; - - class TraceDrillerLogModel : public QAbstractTableModel - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(TraceDrillerLogModel, AZ::SystemAllocator, 0); - - //////////////////////////////////////////////////////////////////////////////////////////////// - // QAbstractTableModel - virtual int rowCount(const QModelIndex& index = QModelIndex()) const; - virtual int columnCount(const QModelIndex& index = QModelIndex()) const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex& index, int role) const; - //////////////////////////////////////////////////////////////////////////////////////////////// - - TraceDrillerLogModel(TraceMessageDataAggregator* data, QObject *pParent = NULL); - virtual ~TraceDrillerLogModel(); - - public slots: - void OnDataCurrentEventChanged(); - void OnDataAddEvent(); - - protected: - TraceMessageDataAggregator* m_data; - AZ::s64 m_lastShownEvent; - QIcon m_criticalIcon; - QIcon m_errorIcon; - QIcon m_warningIcon; - QIcon m_informationIcon; - - - }; - - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.ui b/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.ui deleted file mode 100644 index 229539a92e..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceDrillerDialog.ui +++ /dev/null @@ -1,124 +0,0 @@ - - - TraceDrillerDialog - - - - 0 - 0 - 544 - 250 - - - - - 0 - 250 - - - - Trace Message Driller - - - true - - - - - - - - Window Filter - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - Window Name - - - - - - - Qt::Horizontal - - - QSizePolicy::MinimumExpanding - - - - 20 - 20 - - - - - - - - Message Filter - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - Message - - - - - - - - 0 - 0 - - - - - 95 - 0 - - - - - - - Qt::AlignCenter - - - - - - - - - - diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.cpp deleted file mode 100644 index 64c389daa1..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "TraceMessageDataAggregator.hxx" -#include - -#include "TraceDrillerDialog.hxx" -#include "TraceMessageEvents.h" -#include -#include -#include -#include - -namespace Driller -{ - class TraceMessageDataAggregatorSavedState - : public AZ::UserSettings - { - public: - AZ_RTTI(TraceMessageDataAggregatorSavedState, "{48FADE93-10C0-48BE-96FA-44EFE49D8ED3}", AZ::UserSettings); - AZ_CLASS_ALLOCATOR(TraceMessageDataAggregatorSavedState, AZ::SystemAllocator, 0); - TraceMessageDataAggregatorSavedState() - : m_activeViewCount(0) - {} - - int m_activeViewCount; - - static void Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Field("m_activeViewCount", &TraceMessageDataAggregatorSavedState::m_activeViewCount) - ->Version(2); - } - } - }; - - - TraceMessageDataAggregator::TraceMessageDataAggregator(int identity) - : Aggregator(identity) - , m_dataView(nullptr) - { - m_parser.SetAggregator(this); - - m_persistentState = AZ::UserSettings::CreateFind(AZ_CRC("TRACE MESSAGE DATA AGGREGATOR SAVED STATE", 0xa4996e1f), AZ::UserSettings::CT_GLOBAL); - AZ_Assert(m_persistentState, "Persistent State is NULL?"); - } - - float TraceMessageDataAggregator::ValueAtFrame(FrameNumberType frame) - { - return NumOfEventsAtFrame(frame) > 0 ? 1.0f : -1.0f; - } - - QColor TraceMessageDataAggregator::GetColor() const - { - return QColor(0, 255, 0); - } - - QString TraceMessageDataAggregator::GetName() const - { - return "Trace messages"; - } - - QString TraceMessageDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString TraceMessageDataAggregator::GetDescription() const - { - return "All trace messages"; - } - - QString TraceMessageDataAggregator::GetToolTip() const - { - return "Logged Messages from Application"; - } - - AZ::Uuid TraceMessageDataAggregator::GetID() const - { - return AZ::Uuid("{368D6FB2-9A92-4DFE-8DB4-4F106194BA6F}"); - } - - QWidget* TraceMessageDataAggregator::DrillDownRequest(FrameNumberType frame) - { - (void)frame; - - if (m_dataView) - { - m_dataView->deleteLater(); - OnDataViewDestroyed(m_dataView); - m_dataView = nullptr; - } - - TraceDrillerDialog* dv = aznew TraceDrillerDialog(this, (1024 * GetIdentity()) + 0); - dv->show(); - m_dataView = dv; - - connect(dv, SIGNAL(destroyed(QObject*)), this, SLOT(OnDataViewDestroyed(QObject*))); - ++m_persistentState->m_activeViewCount; - - return dv; - } - void TraceMessageDataAggregator::OptionsRequest() - { - } - void TraceMessageDataAggregator::OnDataViewDestroyed(QObject* dataView) - { - if (dataView == m_dataView) - { - m_dataView = nullptr; - --m_persistentState->m_activeViewCount; - } - } - - void TraceMessageDataAggregator::ApplySettingsFromWorkspace(WorkspaceSettingsProvider* provider) - { - TraceMessageDataAggregatorSavedState* workspace = provider->FindSetting(AZ_CRC("TRACE MESSAGE DATA AGGREGATOR WORKSPACE", 0xff055f40)); - if (workspace) - { - m_persistentState->m_activeViewCount = workspace->m_activeViewCount; - } - } - void TraceMessageDataAggregator::ActivateWorkspaceSettings(WorkspaceSettingsProvider* provider) - { - TraceMessageDataAggregatorSavedState* workspace = provider->FindSetting(AZ_CRC("TRACE MESSAGE DATA AGGREGATOR WORKSPACE", 0xff055f40)); - if (workspace) - { - // kill all existing data view windows in preparation of opening the workspace specified ones - delete m_dataView; - - // the internal count should be 0 from the above house cleaning - // and incremented back up from the workspace instantiations - m_persistentState->m_activeViewCount = 0; - for (int i = 0; i < workspace->m_activeViewCount; ++i) - { - // driller must be created at (frame > 0) for it to have a valid tree to display - TraceDrillerDialog* dataView = qobject_cast(DrillDownRequest(1)); - if (dataView) - { - // apply will overlay the workspace settings on top of the local user settings - dataView->ApplySettingsFromWorkspace(provider); - // activate will do the heavy lifting - dataView->ActivateWorkspaceSettings(provider); - } - } - } - } - - void TraceMessageDataAggregator::SaveSettingsToWorkspace(WorkspaceSettingsProvider* provider) - { - TraceMessageDataAggregatorSavedState* workspace = provider->CreateSetting(AZ_CRC("TRACE MESSAGE DATA AGGREGATOR WORKSPACE", 0xff055f40)); - if (workspace) - { - workspace->m_activeViewCount = m_persistentState->m_activeViewCount; - - if (m_dataView) - { - qobject_cast(m_dataView)->SaveSettingsToWorkspace(provider); - } - } - } - - - // emit all annotations that match the provider's filter, given the start and end frame: - void TraceMessageDataAggregator::EmitAllAnnotationsForFrameRange(int startFrameInclusive, int endFrameInclusive, AnnotationsProvider* ptrProvider) - { - for (; startFrameInclusive <= endFrameInclusive; ++startFrameInclusive) - { - AZ::s64 startEvent = m_frameToEventIndex[startFrameInclusive]; - AZ::s64 endEvent = startEvent + NumOfEventsAtFrame(startFrameInclusive); - - for (AZ::s64 i = startEvent; i < endEvent; ++i) - { - TraceMessageEvent* event = static_cast(m_events[i]); - if (ptrProvider->IsChannelEnabled(event->m_windowCRC)) - { - ptrProvider->AddAnnotation(Driller::Annotation(m_events[i]->GetGlobalEventId(), startFrameInclusive, event->m_message, event->m_window)); - } - } - } - } - - // emit all channels that you are aware of existing within that frame range (You may emit duplicate channels, they will be ignored) - void TraceMessageDataAggregator::EmitAnnotationChannelsForFrameRange(int startFrameInclusive, int endFrameInclusive, AnnotationsProvider* ptrProvider) - { - for (; startFrameInclusive <= endFrameInclusive; ++startFrameInclusive) - { - AZ::s64 startEvent = m_frameToEventIndex[startFrameInclusive]; - AZ::s64 endEvent = startEvent + NumOfEventsAtFrame(startFrameInclusive); - - for (AZ::s64 i = startEvent; i < endEvent; ++i) - { - TraceMessageEvent* event = static_cast(m_events[i]); - ptrProvider->NotifyOfChannelExistence(event->m_window); - } - } - } - - void TraceMessageDataAggregator::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - TraceMessageDataAggregatorSavedState::Reflect(context); - TraceDrillerDialog::Reflect(context); - - serialize->Class() - ->Version(1) - ->SerializeWithNoData(); - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.hxx deleted file mode 100644 index 266432b904..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataAggregator.hxx +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_TRACE_MESSAGE_DATAAGGREGATOR_H -#define DRILLER_TRACE_MESSAGE_DATAAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/DrillerAggregatorOptions.hxx" - -#include "TraceMessageDataParser.h" - -#include -#endif - -namespace AZ { class ReflectContext; } - -namespace Driller -{ - class TraceMessageDataAggregatorSavedState; - - /** - * Trace message driller data aggregator. - */ - class TraceMessageDataAggregator : public Aggregator - { - Q_OBJECT; - TraceMessageDataAggregator(const TraceMessageDataAggregator&) = delete; - public: - AZ_RTTI(TraceMessageDataAggregator, "{CA33E0B0-6E16-4D8C-B3D0-C833AC8574C6}"); - AZ_CLASS_ALLOCATOR(TraceMessageDataAggregator,AZ::SystemAllocator,0); - - TraceMessageDataAggregator(int identity = 0); - - static AZ::u32 DrillerId() { return TraceMessageHandlerParser::GetDrillerId(); } - virtual AZ::u32 GetDrillerId() const { return DrillerId(); } - - static const char* ChannelName() { return "Logging"; } - AZ::Crc32 GetChannelId() const override { return AZ::Crc32(ChannelName()); } - - virtual AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() { return &m_parser; } - - virtual void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*); - virtual void ActivateWorkspaceSettings(WorkspaceSettingsProvider*); - virtual void SaveSettingsToWorkspace(WorkspaceSettingsProvider*); - - ////////////////////////////////////////////////////////////////////////// - // Aggregator - - // emit all annotations that match the provider's filter, given the start and end frame: - virtual void EmitAllAnnotationsForFrameRange( int startFrameInclusive, int endFrameInclusive , AnnotationsProvider* ptrProvider); - - // emit all channels that you are aware of existing within that frame range (You may emit duplicate channels, they will be ignored) - virtual void EmitAnnotationChannelsForFrameRange( int startFrameInclusive, int endFrameInclusive , AnnotationsProvider* ptrProvider); - - public slots: - float ValueAtFrame( FrameNumberType frame ) override; - QColor GetColor() const override; - QString GetName() const override; - QString GetChannelName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - void OptionsRequest() override; - virtual void OnDataViewDestroyed(QObject*); - - public: - TraceMessageHandlerParser m_parser; ///< Parser for this aggregator - - QObject* m_dataView; - AZStd::intrusive_ptr m_persistentState; - - public: - static void Reflect(AZ::ReflectContext* context); - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.cpp deleted file mode 100644 index 9d2981cafc..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "TraceMessageDataParser.h" -#include "TraceMessageDataAggregator.hxx" -#include "TraceMessageEvents.h" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* TraceMessageHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid aggregator before we can process the data!"); - if (tagName == AZ_CRC("OnPrintf", 0xd4b5c294)) - { - m_data->AddEvent(aznew TraceMessageEvent(TraceMessageEvent::ET_PRINTF)); - return this; - } - else if (tagName == AZ_CRC("OnWarning", 0x7d90abea)) - { - m_data->AddEvent(aznew TraceMessageEvent(TraceMessageEvent::ET_WARNING)); - return this; - } - else if (tagName == AZ_CRC("OnError", 0x4993c634)) - { - m_data->AddEvent(aznew TraceMessageEvent(TraceMessageEvent::ET_ERROR)); - return this; - } - return nullptr; - } - - void TraceMessageHandlerParser::OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode) - { - AZ_Assert(m_data, "You must set a valid aggregator before we can process the data!"); - if (dataNode.m_name == AZ_CRC("Window", 0x8be4f9dd)) - { - TraceMessageEvent* event = static_cast(m_data->GetEvents().back()); - event->m_window = dataNode.ReadPooledString(); - event->ComputeCRC(); - } - if (dataNode.m_name == AZ_CRC("Message", 0xb6bd307f)) - { - TraceMessageEvent* event = static_cast(m_data->GetEvents().back()); - event->m_message = dataNode.ReadPooledString(); - } - else if (dataNode.m_name == AZ_CRC("OnAssert", 0xb74db4ce)) - { - TraceMessageEvent* event = aznew TraceMessageEvent(TraceMessageEvent::ET_ASSERT); - event->m_window = "System"; - event->m_message = dataNode.ReadPooledString(); - event->m_windowCRC = AZ_CRC("System", 0xc94d118b); - m_data->AddEvent(event); - } - else if (dataNode.m_name == AZ_CRC("OnException", 0xfe457d12)) - { - TraceMessageEvent* event = aznew TraceMessageEvent(TraceMessageEvent::ET_EXCEPTION); - event->m_window = "System"; - event->m_message = dataNode.ReadPooledString(); - event->m_windowCRC = AZ_CRC("System", 0xc94d118b); - m_data->AddEvent(event); - } - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.h b/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.h deleted file mode 100644 index f2ef934288..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageDataParser.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_TRACE_MESSAGE_PARSER_H -#define DRILLER_TRACE_MESSAGE_PARSER_H - -#include - -namespace Driller -{ - class TraceMessageDataAggregator; - - class TraceMessageHandlerParser - : public AZ::Debug::DrillerHandlerParser - { - public: - TraceMessageHandlerParser() - : m_data(nullptr) - { - } - - static AZ::u32 GetDrillerId() { return AZ_CRC("TraceMessagesDriller", 0xa61d1b00); } - void SetAggregator(TraceMessageDataAggregator* data) { m_data = data; } - - // AZ::Debug::DrillerHandlerParser - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - virtual void OnData(const AZ::Debug::DrillerSAXParser::Data& dataNode); - - protected: - TraceMessageDataAggregator* m_data; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageEvents.h b/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageEvents.h deleted file mode 100644 index 7188c59f2d..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceMessageEvents.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include "Source/Driller/DrillerEvent.h" - -#include - -namespace Driller -{ - class TraceMessageEvent - : public DrillerEvent - { - public: - enum EventType - { - ET_ASSERT, - ET_EXCEPTION, - ET_ERROR, - ET_WARNING, - ET_PRINTF, - }; - - AZ_CLASS_ALLOCATOR(TraceMessageEvent, AZ::SystemAllocator, 0) - - TraceMessageEvent(EventType eventType) - : DrillerEvent(eventType) - , m_window(nullptr) - , m_message(nullptr) - , m_windowCRC(0) - {} - - void ComputeCRC() - { - if (m_window) - { - m_windowCRC = AZ::Crc32(m_window); - } - else - { - m_windowCRC = 0; - } - } - - // no stepping as we can just traverse the list of events - virtual void StepForward(Aggregator* data) { (void)data; } - virtual void StepBackward(Aggregator* data) { (void)data; } - - const char* m_window; ///< Name of the message window - const char* m_message; - AZ::u32 m_windowCRC; // so that we dont constantly take a penalty of CRCing for every event when we do the annotations - }; -} diff --git a/Code/Tools/Standalone/Source/Driller/Trace/TraceOperationTelemetryEvent.h b/Code/Tools/Standalone/Source/Driller/Trace/TraceOperationTelemetryEvent.h deleted file mode 100644 index 10ad51e76b..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Trace/TraceOperationTelemetryEvent.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ -#ifndef DRILLER_TRACE_TRACEOPERATIONTELEMETRYEVENT_H -#define DRILLER_TRACE_TRACEOPERATIONTELEMETRYEVENT_H - -#include "Telemetry/TelemetryEvent.h" - -namespace Driller -{ - class TraceOperationTelemetryEvent - : public Telemetry::TelemetryEvent - { - public: - TraceOperationTelemetryEvent() - : Telemetry::TelemetryEvent("TraceDataViewOperation") - { - } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.cpp b/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.cpp deleted file mode 100644 index 53bdc4fcd1..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.cpp +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "UnsupportedDataAggregator.hxx" -#include - -#include "UnsupportedEvents.h" - -#include - -namespace Driller -{ - UnsupportedDataAggregator::UnsupportedDataAggregator(AZ::u32 drillerId) - : m_parser(drillerId) - , Aggregator(0) - { - m_parser.SetAggregator(this); - } - - float UnsupportedDataAggregator::ValueAtFrame(FrameNumberType frame) - { - const float maxEventsPerFrame = 500.0f; - float numEventsPerFrame = static_cast(NumOfEventsAtFrame(frame)); - return AZStd::GetMin(numEventsPerFrame / maxEventsPerFrame, 1.0f) * 2.0f - 1.0f; - } - - QColor UnsupportedDataAggregator::GetColor() const - { - return QColor(40, 40, 40); - } - - QString UnsupportedDataAggregator::GetName() const - { - char buf[64]; - azsnprintf(buf, AZ_ARRAY_SIZE(buf), "Id: 0x%08x", m_parser.GetDrillerId()); - return buf; - } - - QString UnsupportedDataAggregator::GetChannelName() const - { - return ChannelName(); - } - - QString UnsupportedDataAggregator::GetDescription() const - { - return QString("Unsupported driller"); - } - - QString UnsupportedDataAggregator::GetToolTip() const - { - return QString("Unknown Driller"); - } - - AZ::Uuid UnsupportedDataAggregator::GetID() const - { - return AZ::Uuid("{368D6FB2-9A92-4DFE-8DB4-4F106194BA6F}"); - } - - QWidget* UnsupportedDataAggregator::DrillDownRequest(FrameNumberType frame) - { - (void)frame; - return NULL; - } - void UnsupportedDataAggregator::OptionsRequest() - { - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.hxx b/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.hxx deleted file mode 100644 index ec3ea9dbab..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataAggregator.hxx +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_UNSUPPORTED_DATAAGGREGATOR_H -#define DRILLER_UNSUPPORTED_DATAAGGREGATOR_H - -#if !defined(Q_MOC_RUN) -#include "Source/Driller/DrillerAggregator.hxx" -#include "Source/Driller/DrillerAggregatorOptions.hxx" - -#include "UnsupportedDataParser.h" - -#include -#endif - -namespace Driller -{ - /** - * Unsupported driller data drilling aggregator. - */ - class UnsupportedDataAggregator : public Aggregator - { - Q_OBJECT; - public: - AZ_CLASS_ALLOCATOR(UnsupportedDataAggregator,AZ::SystemAllocator,0); - - UnsupportedDataAggregator(AZ::u32 drillerId); - - virtual AZ::u32 GetDrillerId() const { return m_parser.GetDrillerId(); } - virtual AZ::Debug::DrillerHandlerParser* GetDrillerDataParser() { return &m_parser; } - - static const char* ChannelName() { return "Unsupported"; } - AZ::Crc32 GetChannelId() const override { return AZ::Crc32(ChannelName()); } - - virtual void ApplySettingsFromWorkspace(WorkspaceSettingsProvider*){} - virtual void ActivateWorkspaceSettings(WorkspaceSettingsProvider*){} - virtual void SaveSettingsToWorkspace(WorkspaceSettingsProvider*){} - - ////////////////////////////////////////////////////////////////////////// - // Aggregator - public slots: - float ValueAtFrame( FrameNumberType frame ) override; - QColor GetColor() const override; - QString GetName() const override; - QString GetChannelName() const override; - QString GetDescription() const override; - QString GetToolTip() const override; - AZ::Uuid GetID() const override; - QWidget* DrillDownRequest(FrameNumberType frame) override; - void OptionsRequest() override; - - public: - UnsupportedHandlerParser m_parser; ///< Parser for this aggregator - }; - -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.cpp b/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.cpp deleted file mode 100644 index 110b274d6c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.cpp +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "UnsupportedDataParser.h" -#include "UnsupportedDataAggregator.hxx" -#include "UnsupportedEvents.h" - -namespace Driller -{ - AZ::Debug::DrillerHandlerParser* UnsupportedHandlerParser::OnEnterTag(AZ::u32 tagName) - { - AZ_Assert(m_data, "You must set a valid aggregator before we can process the data!"); - m_data->AddEvent(aznew UnsupportedEvent(tagName)); - return nullptr; - } -} // namespace Driller diff --git a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.h b/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.h deleted file mode 100644 index 6e02dfecb4..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedDataParser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_UNSUPPORTED_PARSER_H -#define DRILLER_UNSUPPORTED_PARSER_H - -#include - -namespace Driller -{ - class UnsupportedDataAggregator; - - class UnsupportedHandlerParser - : public AZ::Debug::DrillerHandlerParser - { - public: - UnsupportedHandlerParser(AZ::u32 drillerId) - : DrillerHandlerParser(false) - , m_drillerId(drillerId) - , m_data(nullptr) - { - } - - AZ::u32 GetDrillerId() const { return m_drillerId; } - void SetAggregator(UnsupportedDataAggregator* data) { m_data = data; } - - // AZ::Debug::DrillerHandlerParser - virtual AZ::Debug::DrillerHandlerParser* OnEnterTag(AZ::u32 tagName); - - protected: - AZ::u32 m_drillerId; - UnsupportedDataAggregator* m_data; - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedEvents.h b/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedEvents.h deleted file mode 100644 index c4338e927c..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Unsupported/UnsupportedEvents.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#ifndef DRILLER_UNSUPPORTED_EVENTS_H -#define DRILLER_UNSUPPORTED_EVENTS_H - -#include "Source/Driller/DrillerEvent.h" - -namespace Driller -{ - class UnsupportedEvent - : public DrillerEvent - { - public: - AZ_CLASS_ALLOCATOR(UnsupportedEvent, AZ::SystemAllocator, 0) - - UnsupportedEvent(unsigned int eventId) - : DrillerEvent(eventId) {} - - // no stepping - virtual void StepForward(Aggregator* data) { (void)data; } - virtual void StepBackward(Aggregator* data) { (void)data; } - }; -} - -#endif diff --git a/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.cpp b/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.cpp deleted file mode 100644 index 591fdd3922..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include "Workspace.h" - -namespace Driller -{ - // this is called when the settings are loaded from file. Since the root element is just a workspace settings provider object, - // we verify the cast and return it: - static void OnObjectLoaded(void* classPtr, const AZ::Uuid& classId, const AZ::SerializeContext* sc, WorkspaceSettingsProvider** target) - { - AZ_Assert(classPtr, "classPtr is NULL!"); - AZ_Assert(target, "You must pass the target to OnObjectLoaded"); - WorkspaceSettingsProvider* container = sc->Cast(classPtr, classId); - AZ_Assert(container, "Failed to cast classPtr to WorkspaceSettingsProvider!"); - - *target = container; - } - - // remember to delete your setting objects on shutdown, since you own them! - WorkspaceSettingsProvider::~WorkspaceSettingsProvider() - { - for (auto it = m_WorkspaceSaveData.begin(); it != m_WorkspaceSaveData.end(); ++it) - { - delete it->second; - } - } - - /// Given a filename, attempt to deserialize a WorkspaceSettingsProvider object from it, using the DH objectstream: - WorkspaceSettingsProvider* WorkspaceSettingsProvider::CreateFromFile(const AZStd::string& filename) - { - using namespace AZ; - - SerializeContext* sc = NULL; - EBUS_EVENT_RESULT(sc, ComponentApplicationBus, GetSerializeContext); - AZ_Assert(sc, "Can't retrieve application's serialization context!"); - - WorkspaceSettingsProvider* resultItem = NULL; - IO::FileIOStream readStream(filename.c_str(), AZ::IO::OpenMode::ModeRead); - if (readStream.IsOpen()) - { - ObjectStream::ClassReadyCB readyCB(AZStd::bind(&OnObjectLoaded, AZStd::placeholders::_1, AZStd::placeholders::_2, AZStd::placeholders::_3, &resultItem)); - if (!ObjectStream::LoadBlocking(&readStream, *sc, readyCB)) - { - AZ_TracePrintf("Driller", "
Failed to deserialize the workspace file: '%s'
", filename.c_str()); - } - } - else - { - AZ_TracePrintf("Driller", "
Failed to open the given filename in order to read it in as a workspace: '%s'
", filename.c_str()); - } - - // use the serializer to consume filename. - return resultItem; - } - - /// serializes this object into the given filename for later retrieval. - bool WorkspaceSettingsProvider::WriteToFile(const AZStd::string& filename) - { - using namespace AZ; - - SerializeContext* sc = NULL; - EBUS_EVENT_RESULT(sc, ComponentApplicationBus, GetSerializeContext); - AZ_Assert(sc, "Can't retrieve application's serialization context!"); - - /// note: Will probably throw an error if it fails. Should check all these things before we call in here. - IO::FileIOStream writeStream(filename.c_str(), AZ::IO::OpenMode::ModeWrite); - - if (!writeStream.IsOpen()) - { - // (will have already called AZ_Error) - return false; - } - - ObjectStream* objStream = ObjectStream::Create(&writeStream, *sc, ObjectStream::ST_XML); - bool writtenOk = objStream->WriteClass(this); - if (!writtenOk) - { - AZ_TracePrintf("Driller", "
Failed to write the workspace object to the workspace file: '%s'
", filename.c_str()); - return false; - } - bool streamOk = objStream->Finalize(); - if (!streamOk) - { - AZ_TracePrintf("Driller", "
Failed to finalize the workspace file: '%s'
", filename.c_str()); - return false; - } - - return true; - } - - void WorkspaceSettingsProvider::Reflect(AZ::ReflectContext* context) - { - AZ::SerializeContext* serialize = azrtti_cast(context); - if (serialize) - { - serialize->Class() - ->Version(2) - ->Field("m_WorkspaceSaveData", &WorkspaceSettingsProvider::m_WorkspaceSaveData); - } - } -} diff --git a/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.h b/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.h deleted file mode 100644 index c4fe606490..0000000000 --- a/Code/Tools/Standalone/Source/Driller/Workspaces/Workspace.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include -#include -#include - -namespace Driller -{ - /** - * The purpose of the WorkspaceSettingsProvider is to save and restore a workspace. - * the workspace can then be used to restore a view of data at a later time, given a file containing that workspace data. - * It is generally overlayed on top of the data it is replacing. - */ - class WorkspaceSettingsProvider - { - public: - AZ_RTTI(WorkspaceSettingsProvider, "{E0BFC3FF-B040-49C3-B618-F2C1B7D45230}"); - AZ_CLASS_ALLOCATOR(WorkspaceSettingsProvider, AZ::SystemAllocator, 0); - - /// The main means of interaction: Creating from a given file name (full path) and reading it back from it. - /// Could return NULL if it fails - static WorkspaceSettingsProvider* CreateFromFile(const AZStd::string& filename); - - /// Will return false if it fails. - bool WriteToFile(const AZStd::string& filename); - - /// Convenience function - casts what it finds to T. returns null if it cannot find that setting. - template - T* FindSetting(AZ::u32 key) - { - auto it = m_WorkspaceSaveData.find(key); - if (it == m_WorkspaceSaveData.end()) - { - return NULL; - } - - return AZ::RttiCast(it->second); - } - - /// Convenience function - creates a new T, will always succeed unless critical out of memory error or exception. - template - T* CreateSetting(AZ::u32 key) - { - AZ::UserSettings* oldSetting = FindSetting(key); - if (oldSetting != NULL) - { - AZ_WarningOnce("Driller", false, "A workspace save data is being written to a save file even though that CRC key already exists: 0x%08x - should not occur\n", key); - m_WorkspaceSaveData.erase(key); - delete oldSetting; - } - - T* newSetting = aznew T(); - m_WorkspaceSaveData[key] = newSetting; - return newSetting; - } - - static void Reflect(AZ::ReflectContext* context); - virtual ~WorkspaceSettingsProvider(); - - protected: - - // we internally store our data in a map of CRC name to pointer. - typedef AZStd::unordered_map SavedWorkspaceMap; - SavedWorkspaceMap m_WorkspaceSaveData; - }; -} diff --git a/Code/Tools/Standalone/Source/ProfilerApplication.cpp b/Code/Tools/Standalone/Source/ProfilerApplication.cpp deleted file mode 100644 index b42c5a21a1..0000000000 --- a/Code/Tools/Standalone/Source/ProfilerApplication.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#include "ProfilerApplication.h" - -#include -#include - -namespace Driller -{ - void Application::RegisterCoreComponents() - { - StandaloneTools::BaseApplication::RegisterCoreComponents(); - - Driller::Context::CreateDescriptor(); - RegisterComponentDescriptor(AzFramework::TargetManagementComponent::CreateDescriptor()); - } - - void Application::CreateApplicationComponents() - { - StandaloneTools::BaseApplication::CreateApplicationComponents(); - EnsureComponentCreated(Driller::Context::RTTI_Type()); - EnsureComponentCreated(AzFramework::TargetManagementComponent::RTTI_Type()); - } - - void Application::SetSettingsRegistrySpecializations(AZ::SettingsRegistryInterface::Specializations& specializations) - { - StandaloneTools::BaseApplication::SetSettingsRegistrySpecializations(specializations); - specializations.Append("driller"); - } -} diff --git a/Code/Tools/Standalone/Source/ProfilerApplication.h b/Code/Tools/Standalone/Source/ProfilerApplication.h deleted file mode 100644 index b55f426da9..0000000000 --- a/Code/Tools/Standalone/Source/ProfilerApplication.h +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) Contributors to the Open 3D Engine Project. - * For complete copyright and license terms please see the LICENSE at the root of this distribution. - * - * SPDX-License-Identifier: Apache-2.0 OR MIT - * - */ - -#pragma once - -#include - -namespace Driller -{ - class Application - : public StandaloneTools::BaseApplication - { - public: - Application(int &argc, char **argv) : BaseApplication(argc, argv) {} - - protected: - void RegisterCoreComponents() override; - void CreateApplicationComponents() override; - void SetSettingsRegistrySpecializations(AZ::SettingsRegistryInterface::Specializations& specializations) override; - }; -} diff --git a/Code/Tools/Standalone/profiler_files.cmake b/Code/Tools/Standalone/profiler_files.cmake deleted file mode 100644 index 7106c1b646..0000000000 --- a/Code/Tools/Standalone/profiler_files.cmake +++ /dev/null @@ -1,190 +0,0 @@ -# -# Copyright (c) Contributors to the Open 3D Engine Project. -# For complete copyright and license terms please see the LICENSE at the root of this distribution. -# -# SPDX-License-Identifier: Apache-2.0 OR MIT -# -# - -set(FILES - Source/ProfilerApplication.h - Source/ProfilerApplication.cpp - Source/Editor/ProfilerEditor.h - Source/Editor/ProfilerEditor.cpp - Source/Driller/Axis.cpp - Source/Driller/Axis.hxx - Source/Driller/AreaChart.cpp - Source/Driller/AreaChart.hxx - Source/Driller/ChannelConfigurationDialog.cpp - Source/Driller/ChannelConfigurationDialog.hxx - Source/Driller/ChannelConfigurationWidget.cpp - Source/Driller/ChannelConfigurationWidget.hxx - Source/Driller/ChannelControl.cpp - Source/Driller/ChannelControl.hxx - Source/Driller/ChannelControl.ui - Source/Driller/ChannelProfilerWidget.cpp - Source/Driller/ChannelProfilerWidget.hxx - Source/Driller/ChannelProfilerWidget.ui - Source/Driller/ChannelDataView.cpp - Source/Driller/ChannelDataView.hxx - Source/Driller/ChartNumberFormats.cpp - Source/Driller/ChartNumberFormats.h - Source/Driller/ChartTypes.cpp - Source/Driller/ChartTypes.hxx - Source/Driller/CollapsiblePanel.cpp - Source/Driller/CollapsiblePanel.hxx - Source/Driller/CollapsiblePanel.ui - Source/Driller/CombinedEventsControl.cpp - Source/Driller/CombinedEventsControl.hxx - Source/Driller/CustomizeCSVExportWidget.cpp - Source/Driller/CustomizeCSVExportWidget.hxx - Source/Driller/CSVExportSettings.h - Source/Driller/DoubleListSelector.cpp - Source/Driller/DoubleListSelector.hxx - Source/Driller/DoubleListSelector.ui - Source/Driller/DrillerAggregator.cpp - Source/Driller/DrillerAggregator.hxx - Source/Driller/DrillerAggregatorOptions.hxx - Source/Driller/DrillerCaptureWindow.cpp - Source/Driller/DrillerCaptureWindow.hxx - Source/Driller/DrillerCaptureWindow.ui - Source/Driller/DrillerContext.cpp - Source/Driller/DrillerContext.h - Source/Driller/DrillerContextInterface.h - Source/Driller/DrillerDataContainer.cpp - Source/Driller/DrillerDataContainer.h - Source/Driller/DrillerDataTypes.h - Source/Driller/DrillerEvent.cpp - Source/Driller/DrillerEvent.h - Source/Driller/DrillerMainChannelsView.ui - Source/Driller/DrillerMainWindow.cpp - Source/Driller/DrillerMainWindow.hxx - Source/Driller/DrillerMainWindow.ui - Source/Driller/DrillerMainWindowMessages.cpp - Source/Driller/DrillerMainWindowMessages.h - Source/Driller/DrillerNetworkMessages.h - Source/Driller/DrillerOperationTelemetryEvent.cpp - Source/Driller/DrillerOperationTelemetryEvent.h - Source/Driller/FilteredListView.cpp - Source/Driller/FilteredListView.hxx - Source/Driller/FilteredListView.ui - Source/Driller/GenericCustomizeCSVExportWidget.cpp - Source/Driller/GenericCustomizeCSVExportWidget.hxx - Source/Driller/GenericCustomizeCSVExportWidget.ui - Source/Driller/RacetrackChart.cpp - Source/Driller/RacetrackChart.hxx - Source/Driller/StripChart.cpp - Source/Driller/StripChart.hxx - Source/Driller/Annotations/AnnotationHeaderView.cpp - Source/Driller/Annotations/AnnotationHeaderView.hxx - Source/Driller/Annotations/AnnotationHeaderView.ui - Source/Driller/Annotations/Annotations.cpp - Source/Driller/Annotations/Annotations.hxx - Source/Driller/Annotations/AnnotationsDataView.cpp - Source/Driller/Annotations/AnnotationsDataView.hxx - Source/Driller/Annotations/AnnotationsDataView_Events.cpp - Source/Driller/Annotations/AnnotationsDataView_Events.hxx - Source/Driller/Annotations/AnnotationsHeaderView_Events.cpp - Source/Driller/Annotations/AnnotationsHeaderView_Events.hxx - Source/Driller/Annotations/ConfigureAnnotationsDialog.ui - Source/Driller/Annotations/ConfigureAnnotationsWindow.cpp - Source/Driller/Annotations/ConfigureAnnotationsWindow.hxx - Source/Driller/Carrier/CarrierDataAggregator.cpp - Source/Driller/Carrier/CarrierDataAggregator.hxx - Source/Driller/Carrier/CarrierDataEvents.h - Source/Driller/Carrier/CarrierDataParser.cpp - Source/Driller/Carrier/CarrierDataParser.h - Source/Driller/Carrier/CarrierDataView.cpp - Source/Driller/Carrier/CarrierDataView.hxx - Source/Driller/Carrier/CarrierDataView.ui - Source/Driller/Carrier/CarrierOperationTelemetryEvent.h - Source/Driller/EventTrace/EventTraceDataAggregator.cpp - Source/Driller/EventTrace/EventTraceDataAggregator.h - Source/Driller/EventTrace/EventTraceDataParser.cpp - Source/Driller/EventTrace/EventTraceDataParser.h - Source/Driller/EventTrace/EventTraceEvents.h - Source/Driller/Memory/MemoryDataAggregator.cpp - Source/Driller/Memory/MemoryDataAggregator.hxx - Source/Driller/Memory/MemoryDataParser.cpp - Source/Driller/Memory/MemoryDataParser.h - Source/Driller/Memory/MemoryDataView.cpp - Source/Driller/Memory/MemoryDataView.hxx - Source/Driller/Memory/MemoryDataView.ui - Source/Driller/Memory/MemoryEvents.cpp - Source/Driller/Memory/MemoryEvents.h - Source/Driller/Profiler/ProfilerDataAggregator.cpp - Source/Driller/Profiler/ProfilerDataAggregator.hxx - Source/Driller/Profiler/ProfilerDataPanel.cpp - Source/Driller/Profiler/ProfilerDataPanel.hxx - Source/Driller/Profiler/ProfilerDataParser.cpp - Source/Driller/Profiler/ProfilerDataParser.h - Source/Driller/Profiler/ProfilerDataView.cpp - Source/Driller/Profiler/ProfilerDataView.hxx - Source/Driller/Profiler/ProfilerDataView.ui - Source/Driller/Profiler/ProfilerEvents.cpp - Source/Driller/Profiler/ProfilerEvents.h - Source/Driller/Profiler/ProfilerOperationTelemetryEvent.h - Source/Driller/Rendering/VRAM/VRAMDataAggregator.cpp - Source/Driller/Rendering/VRAM/VRAMDataAggregator.hxx - Source/Driller/Rendering/VRAM/VRAMDataParser.cpp - Source/Driller/Rendering/VRAM/VRAMDataParser.h - Source/Driller/Rendering/VRAM/VRAMEvents.cpp - Source/Driller/Rendering/VRAM/VRAMEvents.h - Source/Driller/Replica/BaseDetailViewSavedState.h - Source/Driller/Replica/BaseDetailViewQObject.cpp - Source/Driller/Replica/BaseDetailViewQObject.hxx - Source/Driller/Replica/BaseDetailView.inl - Source/Driller/Replica/BaseDetailView.h - Source/Driller/Replica/basedetailview.ui - Source/Driller/Replica/OverallReplicaDetailView.cpp - Source/Driller/Replica/OverallReplicaDetailView.hxx - Source/Driller/Replica/overallreplicadetailview.ui - Source/Driller/Replica/ReplicaBandwidthChartData.cpp - Source/Driller/Replica/ReplicaBandwidthChartData.h - Source/Driller/Replica/ReplicaChunkTypeDetailView.cpp - Source/Driller/Replica/ReplicaChunkTypeDetailView.h - Source/Driller/Replica/ReplicaChunkUsageDataContainers.cpp - Source/Driller/Replica/ReplicaChunkUsageDataContainers.h - Source/Driller/Replica/ReplicaDataAggregator.cpp - Source/Driller/Replica/ReplicaDataAggregator.hxx - Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.cpp - Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.hxx - Source/Driller/Replica/ReplicaDataAggregatorConfigurationPanel.ui - Source/Driller/Replica/ReplicaDataEvents.h - Source/Driller/Replica/ReplicaDataParser.cpp - Source/Driller/Replica/ReplicaDataParser.h - Source/Driller/Replica/ReplicaDataView.cpp - Source/Driller/Replica/ReplicaDataView.hxx - Source/Driller/Replica/replicadataview.ui - Source/Driller/Replica/ReplicaDataViewConfigDialog.ui - Source/Driller/Replica/ReplicaDetailView.cpp - Source/Driller/Replica/ReplicaDetailView.h - Source/Driller/Replica/ReplicaDisplayHelpers.cpp - Source/Driller/Replica/ReplicaDisplayHelpers.h - Source/Driller/Replica/ReplicaDisplayTypes.cpp - Source/Driller/Replica/ReplicaDisplayTypes.h - Source/Driller/Replica/ReplicaDrillerConfigToolbar.cpp - Source/Driller/Replica/ReplicaDrillerConfigToolbar.hxx - Source/Driller/Replica/ReplicaDrillerConfigToolbar.ui - Source/Driller/Replica/ReplicaOperationTelemetryEvent.h - Source/Driller/Replica/ReplicaTreeViewModel.cpp - Source/Driller/Replica/ReplicaTreeViewModel.hxx - Source/Driller/Replica/ReplicaUsageDataContainers.cpp - Source/Driller/Replica/ReplicaUsageDataContainers.h - Source/Driller/Trace/TraceDrillerDialog.cpp - Source/Driller/Trace/TraceDrillerDialog.hxx - Source/Driller/Trace/TraceDrillerDialog.ui - Source/Driller/Trace/TraceMessageDataAggregator.cpp - Source/Driller/Trace/TraceMessageDataAggregator.hxx - Source/Driller/Trace/TraceMessageDataParser.cpp - Source/Driller/Trace/TraceMessageDataParser.h - Source/Driller/Trace/TraceMessageEvents.h - Source/Driller/Trace/TraceOperationTelemetryEvent.h - Source/Driller/Unsupported/UnsupportedDataAggregator.cpp - Source/Driller/Unsupported/UnsupportedDataAggregator.hxx - Source/Driller/Unsupported/UnsupportedDataParser.cpp - Source/Driller/Unsupported/UnsupportedDataParser.h - Source/Driller/Unsupported/UnsupportedEvents.h - Source/Driller/Workspaces/Workspace.cpp - Source/Driller/Workspaces/Workspace.h -) diff --git a/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h b/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h index 1bf80522ed..1d2e8bad42 100644 --- a/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h +++ b/Gems/AWSClientAuth/Code/Tests/AWSClientAuthGemMock.h @@ -610,7 +610,6 @@ namespace AWSClientAuthUnitTest const char* GetExecutableFolder() const override { return nullptr; } const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} AZ::SerializeContext* GetSerializeContext() override diff --git a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp index 4b28fbe4ef..6395913f7a 100644 --- a/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp +++ b/Gems/Atom/Asset/ImageProcessingAtom/Code/Tests/ImageProcessing_Test.cpp @@ -114,7 +114,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const AZ::ComponentApplicationRequests::EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp index 4229416066..b84d4347a7 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshInputBuffers.cpp @@ -23,6 +23,8 @@ #include #include +AZ_DECLARE_BUDGET(AzRender); + namespace AZ { namespace Render diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Base.h b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Base.h index 71b1326fd0..9e1ec4585e 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Base.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI.Reflect/Base.h @@ -8,12 +8,14 @@ #pragma once #include +#include #include #include #include #include #include +AZ_DECLARE_BUDGET(RHI); namespace UnitTest { diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/Factory.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/Factory.h index 11f28e7a94..e0f03df9d7 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/Factory.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/Factory.h @@ -9,12 +9,15 @@ #include #include +#include #include #if defined(USE_RENDERDOC) #include #endif +AZ_DECLARE_BUDGET(RHI); + namespace AZ { namespace RHI diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/RHISystemInterface.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/RHISystemInterface.h index 277b974641..6a9650e0a1 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/RHISystemInterface.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/RHISystemInterface.h @@ -8,12 +8,15 @@ #pragma once +#include #include #include #include #include #include +AZ_DECLARE_BUDGET(RHI); + namespace AZ { namespace RHI diff --git a/Gems/Atom/RHI/Code/Source/RHI/AsyncWorkQueue.cpp b/Gems/Atom/RHI/Code/Source/RHI/AsyncWorkQueue.cpp index a32301276e..52021fa736 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/AsyncWorkQueue.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/AsyncWorkQueue.cpp @@ -9,6 +9,8 @@ #include +AZ_DECLARE_BUDGET(RHI); + namespace AZ { namespace RHI @@ -126,7 +128,7 @@ namespace AZ return; } - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZStd::unique_lock lock(m_waitWorkItemMutex); m_waitWorkItemCondition.wait(lock, [&]() {return HasFinishedWork(workHandle); }); diff --git a/Gems/Atom/RHI/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/Code/Source/RHI/CommandQueue.cpp index 2474967dab..15621c7f2b 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/CommandQueue.cpp @@ -22,7 +22,7 @@ namespace AZ ResultCode CommandQueue::Init(Device& device, const CommandQueueDescriptor& descriptor) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); #if defined (AZ_RHI_ENABLE_VALIDATION) if (IsInitialized()) @@ -116,7 +116,7 @@ namespace AZ //run a command { - AZ_PROFILE_SCOPE(AzRender, "RHI::CommandQueue - Execute Command"); + AZ_PROFILE_SCOPE(RHI, "CommandQueue - Execute Command"); command(GetNativeQueue()); } } diff --git a/Gems/Atom/RHI/Code/Source/RHI/Fence.cpp b/Gems/Atom/RHI/Code/Source/RHI/Fence.cpp index 868d2e3317..b35260caca 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/Fence.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/Fence.cpp @@ -81,7 +81,7 @@ namespace AZ return ResultCode::InvalidOperation; } - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); WaitOnCpuInternal(); return ResultCode::Success; } diff --git a/Gems/Atom/RHI/Code/Source/RHI/FrameScheduler.cpp b/Gems/Atom/RHI/Code/Source/RHI/FrameScheduler.cpp index 0793c1ffd0..0b8c6ad9ce 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/FrameScheduler.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/FrameScheduler.cpp @@ -137,7 +137,7 @@ namespace AZ ResultCode FrameScheduler::ImportScopeProducer(ScopeProducer& scopeProducer) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); if (!ValidateIsProcessing()) { @@ -216,7 +216,7 @@ namespace AZ void FrameScheduler::PrepareProducers() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: PrepareProducers"); for (ScopeProducer* scopeProducer : m_scopeProducers) @@ -237,7 +237,7 @@ namespace AZ void FrameScheduler::CompileProducers() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: CompileProducers"); for (ScopeProducer* scopeProducer : m_scopeProducers) @@ -249,12 +249,12 @@ namespace AZ void FrameScheduler::CompileShaderResourceGroups() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: CompileShaderResourceGroups"); // Execute all queued resource invalidations, which will mark SRG's for compilation. { - AZ_PROFILE_SCOPE(AzRender, "Invalidate Resources"); + AZ_PROFILE_SCOPE(RHI, "Invalidate Resources"); ResourceInvalidateBus::ExecuteQueuedEvents(); } @@ -322,7 +322,7 @@ namespace AZ void FrameScheduler::BuildRayTracingShaderTables() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: BuildRayTracingShaderTables"); for (auto rayTracingShaderTable : m_rayTracingShaderTablesToBuild) @@ -341,7 +341,7 @@ namespace AZ ResultCode FrameScheduler::BeginFrame() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: BeginFrame"); if (!ValidateIsInitialized()) @@ -376,7 +376,7 @@ namespace AZ ResultCode FrameScheduler::EndFrame() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: EndFrame"); if (Validation::IsEnabled()) @@ -417,13 +417,13 @@ namespace AZ void FrameScheduler::ExecuteContextInternal(FrameGraphExecuteGroup& group, uint32_t index) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); FrameGraphExecuteContext* executeContext = group.BeginContext(index); { ScopeProducer* scopeProducer = FindScopeProducer(executeContext->GetScopeId()); - AZ_PROFILE_SCOPE(AzRender, "ScopeProducer: %s", scopeProducer->GetScopeId().GetCStr()); + AZ_PROFILE_SCOPE(RHI, "ScopeProducer: %s", scopeProducer->GetScopeId().GetCStr()); scopeProducer->BuildCommandList(*executeContext); } @@ -432,7 +432,7 @@ namespace AZ void FrameScheduler::ExecuteGroupInternal(AZ::Job* parentJob, uint32_t groupIndex) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: ExecuteGroupInternal"); FrameGraphExecuteGroup* executeGroup = m_frameGraphExecuter->BeginGroup(groupIndex); @@ -475,7 +475,7 @@ namespace AZ void FrameScheduler::Execute(JobPolicy overrideJobPolicy) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "FrameScheduler: Execute"); const uint32_t groupCount = m_frameGraphExecuter->GetGroupCount(); diff --git a/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp b/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp index 69eee86108..c9609edcf5 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/PipelineStateCache.cpp @@ -272,7 +272,7 @@ namespace AZ const PipelineState* PipelineStateCache::AcquirePipelineState(PipelineLibraryHandle handle, const PipelineStateDescriptor& descriptor) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); if (handle.IsNull()) { diff --git a/Gems/Atom/RHI/Code/Source/RHI/RHISystem.cpp b/Gems/Atom/RHI/Code/Source/RHI/RHISystem.cpp index 8f8b7677fd..ed755c538a 100644 --- a/Gems/Atom/RHI/Code/Source/RHI/RHISystem.cpp +++ b/Gems/Atom/RHI/Code/Source/RHI/RHISystem.cpp @@ -19,6 +19,8 @@ #include #include +AZ_DEFINE_BUDGET(RHI); + namespace AZ { namespace RHI @@ -193,11 +195,11 @@ namespace AZ void RHISystem::FrameUpdate(FrameGraphCallback frameGraphCallback) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("RHI", "RHISystem: FrameUpdate"); { - AZ_PROFILE_SCOPE(AzRender, "main per-frame work"); + AZ_PROFILE_SCOPE(RHI, "main per-frame work"); m_frameScheduler.BeginFrame(); frameGraphCallback(m_frameScheduler); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp index 81e52d6d3f..e9beb55314 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/AsyncUploadQueue.cpp @@ -152,21 +152,21 @@ namespace AZ m_copyQueue->QueueCommand([=](void* commandQueue) { - AZ_PROFILE_SCOPE(AzRender, "Upload Buffer"); + AZ_PROFILE_SCOPE(RHI, "Upload Buffer"); size_t pendingByteOffset = 0; size_t pendingByteCount = byteCount; ID3D12CommandQueue* dx12CommandQueue = static_cast(commandQueue); while (pendingByteCount > 0) { - AZ_PROFILE_SCOPE(AzRender, "Upload Buffer Chunk"); + AZ_PROFILE_SCOPE(RHI, "Upload Buffer Chunk"); FramePacket* framePacket = BeginFramePacket(); const size_t bytesToCopy = AZStd::min(pendingByteCount, m_descriptor.m_stagingSizeInBytes); { - AZ_PROFILE_SCOPE(AzRender, "Copy CPU buffer"); + AZ_PROFILE_SCOPE(RHI, "Copy CPU buffer"); memcpy(framePacket->m_stagingResourceData, sourceData + pendingByteOffset, bytesToCopy); } @@ -196,7 +196,7 @@ namespace AZ AsyncUploadQueue::FramePacket* AsyncUploadQueue::BeginFramePacket() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_Assert(!m_recordingFrame, "The previous frame packet isn't ended"); FramePacket* framePacket = &m_framePackets[m_frameIndex]; @@ -212,7 +212,7 @@ namespace AZ void AsyncUploadQueue::EndFramePacket(ID3D12CommandQueue* commandQueue) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_Assert(m_recordingFrame, "The frame packet wasn't started. You need to call StartFramePacket first."); AssertSuccess(m_commandList->Close()); @@ -229,7 +229,7 @@ namespace AZ // [GFX TODO][ATOM-4205] Stage/Upload 3D streaming images more efficiently. uint64_t AsyncUploadQueue::QueueUpload(const RHI::StreamingImageExpandRequest& request, uint32_t residentMip) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); uint64_t fenceValue = m_uploadFence.Increment(); @@ -243,7 +243,7 @@ namespace AZ m_copyQueue->QueueCommand([=](void* commandQueue) { - AZ_PROFILE_SCOPE(AzRender, "Upload Image"); + AZ_PROFILE_SCOPE(RHI, "Upload Image"); ID3D12CommandQueue* dx12CommandQueue = static_cast(commandQueue); FramePacket* framePacket = BeginFramePacket(); @@ -314,7 +314,7 @@ namespace AZ // Copy subresource data to staging memory. { - AZ_PROFILE_SCOPE(AzRender, "Copy CPU image"); + AZ_PROFILE_SCOPE(RHI, "Copy CPU image"); uint8_t* stagingDataStart = framePacket->m_stagingResourceData + framePacket->m_dataOffset; const uint8_t* subresourceSliceDataStart = static_cast(subresource.m_data) + (depth * subresourceSlicePitch); @@ -385,7 +385,7 @@ namespace AZ // Copy subresource data to staging memory { - AZ_PROFILE_SCOPE(AzRender, "Copy CPU image"); + AZ_PROFILE_SCOPE(RHI, "Copy CPU image"); for (uint32_t row = startRow; row < endRow; row++) { uint8_t* stagingDataStart = framePacket->m_stagingResourceData + framePacket->m_dataOffset; @@ -476,7 +476,7 @@ namespace AZ void AsyncUploadQueue::WaitForUpload(uint64_t fenceValue) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); if (!IsUploadFinished(fenceValue)) { @@ -490,7 +490,7 @@ namespace AZ void AsyncUploadQueue::ProcessCallbacks(uint64_t fenceValue) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZStd::lock_guard lock(m_callbackMutex); while (m_callbacks.size() > 0 && m_callbacks.front().second <= fenceValue) { @@ -504,7 +504,7 @@ namespace AZ { m_copyQueue->QueueCommand([=](void* commandQueue) { - AZ_PROFILE_SCOPE(AzRender, "QueueTileMapping"); + AZ_PROFILE_SCOPE(RHI, "QueueTileMapping"); ID3D12CommandQueue* dx12CommandQueue = static_cast(commandQueue); const uint32_t tileCount = request.m_sourceRegionSize.NumTiles; diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListBase.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListBase.cpp index a8ae753294..c5c71a9f43 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListBase.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandListBase.cpp @@ -33,7 +33,7 @@ namespace AZ void CommandListBase::Reset(ID3D12CommandAllocator* commandAllocator) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_Assert(m_queuedBarriers.empty(), "Unflushed barriers in command list."); m_commandList->Reset(commandAllocator, nullptr); @@ -95,7 +95,7 @@ namespace AZ { if (m_queuedBarriers.size()) { - AZ_PROFILE_FUNCTION(AzRenderDetailed); + AZ_PROFILE_FUNCTION(RHI); m_commandList->ResourceBarrier((UINT)m_queuedBarriers.size(), m_queuedBarriers.data()); m_queuedBarriers.clear(); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp index b73228e717..afd0eb8074 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueue.cpp @@ -110,7 +110,7 @@ namespace AZ { QueueCommand([this, &fence](void* commandQueue) { - AZ_PROFILE_SCOPE(AzRender, "SignalFence"); + AZ_PROFILE_SCOPE(RHI, "SignalFence"); ID3D12CommandQueue* dx12CommandQueue = static_cast(commandQueue); dx12CommandQueue->Signal(fence.Get(), fence.GetPendingValue()); }); @@ -138,7 +138,7 @@ namespace AZ QueueCommand([=](void* commandQueue) { - AZ_PROFILE_SCOPE(AzRender, "ExecuteWork"); + AZ_PROFILE_SCOPE(RHI, "ExecuteWork"); AZ_PROFILE_RHI_VARIABLE(m_lastExecuteDuration); static const uint32_t CommandListCountMax = 128; @@ -195,7 +195,7 @@ namespace AZ void CommandQueue::UpdateTileMappings(CommandList& commandList) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); for (const CommandList::TileMapRequest& request : commandList.GetTileMapRequests()) { const uint32_t tileCount = request.m_sourceRegionSize.NumTiles; @@ -229,7 +229,7 @@ namespace AZ void CommandQueue::WaitForIdle() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); Fence fence; fence.Init(m_device.get(), RHI::FenceState::Reset); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueueContext.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueueContext.cpp index f35f66f3e8..96d621df59 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueueContext.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandQueueContext.cpp @@ -101,7 +101,7 @@ namespace AZ void CommandQueueContext::WaitForIdle() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); for (uint32_t hardwareQueueIdx = 0; hardwareQueueIdx < RHI::HardwareQueueClassCount; ++hardwareQueueIdx) { if (m_commandQueues[hardwareQueueIdx]) @@ -113,10 +113,10 @@ namespace AZ void CommandQueueContext::Begin() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); { - AZ_PROFILE_SCOPE(AzRender, "Clearing Command Queue Timers"); + AZ_PROFILE_SCOPE(RHI, "Clearing Command Queue Timers"); for (const RHI::Ptr& commandQueue : m_commandQueues) { commandQueue->ClearTimers(); @@ -131,7 +131,7 @@ namespace AZ void CommandQueueContext::End() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_ATOM_PROFILE_FUNCTION("DX12", "CommandQueueContext: End"); QueueGpuSignals(m_frameFences[m_currentFrameIndex]); @@ -145,7 +145,7 @@ namespace AZ m_currentFrameIndex = (m_currentFrameIndex + 1) % aznumeric_cast(m_frameFences.size()); { - AZ_PROFILE_SCOPE(AzRender, "Wait and Reset Fence"); + AZ_PROFILE_SCOPE(RHI, "Wait and Reset Fence"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("DX12", "CommandQueueContext: Wait on Fences"); FenceEvent event("FrameFence"); diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/Fence.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/Fence.cpp index 6244089d93..10d8abee6d 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/Fence.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/Fence.cpp @@ -60,7 +60,7 @@ namespace AZ { if (fenceValue > GetCompletedValue()) { - AZ_PROFILE_SCOPE(AzRender, "Fence Wait: %s", fenceEvent.GetName()); + AZ_PROFILE_SCOPE(RHI, "Fence Wait: %s", fenceEvent.GetName()); m_fence->SetEventOnCompletion(fenceValue, fenceEvent.m_EventHandle); WaitForSingleObject(fenceEvent.m_EventHandle, INFINITE); } diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/StreamingImagePool.cpp b/Gems/Atom/RHI/DX12/Code/Source/RHI/StreamingImagePool.cpp index 11863cb70b..add7364056 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/StreamingImagePool.cpp +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/StreamingImagePool.cpp @@ -144,7 +144,7 @@ namespace AZ #ifdef AZ_RHI_USE_TILED_RESOURCES { - AZ_PROFILE_SCOPE(AzRender, "StreamImagePool::CreateHeap"); + AZ_PROFILE_SCOPE(RHI, "StreamImagePool::CreateHeap"); CD3DX12_HEAP_DESC heapDesc(descriptor.m_budgetInBytes, D3D12_HEAP_TYPE_DEFAULT, 0, D3D12_HEAP_FLAG_DENY_BUFFERS | D3D12_HEAP_FLAG_DENY_RT_DS_TEXTURES); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueue.cpp index 4bde063d63..d151a11ec1 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueue.cpp @@ -114,7 +114,7 @@ namespace AZ //Autoreleasepool is to ensure that the driver is not leaking memory related to the command buffer and encoder @autoreleasepool { - AZ_PROFILE_SCOPE(AzRender, "ExecuteWork"); + AZ_PROFILE_SCOPE(RHI, "ExecuteWork"); AZ_PROFILE_RHI_VARIABLE(m_lastExecuteDuration); if (request.m_signalFenceValue > 0) diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueueContext.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueueContext.cpp index f0ec98be89..7f0c535383 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueueContext.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandQueueContext.cpp @@ -79,7 +79,7 @@ namespace AZ void CommandQueueContext::End() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); QueueGpuSignals(m_frameFences[m_currentFrameIndex]); for (uint32_t hardwareQueueIdx = 0; hardwareQueueIdx < RHI::HardwareQueueClassCount; ++hardwareQueueIdx) @@ -91,7 +91,7 @@ namespace AZ m_currentFrameIndex = (m_currentFrameIndex + 1) % aznumeric_cast(m_frameFences.size()); { - AZ_PROFILE_SCOPE(AzRender, "Wait and Reset Fence"); + AZ_PROFILE_SCOPE(RHI, "Wait and Reset Fence"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RHI", "CommandQueueContext: Wait on Fences"); //Synchronize the CPU with the GPU by waiting on the fence until signalled by the GPU. CPU can only go upto diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp index 8f44abccef..69c3d3cc20 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/AsyncUploadQueue.cpp @@ -96,7 +96,7 @@ namespace AZ uploadFence->Init(device, RHI::FenceState::Reset); CommandQueue::Command command = [=, &device](void* queue) { - AZ_PROFILE_SCOPE(AzRender, "Upload Buffer"); + AZ_PROFILE_SCOPE(RHI, "Upload Buffer"); size_t pendingByteOffset = 0; size_t pendingByteCount = byteCount; FramePacket* framePacket = nullptr; @@ -110,7 +110,7 @@ namespace AZ while (pendingByteCount > 0) { - AZ_PROFILE_SCOPE(AzRender, "Upload Buffer Chunk"); + AZ_PROFILE_SCOPE(RHI, "Upload Buffer Chunk"); framePacket = BeginFramePacket(vulkanQueue); const size_t bytesToCopy = AZStd::min(pendingByteCount, m_descriptor.m_stagingSizeInBytes); @@ -181,7 +181,7 @@ namespace AZ CommandQueue::Command command = [=, &device](void* queue) { - AZ_PROFILE_SCOPE(AzRender, "Upload Image"); + AZ_PROFILE_SCOPE(RHI, "Upload Image"); Queue* vulkanQueue = static_cast(queue); FramePacket* framePacket = BeginFramePacket(vulkanQueue); @@ -257,7 +257,7 @@ namespace AZ // Copy subresource data to staging memory. { - AZ_PROFILE_SCOPE(AzRender, "Copy CPU image"); + AZ_PROFILE_SCOPE(RHI, "Copy CPU image"); uint8_t* stagingDataStart = reinterpret_cast(framePacket->m_stagingBuffer->GetBufferMemoryView()->Map(RHI::HostMemoryAccess::Write)) + framePacket->m_dataOffset; for (uint32_t row = 0; row < subresourceLayout.m_rowCount; ++row) { @@ -332,7 +332,7 @@ namespace AZ // Copy subresource data to staging memory. { - AZ_PROFILE_SCOPE(AzRender, "Copy CPU image"); + AZ_PROFILE_SCOPE(RHI, "Copy CPU image"); uint8_t* stagingDataStart = reinterpret_cast(framePacket->m_stagingBuffer->GetBufferMemoryView()->Map(RHI::HostMemoryAccess::Write)); stagingDataStart += framePacket->m_dataOffset; @@ -458,7 +458,7 @@ namespace AZ AsyncUploadQueue::FramePacket* AsyncUploadQueue::BeginFramePacket(Queue* queue) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_Assert(!m_recordingFrame, "The previous frame packet isn't ended."); auto& device = static_cast(GetDevice()); @@ -478,7 +478,7 @@ namespace AZ void AsyncUploadQueue::EndFramePacket(Queue* queue, Semaphore* semaphoreToSignal /*=nullptr*/) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZ_Assert(m_recordingFrame, "The frame packet wasn't started. You need to call StartFramePacket first."); m_commandList->EndCommandBuffer(); @@ -644,7 +644,7 @@ namespace AZ void AsyncUploadQueue::ProcessCallback(const RHI::AsyncWorkHandle& handle) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); AZStd::unique_lock lock(m_callbackListMutex); auto findIter = m_callbackList.find(handle); if (findIter != m_callbackList.end()) diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp index 6929b63ac4..bfce4dfb33 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueue.cpp @@ -54,7 +54,7 @@ namespace AZ const ExecuteWorkRequest& request = static_cast(rhiRequest); QueueCommand([=](void* queue) { - AZ_PROFILE_SCOPE(AzRender, "ExecuteWork"); + AZ_PROFILE_SCOPE(RHI, "ExecuteWork"); AZ_PROFILE_RHI_VARIABLE(m_lastExecuteDuration); Queue* vulkanQueue = static_cast(queue); diff --git a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueueContext.cpp b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueueContext.cpp index f31132f039..39f0ac9d58 100644 --- a/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueueContext.cpp +++ b/Gems/Atom/RHI/Vulkan/Code/Source/RHI/CommandQueueContext.cpp @@ -42,7 +42,7 @@ namespace AZ void CommandQueueContext::End() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); for (auto& commandQueue : m_commandQueues) { @@ -54,7 +54,7 @@ namespace AZ m_currentFrameIndex = (m_currentFrameIndex + 1) % GetFrameCount(); { - AZ_PROFILE_SCOPE(AzRender, "Wait on Fences"); + AZ_PROFILE_SCOPE(RHI, "Wait on Fences"); AZ_ATOM_PROFILE_FUNCTION("RHI", "CommandQueueContext: Wait on Fences"); FencesPerQueue& nextFences = m_frameFences[m_currentFrameIndex]; @@ -79,7 +79,7 @@ namespace AZ void CommandQueueContext::WaitForIdle() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RHI); for (auto& commandQueue : m_commandQueues) { commandQueue->WaitForIdle(); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Base.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Base.h index 5c39bc3656..a88c640c19 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Base.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Base.h @@ -14,10 +14,14 @@ #include #include #include +#include #include #include #include +AZ_DECLARE_BUDGET(AzRender); +AZ_DECLARE_BUDGET(RPI); + namespace AZ { namespace RHI @@ -67,3 +71,4 @@ namespace AZ } // namespace RPI } // namespace AZ + diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Base.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Base.h index c62a9439ea..6126f14e4a 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Base.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Reflect/Base.h @@ -7,12 +7,15 @@ */ #pragma once +#include #include #include #include #include +AZ_DECLARE_BUDGET(RPI); + namespace UnitTest { class RPITestFixture; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp index 54163f830b..98b3ab6f5f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Culling.cpp @@ -299,7 +299,7 @@ namespace AZ //work function void Process() override { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); const View::UsageFlags viewFlags = m_jobData->m_view->GetUsageFlags(); const RHI::DrawListMask drawListMask = m_jobData->m_view->GetDrawListMask(); @@ -312,7 +312,7 @@ namespace AZ bool nodeIsContainedInFrustum = ShapeIntersection::Contains(m_jobData->m_frustum, nodeData.m_bounds); #ifdef AZ_CULL_PROFILE_VERBOSE - AZ_PROFILE_SCOPE(AzRender, "process node (view: %s, skip fine cull: %d", + AZ_PROFILE_SCOPE(RPI, "process node (view: %s, skip fine cull: %d", m_view->GetName().GetCStr(), nodeIsContainedInFrustum ? 1 : 0); #endif @@ -385,7 +385,7 @@ namespace AZ if (m_jobData->m_debugCtx->m_debugDraw && (m_jobData->m_view->GetName() == m_jobData->m_debugCtx->m_currentViewSelectionName)) { - AZ_PROFILE_SCOPE(AzRender, "debug draw culling"); + AZ_PROFILE_SCOPE(RPI, "debug draw culling"); AuxGeomDrawPtr auxGeomPtr = AuxGeomFeatureProcessorInterface::GetDrawQueueForScene(m_jobData->m_scene); if (auxGeomPtr) @@ -507,7 +507,7 @@ namespace AZ void CullingScene::ProcessCullables(const Scene& scene, View& view, AZ::Job& parentJob) { - AZ_PROFILE_SCOPE(AzRender, "CullingScene::ProcessCullables() - %s", view.GetName().GetCStr()); + AZ_PROFILE_SCOPE(RPI, "CullingScene::ProcessCullables() - %s", view.GetName().GetCStr()); const Matrix4x4& worldToClip = view.GetWorldToClipMatrix(); Frustum frustum = Frustum::CreateFromMatrixColumnMajor(worldToClip); @@ -598,7 +598,7 @@ namespace AZ auto nodeVisitorLambda = [this, jobData, &parentJob, &frustum, &worklist](const AzFramework::IVisibilityScene::NodeData& nodeData) -> void { - AZ_PROFILE_SCOPE(AzRender, "nodeVisitorLambda()"); + AZ_PROFILE_SCOPE(RPI, "nodeVisitorLambda()"); AZ_Assert(nodeData.m_entries.size() > 0, "should not get called with 0 entries"); AZ_Assert(worklist.size() < worklist.capacity(), "we should always have room to push a node on the queue"); @@ -645,7 +645,7 @@ namespace AZ uint32_t AddLodDataToView(const Vector3& pos, const Cullable::LodData& lodData, RPI::View& view) { #ifdef AZ_CULL_PROFILE_DETAILED - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); #endif const Matrix4x4& viewToClip = view.GetViewToClipMatrix(); @@ -663,7 +663,7 @@ namespace AZ auto addLodToDrawPacket = [&](const Cullable::LodData::Lod& lod) { #ifdef AZ_CULL_PROFILE_VERBOSE - AZ_PROFILE_SCOPE(AzRender, "add draw packets: %zu", lod.m_drawPackets.size()); + AZ_PROFILE_SCOPE(RPI, "add draw packets: %zu", lod.m_drawPackets.size()); #endif numVisibleDrawPackets += static_cast(lod.m_drawPackets.size()); //don't want to pay the cost of aznumeric_cast<> here so using static_cast<> instead for (const RHI::DrawPacket* drawPacket : lod.m_drawPackets) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Material/Material.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Material/Material.cpp index 1de6776d9c..3b82114a69 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Material/Material.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Material/Material.cpp @@ -310,7 +310,7 @@ namespace AZ if (NeedsCompile() && CanCompile()) { - AZ_PROFILE_BEGIN(AzRender, "Material::Compile() Processing Functors"); + AZ_PROFILE_BEGIN(RPI, "Material::Compile() Processing Functors"); for (const Ptr& functor : m_materialAsset->GetMaterialFunctors()) { if (functor) @@ -339,7 +339,7 @@ namespace AZ AZ_Error(s_debugTraceName, false, "Material functor is null."); } } - AZ_PROFILE_END(); + AZ_PROFILE_END(RPI); m_propertyDirtyFlags.reset(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp index 7fd7133cee..2d876fd6ad 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/MeshDrawPacket.cpp @@ -124,7 +124,7 @@ namespace AZ bool MeshDrawPacket::DoUpdate(const Scene& parentScene) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); const ModelLod::Mesh& mesh = m_modelLod->GetMeshes()[m_modelLodMeshIndex]; if (!m_material) @@ -155,7 +155,7 @@ namespace AZ auto appendShader = [&](const ShaderCollection::Item& shaderItem) { - AZ_PROFILE_SCOPE(AzRender, "appendShader()"); + AZ_PROFILE_SCOPE(RPI, "appendShader()"); // Skip the shader item without creating the shader instance // if the mesh is not going to be rendered based on the draw tag @@ -256,7 +256,7 @@ namespace AZ Data::Instance drawSrg; if (drawSrgLayout) { - AZ_PROFILE_SCOPE(AzRender, "create drawSrg"); + AZ_PROFILE_SCOPE(RPI, "create drawSrg"); // If the DrawSrg exists we must create and bind it, otherwise the CommandList will fail validation for SRG being null drawSrg = RPI::ShaderResourceGroup::Create(shader->GetAsset(), shader->GetSupervariantIndex(), drawSrgLayout->GetName()); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp index 0cbcdbf5f4..6fd313e27f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/Model.cpp @@ -42,7 +42,7 @@ namespace AZ Data::Instance Model::CreateInternal(const Data::Asset& modelAsset) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); Data::Instance model = aznew Model(); const RHI::ResultCode resultCode = model->Init(modelAsset); @@ -56,7 +56,7 @@ namespace AZ RHI::ResultCode Model::Init(const Data::Asset& modelAsset) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); m_lods.resize(modelAsset->GetLodAssets().size()); @@ -107,7 +107,7 @@ namespace AZ { if (m_isUploadPending) { - AZ_PROFILE_SCOPE(AzRender, "Model::WaitForUpload - %s", GetDatabaseName()); + AZ_PROFILE_SCOPE(RPI, "Model::WaitForUpload - %s", GetDatabaseName()); for (const Data::Instance& lod : m_lods) { lod->WaitForUpload(); @@ -128,7 +128,7 @@ namespace AZ bool Model::LocalRayIntersection(const AZ::Vector3& rayStart, const AZ::Vector3& rayDir, float& distanceNormalized, AZ::Vector3& normal) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); if (!GetModelAsset()) { @@ -171,7 +171,7 @@ namespace AZ float& distanceNormalized, AZ::Vector3& normal) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); const AZ::Vector3 clampedScale = nonUniformScale.GetMax(AZ::Vector3(AZ::MinTransformScale)); const AZ::Transform inverseTM = modelTransform.GetInverse(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp index cfe0d08270..04fa004228 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLod.cpp @@ -264,7 +264,7 @@ namespace AZ const MaterialModelUvOverrideMap& materialModelUvMap, const MaterialUvNameMap& materialUvNameMap) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); streamBufferViewsOut.clear(); @@ -366,7 +366,7 @@ namespace AZ const MaterialModelUvOverrideMap& materialModelUvMap, const MaterialUvNameMap& materialUvNameMap) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); const Mesh& mesh = m_meshes[meshIndex]; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp index 0fe035dd85..ef9521d23c 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Model/ModelLodUtils.cpp @@ -27,7 +27,7 @@ namespace AZ ModelLodIndex SelectLod(const View* view, const Vector3& position, const Model& model, ModelLodIndex lodOverride) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); ModelLodIndex lodIndex; if (model.GetLodCount() == 1) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index 64ab7fdd96..a8feeb1047 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -189,7 +189,7 @@ namespace AZ void PassSystem::BuildPasses() { m_state = PassSystemState::BuildingPasses; - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); m_passHierarchyChanged = m_passHierarchyChanged || !m_buildPassList.empty(); @@ -239,7 +239,7 @@ namespace AZ void PassSystem::InitializePasses() { m_state = PassSystemState::InitializingPasses; - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); m_passHierarchyChanged = m_passHierarchyChanged || !m_initializePassList.empty(); @@ -286,7 +286,7 @@ namespace AZ return; } - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); PassValidationResults validationResults; m_rootPass->Validate(validationResults); @@ -307,7 +307,7 @@ namespace AZ void PassSystem::FrameUpdate(RHI::FrameGraphBuilder& frameGraphBuilder) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: FrameUpdate"); ResetFrameStatistics(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp index d37002eb6b..51cbc82f2b 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RasterPass.cpp @@ -216,7 +216,7 @@ namespace AZ void RasterPass::CompileResources(const RHI::FrameGraphCompileContext& context) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); if (m_shaderResourceGroup == nullptr) { @@ -230,7 +230,7 @@ namespace AZ void RasterPass::BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); RHI::CommandList* commandList = context.GetCommandList(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp index 5eb9bd2d46..a9028627a0 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RPISystem.cpp @@ -36,6 +36,9 @@ #include +AZ_DEFINE_BUDGET(AzRender); +AZ_DEFINE_BUDGET(RPI); + // This will cause the RPI System to print out global state (like the current pass hierarchy) when an assert is hit // This is useful for rendering engineers debugging a crash in the RPI/RHI layers #define AZ_RPI_PRINT_GLOBAL_STATE_ON_ASSERT 0 @@ -270,7 +273,7 @@ namespace AZ return; } - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); AZ_ATOM_PROFILE_FUNCTION("RPI", "RPISystem: RenderTick"); // Query system update is to increment the frame count diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp index a552ac86f2..6d974a074f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp @@ -377,7 +377,7 @@ namespace AZ void RenderPipeline::OnStartFrame(const TickTimeInfo& tick) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); m_lastRenderStartTime = tick.m_currentGameTime; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Scene.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Scene.cpp index 26fdae1c54..761ce20ee8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Scene.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Scene.cpp @@ -400,7 +400,7 @@ namespace AZ AZ_ATOM_PROFILE_FUNCTION("RPI", "Scene: PrepareRender"); { - AZ_PROFILE_SCOPE(AzRender, "WaitForSimulationCompletion"); + AZ_PROFILE_SCOPE(RPI, "WaitForSimulationCompletion"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "WaitForSimulationCompletion"); WaitAndCleanCompletionJob(m_simulationCompletion); } @@ -408,7 +408,7 @@ namespace AZ SceneNotificationBus::Event(GetId(), &SceneNotification::OnBeginPrepareRender); { - AZ_PROFILE_SCOPE(AzRender, "m_srgCallback"); + AZ_PROFILE_SCOPE(RPI, "m_srgCallback"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "ShaderResourceGroupCallback: SrgCallback"); // Set values for scene srg if (m_srg && m_srgCallback) @@ -484,7 +484,7 @@ namespace AZ } { - AZ_PROFILE_SCOPE(AzRender, "CollectDrawPackets"); + AZ_PROFILE_SCOPE(RPI, "CollectDrawPackets"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "CollectDrawPackets"); AZ::JobCompletion* collectDrawPacketsCompletion = aznew AZ::JobCompletion(); @@ -534,7 +534,7 @@ namespace AZ } { - AZ_PROFILE_BEGIN(AzRender, "FinalizeDrawLists"); + AZ_PROFILE_BEGIN(RPI, "FinalizeDrawLists"); AZ_ATOM_PROFILE_TIME_GROUP_REGION("RPI", "FinalizeDrawLists"); if (jobPolicy == RHI::JobPolicy::Serial) { @@ -542,7 +542,7 @@ namespace AZ { view->FinalizeDrawLists(); } - AZ_PROFILE_END(); + AZ_PROFILE_END(RPI); } else { @@ -558,7 +558,7 @@ namespace AZ finalizeDrawListsJob->SetDependent(finalizeDrawListsCompletion); finalizeDrawListsJob->Start(); } - AZ_PROFILE_END(); + AZ_PROFILE_END(RPI); WaitAndCleanCompletionJob(finalizeDrawListsCompletion); } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Metrics/ShaderMetricsSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Metrics/ShaderMetricsSystem.cpp index 8df5648432..9e633077e7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Metrics/ShaderMetricsSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Metrics/ShaderMetricsSystem.cpp @@ -113,7 +113,7 @@ namespace AZ return; } - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); AZStd::lock_guard lock(m_metricsMutex); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp index f6dcd02804..3b546d192a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Shader/Shader.cpp @@ -297,7 +297,7 @@ namespace AZ const ShaderVariant& Shader::GetVariant(const ShaderVariantId& shaderVariantId) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); Data::Asset shaderVariantAsset = m_asset->GetVariant(shaderVariantId, m_supervariantIndex); if (!shaderVariantAsset || shaderVariantAsset->IsRootVariant()) { @@ -314,14 +314,14 @@ namespace AZ ShaderVariantSearchResult Shader::FindVariantStableId(const ShaderVariantId& shaderVariantId) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); ShaderVariantSearchResult variantSearchResult = m_asset->FindVariantStableId(shaderVariantId); return variantSearchResult; } const ShaderVariant& Shader::GetVariant(ShaderVariantStableId shaderVariantStableId) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); if (!shaderVariantStableId.IsValid() || shaderVariantStableId == ShaderAsset::RootShaderVariantStableId) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp index f1f25e3303..436aa0d538 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/View.cpp @@ -237,7 +237,7 @@ namespace AZ void View::FinalizeDrawLists() { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); m_drawListContext.FinalizeLists(); SortFinalizedDrawLists(); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp index e1da50d2fb..8230c57e15 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Model/ModelAsset.cpp @@ -96,7 +96,7 @@ namespace AZ const AZ::Vector3& rayStart, const AZ::Vector3& rayDir, bool allowBruteForce, float& distanceNormalized, AZ::Vector3& normal) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); if (!m_modelTriangleCount) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp index adeb564675..25fe2a566e 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderAsset.cpp @@ -172,7 +172,7 @@ namespace AZ Data::Asset ShaderAsset::GetVariant( const ShaderVariantId& shaderVariantId, SupervariantIndex supervariantIndex) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); auto variantFinder = AZ::Interface::Get(); AZ_Assert(variantFinder, "The IShaderVariantFinder doesn't exist"); @@ -189,7 +189,7 @@ namespace AZ ShaderVariantSearchResult ShaderAsset::FindVariantStableId(const ShaderVariantId& shaderVariantId) { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); uint32_t dynamicOptionCount = aznumeric_cast(GetShaderOptionGroupLayout()->GetShaderOptions().size()); ShaderVariantSearchResult variantSearchResult{RootShaderVariantStableId, dynamicOptionCount }; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp index b4a0e2e068..f17a144adb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Reflect/Shader/ShaderVariantTreeAsset.cpp @@ -72,7 +72,7 @@ namespace AZ ShaderVariantSearchResult ShaderVariantTreeAsset::FindVariantStableId(const ShaderOptionGroupLayout* shaderOptionGroupLayout, const ShaderVariantId& shaderVariantId) const { - AZ_PROFILE_FUNCTION(AzRender); + AZ_PROFILE_FUNCTION(RPI); struct NodeToVisit { diff --git a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h index 33f237e919..31c1bc6715 100644 --- a/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h +++ b/Gems/Atom/RPI/Code/Tests.Builders/BuilderTestFixture.h @@ -49,7 +49,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} // The functions we need to implement. diff --git a/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h b/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h index 63a5865afa..ee3ad94d4f 100644 --- a/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h +++ b/Gems/Atom/RPI/Code/Tests/Common/AssetManagerTestFixture.h @@ -47,7 +47,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} AZ::SerializeContext* GetSerializeContext() override { diff --git a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp index ff56300b85..3122ddcbd3 100644 --- a/Gems/AudioSystem/Code/Source/Engine/ATL.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/ATL.cpp @@ -13,6 +13,7 @@ #include #endif // !AUDIO_RELEASE +#include #include #include diff --git a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp index af1dfedfaa..dfe34fb6eb 100644 --- a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp +++ b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.cpp @@ -17,7 +17,6 @@ #include #include - namespace Audio { extern CAudioLogger g_audioLogger; diff --git a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.h b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.h index da3b8053b5..1d8f8fb286 100644 --- a/Gems/AudioSystem/Code/Source/Engine/AudioSystem.h +++ b/Gems/AudioSystem/Code/Source/Engine/AudioSystem.h @@ -13,6 +13,7 @@ #include #include +#include #include #include @@ -22,6 +23,8 @@ #define PROVIDE_GETNAME_SUPPORT +AZ_DECLARE_BUDGET(Audio); + namespace Audio { // Forward declarations. diff --git a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp index ec6e7bbbb9..9b61ee0dbe 100644 --- a/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastFamilyComponent.cpp @@ -187,7 +187,7 @@ namespace Blast void BlastFamilyComponent::Activate() { - AZ_PROFILE_FUNCTION(System); + AZ_PROFILE_FUNCTION(Physics); AZ_Assert(m_blastAsset.GetId().IsValid(), "BlastFamilyComponent created with invalid blast asset."); @@ -199,7 +199,7 @@ namespace Blast void BlastFamilyComponent::Deactivate() { - AZ_PROFILE_FUNCTION(System); + AZ_PROFILE_FUNCTION(Physics); // cleanup collision handlers for (auto& itr : m_collisionHandlers) diff --git a/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp b/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp index 711d3a0087..851cb4460b 100644 --- a/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp +++ b/Gems/Blast/Code/Source/Components/BlastSystemComponent.cpp @@ -112,7 +112,7 @@ namespace Blast void BlastSystemComponent::Activate() { - AZ_PROFILE_FUNCTION(System); + AZ_PROFILE_FUNCTION(Physics); auto blastAssetHandler = aznew BlastAssetHandler(); blastAssetHandler->Register(); m_assetHandlers.emplace_back(blastAssetHandler); @@ -141,7 +141,7 @@ namespace Blast void BlastSystemComponent::Deactivate() { - AZ_PROFILE_FUNCTION(System); + AZ_PROFILE_FUNCTION(Physics); CrySystemEventBus::Handler::BusDisconnect(); AZ::TickBus::Handler::BusDisconnect(); BlastSystemRequestBus::Handler::BusDisconnect(); @@ -433,7 +433,7 @@ namespace Blast void BlastSystemComponent::AZBlastProfilerCallback::zoneEnd() { - AZ_PROFILE_END(); + AZ_PROFILE_END(Physics); } static void CmdToggleBlastDebugVisualization(IConsoleCmdArgs* args) diff --git a/Gems/ExpressionEvaluation/Code/Source/ExpressionEvaluationSystemComponent.cpp b/Gems/ExpressionEvaluation/Code/Source/ExpressionEvaluationSystemComponent.cpp index c55385595b..1a72f30e7c 100644 --- a/Gems/ExpressionEvaluation/Code/Source/ExpressionEvaluationSystemComponent.cpp +++ b/Gems/ExpressionEvaluation/Code/Source/ExpressionEvaluationSystemComponent.cpp @@ -18,6 +18,8 @@ #include #include +AZ_DEFINE_BUDGET(ExpressionEvaluation); + namespace ExpressionEvaluation { namespace StructuralParsers diff --git a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp index 2f8d913d9c..647a5dedef 100644 --- a/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp +++ b/Gems/LmbrCentral/Code/Tests/Builders/SliceBuilderTests.cpp @@ -313,7 +313,6 @@ namespace UnitTest const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/LyShine/Code/Source/LyShine.cpp b/Gems/LyShine/Code/Source/LyShine.cpp index 694a9665a8..a3beefe924 100644 --- a/Gems/LyShine/Code/Source/LyShine.cpp +++ b/Gems/LyShine/Code/Source/LyShine.cpp @@ -377,8 +377,6 @@ void CLyShine::SetViewportSize(AZ::Vector2 viewportSize) //////////////////////////////////////////////////////////////////////////////////////////////////// void CLyShine::Update(float deltaTimeInSeconds) { - FRAME_PROFILER(__FUNCTION__, gEnv->pSystem, PROFILE_UI); - if (!m_uiRenderer->IsReady()) { return; @@ -408,8 +406,6 @@ void CLyShine::Update(float deltaTimeInSeconds) //////////////////////////////////////////////////////////////////////////////////////////////////// void CLyShine::Render() { - FRAME_PROFILER(__FUNCTION__, gEnv->pSystem, PROFILE_UI); - if (AZ::RHI::IsNullRenderer()) { return; @@ -587,8 +583,6 @@ AZ::Vector2 CLyShine::GetUiCursorPosition() //////////////////////////////////////////////////////////////////////////////////////////////////// bool CLyShine::OnInputChannelEventFiltered(const AzFramework::InputChannel& inputChannel) { - FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION); - // disable UI inputs when console is open except for a primary release // if we ignore the primary release when there is an active interactable then it will miss its release // which leaves it in a bad state. E.g. a drag operation will be left in flight and not properly @@ -624,8 +618,6 @@ bool CLyShine::OnInputChannelEventFiltered(const AzFramework::InputChannel& inpu //////////////////////////////////////////////////////////////////////////////////////////////////// bool CLyShine::OnInputTextEventFiltered(const AZStd::string& textUTF8) { - FUNCTION_PROFILER(GetISystem(), PROFILE_ACTION); - if (gEnv->pConsole->GetStatus()) // disable UI inputs when console is open { return false; diff --git a/Gems/NvCloth/Code/Include/NvCloth/ICloth.h b/Gems/NvCloth/Code/Include/NvCloth/ICloth.h index e72c0ffe3a..6f40f06f02 100644 --- a/Gems/NvCloth/Code/Include/NvCloth/ICloth.h +++ b/Gems/NvCloth/Code/Include/NvCloth/ICloth.h @@ -8,12 +8,15 @@ #pragma once +#include #include #include #include #include +AZ_DECLARE_BUDGET(Cloth); + namespace NvCloth { class IClothConfigurator; diff --git a/Gems/NvCloth/Code/Include/NvCloth/IFabricCooker.h b/Gems/NvCloth/Code/Include/NvCloth/IFabricCooker.h index 8428500f59..14811b2ec6 100644 --- a/Gems/NvCloth/Code/Include/NvCloth/IFabricCooker.h +++ b/Gems/NvCloth/Code/Include/NvCloth/IFabricCooker.h @@ -8,11 +8,14 @@ #pragma once +#include #include #include #include +AZ_DECLARE_BUDGET(Cloth); + namespace NvCloth { //! Interface to cook particles into fabric. diff --git a/Gems/NvCloth/Code/Include/NvCloth/ITangentSpaceHelper.h b/Gems/NvCloth/Code/Include/NvCloth/ITangentSpaceHelper.h index 66ccd6a333..216dc6b4a5 100644 --- a/Gems/NvCloth/Code/Include/NvCloth/ITangentSpaceHelper.h +++ b/Gems/NvCloth/Code/Include/NvCloth/ITangentSpaceHelper.h @@ -8,10 +8,13 @@ #pragma once +#include #include #include +AZ_DECLARE_BUDGET(Cloth); + namespace NvCloth { //! Interface that provides a set of functions to diff --git a/Gems/NvCloth/Code/Source/System/Cloth.cpp b/Gems/NvCloth/Code/Source/System/Cloth.cpp index c71d1bd584..6cebebbf26 100644 --- a/Gems/NvCloth/Code/Source/System/Cloth.cpp +++ b/Gems/NvCloth/Code/Source/System/Cloth.cpp @@ -20,6 +20,8 @@ #include #include +AZ_DEFINE_BUDGET(Cloth); + namespace NvCloth { namespace Internal diff --git a/Gems/NvCloth/Code/Source/System/SystemComponent.cpp b/Gems/NvCloth/Code/Source/System/SystemComponent.cpp index 77223ba566..3d332aa13d 100644 --- a/Gems/NvCloth/Code/Source/System/SystemComponent.cpp +++ b/Gems/NvCloth/Code/Source/System/SystemComponent.cpp @@ -125,7 +125,7 @@ namespace NvCloth } else { - AZ_PROFILE_END(); + AZ_PROFILE_END(Cloth); } } }; diff --git a/Gems/PhysX/Code/Source/System/PhysXSdkCallbacks.cpp b/Gems/PhysX/Code/Source/System/PhysXSdkCallbacks.cpp index 28981722b6..c9d4041e01 100644 --- a/Gems/PhysX/Code/Source/System/PhysXSdkCallbacks.cpp +++ b/Gems/PhysX/Code/Source/System/PhysXSdkCallbacks.cpp @@ -59,7 +59,7 @@ namespace PhysX { if (!detached) { - AZ_PROFILE_END(); + AZ_PROFILE_END(Physics); } else { diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/EBusHandler.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/EBusHandler.h index decb7ae9c0..9d9830f361 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/EBusHandler.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/EBusHandler.h @@ -8,10 +8,13 @@ #pragma once +#include #include #include "Nodeable.h" +AZ_DECLARE_BUDGET(ScriptCanvas); + struct lua_State; namespace AZ diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp index 62e6369a40..4b9113d39c 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Core/Node.cpp @@ -36,6 +36,8 @@ #include //// +AZ_DECLARE_BUDGET(ScriptCanvas); + namespace NodeCpp { enum Version diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h index 9ab993fdd1..d51489d487 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Data/Data.h @@ -26,6 +26,8 @@ #include #include +AZ_DECLARE_BUDGET(ScriptCanvas); + namespace AZ { class ReflectContext; diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/RuntimeComponent.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/RuntimeComponent.cpp index 89c69ee4c5..6d652136cd 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/RuntimeComponent.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Execution/RuntimeComponent.cpp @@ -23,6 +23,8 @@ #define SCRIPT_CANVAS_RUNTIME_ASSET_CHECK #endif +AZ_DECLARE_BUDGET(ScriptCanvas); + namespace RuntimeComponentCpp { enum class RuntimeComponentVersion : unsigned int diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Internal/Nodes/StringFormatted.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Internal/Nodes/StringFormatted.cpp index 552e04a850..a943f167e1 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Internal/Nodes/StringFormatted.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Internal/Nodes/StringFormatted.cpp @@ -13,6 +13,8 @@ #include +AZ_DECLARE_BUDGET(ScriptCanvas); + namespace ScriptCanvas { namespace Nodes diff --git a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp index 241d7d2df9..5b38b640ca 100644 --- a/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp +++ b/Gems/ScriptCanvas/Code/Tests/ScriptCanvasBuilderTests.cpp @@ -91,7 +91,6 @@ protected: const char* GetAppRoot() const override { return nullptr; } const char* GetEngineRoot() const override { return nullptr; } const char* GetExecutableFolder() const override { return nullptr; } - AZ::Debug::DrillerManager* GetDrillerManager() override { return nullptr; } void EnumerateEntities(const AZ::ComponentApplicationRequests::EntityCallback& /*callback*/) override {} void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {} ////////////////////////////////////////////////////////////////////////// diff --git a/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsSystemEditorComponent.cpp b/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsSystemEditorComponent.cpp index 548f8d137a..b7586618dd 100644 --- a/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsSystemEditorComponent.cpp +++ b/Gems/ScriptEvents/Code/Source/Editor/ScriptEventsSystemEditorComponent.cpp @@ -22,6 +22,8 @@ #if defined(SCRIPTEVENTS_EDITOR) +AZ_DECLARE_BUDGET(AzToolsFramework); + namespace ScriptEventsEditor { //////////////////////////// diff --git a/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.cpp b/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.cpp index 3d8f69de10..773d5d2255 100644 --- a/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.cpp +++ b/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.cpp @@ -26,6 +26,8 @@ #include #include +AZ_DEFINE_BUDGET(ScriptCanvas); + namespace ScriptEvents { void ScriptEventsSystemComponent::Reflect(AZ::ReflectContext* context) diff --git a/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.h b/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.h index 792d337c7f..64a0e49bca 100644 --- a/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.h +++ b/Gems/ScriptEvents/Code/Source/ScriptEventsSystemComponent.h @@ -20,6 +20,8 @@ #include #include +AZ_DECLARE_BUDGET(ScriptCanvas); + namespace ScriptEvents { class ScriptEventsSystemComponent diff --git a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp index 5af3fd58b9..812ed3f0da 100644 --- a/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp +++ b/Gems/Terrain/Code/Source/TerrainRenderer/TerrainFeatureProcessor.cpp @@ -269,7 +269,7 @@ namespace Terrain void TerrainFeatureProcessor::ProcessSurfaces(const FeatureProcessor::RenderPacket& process) { - AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); + AZ_PROFILE_FUNCTION(AzRender); if (m_drawListTag.IsNull()) {