/*---------------------------------------------------------------------------* Project: NintendoWare File: SmCommandUtility.cpp Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc. All rights reserved. These coded instructions, statements, and computer programs contain proprietary information of Nintendo and/or its licensed developers and are protected by national and international copyright laws. 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. The content herein is highly confidential and should be handled accordingly. $Revision: $ *---------------------------------------------------------------------------*/ #include #include #include #include "../include/SmCommandUtility.h" GLuint SmStaticCommandCache::m_StaticCommandList = 0; SmStaticCommandCache* s_StaticCmdCache = NULL; namespace { //---------------------------------------- // コンストラクタ SmStaticCommandCache::SmStaticCommandCache() { #define STATIC_CMD_BUFFER_SIZE 0x50000 NW_ASSERT( !s_StaticCmdCache ); // 現在バインドされているコマンドリスト GLint currentCmdList; nngxGetCmdlistParameteri( NN_GX_CMDLIST_BINDING, ¤tCmdList ); // コマンドリストを生成 nngxGenCmdlists( 1, &m_StaticCommandList ); nngxBindCmdlist( m_StaticCommandList ); nngxCmdlistStorage( STATIC_CMD_BUFFER_SIZE, 256 ); nngxSetCmdlistParameteri(NN_GX_CMDLIST_RUN_MODE, NN_GX_CMDLIST_SERIAL_RUN); // 戻す nngxBindCmdlist( currentCmdList ); s_StaticCmdCache = this; } //---------------------------------------- // デストラクタ SmStaticCommandCache::~SmStaticCommandCache() { nngxDeleteCmdlists( 1, &m_StaticCommandList ); s_StaticCmdCache = NULL; } //---------------------------------------- // void SmStaticCommandCache::StartStaticCmdCache( SmCommandReuser& cmdReuser ) { cmdReuser.StartCaching( m_StaticCommandList ); NW_GL_ASSERT(); } //---------------------------------------- // void SmStaticCommandCache::EndStaticCmdCache( SmCommandReuser& cmdReuser ) { cmdReuser.EndCaching(); NW_GL_ASSERT(); } //---------------------------------------- // void SmStaticCommandCache::CreateCopiedCmdCache( CopiedCmdCache& cmdCacheCopied ) { GLsizei buffSize; GLsizei reqSize; GLsizei copiedBuffSize; // 現在バインドされているコマンドリストをストア GLint currentCmdList; nngxGetCmdlistParameteri( NN_GX_CMDLIST_BINDING, ¤tCmdList ); nngxBindCmdlist( m_StaticCommandList ); nngxGetCmdlistParameteri( NN_GX_CMDLIST_USED_BUFSIZE, &buffSize ); nngxGetCmdlistParameteri( NN_GX_CMDLIST_USED_REQCOUNT, &reqSize ); copiedBuffSize = nngxExportCmdlist( m_StaticCommandList, 0, buffSize, 0, reqSize, 0, 0 ); NW_GL_ASSERT(); if ( !cmdCacheCopied.cmdBuff ) { cmdCacheCopied.cmdBuff = m_Allocator->Alloc( copiedBuffSize ); cmdCacheCopied.cmdBuffSize = copiedBuffSize; nngxExportCmdlist( m_StaticCommandList, 0, buffSize, 0, reqSize, copiedBuffSize, cmdCacheCopied.cmdBuff ); } // 戻す nngxBindCmdlist( currentCmdList ); NW_GL_ASSERT(); } //---------------------------------------- // void SmStaticCommandCache::DestroyCopiedCmdCache( CopiedCmdCache& cmdCacheCopied ) { nw::os::SafeFree( cmdCacheCopied.cmdBuff, m_Allocator ); } //---------------------------------------- // void SmStaticCommandCache::UseCopiedCmdCache( CopiedCmdCache& cmdCacheCopied ) { // 現在バインドされているコマンドリストをストア GLint currentCmdList; nngxGetCmdlistParameteri( NN_GX_CMDLIST_BINDING, ¤tCmdList ); // インポート nngxImportCmdlist( currentCmdList, cmdCacheCopied.cmdBuff, cmdCacheCopied.cmdBuffSize ); NW_GL_ASSERT(); } } // namespace