1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     gr_RenderState.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: 38755 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_GR_RENDER_STATE_H_
17 #define NN_GR_RENDER_STATE_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             /* Please see man pages for details
29 
30              */
31             class RenderState
32             {
33             public :
34                 /* Please see man pages for details
35 
36                  */
37                 enum ColorMask
38                 {
39                     //
40                     COLOR_MASK_R    = 1 << 0,
41                     //
42                     COLOR_MASK_G    = 1 << 1,
43                     //
44                     COLOR_MASK_B    = 1 << 2,
45                     //
46                     COLOR_MASK_A    = 1 << 3,
47                     //
48                     COLOR_MASK_RGBA = COLOR_MASK_R | COLOR_MASK_G | COLOR_MASK_B | COLOR_MASK_A
49                 };
50 
51                 /* Please see man pages for details
52 
53                  */
54                 /*
55                     By setting each value and calling the MakeCommand function, the render command can be generated.
56                 */
57                 class AlphaTest
58                 {
59                 public :
60                     /* Please see man pages for details
61 
62 
63 
64 
65                      */
66                     bool isEnable;
67 
68                     /* Please see man pages for details
69 
70 
71 
72 
73                      */
74                     u8 refValue;
75 
76                     /* Please see man pages for details
77 
78 
79 
80                     */
81                     PicaDataAlphaTest func;
82 
83                     NN_PADDING1;
84 
85                 public :
86                     /* Please see man pages for details
87 
88 
89 
90                      */
91                     explicit AlphaTest( const RenderState& renderState_ );
92 
93                     /* Please see man pages for details
94 
95 
96 
97 
98 
99 
100                      */
101                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
102 
103 
104                     /* Please see man pages for details
105 
106 
107 
108 
109 
110 
111                      */
112                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
113 
114                 protected:
115                     const RenderState& m_RenderState;
116                 };
117 
118                 /* Please see man pages for details
119 
120 
121 
122                 */
123                 class Blend
124                 {
125                 public :
126                     /* Please see man pages for details
127 
128 
129 
130                      */
131                     bool isEnable;
132 
133                     /* Please see man pages for details
134 
135                           
136                     */
137                     PicaDataBlendEquation eqRgb;
138 
139 
140                     /* Please see man pages for details
141 
142 
143                     */
144                     PicaDataBlendEquation eqAlpha;
145 
146                     /* Please see man pages for details
147 
148 
149 
150                     */
151                     PicaDataBlendFunc srcRgb;
152 
153                     /* Please see man pages for details
154 
155 
156 
157                     */
158                     PicaDataBlendFunc srcAlpha;
159 
160 
161                     /* Please see man pages for details
162 
163 
164 
165                     */
166                     PicaDataBlendFunc dstRgb;
167 
168                     /* Please see man pages for details
169 
170 
171                            
172                     */
173                     PicaDataBlendFunc dstAlpha;
174 
175 
176                     /* Please see man pages for details
177 
178 
179 
180                     */
181                     u8 colorR;
182 
183 
184                     /* Please see man pages for details
185 
186 
187 
188                     */
189                     u8 colorG;
190 
191 
192                     /* Please see man pages for details
193 
194 
195 
196                     */
197                     u8 colorB;
198 
199 
200                     /* Please see man pages for details
201 
202 
203                     */
204                     u8 colorA;
205 
206                     NN_PADDING1;
207 
208                 public :
209                     /* Please see man pages for details
210 
211 
212 
213                      */
214                     explicit Blend( const RenderState& renderState_ );
215 
216 
217                     /* Please see man pages for details
218 
219 
220 
221 
222 
223 
224                      */
225                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
226 
227                     /* Please see man pages for details
228 
229 
230 
231 
232 
233 
234                      */
235                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
236 
237                 protected:
238                     const RenderState& m_RenderState;
239 
240                 };
241 
242                 /* Please see man pages for details
243 
244 
245 
246                 */
247                 class LogicOp
248                 {
249                 public :
250                     /* Please see man pages for details
251 
252 
253                      */
254                     bool isEnable;
255 
256                     /* Please see man pages for details
257 
258 
259 
260                     */
261                     PicaDataLogicOp opCode;
262 
263                     NN_PADDING2;
264 
265                 public :
266                     /* Please see man pages for details
267 
268 
269 
270                      */
271                     explicit LogicOp( const RenderState& renderState_ );
272 
273                     /* Please see man pages for details
274 
275 
276 
277 
278 
279 
280                      */
281                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
282 
283                 protected:
284                     const RenderState& m_RenderState;
285                 };
286 
287                 /* Please see man pages for details
288 
289 
290 
291                 */
292                 class ShadowMap
293                 {
294                 public :
295                     /* Please see man pages for details
296 
297 
298 
299                     */
300                     explicit ShadowMap( const RenderState& renderState_ );
301 
302                     /* Please see man pages for details
303 
304 
305 
306 
307 
308 
309 
310                  */
311                     bit32* MakeCommand( bit32* command,
312                                         bool isUpdateFBAccess = true,
313                                         bool isAddDummyCommand = true ) const;
314 
315                     /* Please see man pages for details
316 
317 
318 
319 
320 
321 
322                     */
323                     bit32* MakeTextureCommand( bit32* command,
324                                                bool isAddDummyCommand = true ) const;
325 
326                     /* Please see man pages for details
327 
328 
329 
330 
331 
332                     */
333                     bit32* MakeAttenuationCommand( bit32* command ) const;
334 
335                     /* Please see man pages for details
336 
337 
338 
339 
340 
341 
342                      */
343                     bool isEnable;
344 
345                     /* Please see man pages for details
346 
347 
348 
349                     */
350                     bool isPerspective;
351                     NN_PADDING2;
352 
353                     /* Please see man pages for details
354 
355 
356 
357 
358                     */
359                     f32 zBias;
360 
361 
362                     /* Please see man pages for details
363 
364 
365 
366 
367                     */
368                     f32 zScale;
369 
370                     /* Please see man pages for details
371 
372 
373 
374                     */
375                     f32 penumbraScale;
376 
377                     /* Please see man pages for details
378 
379 
380 
381                     */
382                     f32 penumbraBias;
383 
384                 protected:
385                     const RenderState& m_RenderState;
386                 };
387 
388                 /* Please see man pages for details
389 
390                  */
391                 class StencilTest
392                 {
393                 public :
394                     /* Please see man pages for details
395 
396                      */
397                     bool isEnable;
398 
399                     /* Please see man pages for details
400 
401 
402 
403                      */
404                     bit8 maskOp;
405                     NN_PADDING2;
406 
407                     /* Please see man pages for details
408 
409 
410 
411 
412                     */
413                     PicaDataStencilTest func;
414                     NN_PADDING3;
415 
416 
417                     /* Please see man pages for details
418 
419 
420                     */
421                     bit32  ref;
422 
423 
424                     /* Please see man pages for details
425 
426 
427 
428                     */
429                     /*
430                         By setting the stencil buffer value to stencil, the gap between ( stencil & mask ) and ( ref & mask ) are compared
431 432                      */
433                     bit32  mask;
434 
435 
436                     /* Please see man pages for details
437 
438 
439 
440 
441 
442                     */
443                     PicaDataStencilOp opFail;
444 
445 
446                     /* Please see man pages for details
447 
448 
449 
450 
451 
452                     */
453                     PicaDataStencilOp  opZFail;
454 
455 
456                     /* Please see man pages for details
457 
458 
459 
460 
461                     */
462                     PicaDataStencilOp  opZPass;
463 
464                     NN_PADDING1;
465 
466                 public :
467                     /* Please see man pages for details
468 
469 
470 
471                      */
472                     explicit StencilTest( const RenderState& renderState_ );
473 
474                     /* Please see man pages for details
475 
476 
477 
478 
479 
480 
481                      */
482                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
483 
484                     /* Please see man pages for details
485 
486 
487 
488 
489 
490 
491                      */
492                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
493 
494                 protected:
495                     const RenderState& m_RenderState;
496                 };
497 
498                 /* Please see man pages for details
499 
500                  */
501                 class DepthTest
502                 {
503                 public :
504                     /* Please see man pages for details
505 
506 
507 
508 
509                      */
510                     bool             isEnable;
511 
512 
513                     /* Please see man pages for details
514 
515 
516 
517                      */
518                     bool             isEnableWrite;
519 
520                     /* Please see man pages for details
521 
522 
523 
524                     */
525                     PicaDataDepthTest func;
526 
527                     NN_PADDING1;
528 
529                 public :
530                     /* Please see man pages for details
531 
532 
533 
534                      */
535                     explicit DepthTest( const RenderState& renderState_ );
536 
537 
538                     /* Please see man pages for details
539 
540 
541 
542 
543 
544 
545 
546 
547                      */
548                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
549 
550                     /* Please see man pages for details
551 
552 
553 
554 
555 
556 
557 
558                      */
559                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
560 
561                 protected:
562                     const RenderState& m_RenderState;
563                 };
564 
565                 /* Please see man pages for details
566 
567                  */
568                 class WBuffer
569                 {
570                 public :
571 
572                     /* Please see man pages for details
573 
574 
575                      */
576                     f32 wScale;
577 
578                     /* Please see man pages for details
579 
580 
581                      */
582                     bool isEnablePolygonOffset;
583 
584                     NN_PADDING3;
585 
586                     /* Please see man pages for details
587 
588 
589 
590 
591 
592 
593 
594 
595 
596                      */
597 
598                     f32  polygonOffsetUnit;
599 
600                     /* Please see man pages for details
601 
602 
603 
604 
605 
606                      */
607                     f32  depthRangeNear;
608 
609                     /* Please see man pages for details
610 
611 
612 
613 
614 
615                      */
616                     f32  depthRangeFar;
617 
618                     /* Please see man pages for details
619 
620 
621 
622                      */
623                     u8   depthRangeBit;
624 
625                     NN_PADDING3;
626 
627                 public :
628                     /* Please see man pages for details
629 
630 
631 
632                      */
633                     explicit WBuffer( const RenderState& renderState_ );
634 
635                     /* Please see man pages for details
636 
637 
638 
639 
640 
641 
642                      */
643                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
644 
645                 protected:
646                     const RenderState& m_RenderState;
647                 };
648 
649                 /* Please see man pages for details
650 
651                  */
652                 class Culling
653                 {
654                 public :
655                     /* Please see man pages for details
656 
657 
658 
659 
660                      */
661                     bool isEnable;
662 
663                     /* Please see man pages for details
664 
665                      */
666                     enum FrontFace
667                     {
668                         /* Please see man pages for details
669 
670                         */
671                         FRONT_FACE_CW ,
672 
673                         /* Please see man pages for details
674 
675                         */
676                         FRONT_FACE_CCW
677                     };
678 
679                     /* Please see man pages for details
680 
681 
682 
683                      */
684                     FrontFace frontFace;
685 
686                     /* Please see man pages for details
687 
688                      */
689                     enum CullFace
690                     {
691                         /* Please see man pages for details
692 
693                         */
694                         CULL_FACE_FRONT,
695                          /* Please see man pages for details
696 
697                         */
698                         CULL_FACE_BACK
699                     };
700 
701                     /* Please see man pages for details
702 
703 
704 
705                      */
706                     CullFace cullFace;
707 
708                     NN_PADDING1;
709 
710                 public :
711                     /* Please see man pages for details
712 
713 
714 
715                      */
716                     explicit Culling( const RenderState& renderState_ );
717 
718 
719                     /* Please see man pages for details
720 
721 
722 
723 
724 
725                      */
726                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
727 
728                     /* Please see man pages for details
729 
730 
731 
732 
733 
734 
735                      */
736                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
737 
738                 protected:
739                     const RenderState& m_RenderState;
740                 };
741 
742                 /* Please see man pages for details
743 
744                 */
745                 /*
746                     The frame buffer access settings depend on the color mask, blend, logical operation, depth test, and stencil test settings, so specify to reference with the constructor.
747 
748                     If changes occur to frame buffer access after generating the command to change the above settings, a command must be generated with the FBAccess::MakeCommand function.
749 
750 
751                 */
752                 class FBAccess
753                 {
754                 public :
755                     /* Please see man pages for details
756 
757 
758 
759 
760                      */
761                     explicit FBAccess( const RenderState& renderState_ );
762 
763                     /* Please see man pages for details
764 
765 
766 
767 
768 
769 
770                      */
771                     bit32* MakeCommand( bit32* command, bool isClearFrameBufferCache = true ) const;
772 
773                     /* Please see man pages for details
774 
775 
776 
777 
778 
779 
780                      */
781                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
782 
783                     /* Please see man pages for details
784 
785 
786 
787 
788 
789                      */
790                     static bit32* MakeClearCacheCommand( bit32* command );
791 
792                 protected:
793                     const RenderState& m_RenderState;
794                 };
795 
796             public :
797                 /* Please see man pages for details
798 
799 
800 
801 
802                  */
803                 Blend       blend;
804 
805                 /* Please see man pages for details
806 
807 
808 
809 
810                  */
811                 LogicOp     logicOp;
812 
813                 /* Please see man pages for details
814 
815 
816 
817                  */
818                 ShadowMap  shadowMap;
819 
820                 /* Please see man pages for details
821 
822 
823                  */
824                 AlphaTest   alphaTest;
825 
826                 /* Please see man pages for details
827 
828 
829                  */
830                 StencilTest stencilTest;
831 
832                 /* Please see man pages for details
833 
834 
835                  */
836                 ColorMask   colorMask;
837                 NN_PADDING3;
838 
839                 /* Please see man pages for details
840 
841 
842 
843 
844                  */
845                 DepthTest   depthTest;
846 
847                 /* Please see man pages for details
848 
849 
850 
851 
852                  */
853                 Culling     cullingTest;
854 
855                 /* Please see man pages for details
856 
857 
858 
859 
860                  */
861                 WBuffer     wBuffer;
862 
863                 /* Please see man pages for details
864 
865 
866 
867                  */
868                 FBAccess    fbAccess;
869 
870             public :
871                 /* Please see man pages for details
872 
873 
874 
875 
876 
877 
878 
879 
880 
881 
882 
883                  */
884                 explicit RenderState();
885 
886                 /* Please see man pages for details
887 
888 
889 
890 
891 
892 
893 
894 
895 
896 
897 
898 
899 
900 
901 
902 
903                  */
904                 bit32* MakeCommand( bit32* command, bool isClearFrameBufferCache = true ) const;
905 
906                 /* Please see man pages for details
907 
908 
909 
910 
911 
912 
913                  */
914                 static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
915             };
916 
917         } // namespace CTR
918     } // namespace gr
919 } // namespace nn
920 
921 #endif // NN_GR_RENDER_STATE_H_
922