1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: dev_CallbackChain.h 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: 14250 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NW_DEV_CALLBACK_CHAIN_H_ 17 #define NW_DEV_CALLBACK_CHAIN_H_ 18 19 #include <nw/types.h> 20 #include <nw/os.h> 21 22 #if defined(NW_PLATFORM_CTR) 23 #include <nn/gx.h> 24 #endif 25 26 27 namespace nw { 28 namespace dev { 29 30 #if defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) 31 32 //--------------------------------------------------------------------------- 33 //! @brief GPUコマンドのコールバックチェインです。 34 //--------------------------------------------------------------------------- 35 class CallbackChain 36 { 37 public: 38 //! @brief コンストラクタです。 39 CallbackChain( nw::os::IAllocator* allocator ); 40 41 //! @brief デストラクタです。 42 ~CallbackChain(); 43 44 //! @brief インスタンスを破棄します。 45 void Destroy(); 46 47 //! @brief バインドされているコマンドリストにコールバックを設定します。 48 void SetCallback(); 49 50 //! @brief コールバックチェイン処理を開始します。 51 void Begin(); 52 53 //! @brief コールバックチェイン処理を終了します。 54 void End(); 55 56 //! @brief GPU処理コストをmsecで取得します。 GetCostTime()57 f32 GetCostTime() const { return m_Cost; } 58 59 private: 60 //! @brief コールバックの呼び出しです。 61 void Invoke(GLint id); 62 63 //! @brief 登録されるコールバック関数です。 64 static void CommandListCallback(GLint id); 65 66 f32 m_Cost; 67 uint m_MaxRequestCount; 68 uint m_StartReqCount; 69 uint m_EndReqCount; 70 uint m_CurrentReqCount; 71 s64* m_MicroSecArray; 72 73 os::IAllocator* m_Allocator; 74 75 static CallbackChain* s_CallbackChain; 76 }; 77 78 #else 79 80 class CallbackChain 81 { 82 public: 83 //! @brief コンストラクタです。 84 CallbackChain( nw::os::IAllocator* allocator ){} 85 86 //! @brief デストラクタです。 87 ~CallbackChain(){} 88 89 //! @brief インスタンスを破棄します。 90 void Destroy(){} 91 92 //! @brief バインドされているコマンドリストにコールバックを設定します。 93 void SetCallback(); 94 95 //! @brief コールバックチェイン処理を開始します。 96 void Begin(){} 97 98 //! @brief コールバックチェイン処理を終了します。 99 void End(){} 100 101 //! @brief 前フレームのGPU処理コストをmsecで取得します。 102 f32 GetCostTime() const { return 0.f; } 103 }; 104 105 106 #endif // defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) 107 108 } // namespace nw::dev 109 } // namespace nw 110 111 #endif // NW_DEV_CALLBACK_CHAIN_H_ 112 113