| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266 |
- //********************************** Banshee Engine (www.banshee3d.com) **************************************************//
- //**************** Copyright (c) 2016 Marko Pintera ([email protected]). All rights reserved. **********************//
- #pragma once
- #include "BsPrerequisites.h"
- #include "Scene/BsComponent.h"
- #include "Profiling/BsProfilerGPU.h"
- #include "Utility/BsModule.h"
- #include "Utility/BsEvent.h"
- namespace bs
- {
- /** @addtogroup GUI-Internal
- * @{
- */
- class ProfilerOverlayInternal;
- /** Determines type of data to display on the profiler overlay. */
- enum class ProfilerOverlayType
- {
- CPUSamples,
- GPUSamples
- };
- /**
- * Handles rendering of Profiler information as an overlay in a viewport.
- *
- * @note Component wrapper of ProfilerOverlayInternal.
- */
- class BS_EXPORT CProfilerOverlay : public Component
- {
- public:
- /** Constructs a new overlay attached to the specified parent and displayed on the provided viewport. */
- CProfilerOverlay(const HSceneObject& parent, const SPtr<Camera>& target);
- ~CProfilerOverlay();
- /** Changes the camera to display the overlay on. */
- void setTarget(const SPtr<Camera>& target);
- /** Shows the overlay of the specified type. */
- void show(ProfilerOverlayType type);
- /** Hides the overlay. */
- void hide();
- /** @copydoc Component::update */
- void update() override;
- private:
- ProfilerOverlayInternal* mInternal;
- /************************************************************************/
- /* RTTI */
- /************************************************************************/
- public:
- friend class ProfilerOverlayRTTI;
- static RTTITypeBase* getRTTIStatic();
- RTTITypeBase* getRTTI() const override;
- CProfilerOverlay(); // Serialization only
- };
- /** Handles rendering of Profiler information as an overlay in a viewport. */
- class BS_EXPORT ProfilerOverlayInternal
- {
- public:
- /** Holds data about GUI elements in a single row of a "CPU basic" sample. */
- struct BasicRow
- {
- GUILayout* labelLayout;
- GUILayout* contentLayout;
- GUIFixedSpace* labelSpace;
- GUILabel* guiName;
- GUILabel* guiPctOfParent;
- GUILabel* guiNumCalls;
- GUILabel* guiNumAllocs;
- GUILabel* guiNumFrees;
- GUILabel* guiAvgTime;
- GUILabel* guiTotalTime;
- GUILabel* guiAvgTimeSelf;
- GUILabel* guiTotalTimeSelf;
- HString name;
- HString pctOfParent;
- HString numCalls;
- HString numAllocs;
- HString numFrees;
- HString avgTime;
- HString totalTime;
- HString avgTimeSelf;
- HString totalTimeSelf;
- bool disabled;
- };
- /** Holds data about GUI elements in a single row of a "CPU precise" sample. */
- struct PreciseRow
- {
- GUILayout* labelLayout;
- GUILayout* contentLayout;
- GUIFixedSpace* labelSpace;
- GUILabel* guiName;
- GUILabel* guiPctOfParent;
- GUILabel* guiNumCalls;
- GUILabel* guiNumAllocs;
- GUILabel* guiNumFrees;
- GUILabel* guiAvgCycles;
- GUILabel* guiTotalCycles;
- GUILabel* guiAvgCyclesSelf;
- GUILabel* guiTotalCyclesSelf;
- HString name;
- HString pctOfParent;
- HString numCalls;
- HString numAllocs;
- HString numFrees;
- HString avgCycles;
- HString totalCycles;
- HString avgCyclesSelf;
- HString totalCyclesSelf;
- bool disabled;
- };
-
- /** Holds data about GUI elements in a single row of a GPU sample. */
- struct GPUSampleRow
- {
- GUILayout* layout;
- GUILabel* guiName;
- GUILabel* guiTime;
- HString name;
- HString time;
- bool disabled;
- };
- public:
- /** Constructs a new overlay attached to the specified parent and displayed on the provided camera. */
- ProfilerOverlayInternal(const SPtr<Camera>& target);
- ~ProfilerOverlayInternal();
- /** Changes the camera to display the overlay on. */
- void setTarget(const SPtr<Camera>& target);
- /** Shows the overlay of the specified type. */
- void show(ProfilerOverlayType type);
- /** Hides the overlay. */
- void hide();
- /** Updates overlay contents. Should be called once per frame. */
- void update();
- private:
- /** Called whenever the viewport resizes in order to rearrange the GUI elements. */
- void targetResized();
- /** Updates sizes of GUI areas used for displaying CPU sample data. To be called after viewport change or resize. */
- void updateCPUSampleAreaSizes();
- /** Updates sizes of GUI areas used for displaying GPU sample data. To be called after viewport change or resize. */
- void updateGPUSampleAreaSizes();
- /**
- * Updates CPU GUI elements from the data in the provided profiler reports. To be called whenever a new report is
- * received.
- */
- void updateCPUSampleContents(const ProfilerReport& simReport, const ProfilerReport& coreReport);
- /**
- * Updates GPU GUI elemnts from the data in the provided profiler report. To be called whenever a new report is
- * received.
- */
- void updateGPUSampleContents(const GPUProfilerReport& gpuReport);
- static const UINT32 MAX_DEPTH;
- ProfilerOverlayType mType;
- SPtr<Viewport> mTarget;
- HSceneObject mWidgetSO;
- HGUIWidget mWidget;
- GUILayout* mBasicLayoutLabels = nullptr;
- GUILayout* mPreciseLayoutLabels = nullptr;
- GUILayout* mBasicLayoutContents = nullptr;
- GUILayout* mPreciseLayoutContents = nullptr;
- GUIElement* mTitleBasicName = nullptr;
- GUIElement* mTitleBasicPctOfParent = nullptr;
- GUIElement* mTitleBasicNumCalls = nullptr;
- GUIElement* mTitleBasicNumAllocs = nullptr;
- GUIElement* mTitleBasicNumFrees = nullptr;
- GUIElement* mTitleBasicAvgTime = nullptr;
- GUIElement* mTitleBasicTotalTime = nullptr;
- GUIElement* mTitleBasicAvgTitleSelf = nullptr;
- GUIElement* mTitleBasicTotalTimeSelf = nullptr;
- GUIElement* mTitlePreciseName = nullptr;
- GUIElement* mTitlePrecisePctOfParent = nullptr;
- GUIElement* mTitlePreciseNumCalls = nullptr;
- GUIElement* mTitlePreciseNumAllocs = nullptr;
- GUIElement* mTitlePreciseNumFrees = nullptr;
- GUIElement* mTitlePreciseAvgCycles = nullptr;
- GUIElement* mTitlePreciseTotalCycles = nullptr;
- GUIElement* mTitlePreciseAvgCyclesSelf = nullptr;
- GUIElement* mTitlePreciseTotalCyclesSelf = nullptr;
- GUILayout* mGPULayoutFrameContents = nullptr;
- GUILayout* mGPULayoutFrameContentsLeft = nullptr;
- GUILayout* mGPULayoutFrameContentsRight = nullptr;
- GUILayout* mGPULayoutSamples = nullptr;
- GUILayout* mGPULayoutSampleContents = nullptr;
- GUILabel* mGPUFrameNumLbl;
- GUILabel* mGPUTimeLbl;
- GUILabel* mGPUDrawCallsLbl;
- GUILabel* mGPURenTargetChangesLbl;
- GUILabel* mGPUPresentsLbl;
- GUILabel* mGPUClearsLbl;
- GUILabel* mGPUVerticesLbl;
- GUILabel* mGPUPrimitivesLbl;
- GUILabel* mGPUSamplesLbl;
- GUILabel* mGPUPipelineStateChangesLbl;
- GUILabel* mGPUObjectsCreatedLbl;
- GUILabel* mGPUObjectsDestroyedLbl;
- GUILabel* mGPUResourceWritesLbl;
- GUILabel* mGPUResourceReadsLbl;
- GUILabel* mGPUParamBindsLbl;
- GUILabel* mGPUVertexBufferBindsLbl;
- GUILabel* mGPUIndexBufferBindsLbl;
- HString mGPUFrameNumStr;
- HString mGPUTimeStr;
- HString mGPUDrawCallsStr;
- HString mGPURenTargetChangesStr;
- HString mGPUPresentsStr;
- HString mGPUClearsStr;
- HString mGPUVerticesStr;
- HString mGPUPrimitivesStr;
- HString mGPUSamplesStr;
- HString mGPUPipelineStateChangesStr;
- HString mGPUObjectsCreatedStr;
- HString mGPUObjectsDestroyedStr;
- HString mGPUResourceWritesStr;
- HString mGPUResourceReadsStr;
- HString mGPUParamBindsStr;
- HString mGPUVertexBufferBindsStr;
- HString mGPUIndexBufferBindsStr;
- Vector<BasicRow> mBasicRows;
- Vector<PreciseRow> mPreciseRows;
- Vector<GPUSampleRow> mGPUSampleRows;
- HEvent mTargetResizedConn;
- bool mIsShown;
- };
- /** @} */
- }
|