OROCHI
 
Loading...
Searching...
No Matches
GxToolMemory.h
Go to the documentation of this file.
1//===========================================================================
10//===========================================================================
11#pragma once
12
13#if GX_DEVELOP
14GX_CORE_NAMESPACE_BEGIN()
15
16class GxGuiFormProperty;
17class GxGuiSplitter;
18class GxGuiSplitterCross;
19
20//===========================================================================
23//===========================================================================
24/* GUI内訳
25 ┏GxToolMemory━━━━━━━━━━━━━━━━━━━━━━━━┓
26 ┃ ┃
27 ┃┌GxGuiSplitter _pSplitterCircleBar ───────────┐┃
28 ┃│┏GxGuiSplitter ━━━━━━━━━━━━━━━━━━━┓│┃
29 ┃│┃┌GxGuiBarGraphForm ───────────────┐┃│┃
30 ┃│┃│┏GxGuiSplitterCross _pSplitterBarGraph ━━━┓│┃│┃
31 ┃│┃│┃┌GxGuiBarGraphName ┐┃┌GxGuiBarGraphBar┐┃│┃│┃
32 ┃│┃│┃│ │┃│ │┃│┃│┃
33 ┃│┃│┃└─────────┘┃└────────┘┃│┃│┃
34 ┃│┃│┣━━━━━━━━━━━╋━━━━━━━━━━┫│┃│┃
35 ┃│┃│┃┌GxGuiBarGraphName ┐┃┌GxGuiBarGraphBar┐┃│┃│┃
36 ┃│┃│┃│ │┃│ │┃│┃│┃
37 ┃│┃│┃└─────────┘┃└────────┘┃│┃│┃
38 ┃│┃│┣━━━━━━━━━━━╋━━━━━━━━━━┫│┃│┃
39 ┃│┃│┃┌GxGuiBarGraphName ┐┃┌GxGuiBarGraphBar┐┃│┃│┃
40 ┃│┃│┃│ │┃│ │┃│┃│┃
41 ┃│┃│┃└─────────┘┃└────────┘┃│┃│┃
42 ┃│┃│┗━━━━━━━━━━━┻━━━━━━━━━━┛│┃│┃
43 ┃│┃└────────────────────────┘┃│┃
44 ┃│┣━━━━━━━━━━━━━━━━━━━━━━━━━━┫│┃
45 ┃│┃┌GxGuiBarGraphHelp ───────────────┐┃│┃
46 ┃│┃│ │┃│┃
47 ┃│┃└────────────────────────┘┃│┃
48 ┃│┗━━━━━━━━━━━━━━━━━━━━━━━━━━┛│┃
49 ┃└────────────────────────────┘┃
50 ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛
51*/
52class GxToolMemory : public GxToolBase
53{
54 //-------------------------------------------------------------
56 //-------------------------------------------------------------
58private:
59 class GxGuiCircleGraph;
60 class GxGuiLineGraphForm;
61 class GxGuiBarGraphName;
62 class GxGuiBarGraphForm;
63 class GxGuiBarGraphBar;
64 class GxGuiBarGraphHelp;
65public:
66 // RTTI定義
67 GX_RTTI_CLASS_NAME_ICON( GxToolMemory, GxToolBase, "メモリ管理", GxRtti::ICON_TYPE::CORE )
68 // ClassBaseReference継承クラス用禁止宣言
70 // new, delete定義
71 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
72
73
74 static constexpr u32 CIRCLE_SIZE = 0;
76 static constexpr u32 FORM_WIDTH = 800;
78 static constexpr u32 FORM_HEIGHT = 615;
80 static constexpr u32 FORM_MIN_HEIGHT = 330;
82 static constexpr u32 NAME_WIDTH = 200;
84 static constexpr u32 DRAW_LEFT_X = 10;
86 static constexpr u32 DRAW_LEFT_Y = 10;
88 static constexpr u32 DRAW_WIDTH = FORM_WIDTH - DRAW_LEFT_X * 2 - NAME_WIDTH - CIRCLE_SIZE;
90 static constexpr u32 BAR_DRAW_HEIGHT = 15;
92 static constexpr u32 BAR_FRAME_HEIGHT = 16 ;
94 static constexpr u32 DEFAULT_SPLIT_POSITION = 600;
96 static const GxColor MEMORY_HARD_COLOR;
98 static const GxColor MEMORY_TOTAL_COLOR;
100 static const GxColor MEMORY_VRAM_COLOR;
102 static const GxColor MEMORY_MAIN_COLOR;
103
105 enum class BLOCK_STATE
106 {
107 UNKNOWN = 0,
108 USER,
109 FREE,
110 MANAGED,
111 MAX,
112 };
113
115 static const GxColor BLOCK_COLOR[static_cast<s32>(BLOCK_STATE::MAX)];
117 static GX_CSTR BLOCK_NAME[static_cast<s32>(BLOCK_STATE::MAX)];
118
120 enum class TYPE_INFO
121 {
122 ALLOCATOR = 0,
123 HARD = static_cast<s32>(GxAllocatorList::ALLOCATOR_TYPE::MAX),
124 TOTAL,
125 VRAM,
126 MAIN,
127 MAX
128 };
129
131 //-------------------------------------------------------------
133 //-------------------------------------------------------------
135
137 GxToolMemory( void );
138
140 b32 initialize( void ) override;
141
143 //-------------------------------------------------------------
145 //-------------------------------------------------------------
147protected:
149 void update(void) override;
151 void addMenuFilePropertyExtra(GxPropertyTable& table) override;
152
154 void addMenuOwnProperty(GxPropertyTable& table) override;
155
157 void onViewMaxExpand(void) override;
158
160 virtual void onViewMiddleExpand(void);
161
163 void onViewMinExpand(void) override;
164
166 b32 addGraphBar(TYPE_INFO type, GX_CSTR name);
167
169 void dumpToCsvEvent(void);
170
172 void clearUsedSizeMax(void);
174 void setUsedSizeDiff(void);
175
176public:
179 static void dumpToCsv(void);
180
182 static void mappingFillAll(u8* pBuffer, u32 bufferSize, u8 no);
183
185 static void mappingNoFromOffset(u8* pBuffer, u32 bufferSize, u64 minOffset, u64 maxOffset, u64 leftValue, u64 rightValue, u8 no, b32 usePriority = true);
186
188 static void drawBarFromMap(const GxRect& rect, u8* pBuffer, u32 bufferSize, const GxColor* pColorTable);
189
191 //-------------------------------------------------------------
193 //-------------------------------------------------------------
195
197 static void getHeapInformation( const GxAllocator* pAllocator,GxString& message );
198
200 static void getHardMemoryInformation( GxString& message );
201
203 static void getTotalMemoryInformation( GxString& message );
204
206 static void getHeapInformationDetail( GxString& message, const GxAllocatorHeap::GxHeapInformation* pInformation );
207
209 static u32 getHeaderSize( const GxAllocatorHeap::GxHeapInformation* pInformation);
210
212 static u32 getUserSize( const GxAllocatorHeap::GxHeapInformation* pInformation);
213
215 static u32 getFreeSize( const GxAllocatorHeap::GxHeapInformation* pInformation);
216
218 static u64 getMemorySizeWithoutGPU(void);
219
221 GxGuiBarGraphBar* getBarGraphBar( const u32 index );
222
224 GX_FORCE_INLINE b32 isBarDrawRate( void ) const { return _isBarDrawRate; }
225
227 u64 getAllocatorMaxSize( void ) const;
228
230 constexpr GxGuiSplitter* getSplitterBarAttr(void) const { return _pSplitterBarAttr; }
231
233 //-------------------------------------------------------------
235 //-------------------------------------------------------------
237private:
238 GxGuiSplitter* _pSplitterBarMain;
239 GxGuiSplitterCross* _pSplitterBarGraph;
240 GxGuiSplitter* _pSplitterBarAttr;
241 b32 _isBarDrawRate;
242
244};
245
246//===========================================================================
248//===========================================================================
249class GxToolMemory::GxGuiLineGraphForm : public GxGuiForm
250{
251 //-------------------------------------------------------------
253 //-------------------------------------------------------------
255public:
256 // RTTI定義
257 GX_RTTI_CLASS_NAME( GxGuiLineGraphForm, GxGuiForm, "ヒープアロケータ折れ線グラフ" )
258 // ClassBaseReference継承クラス用禁止宣言
259 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiLineGraphForm )
260
262 static constexpr u32 ALLOCATOR_MAX_COUNT = GxMath::VALUE_16;
263
265 //-------------------------------------------------------------
267 //-------------------------------------------------------------
269private:
271 GxGuiLineGraphForm( void ){}
272public:
274 GxGuiLineGraphForm( GxToolMemory* pTool );
276 b32 initialize( void ) override;
277
279 //-------------------------------------------------------------
281 //-------------------------------------------------------------
283
285 void onDraw( void ) override;
286
288 //-------------------------------------------------------------
290 //-------------------------------------------------------------
292private:
293 GxToolMemory* _pTool;
294 GxGuiGraphTime* _pGraph;
295 u32 _plotValueArray[ALLOCATOR_MAX_COUNT];
296
298};
299
300//===========================================================================
303//===========================================================================
304class GxToolMemory::GxGuiBarGraphForm : public GxGuiForm
305{
306 //-------------------------------------------------------------
308 //-------------------------------------------------------------
310public:
311 // RTTI定義
312 GX_RTTI_CLASS( GxToolMemory::GxGuiBarGraphForm, GxGuiForm )
313 // ClassBaseReference継承クラス用禁止宣言
314 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiBarGraphForm )
315 // new, delete定義
316 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
317
318
319 //-------------------------------------------------------------
321 //-------------------------------------------------------------
323
325 GxGuiBarGraphForm( void );
326
328};
329
330//===========================================================================
333//===========================================================================
334class GxToolMemory::GxGuiBarGraphName : public GxGuiForm
335{
336 //-------------------------------------------------------------
338 //-------------------------------------------------------------
340public:
341 // RTTI定義
342 GX_RTTI_CLASS( GxToolMemory::GxGuiBarGraphName, GxGuiForm )
343 // new, delete定義
344 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
345 // ClassBaseReference継承クラス用禁止宣言
346 GX_PROHIBIT_CLASS_BASE_REFERENCE(GxGuiBarGraphName)
347
348
349 //-------------------------------------------------------------
351 //-------------------------------------------------------------
353
355 GxGuiBarGraphName( void );
357 GxGuiBarGraphName( GxAllocatorList* pAllocatorList, GX_CSTR pName, const f32 captionSizeRate = 0.0f , GxToolMemory* pTool = nullptr);
359 GxGuiBarGraphName( GxToolMemory::TYPE_INFO typeInfo, GX_CSTR pName, const f32 captionSizeRate = 0.0f , GxToolMemory* pTool = nullptr);
361 b32 initialize( void ) override;
362
364 //-------------------------------------------------------------
366 //-------------------------------------------------------------
368
370 constexpr void setCaptionSizeRate(const f32 captionSizeRate){ _captionSizeRate = captionSizeRate; };
371
373 //-------------------------------------------------------------
375 //-------------------------------------------------------------
377protected:
379 void onDraw( void ) override;
380
382 void onMouseHover( const GxPoint2& position ) override;
383
384private:
386 void createToolHeapInformation( void );
387
389 //-------------------------------------------------------------
391 //-------------------------------------------------------------
393
394 GxAllocatorList* _pAllocatorList;
395 GxString _name;
396 f32 _captionSizeRate;
397 GxToolMemory::TYPE_INFO _typeInfo;
398 GxToolMemory* _pTool;
399 GxGuiButton* _pButton;
400
402};
403
404//===========================================================================
407//===========================================================================
408// todo:あるいはボタンを使う?
409class GxToolMemory::GxGuiBarGraphBar : public GxGuiBase
410{
411 //-------------------------------------------------------------
413 //-------------------------------------------------------------
415public:
416 // RTTI定義
417 GX_RTTI_CLASS( GxToolMemory::GxGuiBarGraphBar, GxGuiBase )
418 // new, delete定義
419 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
420 // ClassBaseReference継承クラス用禁止宣言
421 GX_PROHIBIT_CLASS_BASE_REFERENCE(GxGuiBarGraphBar)
422
423
424 //-------------------------------------------------------------
426 //-------------------------------------------------------------
428
430 GxGuiBarGraphBar( void );
432 GxGuiBarGraphBar( GxToolMemory* pTool, GxAllocatorList* pAllocatorList );
434 GxGuiBarGraphBar( GxToolMemory* pTool, GxToolMemory::TYPE_INFO typeInfo );
435
437 b32 initialize( void ) override;
439 void cleanup( void ) override;
440
442 //-------------------------------------------------------------
444 //-------------------------------------------------------------
446
448 void onDraw( void ) override;
449
451 void onMouseHover( const GxPoint2& position ) override;
452
453private:
455 void createBarTable( u32 width );
456
458 //-------------------------------------------------------------
460 //-------------------------------------------------------------
462
463 GxToolMemory* _pTool;
464 GxToolMemory::TYPE_INFO _typeInfo;
465 GxAllocatorList* _pAllocatorList;
466 u8* _pColorType;
467 u32 _tableSize;
468 GxArrayClassBase _allocatorArray;
469
471};
472
473//===========================================================================
476//===========================================================================
477class GxToolMemory::GxGuiBarGraphHelp : public GxGuiForm
478{
479 //-------------------------------------------------------------
481 //-------------------------------------------------------------
483public:
484 // RTTI定義
485 GX_RTTI_CLASS( GxToolMemory::GxGuiBarGraphHelp, GxGuiForm )
486 // new, delete定義
487 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
488 // ClassBaseReference継承クラス用禁止宣言
489 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiBarGraphHelp )
490
491
492 static const f32 SCALE_MINIMUM;
493
495 //-------------------------------------------------------------
497 //-------------------------------------------------------------
499
501 GxGuiBarGraphHelp( void );
502
504 //-------------------------------------------------------------
506 //-------------------------------------------------------------
508
510 void onDraw( void ) override;
511
513};
514
515//===========================================================================
517//===========================================================================
518class GxToolMemory::GxGuiCircleGraph : public GxGuiBase
519{
520 //-------------------------------------------------------------
522 //-------------------------------------------------------------
524public:
525 // RTTI定義
526 GX_RTTI_CLASS( GxToolMemory::GxGuiCircleGraph, GxGuiBase )
527 // new, delete定義
528 GX_OPERATOR_NEW_DELETE(GxAllocatorList::ALLOCATOR_TYPE::DEVELOP)
529 // ClassBaseReference継承クラス用禁止宣言
530 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiCircleGraph )
531
532
533 static constexpr u32 ALLOCATOR_MAX = GxMath::VALUE_32;
534
536 //-------------------------------------------------------------
538 //-------------------------------------------------------------
540
542 GxGuiCircleGraph( void );
543
545 //-------------------------------------------------------------
547 //-------------------------------------------------------------
549
551 void onDraw(void) override;
552
554 void addAllocatorList( GxAllocatorList* pAllocatorList );
555
557 //-------------------------------------------------------------
559 //-------------------------------------------------------------
561private:
562 GxAllocatorList* _pAllocatorList[ALLOCATOR_MAX];
563 u32 _numAllocator;
564
566};
567
568//===========================================================================
570//===========================================================================
571/* GUI内訳
572 ┏GxToolAllocatorHeap ━━━━━━┓
573 ┃┌GxGuiAllocatorHeapBarTotal─┐┃
574 ┃└──────────────┘┃
575 ┃┌GxGuiAllocatorHeapBar ───┐┃
576 ┃└──────────────┘┃
577 ┗━━━━━━━━━━━━━━━━┛
578*/
579class GxToolAllocatorHeap : public GxGuiForm
580{
581 //-------------------------------------------------------------
583 //-------------------------------------------------------------
585public:
586 // RTTI定義
587 GX_RTTI_CLASS_NAME( GxToolAllocatorHeap, GxGuiForm, "ヒープアロケータ詳細情報" )
588 // ClassBaseReference継承クラス用禁止宣言
589 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxToolAllocatorHeap )
590
592 enum class TYPE_OUTPUT
593 {
594 TEXT,
595 CSV
596 };
597
599 enum class TYPE_HEAP_INFOMATION_POS
600 {
601 HEADER = 0,
602 USER,
603 FREE
604 };
605
606 // インナークラス
607 class GxGuiAllocatorHeapBarTotal;
608 class GxGuiAllocatorHeapBar;
609
611 //-------------------------------------------------------------
613 //-------------------------------------------------------------
615
617 GxToolAllocatorHeap( void );
618
620 GxToolAllocatorHeap( GxAllocator* pAllocator );
621
623 b32 initialize( void ) override;
624
626 //-------------------------------------------------------------
628 //-------------------------------------------------------------
630public:
632 constexpr GxAllocator* getAllocater( void ) const { return _pAllocator; }
633
635 void setSelectedOffset( s32 selectedOffset, b32 isForce = false );
637 GX_FORCE_INLINE void setSelectedWidthRatio( f32 selectedWidthRatio ){ _selectedWidthRatio = GxMath::getClamp( selectedWidthRatio, 0.1f, 4096.f ); }
640 constexpr s32 getSelectedOffset( void ) const { return _selectedOffset; }
642 constexpr s32 getSelectedTargetOffset( void ) const { return _selectedTargetOffset; }
645 GX_FORCE_INLINE s32 getSelectedWidth( void ) const { return static_cast<s32>( static_cast<f32>( getClientRegion().getWidth() ) * _selectedWidthRatio ); }
647 constexpr f32 getSelectedWidthRatio( void ) const { return _selectedWidthRatio; }
649 GX_FORCE_INLINE b32 isDispSize( void ) const { return _isDisplaySize; }
651 GX_FORCE_INLINE b32 isDispFileName( void ) const { return _isDisplayFileName; }
653 static void drawScale( const GxRect& rect, u32 min, u32 max );
654
655 // 指定位置のヒープ情報取得
656 const GxAllocatorHeap::GxHeapInformation* getHeapAllocatorInfomation( s32 offset, TYPE_HEAP_INFOMATION_POS& type ) const;
657
658protected:
660 void goPreviousHeapInfo( void );
662 void goNextHeapInfo( void );
664 constexpr void resetRatio( void ){ _selectedWidthRatio = 1.f; }
666 void outputHeapInfo( s32 typeOutput );
667
669 //-------------------------------------------------------------
671 //-------------------------------------------------------------
673private:
675 virtual void addMenuOwnProperty(GxPropertyTable& table);
677 void onKeyPress( GxKeyboard::KEY key ) override;
679 void onMouseWheel( const GxPoint2& position, s32 rotate ) override;
680
682 void update( void ) override;
683
685 void updateTargetHeapInfomation( void );
686
688 //-------------------------------------------------------------
690 //-------------------------------------------------------------
692private:
693 GxAllocator* _pAllocator;
694 GxGuiSplitterCross* _pGuiSplitterCross;
695
696 s32 _selectedOffset;
697
698 s32 _selectedTargetOffset;
699 f32 _selectedWidthRatio;
700
701 b32 _isDisplaySize;
702 b32 _isDisplayFileName;
703
705};
706
707//===========================================================================
709//===========================================================================
710class GxToolAllocatorHeap::GxGuiAllocatorHeapBarTotal : public GxGuiBase
711{
712 //-------------------------------------------------------------
714 //-------------------------------------------------------------
716public:
717 // RTTI定義
718 GX_RTTI_CLASS( GxGuiAllocatorHeapBarTotal, GxGuiBase )
719 // ClassBaseReference継承クラス用禁止宣言
720 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiAllocatorHeapBarTotal )
721
722
723 //-------------------------------------------------------------
725 //-------------------------------------------------------------
727
729 GxGuiAllocatorHeapBarTotal( void );
730
732 GxGuiAllocatorHeapBarTotal( GxToolAllocatorHeap* pTool );
733
735 void cleanup(void) override;
736
738 //-------------------------------------------------------------
740 //-------------------------------------------------------------
742protected:
744 void update( void ) override;
746 void onDraw( void ) override;
748 void onMouseDown( const GxPoint2& position, u32 button ) override;
750 void onSize( const GxSize& size ) override;
752 void onMouseHover( const GxPoint2& position ) override;
753
754 // 棒表示の領域作成
755 void createBarTable( u32 width );
756
758 //-------------------------------------------------------------
760 //-------------------------------------------------------------
762private:
763 GxToolAllocatorHeap* _pTool;
764 b32 _onMoveRange;
765
766 u8* _pColorType;
767 u32 _tableSize;
768
770};
771
772//===========================================================================
774//===========================================================================
775class GxToolAllocatorHeap::GxGuiAllocatorHeapBar : public GxGuiBase
776{
777 //-------------------------------------------------------------
779 //-------------------------------------------------------------
781public:
782 // RTTI定義
783 GX_RTTI_CLASS( GxGuiAllocatorHeapBar, GxGuiBase )
784 // ClassBaseReference継承クラス用禁止宣言
785 GX_PROHIBIT_CLASS_BASE_REFERENCE( GxGuiAllocatorHeapBar )
786
787
788 //-------------------------------------------------------------
790 //-------------------------------------------------------------
792
794 GxGuiAllocatorHeapBar( void );
795
797 GxGuiAllocatorHeapBar( GxToolAllocatorHeap* pTool );
798
800 void cleanup(void) override;
801
803 //-------------------------------------------------------------
805 //-------------------------------------------------------------
807
809 void update( void ) override;
811 void onDraw( void ) override;
812
814 void onMouseWheel( const GxPoint2& position, s32 rotate ) override;
815
817 void onMouseDown( const GxPoint2& position, u32 button ) override;
818
820 void onClick( const GxPoint2& position, u32 button ) override;
821
823 void onDoubleClick( const GxPoint2& position, u32 button ) override;
824
826 void onSize( const GxSize& size ) override;
827
829 void onMouseHover( const GxPoint2& position ) override;
830
831protected:
833 void outputFileName( void* pObject );
834
836 void createBarTable( u32 width );
837
839 //-------------------------------------------------------------
841 //-------------------------------------------------------------
843private:
844 GxToolAllocatorHeap* _pTool;
845 b32 _mouseDown;
846 s32 _mouseDownOffset;
847
848 u8* _pColorType;
849 u32 _tableSize;
850
852};
853
854GX_CORE_NAMESPACE_END()
855#endif // GX_DEVELOP
#define GX_PROHIBIT_CLASS_BASE_REFERENCE(__CLASS__)
GxClassBaseReference継承の禁止宣言(new以外の生成禁止 + コピー禁止)
Definition GxBase.h:244
@ MAX
定義数
@ UNKNOWN
未定義
メモリアロケータ基底クラス
Definition GxAllocator.h:82
メモリアロケータリスト
Definition GxAllocator.h:347
@ MAX
定義アロケータ数
配列クラス
Definition GxArrayClassBase.h:18
算術演算クラス
Definition GxMath.h:84
static constexpr u32 VALUE_32
32
Definition GxMath.h:124
static GX_FORCE_INLINE T getClamp(const T value, const T min, const T max)
最小値・最大値で切り落とす
Definition GxMath.h:170
プロパティテーブルクラス
Definition GxProperty.h:1641
ヒープ情報ヘッダー (BLOCK_SIZEアライメント)
Definition GxAllocatorHeap.h:56
Definition GxColor.h:21
座標
Definition GxStruct.h:867
矩形
Definition GxStruct.h:951
サイズ
Definition GxStruct.h:730
文字列型クラス
Definition GxString.h:18
32bitブーリアン
Definition GxDefine.h:173