1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gr_Texture.h 4 5 Copyright (C)2010 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 33699 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_GR_TEXTURE_H_ 17 #define NN_GR_TEXTURE_H_ 18 19 #include <nn/gr/CTR/gr_Prefix.h> 20 21 namespace nn 22 { 23 namespace gr 24 { 25 namespace CTR 26 { 27 28 /*! 29 @brief テクスチャ設定のためのクラスです。 30 */ 31 class Texture 32 { 33 public : 34 35 /*! 36 @brief 各テクスチャユニットの共通設定のためのクラスです。 37 */ 38 class UnitBase 39 { 40 public : 41 /*! 42 @brief テクスチャの物理アドレスの設定です。型は uptr です。 43 */ 44 uptr physicalAddr; 45 46 47 /*! 48 @brief テクスチャの幅の設定です。型は u16 です。 49 */ 50 u16 width; 51 52 53 /*! 54 @brief テクスチャの高さの設定です。型は u16 です。 55 */ 56 u16 height; 57 58 /*! 59 @brief テクスチャのフォーマットの設定です。 60 型は @ref PicaDataTextureFormat です。 61 */ 62 PicaDataTextureFormat format; 63 64 /*! 65 @brief テクスチャ座標 s の設定です。 66 型は @ref PicaDataTextureWrap です。 67 初期値はPICA_DATA_TEXTURE_WRAP_REPEATです。 68 */ 69 PicaDataTextureWrap wrapT; 70 71 /*! 72 @brief テクスチャ座標 s の設定です。 73 型は @ref PicaDataTextureWrap です。 74 初期値はPICA_DATA_TEXTURE_WRAP_REPEATです。 75 */ 76 PicaDataTextureWrap wrapS; 77 78 /*! 79 @brief テクスチャ拡大フィルタの設定です。 80 型は @ref PicaDataTextureMagFilter です。 81 初期値はPICA_DATA_TEXTURE_MAG_FILTER_NEARESTです。 82 */ 83 PicaDataTextureMagFilter magFilter; 84 85 86 /*! 87 @brief テクスチャ縮小フィルタの設定です。 88 型は @ref PicaDataTextureMinFilter です。 89 初期値は PICA_DATA_TEXTURE_MIN_FILTER_NEAREST です。 90 */ 91 PicaDataTextureMinFilter minFilter; 92 NN_PADDING3; 93 94 /*! 95 @brief LODバイアスの設定です。 96 型は f32 です。 97 初期値は0.fです。 98 [-16.f : 16.f]の範囲で設定してください。 99 コマンド生成時には13bit固定小数(fraction8)に変換されます。 100 MipMapが有効でないときは、無視されます。 101 @see IsEnableMipMap() 102 */ 103 f32 lodBias; 104 105 /*! 106 @brief 最小LODレベルを設定します。値は u8 です。 107 初期値は0です。 108 0以上の値で設定します。 109 MipMapが有効でないときは、無視されます。 110 @see IsEnableMipMap() 111 */ 112 u8 minLodLevel; 113 114 115 /*! 116 @brief 最大LODレベルを設定します。値は u8 です。 117 初期値は0です。 118 ロードしたMipMapの段数-1を設定してください。 119 MipMapが有効でないときは、無視されます。 120 @see IsEnableMipMap() 121 */ 122 u8 maxLodLevel; 123 124 125 /*! 126 @brief ボーダーカラーの赤成分です。 127 値は u8 です。 128 初期値は0です。 129 */ 130 u8 borderColorR; 131 132 /*! 133 @brief ボーダーカラーの緑成分です。 134 値は u8 です。 135 初期値は0です。 136 */ 137 u8 borderColorG; 138 139 140 /*! 141 @brief ボーダーカラーの青成分です。 142 値は u8 です。 143 初期値は0です。 144 */ 145 u8 borderColorB; 146 147 148 /*! 149 @brief ボーダーカラーのアルファ成分です。 150 値は u8 です。 151 初期値は0です。 152 */ 153 u8 borderColorA; 154 155 NN_PADDING2; 156 157 protected : 158 /*! 159 @brief MipMapが有効かどうかを判定します。 160 161 @return 有効なときに true を返します。 162 */ IsEnableMipMap()163 bool IsEnableMipMap() const 164 { 165 if ( minFilter == PICA_DATA_TEXTURE_MIN_FILTER_LINEAR ) 166 { 167 return false; 168 } 169 170 if ( minFilter == PICA_DATA_TEXTURE_MIN_FILTER_NEAREST ) 171 { 172 return false; 173 } 174 175 return true; 176 } 177 178 /*! 179 @brief 初期値を設定します。 180 */ 181 UnitBase(); 182 }; 183 184 public : 185 186 /*! 187 @brief テクスチャユニット0の設定のためのクラスです。 188 */ 189 class Unit0 : public UnitBase 190 { 191 public : 192 /*! 193 @brief テクスチャユニット0のサンプラータイプの設定です。 194 型は @ref PicaDataTexture0SamplerType です。 195 初期値はPICA_DATA_TEXTURE0_SAMPLER_TYPE_TEXTURE_FALSEです。 196 */ 197 PicaDataTexture0SamplerType texType; 198 NN_PADDING3; 199 200 /*! 201 @brief キューブマップ[ +x ]テクスチャの物理アドレスの設定です。 202 型は uptr です。 203 */ 204 uptr cubeMapAddrPosX; 205 206 /*! 207 @brief キューブマップ[ -x ]テクスチャの物理アドレスの設定です。 208 型は uptr です。 209 */ 210 uptr cubeMapAddrNegX; 211 212 /*! 213 @brief キューブマップ[ +y ]テクスチャの物理アドレスの設定です。 214 型は uptr です。 215 */ 216 uptr cubeMapAddrPosY; 217 218 /*! 219 @brief キューブマップ[ -Y ]テクスチャの物理アドレスの設定です。 220 型は uptr です。 221 */ 222 uptr cubeMapAddrNegY; 223 224 /*! 225 @brief キューブマップ[ +Z ]テクスチャの物理アドレスの設定です。 226 型は uptr です。 227 */ 228 uptr cubeMapAddrPosZ; 229 230 /*! 231 @brief キューブマップ[ -Z ]テクスチャの物理アドレスの設定です。 232 型は uptr です。 233 */ 234 uptr cubeMapAddrNegZ; 235 236 public : 237 /*! 238 @brief 設定された情報をもとに、テクスチャユニット0の設定コマンドを生成します。 239 240 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 241 @param[in] is_update_texture_func サンプラータイプなどの設定を変えた場合はtrueを設定します。 242 243 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 244 */ 245 bit32* MakeCommand( bit32* command, bool is_update_texture_func = true ) const; 246 247 /*! 248 @brief 初期値を設定します。 249 250 @param[in] texture_ テクスチャです。 251 */ 252 explicit Unit0( const Texture& texture_ ); 253 254 protected : 255 const Texture& m_Texture; 256 }; 257 258 /*! 259 @brief テクスチャユニット1の設定のためのクラスです。 260 */ 261 class Unit1 : public UnitBase 262 { 263 public : 264 /*! 265 @brief テクスチャユニット1のサンプラータイプの設定です。 266 型は @ref PicaDataTexture1SamplerType です。 267 初期値はPICA_DATA_TEXTURE1_SAMPLER_TYPE_FALSEです。 268 */ 269 PicaDataTexture1SamplerType texType; 270 NN_PADDING3; 271 272 public : 273 /*! 274 @brief 設定された情報をもとに、テクスチャユニット1の設定コマンドを生成します。 275 276 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 277 @param[in] is_update_texture_func サンプラータイプなどの設定を変えた場合はtrueを設定します。 278 279 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 280 */ 281 bit32* MakeCommand( bit32* command, bool is_update_texture_func = true ) const; 282 283 /*! 284 @brief 初期値を設定します。 285 286 @param[in] texture_ テクスチャです。 287 */ 288 explicit Unit1( const Texture& texture_ ); 289 290 protected : 291 const Texture& m_Texture; 292 }; 293 294 /*! 295 @brief テクスチャユニット2の設定のためのクラスです。 296 */ 297 class Unit2 : public UnitBase 298 { 299 public : 300 /*! 301 @brief テクスチャユニット2のサンプラータイプの設定です。 302 型は @ref PicaDataTexture2SamplerType です。 303 */ 304 PicaDataTexture2SamplerType texType; 305 306 /* 307 @brief テクスチャユニット2のテクスチャ座標選択の設定です。 308 型は @ref PicaDataTexture2TexCoord です。 309 初期値は PICA_DATA_TEXTURE2_TEXCOORD_TEXTURE2 です。 310 */ 311 PicaDataTexture2TexCoord texCoord; 312 313 NN_PADDING2; 314 315 public : 316 /*! 317 @brief 設定された情報をもとに、テクスチャユニット2の設定コマンドを生成します。 318 319 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 320 @param[in] is_update_texture_func サンプラータイプなどの設定を変えた場合はtrueを設定します。 321 322 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 323 */ 324 bit32* MakeCommand( bit32* command, bool is_update_texture_func = true ) const; 325 326 /*! 327 @brief 初期値を設定します。 328 329 @param[in] texture_ テクスチャです。 330 */ 331 explicit Unit2( const Texture& texture_ ); 332 333 protected : 334 const Texture& m_Texture; 335 }; 336 337 /*! 338 @brief テクスチャユニット3の設定のためのクラスです。 339 */ 340 class Unit3 : protected UnitBase 341 { 342 public : 343 /*! 344 @brief テクスチャユニット3のサンプラータイプの設定です。 345 型は @ref PicaDataTexture3SamplerType です。 346 初期値は PICA_DATA_TEXTURE3_SAMPLER_TYPE_FALSE です。 347 */ 348 PicaDataTexture3SamplerType texType; 349 350 /*! 351 @brief テクスチャユニット3のテクスチャ座標選択の設定です。 352 型は @ref PicaDataTexture3TexCoord です。 353 初期値はPICA_DATA_TEXTURE3_TEXCOORD_TEXTURE0です。 354 */ 355 PicaDataTexture3TexCoord texCoord; 356 357 NN_PADDING2; 358 359 public : 360 /*! 361 @brief 設定された情報をもとに、テクスチャユニット3の設定コマンドを生成します。 362 363 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 364 @param[in] is_update_texture_func サンプラータイプなどの設定を変えた場合はtrueを設定します。 365 366 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 367 */ 368 bit32* MakeCommand( bit32* command, bool is_update_texture_func = true ) const; 369 370 /*! 371 @brief 初期値を設定します。 372 373 @param[in] texture_ テクスチャです。 374 */ 375 explicit Unit3( const Texture& texture_ ); 376 377 protected : 378 const Texture& m_Texture; 379 }; 380 381 public : 382 /*! 383 @brief テクスチャユニット0についての設定です。 384 型は nn::gr::CTR::Texture::Unit0 です。 385 */ 386 Unit0 unit0; 387 388 /*! 389 @brief テクスチャユニット1についての設定です。 390 型は nn::gr::CTR::Texture::Unit1 です。 391 */ 392 Unit1 unit1; 393 394 /*! 395 @brief テクスチャユニット2についての設定です。 396 型は nn::gr::CTR::Texture::Unit2 です。 397 */ 398 Unit2 unit2; 399 400 /*! 401 @brief テクスチャユニット3についての設定です。 402 型は nn::gr::CTR::Texture::Unit3 です。 403 */ 404 Unit3 unit3; 405 406 public : 407 /*! 408 @brief 各設定の初期値を設定します。 409 */ 410 Texture(); 411 412 /*! 413 @brief 設定された情報をもとに、すべてのテクスチャの設定コマンドを生成します。 414 415 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 416 @param[in] isAddDummyCommand 0x80 へのダミー書き込みコマンドを 3回 生成します。 417 418 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 419 */ 420 bit32* MakeCommand( bit32* command, bool isAddDummyCommand = true ) const; 421 422 /*! 423 @brief 設定された情報をもとに、テクスチャユニットの有効/無効コマンドなどを生成します。 424 425 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 426 @param[in] isAddDummyCommand 0x80 へのダミー書き込みコマンドを 3回 生成します。 427 428 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 429 */ 430 bit32* MakeFuncCommand( bit32* command, bool isAddDummyCommand = true ) const; 431 432 /*! 433 @brief テクスチャを無効化する最小限のコマンドを生成します。 434 435 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 436 @param[in] isAddDummyCommand 0x80 へのダミー書き込みコマンドを 3回 生成します。 437 438 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 439 */ 440 static bit32* MakeDisableCommand( bit32* command, bool isAddDummyCommand = true ); 441 442 protected: 443 /*! 444 @brief 0x80 へのダミーコマンドを生成します。 445 446 @param[in] command 描画コマンドの書き込み先の先頭アドレスです。 447 448 @return 書き込まれた描画コマンドの終端の次のアドレスを返します。 449 */ 450 static bit32* MakeDummyCommand_( bit32* command ); 451 }; 452 453 } // namespace CTR 454 } // namespace gr 455 } // namespace nn 456 457 #endif // NN_GR_TEXTURE_H_ 458