1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: gd_Combiner.h 4 Copyright (C)2011 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 *--------------------------------------------------------------------------- 11 12 13 */ 14 15 16 #ifndef NN_GD_CTR_GD_COMBINER_H_ 17 #define NN_GD_CTR_GD_COMBINER_H_ 18 19 #include <nn/gd/CTR/gd_Types.h> 20 #include <nn/gd/CTR/gd_Result.h> 21 22 #include <string.h> 23 24 #if NN_GD_DOCUMENT_TYPE == ENGLISH 25 /* Please see man pages for details 26 27 28 */ 29 #else 30 /* Please see man pages for details 31 32 33 */ 34 #endif 35 36 namespace nn { 37 namespace gd { 38 namespace CTR { 39 40 class CombinerState; 41 class CombinerDescription; 42 class LightingStage; 43 44 #if NN_GD_DOCUMENT_TYPE == ENGLISH 45 /* Please see man pages for details 46 47 48 49 50 51 52 */ 53 #else 54 /* Please see man pages for details 55 56 57 58 59 60 61 */ 62 #endif 63 class CombinerStage 64 { 65 public: 66 #if NN_GD_DOCUMENT_TYPE == ENGLISH 67 /* Please see man pages for details */ 68 #else 69 /* Please see man pages for details */ 70 #endif 71 static const u32 COUNT_TEXTURE_COMBINER_UNITS = 6; 72 73 #if NN_GD_DOCUMENT_TYPE == ENGLISH 74 /* Please see man pages for details */ 75 #else 76 /* Please see man pages for details */ 77 #endif 78 enum UnitId 79 { 80 UNIT0 = 0, 81 UNIT1 = 1, 82 UNIT2 = 2, 83 UNIT3 = 3, 84 UNIT4 = 4, 85 UNIT5 = 5, 86 87 UNIT_RESERVED_MAX_U32 = 0xffffffffu 88 }; 89 90 #if NN_GD_DOCUMENT_TYPE == ENGLISH 91 /* Please see man pages for details */ 92 #else 93 /* Please see man pages for details 94 95 */ 96 #endif 97 enum Source 98 { 99 SOURCE_PRIMARY_COLOR = 0x0, 100 SOURCE_FRAGMENT_PRIMARY_COLOR = 0x1, 101 SOURCE_FRAGMENT_SECONDARY_COLOR = 0x2, 102 SOURCE_TEXTURE0 = 0x3, 103 SOURCE_TEXTURE1 = 0x4, 104 SOURCE_TEXTURE2 = 0x5, 105 SOURCE_TEXTURE3 = 0x6, 106 SOURCE_PREVIOUS_BUFFER = 0xd, 107 SOURCE_CONSTANT = 0xe, 108 SOURCE_PREVIOUS = 0xf, 109 110 SOURCE_RESERVED_MAX_U32 = 0xffffffffu 111 }; 112 113 #if NN_GD_DOCUMENT_TYPE == ENGLISH 114 /* Please see man pages for details */ 115 #else 116 /* Please see man pages for details */ 117 #endif 118 enum OperandRgb 119 { 120 OPERAND_RGB_SRC_COLOR = 0x0, 121 OPERAND_RGB_ONE_MINUS_SRC_COLOR = 0x1, 122 OPERAND_RGB_SRC_ALPHA = 0x2, 123 OPERAND_RGB_ONE_MINUS_SRC_ALPHA = 0x3, 124 OPERAND_RGB_SRC_R = 0x4, 125 OPERAND_RGB_ONE_MINUS_SRC_R = 0x5, 126 OPERAND_RGB_SRC_G = 0x8, 127 OPERAND_RGB_ONE_MINUS_SRC_G = 0x9, 128 OPERAND_RGB_SRC_B = 0xc, 129 OPERAND_RGB_ONE_MINUS_SRC_B = 0xd, 130 131 OPERAND_RGB_RESERVED_MAX_U32 = 0xffffffffu 132 }; 133 134 #if NN_GD_DOCUMENT_TYPE == ENGLISH 135 /* Please see man pages for details */ 136 #else 137 /* Please see man pages for details */ 138 #endif 139 enum OperandAlpha 140 { 141 OPERAND_ALPHA_SRC_ALPHA = 0x0, 142 OPERAND_ALPHA_ONE_MINUS_SRC_ALPHA = 0x1, 143 OPERAND_ALPHA_SRC_R = 0x2, 144 OPERAND_ALPHA_ONE_MINUS_SRC_R = 0x3, 145 OPERAND_ALPHA_SRC_G = 0x4, 146 OPERAND_ALPHA_ONE_MINUS_SRC_G = 0x5, 147 OPERAND_ALPHA_SRC_B = 0x6, 148 OPERAND_ALPHA_ONE_MINUS_SRC_B = 0x7, 149 150 OPERAND_ALPHA_RESERVED_MAX_U32 = 0xffffffffu 151 }; 152 153 #if NN_GD_DOCUMENT_TYPE == ENGLISH 154 /* Please see man pages for details */ 155 #else 156 /* Please see man pages for details */ 157 #endif 158 enum CombineRgb 159 { 160 COMBINE_RGB_REPLACE = 0x0, 161 COMBINE_RGB_MODULATE = 0x1, 162 COMBINE_RGB_ADD = 0x2, 163 COMBINE_RGB_ADD_SIGNED = 0x3, 164 COMBINE_RGB_INTERPOLATE = 0x4, 165 COMBINE_RGB_SUBTRACT = 0x5, 166 COMBINE_RGB_DOT3_RGB = 0x6, 167 COMBINE_RGB_DOT3_RGBA = 0x7, 168 COMBINE_RGB_MULT_ADD = 0x8, 169 COMBINE_RGB_ADD_MULT = 0x9, 170 171 COMBINE_RGB_RESERVED_MAX_U32 = 0xffffffffu 172 }; 173 174 #if NN_GD_DOCUMENT_TYPE == ENGLISH 175 /* Please see man pages for details */ 176 #else 177 /* Please see man pages for details */ 178 #endif 179 enum CombineAlpha 180 { 181 COMBINE_ALPHA_REPLACE = 0x0, 182 COMBINE_ALPHA_MODULATE = 0x1, 183 COMBINE_ALPHA_ADD = 0x2, 184 COMBINE_ALPHA_ADD_SIGNED = 0x3, 185 COMBINE_ALPHA_INTERPOLATE = 0x4, 186 COMBINE_ALPHA_SUBTRACT = 0x5, 187 COMBINE_ALPHA_DOT3_RGBA = 0x7, 188 COMBINE_ALPHA_MULT_ADD = 0x8, 189 COMBINE_ALPHA_ADD_MULT = 0x9, 190 191 COMBINE_ALPHA_RESERVED_MAX_U32 = 0xffffffffu 192 }; 193 194 #if NN_GD_DOCUMENT_TYPE == ENGLISH 195 /* Please see man pages for details */ 196 #else 197 /* Please see man pages for details */ 198 #endif 199 enum Scale 200 { 201 SCALE_1 = 0x0, 202 SCALE_2 = 0x1, 203 SCALE_4 = 0x2, 204 205 SCALE_RESERVED_MAX_U32 = 0xffffffffu 206 }; 207 208 #if NN_GD_DOCUMENT_TYPE == ENGLISH 209 /* Please see man pages for details */ 210 #else 211 /* Please see man pages for details */ 212 #endif 213 enum BufferInput 214 { 215 INPUT_PREVIOUS_BUFFER = 0x0, 216 INPUT_PREVIOUS_UNIT = 0x1, 217 218 INPUT_PREVIOUS_RESERVED_MAX_U32 = 0xffffffffu 219 }; 220 221 222 #if NN_GD_DOCUMENT_TYPE == ENGLISH 223 /* Please see man pages for details 224 225 226 */ 227 #else 228 /* Please see man pages for details 229 230 231 232 233 234 235 236 237 238 239 240 */ 241 #endif 242 static nnResult CreateTextureCombinerState(const CombinerDescription* description, CombinerState** textureCombinerState); 243 244 #if NN_GD_DOCUMENT_TYPE == ENGLISH 245 /* Please see man pages for details 246 247 */ 248 #else 249 /* Please see man pages for details 250 251 252 253 254 255 256 257 */ 258 #endif 259 static nnResult ReleaseTextureCombinerState(CombinerState* textureCombinerState); 260 261 #if NN_GD_DOCUMENT_TYPE == ENGLISH 262 /* Please see man pages for details 263 264 */ 265 #else 266 /* Please see man pages for details 267 268 269 270 271 272 273 274 275 276 277 278 */ 279 #endif 280 static nnResult SetTextureCombinerState(CombinerState* textureCombinerState); 281 282 #if NN_GD_DOCUMENT_TYPE == ENGLISH 283 /* Please see man pages for details 284 285 286 287 288 289 */ 290 #else 291 /* Please see man pages for details 292 293 294 295 296 297 298 299 300 301 302 */ 303 #endif 304 static nnResult SetTextureCombinerUnitConstantColor(UnitId unit, u8 colorR, u8 colorG, u8 colorB, u8 colorA); 305 306 }; // CombinerStage 307 308 309 #if NN_GD_DOCUMENT_TYPE == ENGLISH 310 /* Please see man pages for details 311 312 313 */ 314 #else 315 /* Please see man pages for details 316 317 318 */ 319 #endif 320 class CombinerUnitDescription 321 { 322 public: 323 324 #if NN_GD_DOCUMENT_TYPE == ENGLISH 325 /* Please see man pages for details 326 327 */ 328 #else 329 /* Please see man pages for details 330 331 */ 332 #endif 333 CombinerStage::Source m_SrcRGB[3]; 334 335 #if NN_GD_DOCUMENT_TYPE == ENGLISH 336 /* Please see man pages for details 337 338 */ 339 #else 340 /* Please see man pages for details 341 342 */ 343 #endif 344 CombinerStage::Source m_SrcAlpha[3]; 345 346 #if NN_GD_DOCUMENT_TYPE == ENGLISH 347 /* Please see man pages for details 348 349 */ 350 #else 351 /* Please see man pages for details 352 353 */ 354 #endif 355 CombinerStage::OperandRgb m_OperandRgb[3]; 356 357 #if NN_GD_DOCUMENT_TYPE == ENGLISH 358 /* Please see man pages for details 359 360 */ 361 #else 362 /* Please see man pages for details 363 364 */ 365 #endif 366 CombinerStage::OperandAlpha m_OperandAlpha[3]; 367 368 #if NN_GD_DOCUMENT_TYPE == ENGLISH 369 /* Please see man pages for details 370 371 */ 372 #else 373 /* Please see man pages for details 374 375 */ 376 #endif 377 CombinerStage::CombineRgb m_CombineRgb; 378 379 #if NN_GD_DOCUMENT_TYPE == ENGLISH 380 /* Please see man pages for details 381 382 */ 383 #else 384 /* Please see man pages for details 385 386 */ 387 #endif 388 CombinerStage::CombineAlpha m_CombineAlpha; 389 390 #if NN_GD_DOCUMENT_TYPE == ENGLISH 391 /* Please see man pages for details 392 393 */ 394 #else 395 /* Please see man pages for details 396 397 */ 398 #endif 399 CombinerStage::Scale m_ScaleRgb; 400 401 #if NN_GD_DOCUMENT_TYPE == ENGLISH 402 /* Please see man pages for details 403 404 */ 405 #else 406 /* Please see man pages for details 407 408 */ 409 #endif 410 CombinerStage::Scale m_ScaleAlpha; 411 }; 412 413 #if NN_GD_DOCUMENT_TYPE == ENGLISH 414 /* Please see man pages for details 415 416 417 418 */ 419 #else 420 /* Please see man pages for details 421 422 423 424 */ 425 #endif 426 class CombinerDescription 427 { 428 public: 429 #if NN_GD_DOCUMENT_TYPE == ENGLISH 430 /* Please see man pages for details 431 432 */ 433 #else 434 /* Please see man pages for details 435 436 */ 437 #endif 438 CombinerUnitDescription m_CombinerUnit[CombinerStage::COUNT_TEXTURE_COMBINER_UNITS]; 439 440 #if NN_GD_DOCUMENT_TYPE == ENGLISH 441 /* Please see man pages for details 442 443 */ 444 #else 445 /* Please see man pages for details 446 447 */ 448 #endif 449 u8 m_BufferColor[4]; 450 451 #if NN_GD_DOCUMENT_TYPE == ENGLISH 452 /* Please see man pages for details 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 */ 484 #else 485 /* Please see man pages for details 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 */ 519 #endif 520 u32 m_CombinerInUse; 521 522 #if NN_GD_DOCUMENT_TYPE == ENGLISH 523 /* Please see man pages for details 524 525 526 527 528 529 */ 530 #else 531 /* Please see man pages for details 532 533 534 535 */ 536 #endif 537 struct BufferInput 538 { 539 //!Color of texture combiner unit 1 540 CombinerStage::BufferInput m_Rgb1; 541 //!Color of texture combiner unit 2 542 CombinerStage::BufferInput m_Rgb2; 543 //!Color of texture combiner unit 3 544 CombinerStage::BufferInput m_Rgb3; 545 //!Color of texture combiner unit 4 546 CombinerStage::BufferInput m_Rgb4; 547 //!Alpha of texture combiner unit 1 548 CombinerStage::BufferInput m_Alpha1; 549 //!Alpha of texture combiner unit 2 550 CombinerStage::BufferInput m_Alpha2; 551 //!Alpha of texture combiner unit 3 552 CombinerStage::BufferInput m_Alpha3; 553 //!Alpha of texture combiner unit 4 554 CombinerStage::BufferInput m_Alpha4; 555 }; 556 557 #if NN_GD_DOCUMENT_TYPE == ENGLISH 558 /* Please see man pages for details 559 560 */ 561 #else 562 /* Please see man pages for details 563 564 565 */ 566 #endif 567 struct BufferInput m_BufferInput; 568 569 #if NN_GD_DOCUMENT_TYPE == ENGLISH 570 /* Please see man pages for details 571 572 573 574 575 576 577 */ 578 #else 579 /* Please see man pages for details 580 581 582 583 584 585 586 */ 587 #endif SetSourceRGB(CombinerStage::UnitId unit,CombinerStage::Source sourceRGB1,CombinerStage::Source sourceRGB2,CombinerStage::Source sourceRGB3)588 void SetSourceRGB(CombinerStage::UnitId unit, CombinerStage::Source sourceRGB1, CombinerStage::Source sourceRGB2, CombinerStage::Source sourceRGB3) 589 { 590 m_CombinerUnit[unit].m_SrcRGB[0] = sourceRGB1; 591 m_CombinerUnit[unit].m_SrcRGB[1] = sourceRGB2; 592 m_CombinerUnit[unit].m_SrcRGB[2] = sourceRGB3; 593 } 594 595 #if NN_GD_DOCUMENT_TYPE == ENGLISH 596 /* Please see man pages for details 597 598 599 600 601 602 603 */ 604 #else 605 /* Please see man pages for details 606 607 608 609 610 611 612 */ 613 #endif SetOperandRGB(CombinerStage::UnitId unit,CombinerStage::OperandRgb opRGB1,CombinerStage::OperandRgb opRGB2,CombinerStage::OperandRgb opRGB3)614 void SetOperandRGB(CombinerStage::UnitId unit, CombinerStage::OperandRgb opRGB1, CombinerStage::OperandRgb opRGB2, CombinerStage::OperandRgb opRGB3) 615 { 616 m_CombinerUnit[unit].m_OperandRgb[0] = opRGB1; 617 m_CombinerUnit[unit].m_OperandRgb[1] = opRGB2; 618 m_CombinerUnit[unit].m_OperandRgb[2] = opRGB3; 619 } 620 621 #if NN_GD_DOCUMENT_TYPE == ENGLISH 622 /* Please see man pages for details 623 624 625 626 627 628 629 */ 630 #else 631 /* Please see man pages for details 632 633 634 635 636 637 638 */ 639 #endif SetSourceAlpha(CombinerStage::UnitId unit,CombinerStage::Source sourceA1,CombinerStage::Source sourceA2,CombinerStage::Source sourceA3)640 void SetSourceAlpha(CombinerStage::UnitId unit, CombinerStage::Source sourceA1, CombinerStage::Source sourceA2, CombinerStage::Source sourceA3) 641 { 642 m_CombinerUnit[unit].m_SrcAlpha[0] = sourceA1; 643 m_CombinerUnit[unit].m_SrcAlpha[1] = sourceA2; 644 m_CombinerUnit[unit].m_SrcAlpha[2] = sourceA3; 645 } 646 647 #if NN_GD_DOCUMENT_TYPE == ENGLISH 648 /* Please see man pages for details 649 650 651 652 653 654 655 */ 656 #else 657 /* Please see man pages for details 658 659 660 661 662 663 664 */ 665 #endif SetOperandAlpha(CombinerStage::UnitId unit,CombinerStage::OperandAlpha opA1,CombinerStage::OperandAlpha opA2,CombinerStage::OperandAlpha opA3)666 void SetOperandAlpha(CombinerStage::UnitId unit, CombinerStage::OperandAlpha opA1, CombinerStage::OperandAlpha opA2, CombinerStage::OperandAlpha opA3) 667 { 668 m_CombinerUnit[unit].m_OperandAlpha[0] = opA1; 669 m_CombinerUnit[unit].m_OperandAlpha[1] = opA2; 670 m_CombinerUnit[unit].m_OperandAlpha[2] = opA3; 671 } 672 673 #if NN_GD_DOCUMENT_TYPE == ENGLISH 674 /* Please see man pages for details 675 676 677 678 679 */ 680 #else 681 /* Please see man pages for details 682 683 684 685 686 */ 687 #endif SetCombineRGB(CombinerStage::UnitId unit,CombinerStage::CombineRgb combineRgb)688 void SetCombineRGB(CombinerStage::UnitId unit, CombinerStage::CombineRgb combineRgb) 689 { 690 m_CombinerUnit[unit].m_CombineRgb = combineRgb; 691 } 692 693 #if NN_GD_DOCUMENT_TYPE == ENGLISH 694 /* Please see man pages for details 695 696 697 698 699 */ 700 #else 701 /* Please see man pages for details 702 703 704 705 706 */ 707 #endif SetCombineAlpha(CombinerStage::UnitId unit,CombinerStage::CombineAlpha combineAlpha)708 void SetCombineAlpha(CombinerStage::UnitId unit, CombinerStage::CombineAlpha combineAlpha) 709 { 710 m_CombinerUnit[unit].m_CombineAlpha = combineAlpha; 711 } 712 713 #if NN_GD_DOCUMENT_TYPE == ENGLISH 714 /* Please see man pages for details 715 716 717 718 719 */ 720 #else 721 /* Please see man pages for details 722 723 724 725 726 */ 727 #endif SetScaleRGB(CombinerStage::UnitId unit,CombinerStage::Scale scaleRgb)728 void SetScaleRGB(CombinerStage::UnitId unit, CombinerStage::Scale scaleRgb) 729 { 730 m_CombinerUnit[unit].m_ScaleRgb = scaleRgb; 731 } 732 733 #if NN_GD_DOCUMENT_TYPE == ENGLISH 734 /* Please see man pages for details 735 736 737 738 739 */ 740 #else 741 /* Please see man pages for details 742 743 744 745 746 */ 747 #endif SetScaleAlpha(CombinerStage::UnitId unit,CombinerStage::Scale scaleAlpha)748 void SetScaleAlpha(CombinerStage::UnitId unit, CombinerStage::Scale scaleAlpha) 749 { 750 m_CombinerUnit[unit].m_ScaleAlpha = scaleAlpha; 751 } 752 753 #if NN_GD_DOCUMENT_TYPE == ENGLISH 754 /* Please see man pages for details 755 756 757 758 759 */ 760 #else 761 /* Please see man pages for details 762 763 764 765 766 */ 767 #endif SetBufferColor(u8 colorR,u8 colorG,u8 colorB,u8 colorA)768 void SetBufferColor(u8 colorR, u8 colorG, u8 colorB, u8 colorA) 769 { 770 m_BufferColor[0] = colorR; 771 m_BufferColor[1] = colorG; 772 m_BufferColor[2] = colorB; 773 m_BufferColor[3] = colorA; 774 } 775 776 #if NN_GD_DOCUMENT_TYPE == ENGLISH 777 /* Please see man pages for details 778 779 780 */ 781 #else 782 /* Please see man pages for details 783 784 785 */ 786 #endif SetCombinerInUse(CombinerStage::UnitId unit,gdBool mode)787 void SetCombinerInUse(CombinerStage::UnitId unit, gdBool mode) 788 { 789 u32 UseId = 1<<unit; 790 791 m_CombinerInUse &= ~(UseId); 792 if (mode == GD_TRUE) m_CombinerInUse |= UseId; 793 } 794 795 #if NN_GD_DOCUMENT_TYPE == ENGLISH 796 /* Please see man pages for details 797 */ 798 #else 799 /* Please see man pages for details 800 */ 801 #endif CombinerDescription()802 CombinerDescription() 803 { 804 ToDefault(); 805 } 806 807 #if NN_GD_DOCUMENT_TYPE == ENGLISH 808 /* Please see man pages for details 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 */ 827 #else 828 /* Please see man pages for details 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 */ 860 #endif ToDefault()861 void ToDefault() 862 { 863 memset(m_CombinerUnit, 0, sizeof(m_CombinerUnit)); 864 865 m_CombinerUnit[0].m_SrcRGB[0] = m_CombinerUnit[0].m_SrcRGB[1] = m_CombinerUnit[0].m_SrcRGB[2] = CombinerStage::SOURCE_CONSTANT; 866 m_CombinerUnit[0].m_SrcAlpha[0] = m_CombinerUnit[0].m_SrcAlpha[1] = m_CombinerUnit[0].m_SrcAlpha[2] = CombinerStage::SOURCE_CONSTANT; 867 868 for (int i = 1; i < CombinerStage::COUNT_TEXTURE_COMBINER_UNITS; i++) 869 { 870 m_CombinerUnit[i].m_SrcRGB[0] = m_CombinerUnit[i].m_SrcRGB[1] = m_CombinerUnit[i].m_SrcRGB[2] = CombinerStage::SOURCE_PREVIOUS; 871 m_CombinerUnit[i].m_SrcAlpha[0] = m_CombinerUnit[i].m_SrcAlpha[1] = m_CombinerUnit[i].m_SrcAlpha[2] = CombinerStage::SOURCE_PREVIOUS; 872 } 873 m_BufferInput.m_Rgb1 = m_BufferInput.m_Rgb2 = m_BufferInput.m_Rgb3 = m_BufferInput.m_Rgb4 = 874 m_BufferInput.m_Alpha1 = m_BufferInput.m_Alpha2 = m_BufferInput.m_Alpha3 = m_BufferInput.m_Alpha4 = CombinerStage::INPUT_PREVIOUS_BUFFER; 875 m_BufferColor[0] = m_BufferColor[1] = m_BufferColor[2] = m_BufferColor[3] = 0; 876 m_CombinerInUse = 0; 877 } 878 879 }; // CombinerDescription; 880 881 } // namespace CTR 882 } // namespace gd 883 } // namespace nn 884 885 886 #endif // NN_GD_CTR_GD_COMBINER_H_ 887