/*---------------------------------------------------------------------------* Project: NintendoWare File: demo_GraphicsMemoryAllocator.h 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: 31311 $ *---------------------------------------------------------------------------*/ #ifndef NW_DEMO_GRAPHICS_MEMORY_H_ #define NW_DEMO_GRAPHICS_MEMORY_H_ #include #include #include #include #include namespace nw { namespace demo { //--------------------------------------------------------------------------- //! @brief グラフィックス用のメモリを管理するクラスです。 //--------------------------------------------------------------------------- class GraphicsMemoryAllocator { public: //--------------------------------------------------------------------------- //! @brief グラフィックスメモリアロケータの初期化を行います。 //--------------------------------------------------------------------------- void Initialize(os::IAllocator* allocator); //--------------------------------------------------------------------------- //! @brief グラフィックスメモリアロケータの終了処理を行います。 //--------------------------------------------------------------------------- void Finalize(); //--------------------------------------------------------------------------- //! @brief グラフィックスメモリの確保を行います。 //! //! @param[in] area メモリを確保する領域です。 //! @param[in] aim メモリの使用用途です。 //! @param[in] id オブジェクトの名前です。 //! @param[in] size 確保するサイズです。 //! //! @return 確保したメモリのアドレスを返します。 //--------------------------------------------------------------------------- void* Allocate(GLenum area, GLenum aim, GLuint id, GLsizei size); //--------------------------------------------------------------------------- //! @brief グラフィックスメモリの解放を行います。 //! //! @param[in] area メモリを解放する領域です。 //! @param[in] aim メモリの使用用途です。 //! @param[in] id オブジェクトの名前です。 //! @param[in] addr 解放するアドレスです。 //--------------------------------------------------------------------------- void Deallocate(GLenum area, GLenum aim, GLuint id, void* addr); //---------------------------------------- //! @name コンストラクタ/デストラクタ //@{ //! コンストラクタです。 GraphicsMemoryAllocator() : m_Initialized( false ), m_CurrentAddrVramA( NULL ), m_CurrentAddrVramB( NULL ), m_DeviceMemoryAllocator( NULL ) {} //! デストラクタです。 virtual ~GraphicsMemoryAllocator() { Finalize(); } //@} private: bool m_Initialized; uptr m_CurrentAddrVramA; uptr m_CurrentAddrVramB; os::IAllocator* m_DeviceMemoryAllocator; uptr MathRoundup(uptr x, int base) { return ((x) + ((base)-1)) & ~((base)-1); } }; } // namespace demo } // namespace nw #endif // NW_DEMO_GRAPHICS_MEMORY_H_