1 /*---------------------------------------------------------------------------*
2   Project:  Horizon
3   File:     gr_FrameBuffer.h
4 
5   Copyright (C)2009-2012 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: 47820 $
14  *---------------------------------------------------------------------------*/
15 
16 #ifndef NN_GR_FRAME_BUFFER_H_
17 #define NN_GR_FRAME_BUFFER_H_
18 
19 #include <nn/gr/CTR/gr_Utility.h>
20 #include <nn/gx/CTR/gx_CTRRaw.h>
21 
22 namespace nn
23 {
24     namespace gr
25     {
26         namespace CTR
27         {
28 
29             /* Please see man pages for details
30 
31              */
32             class FrameBuffer
33             {
34             public :
35                 static const u32 COLOR_BUFFER_BIT         = 0x1; //
36                 static const u32 DEPTH_BUFFER_BIT         = 0x2; //
37                 static const u32 STENCIL_BUFFER_BIT       = 0x4; //
38                 static const u32 DEPTH_STENCIL_BUFFER_BIT = DEPTH_BUFFER_BIT | STENCIL_BUFFER_BIT; //
39 
40                 /* Please see man pages for details
41 
42                  */
43                 enum BlockSize
44                 {
45                     /* Please see man pages for details
46 
47                     */
48                     BLOCK_SIZE8  = 0x0,
49 
50                     /* Please see man pages for details
51 
52 
53                     */
54                     BLOCK_SIZE32 = 0x1
55                 };
56 
57                 /* Please see man pages for details
58 
59                 */
60                 class ColorBuffer
61                 {
62                 public :
63                     /* Please see man pages for details
64 
65                     */
66                     uptr  virtualAddr;
67 
68                     /* Please see man pages for details
69 
70                     */
71                     PicaDataColor format;
72 
73                     /* Please see man pages for details
74 
75                     */
76                     BlockSize blockSize;
77                     NN_PADDING2;
78 
79                     /* Please see man pages for details
80 
81                     */
82                     s32 width;
83 
84                     /* Please see man pages for details
85 
86                     */
87                     s32 height;
88 
89                     /* Please see man pages for details
90 
91 
92                      */
93                     f32 clearColor[ 4 ];
94 
95                 public :
96                     /* Please see man pages for details
97 
98 
99 
100                      */
101                     explicit ColorBuffer( const FrameBuffer& frameBuffer_ );
102 
103                     /* Please see man pages for details
104 
105 
106 
107 
108 
109                      */
110                     bit32* MakeRenderBlockModeCommand( bit32* command ) const;
111 
112                     /* Please see man pages for details
113 
114 
115 
116 
117 
118 
119                      */
120                     bit32* MakeCommand( bit32* command, bool isAddRenderBlockMode = false ) const;
121 
122                 protected :
123                     const FrameBuffer& m_FrameBuffer;
124                 };
125 
126                 /* Please see man pages for details
127 
128                 */
129                 class DepthStencilBuffer
130                 {
131                 public :
132                     /* Please see man pages for details
133 
134                     */
135                     uptr  virtualAddr;
136 
137                     /* Please see man pages for details
138 
139                     */
140                     PicaDataDepth format;
141                     NN_PADDING3;
142 
143                     /* Please see man pages for details
144 
145                     */
146                     s32 width;
147 
148                     /* Please see man pages for details
149 
150                     */
151                     s32 height;
152 
153                     /* Please see man pages for details
154 
155 
156 
157                      */
158                     f32 clearDepth;
159 
160                     /* Please see man pages for details
161 
162 
163 
164                      */
165                     u8 clearStencil;
166                     NN_PADDING3;
167 
168                 public :
169                     /* Please see man pages for details
170 
171 
172 
173                      */
174                     explicit DepthStencilBuffer( const FrameBuffer& frameBuffer_ );
175 
176                     /* Please see man pages for details
177 
178 
179 
180 
181 
182                      */
183                     bit32* MakeCommand( bit32* command ) const;
184 
185                 protected :
186                     const FrameBuffer& m_FrameBuffer;
187                 };
188 
189             public :
190                 /* Please see man pages for details
191 
192 
193                  */
194                 ColorBuffer colorBuffer;
195 
196                 /* Please see man pages for details
197 
198 
199                  */
200                 DepthStencilBuffer depthStencilBuffer;
201 
202                 /* Please see man pages for details
203 
204                  */
205                 s32 width;
206 
207                 /* Please see man pages for details
208 
209                  */
210                 s32 height;
211 
212             public :
213                 /* Please see man pages for details
214 
215 
216 
217 
218                  */
219                 explicit FrameBuffer();
220 
221                 /* Please see man pages for details
222 
223 
224 
225 
226 
227 
228                  */
229                 static bit32* MakeClearCacheCommand( bit32* command );
230 
231                 /* Please see man pages for details
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242                  */
243                 bit32* MakeCommand( bit32* command, const u32 bufferBit, bool isClearCache = true ) const;
244 
245                 /* Please see man pages for details
246 
247 
248 
249 
250 
251 
252                  */
253                 void MakeClearRequest( const u32 bufferBit, bool isAddSplitDrawCmdlist = true );
254                 void MakeClearRequestRaw( nngxCommandList* commandList, const u32 bufferBit, bool isAddSplitDrawCmdlist = true );
255             };
256 
257         } // namespace CTR
258     } // namespace gr
259 } // namespace nn
260 
261 #endif // NN_GR_FRAME_BUFFER_H_
262