/*---------------------------------------------------------------------------* Project: NintendoWare File: SmCommandReuser.h 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: 18422 $ *---------------------------------------------------------------------------*/ #ifndef SM_COMMAND_REUSER_H_ #define SM_COMMAND_REUSER_H_ #include //--------------------------------------------------------------------------- // コマンドを作って再利用するクラスです。 class SmCommandReuser { public: SmCommandReuser() : m_StoreCommandListId(0), m_CommandListId(0), m_BufferOffset(0), m_BufferSize(0), m_RequestId(0), m_RequestSize(0) {} // キャッシュ作成を開始します。 void StartCaching(GLuint cachingCommandListId) { // 現在バインドされているコマンドリストをストア nngxGetCmdlistParameteri( NN_GX_CMDLIST_BINDING, &m_StoreCommandListId ); // キャッシュ用のコマンドリストへ切り替え m_CommandListId = cachingCommandListId; nngxBindCmdlist(cachingCommandListId); nngxClearCmdlist(); nngxStartCmdlistSave(); NW_GL_ASSERT(); } // キャッシュ作成を終了します。 void EndCaching() { nngxSplitDrawCmdlist(); NW_GL_ASSERT(); nngxStopCmdlistSave( &this->m_BufferOffset, &this->m_BufferSize, &this->m_RequestId, &this->m_RequestSize); NW_GL_ASSERT(); nngxBindCmdlist( m_StoreCommandListId ); } // キャッシュしたコマンドを使用します。 void UseCommand( bool isCopyBuffer ) { GLboolean copyBuffer = isCopyBuffer ? GL_TRUE : GL_FALSE; nngxUseSavedCmdlist( this->m_CommandListId, this->m_BufferOffset, this->m_BufferSize, this->m_RequestId, this->m_RequestSize, 0, copyBuffer); NW_GL_ASSERT(); } // キャッシュされているか? bool IsCach() { if( m_BufferSize > 0 ) { return true; } else { return false; } } GLsizei GetBufferSize() const { return m_BufferSize; } private: GLint m_StoreCommandListId; GLuint m_CommandListId; GLuint m_BufferOffset; GLsizei m_BufferSize; GLuint m_RequestId; GLsizei m_RequestSize; }; //--------------------------------------------------------------------------- // 静的なコマンドキャッシュ領域を確保し、コマンドを登録します。 class SmStaticCommandCach { public: // コンストラクタ SmStaticCommandCach() { nngxGenCmdlists(1, &(m_CachingCommandList)); nngxBindCmdlist(m_CachingCommandList); nngxCmdlistStorage(description.cachingCommandBufferSize, description.cachingRequestCount); nngxSetCmdlistParameteri(NN_GX_CMDLIST_RUN_MODE, NN_GX_CMDLIST_SERIAL_RUN); } }; #endif // SM_COMMAND_REUSER_H_