| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282 |
- #pragma once
- #include "BsPrerequisites.h"
- #include "BsComponent.h"
- #include "BsProfilerGPU.h"
- #include "BsModule.h"
- #include "BsEvent.h"
- namespace BansheeEngine
- {
- class ProfilerOverlayInternal;
- /**
- * @brief Determines type of data to display on the profiler overlay.
- */
- enum class ProfilerOverlayType
- {
- CPUSamples,
- GPUSamples
- };
- /**
- * @brief Handles rendering of Profiler information as an overlay in a viewport.
- *
- * @note Component wrapper of ProfilerOverlayInternal.
- */
- class BS_EXPORT ProfilerOverlay : public Component
- {
- public:
- /**
- * @brief Constructs a new overlay attached to the specified parent and displayed on the provided viewport.
- */
- ProfilerOverlay(const HSceneObject& parent, const CameraPtr& target);
- ~ProfilerOverlay();
- /**
- * @brief Changes the camera to display the overlay on.
- */
- void setTarget(const CameraPtr& target);
- /**
- * @brief Shows the overlay of the specified type.
- */
- void show(ProfilerOverlayType type);
- /**
- * @brief Hides the overlay.
- */
- void hide();
- /**
- * @copydoc Component::update
- */
- void update() override;
- private:
- ProfilerOverlayInternal* mInternal;
- /************************************************************************/
- /* RTTI */
- /************************************************************************/
- public:
- friend class ProfilerOverlayRTTI;
- static RTTITypeBase* getRTTIStatic();
- virtual RTTITypeBase* getRTTI() const override;
- ProfilerOverlay() { } // Serialization only
- };
- /**
- * @brief Handles rendering of Profiler information as an overlay in a viewport.
- */
- class BS_EXPORT ProfilerOverlayInternal
- {
- public:
- /**
- * @brief 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;
- };
- /**
- * @brief 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;
- };
-
- /**
- * @brief 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:
- /**
- * @brief Constructs a new overlay attached to the specified parent and displayed on the provided camera.
- */
- ProfilerOverlayInternal(const CameraPtr& target);
- ~ProfilerOverlayInternal();
- /**
- * @brief Changes the camera to display the overlay on.
- */
- void setTarget(const CameraPtr& target);
- /**
- * @brief Shows the overlay of the specified type.
- */
- void show(ProfilerOverlayType type);
- /**
- * @brief Hides the overlay.
- */
- void hide();
- /**
- * @brief Updates overlay contents. Should be called once per frame.
- */
- void update();
- private:
- /**
- * @brief Called whenever the viewport resizes in order to rearrange the GUI elements.
- */
- void targetResized();
- /**
- * @brief Updates sizes of GUI areas used for displaying CPU sample data. To be called
- * after viewport change or resize.
- */
- void updateCPUSampleAreaSizes();
- /**
- * @brief Updates sizes of GUI areas used for displaying GPU sample data. To be called
- * after viewport change or resize.
- */
- void updateGPUSampleAreaSizes();
- /**
- * @brief 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);
- /**
- * @brief 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;
- ViewportPtr mTarget;
- HSceneObject mWidgetSO;
- GameObjectHandle<CGUIWidget> 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;
- HString mGPUFrameNumStr;
- HString mGPUTimeStr;
- HString mGPUDrawCallsStr;
- HString mGPURenTargetChangesStr;
- HString mGPUPresentsStr;
- HString mGPUClearsStr;
- HString mGPUVerticesStr;
- HString mGPUPrimitivesStr;
- HString mGPUSamplesStr;
- HString mGPUBlendStateChangesStr;
- HString mGPURasterStateChangesStr;
- HString mGPUDepthStencilStateChangesStr;
- HString mGPUObjectsCreatedStr;
- HString mGPUObjectsDestroyedStr;
- HString mGPUResourceWritesStr;
- HString mGPUResourceReadsStr;
- HString mGPUTextureBindsStr;
- HString mGPUSamplerBindsStr;
- HString mGPUVertexBufferBindsStr;
- HString mGPUIndexBufferBindsStr;
- HString mGPUGPUProgramBufferBindsStr;
- HString mGPUGPUProgramBindsStr;
- Vector<BasicRow> mBasicRows;
- Vector<PreciseRow> mPreciseRows;
- Vector<GPUSampleRow> mGPUSampleRows;
- HEvent mTargetResizedConn;
- bool mIsShown;
- };
- }
|