1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     gr_RenderState.h
4   Copyright (C)2010 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   $Rev: 37152 $
11  *---------------------------------------------------------------------------
12 
13 
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                     Sets values. Rendering commands can be generated by calling the MakeCommand function.
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                     f32 zScale;
368 
369                     /* Please see man pages for details
370 
371 
372 
373                     */
374                     f32 penumbraScale;
375 
376                     /* Please see man pages for details
377 
378 
379 
380                     */
381                     f32 penumbraBias;
382 
383                 protected:
384                     const RenderState& m_RenderState;
385                 };
386 
387                 /* Please see man pages for details
388 
389                  */
390                 class StencilTest
391                 {
392                 public :
393                     /* Please see man pages for details
394 
395                      */
396                     bool isEnable;
397 
398                     /* Please see man pages for details
399 
400 
401 
402                      */
403                     bit8 maskOp;
404                     NN_PADDING2;
405 
406                     /* Please see man pages for details
407 
408 
409 
410 
411                     */
412                     PicaDataStencilTest func;
413                     NN_PADDING3;
414 
415 
416                     /* Please see man pages for details
417 
418 
419                     */
420                     bit32  ref;
421 
422 
423                     /* Please see man pages for details
424 
425 
426 
427                     */
428                     /*
429                         If the stencil buffer value is used as stencil, a comparison is made between ( stencil & mask ) and ( ref & mask ).
430 
431                      */
432                     bit32  mask;
433 
434 
435                     /* Please see man pages for details
436 
437 
438 
439 
440 
441                     */
442                     PicaDataStencilOp opFail;
443 
444 
445                     /* Please see man pages for details
446 
447 
448 
449 
450 
451                     */
452                     PicaDataStencilOp  opZFail;
453 
454 
455                     /* Please see man pages for details
456 
457 
458 
459 
460                     */
461                     PicaDataStencilOp  opZPass;
462 
463                     NN_PADDING1;
464 
465                 public :
466                     /* Please see man pages for details
467 
468 
469 
470 */
471                     explicit StencilTest( const RenderState& renderState_ );
472 
473                     /* Please see man pages for details
474 
475 
476 
477 
478 
479 
480                      */
481                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
482 
483                     /* Please see man pages for details
484 
485 
486 
487 
488 
489 
490 */
491                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
492 
493                 protected:
494                     const RenderState& m_RenderState;
495                 };
496 
497                 /* Please see man pages for details
498 
499                  */
500                 class DepthTest
501                 {
502                 public :
503                     /* Please see man pages for details
504 
505 
506 
507 
508                      */
509                     bool             isEnable;
510 
511 
512                     /* Please see man pages for details
513 
514 
515 
516                      */
517                     bool             isEnableWrite;
518 
519                     /* Please see man pages for details
520 
521 
522 
523                     */
524                     PicaDataDepthTest func;
525 
526                     NN_PADDING1;
527 
528                 public :
529                     /* Please see man pages for details
530 
531 
532 
533 */
534                     explicit DepthTest( const RenderState& renderState_ );
535 
536 
537                     /* Please see man pages for details
538 
539 
540 
541 
542 
543 
544 
545 
546 */
547                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
548 
549                     /* Please see man pages for details
550 
551 
552 
553 
554 
555 
556 
557 */
558                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
559 
560                 protected:
561                     const RenderState& m_RenderState;
562                 };
563 
564                 /* Please see man pages for details
565 
566                  */
567                 class WBuffer
568                 {
569                 public :
570 
571                     /* Please see man pages for details
572 
573 
574                      */
575                     f32 wScale;
576 
577                     /* Please see man pages for details
578 
579 
580                      */
581                     bool isEnablePolygonOffset;
582 
583                     NN_PADDING3;
584 
585                     /* Please see man pages for details
586 
587 
588 
589 
590 
591 
592 
593 
594 
595 */
596 
597                     f32  polygonOffsetUnit;
598 
599                     /* Please see man pages for details
600 
601 
602 
603 
604 
605                      */
606                     f32  depthRangeNear;
607 
608                     /* Please see man pages for details
609 
610 
611 
612 
613 
614                      */
615                     f32  depthRangeFar;
616 
617                     /* Please see man pages for details
618 
619 
620 
621                      */
622                     u8   depthRangeBit;
623 
624                     NN_PADDING3;
625 
626                 public :
627                     /* Please see man pages for details
628 
629 
630 
631 */
632                     explicit WBuffer( const RenderState& renderState_ );
633 
634                     /* Please see man pages for details
635 
636 
637 
638 
639 
640 
641 */
642                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
643 
644                 protected:
645                     const RenderState& m_RenderState;
646                 };
647 
648                 /* Please see man pages for details
649 
650                  */
651                 class Culling
652                 {
653                 public :
654                     /* Please see man pages for details
655 
656 
657 
658 
659                      */
660                     bool isEnable;
661 
662                     /* Please see man pages for details
663 
664                      */
665                     enum FrontFace
666                     {
667                         /* Please see man pages for details
668 
669                         */
670                         FRONT_FACE_CW ,
671 
672                         /* Please see man pages for details
673 
674                         */
675                         FRONT_FACE_CCW
676                     };
677 
678                     /* Please see man pages for details
679 
680 
681 
682                      */
683                     FrontFace frontFace;
684 
685                     /* Please see man pages for details
686 
687                      */
688                     enum CullFace
689                     {
690                         /* Please see man pages for details
691 
692                         */
693                         CULL_FACE_FRONT,
694                          /* Please see man pages for details
695 
696                         */
697                         CULL_FACE_BACK
698                     };
699 
700                     /* Please see man pages for details
701 
702 
703 
704                      */
705                     CullFace cullFace;
706 
707                     NN_PADDING1;
708 
709                 public :
710                     /* Please see man pages for details
711 
712 
713 
714 */
715                     explicit Culling( const RenderState& renderState_ );
716 
717 
718                     /* Please see man pages for details
719 
720 
721 
722 
723 
724                      */
725                     bit32* MakeCommand( bit32* command, bool isUpdateFBAccess = true ) const;
726 
727                     /* Please see man pages for details
728 
729 
730 
731 
732 
733 
734 */
735                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
736 
737                 protected:
738                     const RenderState& m_RenderState;
739                 };
740 
741                 /* Please see man pages for details
742 
743                 */
744                 /*
745                     Frame buffer access settings depend on the color mask, blend, logical operations, depth test, and stencil test settings. Accordingly, specify references using the constructor.
746 
747                     If frame buffer access settings change after generating a command that changes the above settings, a command must be generated using FBAccess::MakeCommand function.
748 
749 
750                 */
751                 class FBAccess
752                 {
753                 public :
754                     /* Please see man pages for details
755 
756 
757 
758 
759 */
760                     explicit FBAccess( const RenderState& renderState_ );
761 
762                     /* Please see man pages for details
763 
764 
765 
766 
767 
768 
769 */
770                     bit32* MakeCommand( bit32* command, bool isClearFrameBufferCache = true ) const;
771 
772                     /* Please see man pages for details
773 
774 
775 
776 
777 
778 
779 */
780                     static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
781 
782                     /* Please see man pages for details
783 
784 
785 
786 
787 
788 */
789                     static bit32* MakeClearCacheCommand( bit32* command );
790 
791                 protected:
792                     const RenderState& m_RenderState;
793                 };
794 
795             public :
796                 /* Please see man pages for details
797 
798 
799 
800 
801                  */
802                 Blend       blend;
803 
804                 /* Please see man pages for details
805 
806 
807 
808 
809                  */
810                 LogicOp     logicOp;
811 
812                 /* Please see man pages for details
813 
814 
815 
816                  */
817                 ShadowMap  shadowMap;
818 
819                 /* Please see man pages for details
820 
821 
822                  */
823                 AlphaTest   alphaTest;
824 
825                 /* Please see man pages for details
826 
827 
828                  */
829                 StencilTest stencilTest;
830 
831                 /* Please see man pages for details
832 
833 
834                  */
835                 ColorMask   colorMask;
836                 NN_PADDING3;
837 
838                 /* Please see man pages for details
839 
840 
841 
842 
843 */
844                 DepthTest   depthTest;
845 
846                 /* Please see man pages for details
847 
848 
849 
850 
851 */
852                 Culling     cullingTest;
853 
854                 /* Please see man pages for details
855 
856 
857 
858 
859 */
860                 WBuffer     wBuffer;
861 
862                 /* Please see man pages for details
863 
864 
865 
866                  */
867                 FBAccess    fbAccess;
868 
869             public :
870                 /* Please see man pages for details
871 
872 
873 
874 
875 
876 
877 
878 
879 
880 
881 
882 */
883                 explicit RenderState();
884 
885                 /* Please see man pages for details
886 
887 
888 
889 
890 
891 
892 
893 
894 
895 
896 
897 
898 
899 
900 
901 
902 */
903                 bit32* MakeCommand( bit32* command, bool isClearFrameBufferCache = true ) const;
904 
905                 /* Please see man pages for details
906 
907 
908 
909 
910 
911 
912 */
913                 static bit32* MakeDisableCommand( bit32* command, bool isClearFrameBufferCache = true );
914             };
915 
916         } // namespace CTR
917     } // namespace gr
918 } // namespace nn
919 
920 #endif // NN_GR_RENDER_STATE_H_
921