1 /*---------------------------------------------------------------------------*
2 Project: NintendoWare
3 File: demo_DebugUtility.cpp
4
5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Revision: 18943 $
14 *---------------------------------------------------------------------------*/
15
16 #include <nw/types.h>
17 #include <nw/os.h>
18 #include <nw/ut/ut_Inlines.h>
19 #include <nw/demo/demo_DebugUtility.h>
20
21 #include <nn/fs.h>
22
23
24 namespace nw {
25 namespace demo {
26
27 size_t DebugUtility::s_DeviceMemoryFreeSize;
28 size_t DebugUtility::s_ParticleMemoryFreeSize;
29 bool DebugUtility::s_IsForceCpuProfilingMode = false;
30 bool DebugUtility::s_SilentMode = false;
31 int DebugUtility::s_ProfileCallCount = 0;
32
33 static s32 s_RefreshMeterCount = 0;
34 static bool s_LastCpuCountingMode = false;
35
36 //----------------------------------------
37 void
DrawLoadMeter(nw::demo::RenderSystem * renderSystem,nw::demo::GraphicsDrawing * graphicsDrawing,bool refreshMeter)38 DebugUtility::DrawLoadMeter(
39 nw::demo::RenderSystem* renderSystem,
40 nw::demo::GraphicsDrawing* graphicsDrawing,
41 bool refreshMeter
42 )
43 {
44 NW_POINTER_ASSERT(renderSystem);
45 NW_POINTER_ASSERT(graphicsDrawing);
46
47 if (nw::demo::DebugUtility::IsCpuProfilingMode() != s_LastCpuCountingMode)
48 {
49 if (!s_SilentMode)
50 {
51 if (nw::demo::DebugUtility::IsCpuProfilingMode())
52 {
53 NW_DEV_LOG("-------------------------------------------------------------------------------\n");
54 NW_DEV_LOG("| Entering CPU profiling mode. |\n");
55 NW_DEV_LOG("-------------------------------------------------------------------------------\n");
56 NW_DEV_LOG("Command list won't run.\n");
57 NW_DEV_LOG("Load meter will be output to log.\n");
58 NW_DEV_LOG("To leave profiling mode, turn DBG switch OFF.\n");
59 NW_DEV_LOG("\n");
60 }
61 else
62 {
63 NW_DEV_LOG("-------------------------------------------------------------------------------\n");
64 NW_DEV_LOG("| Leaving CPU profiling mode. |\n");
65 NW_DEV_LOG("-------------------------------------------------------------------------------\n");
66 }
67 }
68 s_LastCpuCountingMode = nw::demo::DebugUtility::IsCpuProfilingMode();
69 }
70
71 if (refreshMeter)
72 {
73 if (nw::demo::DebugUtility::IsCpuProfilingMode())
74 {
75 if ( ++s_RefreshMeterCount > 2)
76 {
77 renderSystem->CalcLoadMeter();
78 if (!s_SilentMode)
79 {
80 renderSystem->LogLoadMeter();
81 NW_DEV_LOG("\n");
82 }
83 s_RefreshMeterCount = 0;
84 }
85 }
86 else
87 {
88 renderSystem->CalcLoadMeter();
89 }
90 }
91
92 renderSystem->DrawLoadMeter(*graphicsDrawing, 40, 158);
93 }
94
95 } // namespace demo
96 } // namespace nw
97