/*---------------------------------------------------------------------------* Project: NintendoWare File: gfx_ResLookupTable.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: 18106 $ *---------------------------------------------------------------------------*/ #ifndef NW_GFX_RESLOOKUPTABLE_H_ #define NW_GFX_RESLOOKUPTABLE_H_ #include #include #include #include #include #include #include #include namespace nw { namespace gfx { namespace res { //! @details :private struct ResLookupTableData { nw::ut::ResTypeInfo typeInfo; }; //! @details :private // // CommandCacheTable のコマンドフォーマットは次の通りです。 // 0 : LUT設定レジスタ(0x1c8, 0x132) などの 0 番目の設定値 [0:11]value, [23:12]diff。 // 1 : レジスタへの書き込みヘッダ。 // 2~ : LUTサイズ分の LUT設定。 struct ResImageLookupTableData : public ResLookupTableData { nw::ut::BinString toName; nw::ut::ResBool m_IsAbs; u8 _padding_0[3]; nw::ut::ResS32 m_CommandCacheTableCount; nw::ut::Offset toCommandCacheTable; }; //! @details :private struct ResReferenceLookupTableData : public ResLookupTableData { nw::ut::BinString toPath; nw::ut::BinString toTableName; nw::ut::Offset toTargetLut; }; class ResImageLookupTable; //-------------------------------------------------------------------------- //! @brief 参照テーブルを表すバイナリリソースのベースクラスです。 //--------------------------------------------------------------------------- class ResLookupTable : public nw::ut::ResCommon { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResLookupTable) }; NW_RES_CTOR( ResLookupTable ) //--------------------------------------------------------------------------- //! @brief インスタンスの型情報を取得します。 //! //! @return 型情報です。 //--------------------------------------------------------------------------- nw::ut::ResTypeInfo GetTypeInfo() const { return ref().typeInfo; } //--------------------------------------------------------------------------- //! @brief 参照を解決した、ResImageLookupTable のインスタンスを取得します。 //! //! @return ResImageLookupTable のインスタンスです。 //--------------------------------------------------------------------------- NW_INLINE ResImageLookupTable Dereference(); NW_INLINE const ResImageLookupTable Dereference() const; //--------------------------------------------------------------------------- //! @brief リソースの初期化処理をおこないます。 //--------------------------------------------------------------------------- Result Setup(); //--------------------------------------------------------------------------- //! @brief リソースの後始末をおこないます。 //--------------------------------------------------------------------------- void Cleanup(); }; //-------------------------------------------------------------------------- //! @brief 参照テーブルを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResImageLookupTable : public ResLookupTable { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResImageLookupTable) }; enum { SIGNATURE = NW_RES_SIGNATURE32('ILUT') }; NW_RES_CTOR_INHERIT( ResImageLookupTable, ResLookupTable ) //--------------------------------------------------------------------------- //! @fn void SetCommandCache(int idx, u32 value) //! @brief コマンドキャッシュのリストに要素を設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn void SetAbs(bool value) //! @brief テーブルへアクセスするための入力値の絶対値化フラグを設定します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn bool IsAbs() const //! @brief テーブルへアクセスするための入力値の絶対値化フラグを取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn const char * GetName() const //! @brief テーブル名を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetCommandCacheCount() const //! @brief コマンドキャッシュの要素数を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn u32 GetCommandCache(int idx) const //! @brief コマンドキャッシュを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_STRING_DECL( Name ) // GetName() NW_RES_FIELD_BOOL_PRIMITIVE_DECL( Abs ) // IsAbs(), SetAbs() NW_RES_FIELD_PRIMITIVE_LIST_DECL( u32, CommandCache ) // GetCommandCache(), GetCommandCacheCount(), GetCommandCache(int idx) }; //-------------------------------------------------------------------------- //! @brief 参照テーブルへのリファレンス表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResReferenceLookupTable : public ResLookupTable { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResReferenceLookupTable) }; enum { SIGNATURE = NW_RES_SIGNATURE32('RLUT') }; NW_RES_CTOR_INHERIT( ResReferenceLookupTable, ResLookupTable ) //--------------------------------------------------------------------------- //! @fn ResImageLookupTable GetTargetLut() //! @brief 参照解決済みのルックアップテーブルを取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn const char * GetTableName() const //! @brief 参照先ルックアップテーブルの名前を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn const char * GetPath() const //! @brief 参照先ルックアップテーブルセットのパス名を取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_STRING_DECL( Path ) // GetPath() NW_RES_FIELD_STRING_DECL( TableName ) // GetTableName() NW_RES_FIELD_CLASS_DECL( ResImageLookupTable, TargetLut ) // GetTargetLut() }; //! @details :private struct ResLookupTableSetData : public ResSceneObjectData { nw::ut::ResS32 m_SamplersDicCount; nw::ut::Offset toSamplersDic; }; //-------------------------------------------------------------------------- //! @brief 参照テーブルセットを表すバイナリリソースクラスです。 //--------------------------------------------------------------------------- class ResLookupTableSet : public ResSceneObject { public: enum { TYPE_INFO = NW_GFX_RES_TYPE_INFO(ResLookupTableSet) }; enum { SIGNATURE = NW_RES_SIGNATURE32('LUTS') }; enum { BINARY_REVISION = REVISION_RES_LUT_SET }; NW_RES_CTOR_INHERIT( ResLookupTableSet, ResSceneObject ) //--------------------------------------------------------------------------- //! @fn s32 GetSamplersIndex(const char * key) const //! @brief 参照テーブルセットの辞書データ中でのインデックス番号を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn s32 GetSamplersCount() const //! @brief 参照テーブルセットの要素数を取得します。 //--------------------------------------------------------------------------- //--------------------------------------------------------------------------- //! @fn ResImageLookupTable GetSamplers(int idx) //! @brief 参照テーブルセットを取得します。 //--------------------------------------------------------------------------- NW_RES_FIELD_CLASS_DIC_DECL( ResImageLookupTable, Samplers, nw::ut::ResDicPatricia ) //--------------------------------------------------------------------------- //! @brief リソースの初期化処理をおこないます。 //! //! @param[in] allocator アロケータです。 //! @param[in] graphicsFile グラフィックスリソースです。 //--------------------------------------------------------------------------- Result Setup(os::IAllocator* allocator, ResGraphicsFile graphicsFile); //--------------------------------------------------------------------------- //! @brief リソースの後始末をおこないます。 //--------------------------------------------------------------------------- void Cleanup(); //--------------------------------------------------------------------------- //! @brief リビジョンを取得します。 //! //! @return リソースのリビジョン情報です。 //--------------------------------------------------------------------------- u32 GetRevision() const { return this->GetHeader().revision; } }; //---------------------------------------- NW_INLINE ResImageLookupTable ResLookupTable::Dereference() { NW_ASSERT( this->IsValid() ); switch ( this->ref().typeInfo ) { case ResImageLookupTable::TYPE_INFO: { return ResStaticCast(*this); } case ResReferenceLookupTable::TYPE_INFO: { ResReferenceLookupTable resRefLut = ResStaticCast( *this ); NW_ASSERT( resRefLut.GetTargetLut().IsValid() ); return resRefLut.GetTargetLut(); } default: { NW_FATAL_ERROR("Unsupported lut type."); return ResImageLookupTable(); } } } //---------------------------------------- NW_INLINE const ResImageLookupTable ResLookupTable::Dereference() const { NW_ASSERT( this->IsValid() ); switch ( this->ref().typeInfo ) { case ResImageLookupTable::TYPE_INFO: { return ResStaticCast(*this); } case ResReferenceLookupTable::TYPE_INFO: { ResReferenceLookupTable resRefLut = ResStaticCast( *this ); NW_ASSERT( resRefLut.GetTargetLut().IsValid() ); return resRefLut.GetTargetLut(); } default: { NW_FATAL_ERROR("Unsupported lut type."); return ResImageLookupTable(); } } } } // namespace res } // namespace gfx } // namespace nw #endif // NW_GFX_RESLOOKUPTABLE_H_