/*---------------------------------------------------------------------------* Project: NintendoWare File: dev_CallbackChain.cpp Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo of America Inc. and/or Nintendo Company Ltd., and are protected by Federal copyright law. They may not be disclosed to third parties or copied or duplicated in any form, in whole or in part, without the prior written consent of Nintendo. $Revision: 14250 $ *---------------------------------------------------------------------------*/ #include #if defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) #include #endif namespace nw { namespace dev { #if defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) CallbackChain* CallbackChain::s_CallbackChain = NULL; //! @brief コンストラクタです。 CallbackChain::CallbackChain( nw::os::IAllocator* allocator ) : m_Cost( 0.f ), m_StartReqCount( 0 ), m_EndReqCount( 0 ), m_CurrentReqCount( 0 ), m_MicroSecArray( NULL ), m_Allocator( allocator ) { NW_ASSERT( !s_CallbackChain ); NW_NULL_ASSERT( m_Allocator ); GLint maxRequestCount = 0; s_CallbackChain = this; nngxGetCmdlistParameteri(NN_GX_CMDLIST_MAX_REQCOUNT, &maxRequestCount); m_MaxRequestCount = maxRequestCount; m_MicroSecArray = static_cast( m_Allocator->Alloc( sizeof(s64) * m_MaxRequestCount ) ); NW_NULL_ASSERT( m_MicroSecArray ); } //! @brief デストラクタです。 CallbackChain::~CallbackChain() { m_Allocator->Free( m_MicroSecArray ); s_CallbackChain = NULL; nngxSetCmdlistCallback(NULL); } //! @brief インスタンスを破棄します。 void CallbackChain::Destroy() { if (m_Allocator != NULL) { void* memory = reinterpret_cast(this); this->~CallbackChain(); m_Allocator->Free(memory); } } //! @brief バインドされているコマンドリストにコールバックを設定します。 void CallbackChain::SetCallback() { nngxStopCmdlist(); nngxSetCmdlistCallback(CallbackChain::CommandListCallback); nngxRunCmdlist(); } //! @brief コールバックチェイン処理を開始します。 void CallbackChain::Begin() { int i = 0; s64 costMicro = 0; GLint requestCount = 0; for ( i = m_StartReqCount; i < m_EndReqCount; ++i ) { if ( m_MicroSecArray[i+1] != 0 && m_MicroSecArray[i] != 0 ) { costMicro += m_MicroSecArray[i+1] - m_MicroSecArray[i]; } } m_Cost = static_cast(costMicro) / 1000.f; for ( i = 0; iInvoke(id); } } #endif // defined(NW_DEV_ENABLED) && defined(NW_PLATFORM_CTR) } // namespace nw::dev } // namespace nw