1 /*---------------------------------------------------------------------------*
2 
3   Copyright (C) 2010-2011 Nintendo.  All rights reserved.
4 
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 // gx2Constant.h
14 //
15 // Declares misc function prototypes for gx2 library.
16 
17 #ifndef _CAFE_GX2_CONSTANT_H_
18 #define _CAFE_GX2_CONSTANT_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif // __cplusplus
24 
25 /// @addtogroup GX2ConstGroup
26 /// @{
27 
28 //----------------------------------------------------------------------
29 // Alignments
30 
31 /// \brief All shader binaries (the executable code) must be
32 /// aligned in memory by this value in bytes.
33 ///
34 #define GX2_SHADER_ALIGNMENT 0x100
35 
36 /// \brief Describes the needed byte-alignment for scan buffers.
37 ///
38 #define GX2_SCAN_BUFFER_ALIGNMENT 0x1000
39 
40 /// \brief All uniform blocks must be aligned by this many bytes.
41 /// This only applies in \ref GX2_SHADER_MODE_UNIFORM_BLOCK
42 ///
43 #define GX2_UNIFORM_BLOCK_ALIGNMENT 0x100
44 
45 /// \brief Context state buffers must be aligned by this many bytes.
46 ///
47 #define GX2_CONTEXT_STATE_ALIGNMENT 0x100
48 
49 /// \brief Display list buffers must be aligned by this many bytes.
50 ///
51 #define GX2_DISPLAY_LIST_ALIGNMENT 0x20
52 
53 /// \brief For optimal performance Vertex Buffers should be aligned by this many bytes
54 ///
55 #define GX2_VERTEX_BUFFER_ALIGNMENT 0x40
56 
57 /// \brief For optimal performance Index Buffers should be aligned by this many bytes
58 ///
59 #define GX2_INDEX_BUFFER_ALIGNMENT 0x20
60 
61 /// \brief \ref GX2DispatchParams should be aligned by this many bytes
62 ///
63 #define GX2_DISPATCH_PARAMS_ALIGNMENT 0x100
64 
65 /// \brief This alignment should be used for general buffers such as condtional render, perf, top/bottom gpu counters
66 ///
67 #define GX2_DEFAULT_BUFFER_ALIGNMENT 0x40
68 
69 /// \brief Stream out buffers must be aligned by this many bytes.
70 ///
71 #define GX2_STREAMOUT_BUFFER_ALIGNMENT 0x100
72 
73 /// \brief Stream out context memory must be aligned by this many bytes.
74 ///
75 #define GX2_STREAMOUT_CONTEXT_ALIGNMENT 4
76 
77 /// \brief Export buffer alignment
78 ///
79 #define GX2_EXPORT_BUFFER_ALIGNMENT 0x100
80 
81 //----------------------------------------------------------------------
82 // Byte Sizes
83 
84 /// \brief Default size in bytes used to create command buffer FIFO.
85 ///
86 /// \note Not used yet.
87 ///
88 #define GX2_FIFO_PREFERRED_SIZE (16*1024*1024)
89 
90 /// \brief Size of fetch shader header in bytes.
91 /// See \ref GX2CalcFetchShaderSize()
92 ///
93 #define GX2_FETCH_SHADER_CONTROL_FLOW_SIZE 64
94 
95 /// \brief Size of fetch shader descriptor (one per attribute) in bytes.
96 /// See \ref GX2CalcFetchShaderSize()
97 ///
98 #define GX2_FETCH_SHADER_INSTRUCTION_SIZE 16
99 
100 /// \brief Size of fetch shader alu instruction in bytes.
101 /// See \ref GX2CalcFetchShaderSize()
102 ///
103 #define GX2_FETCH_SHADER_ALU_INSTRUCTION_SIZE 8
104 
105 /// \brief Max size of one uniform block in bytes.
106 /// This applies to \ref GX2_SHADER_MODE_UNIFORM_BLOCK (includes \ref GX2_SHADER_MODE_GEOMETRY_SHADER)
107 /// Each uniform block enables 4096 * vec4 = 65536 bytes
108 ///
109 #define GX2_MAX_UNIFORM_BLOCK_SIZE 65536
110 
111 /// \brief The number of uniform block slot.
112 /// This applies to \ref GX2_SHADER_MODE_UNIFORM_BLOCK (includes \ref GX2_SHADER_MODE_GEOMETRY_SHADER)
113 ///
114 #define GX2_MAX_UNIFORM_BLOCK_SLOT 16
115 
116 /// \brief Stream out buffer context size in bytes.
117 ///
118 #define GX2_STREAMOUT_BUFFER_CONTEXT_SIZE 4
119 
120 //----------------------------------------------------------------------
121 // Perf/Query Counter Invalid Values
122 
123 /// \brief Value used to initialize 64-bit counters before they are read
124 /// (for \ref GX2PerfGroup, \ref GX2QueryGroup).
125 ///
126 #define GX2_INVALID_COUNTER_VALUE_U64 0xFFFFFFFFFFFFFFFF
127 
128 /// \brief Value used to initialize 32-bit counters before they are read
129 /// (for \ref GX2PerfGroup, \ref GX2QueryGroup).
130 ///
131 #define GX2_INVALID_COUNTER_VALUE_U32 0xFFFFFFFF
132 
133 /// \brief Value used to initialize 8-bit counters before they are read
134 /// (for \ref GX2PerfGroup, \ref GX2QueryGroup).
135 ///
136 #define GX2_INVALID_COUNTER_VALUE_U8 0xFF
137 
138 /// \brief 27MHz refence clock used with \ref GX2SampleTopGPUCycle and \ref GX2SampleBottomGPUCycle
139 ///
140 #define GX2_TOP_BOTTOM_CLOCK_CYCLES (27000000)
141 
142 /// \brief Default timeout for \ref GX2WaitTimeStamp and \ref GX2WaitForFlip in
143 /// on seconds. This timeout value can be changed via \ref GX2SetGPUTimeout API.
144 ///
145 #define GX2_DEFAULT_GPU_TIMEOUT_IN_MILLISEC (10 * 1000)
146 
147 /// \brief Default interrupt count limit for each 1/60 second frame before a
148 /// warning is issued (in DEBUG only).  Change with \ref GX2SetInterruptCountLimit.
149 ///
150 #define GX2_DEFAULT_INTERRUPT_COUNT_LIMIT (10000)
151 
152 //----------------------------------------------------------------------
153 // Pixel/texel Sizes
154 
155 /// \brief Max viewport size.
156 ///
157 #define GX2_MAX_VIEWPORT_SIZE        8192
158 
159 /// \brief Max guardband size.
160 ///
161 #define GX2_MAX_GUARDBAND_SIZE       8192
162 
163 /// \brief Max texture width.
164 ///
165 #define GX2_MAX_TEXTURE_WIDTH        8192
166 
167 /// \brief Max texture height.
168 ///
169 #define GX2_MAX_TEXTURE_HEIGHT       8192
170 
171 /// \brief Max texture depth.
172 ///
173 #define GX2_MAX_TEXTURE_DEPTH        8192
174 
175 /// \brief Log 2 of Max texture size.
176 ///
177 #define GX2_LOG2_MAX_TEXTURE_SIZE    13
178 
179 /// \brief Max total texture buffer size in texels.
180 ///
181 #define GX2_MAX_TEXTURE_BUFFER_SIZE  (1 << 28)
182 
183 /// \brief Total faces in a cubemap.
184 ///
185 #define GX2_CUBEMAP_FACE_COUNT  6
186 
187 //----------------------------------------------------------------------
188 // Numbers of draw-related things
189 
190 /// \brief Max number of attribute buffers.
191 ///
192 #define GX2_MAX_ATTRIB_BUFFERS       16
193 
194 /// \brief Max number of vertices per draw call (draw packet size).
195 ///
196 #define GX2_MAX_DRAW_VERTICES        0xFFFFFF
197 
198 /// \brief Max number of indices per draw immediate call for U32 indices.
199 /// The value for U16 indices is double this (that is, it is only the total byte
200 /// size that matters).
201 ///
202 #define GX2_MAX_DRAW_IMMEDIATE_U32_INDICES 0x3FFE
203 
204 /// \brief Max number of pixel shader uniforms.
205 /// This only applies in \ref GX2_SHADER_MODE_UNIFORM_REGISTER
206 ///
207 #define GX2_MAX_PS_UNIFORM_VARS      256
208 
209 /// \brief Max number of vertex shader uniforms.
210 /// This only applies in \ref GX2_SHADER_MODE_UNIFORM_REGISTER
211 ///
212 #define GX2_MAX_VS_UNIFORM_VARS      256
213 
214 /// \brief Max number of uniform blocks (per shader).
215 /// This only applies in \ref GX2_SHADER_MODE_UNIFORM_BLOCK
216 ///
217 #define GX2_MAX_UNIFORM_BLOCKS       16
218 
219 /// \brief Max number of texture samplers (per shader).
220 ///
221 //#define GX2_MAX_SAMPLERS             16
222 #define GX2_MAX_SAMPLERS             18
223 
224 /// \brief Max simultaneous Render Targets/Draw (color) buffers.
225 /// This does not include the depth/stencil buffer.
226 ///
227 #define GX2_MAX_RENDER_TARGETS       8
228 
229 /// \brief Max number of stream out buffers.
230 ///
231 #define GX2_MAX_STREAMOUT_BUFFERS    4
232 
233 /// \brief The max number of rectangles accepted by GX2CopySurfaceEx()
234 ///
235 #define GX2_MAX_COPY_SURFACE_EX_RECTS 25
236 
237 /// \brief Maximum number of work-items per work-group
238 #define GX2_MAX_WORK_ITEMS_PER_WORK_GROUP 64
239 
240 //----------------------------------------------------------------------
241 // Special values, shader-related
242 
243 /// \brief Return value for \ref GX2GetVertexUniformVarOffset,
244 ///        \ref GX2GetGeometryUniformVarOffset,
245 ///        and \ref GX2GetPixelUniformVarOffset when named uniform
246 ///        cannot be found.
247 ///
248 #define GX2_UNIFORM_VAR_INVALID_OFFSET 0xFFFFFFFF
249 
250 /// \brief Used to mark uniform block indexes as invalid, meaning
251 /// the associated uniform var is a register var, not a block var.
252 ///
253 #define GX2_UNIFORM_BLOCK_INDEX_INVALID 0xFFFFFFFF
254 
255 /// \brief Used to mark uniform block index for the 'global',
256 ///        (non-named) uniforms.
257 ///
258 /// Uniforms in the global block can have initial values.
259 ///
260 /// \note If the default block is empty, then another (non-default)
261 ///       block may have a block index of 0.
262 ///
263 #define GX2_UNIFORM_BLOCK_INDEX_DEFAULT_BLOCK 0
264 
265 /// \brief Max number of pixels shader threads when the geometry shader is disabled
266 ///
267 #define GX2_MAX_PS_THREADS_GS_DISABLED    136
268 
269 /// \brief Max number of pixels shader threads when the geometry shader is enabled
270 ///
271 #define GX2_MAX_PS_THREADS_GS_ENABLED     124
272 
273 /// \brief Max number of vertex shader threads when the geometry shader is disabled
274 ///
275 #define GX2_MAX_VS_THREADS_GS_DISABLED     48
276 
277 /// \brief Max number of vertex shader threads when the geometry shader is enabled
278 ///
279 #define GX2_MAX_VS_THREADS_GS_ENABLED      32
280 
281 /// \brief Max number of geometry shader threads
282 #define GX2_MAX_GS_THREADS                  8
283 
284 /// \brief Max number of GPRs available when the geometry shader is disabled
285 ///
286 #define GX2_TOTAL_GPRS_GS_DISABLED  248
287 
288 /// \brief Max number of GPRs available when the geometry shader is disabled
289 ///
290 #define GX2_TOTAL_GPRS_GS_ENABLED  184
291 
292 /// \brief Max number of stack entries
293 ///
294 #define GX2_TOTAL_STACK_ENTRIES 256
295 
296 
297 /// \brief Used to specify is an attribute stream is a system generated value and does not
298 /// come from a buffer
299 ///
300 /// Set the buffer member of \ref GX2AttribStream to this define to identify the attribute
301 /// is a system generated value
302 ///
303 #define GX2_SYSTEM_GENERATED_ATTRIBUTE  GX2_MAX_ATTRIB_BUFFERS
304 
305 /// \brief Specifies the system generated value is the barycentric coordinate used for tessellation
306 ///
307 /// Set the offset member of \ref GX2AttribStream to this define to identify the system generated
308 /// barycentric coordinate location in the vertex shader for tessellation
309 ///
310 #define GX2_SYSGEN_ATTRIB_TESSELLATION_BARYC 0
311 
312 /// \brief Specifies the system generated value is the super primitive index used for tessellation
313 ///
314 /// Set the offset member of \ref GX2AttribStream to this define to identify the system generated
315 /// super primitive index location in the vertex shader for tessellation
316 ///
317 #define GX2_SYSGEN_ATTRIB_TESSELLATION_INDEX 1
318 
319 
320 //----------------------------------------------------------------------
321 // Special values, texture related
322 
323 /// \brief Max texture anisotropy.
324 ///
325 #define GX2_MAX_TEXTURE_ANISOTROPY 16.f
326 
327 /// \brief Auxiliary buffers must be initialized to this value. (see \ref GX2AASurfaceSect)
328 ///
329 #define GX2_AUX_BUFFER_CLEAR_VALUE 0xCC
330 
331 //----------------------------------------------------------------------
332 // Numbers of counters
333 
334 /// \brief Number of available cp counters per sampling
335 #define GX2_NUM_COUNTER_CP          0x01
336 /// \brief Number of available grbm counters per sampling
337 #define GX2_NUM_COUNTER_GRBM        0x02
338 /// \brief Number of available pa_su counters per sampling
339 #define GX2_NUM_COUNTER_PA_SU       0x04
340 /// \brief Number of available pa_sc counters per sampling
341 #define GX2_NUM_COUNTER_PA_SC       0x04
342 /// \brief Number of available vgt counters per sampling
343 #define GX2_NUM_COUNTER_VGT         0x04
344 /// \brief Number of available sq counters per sampling
345 #define GX2_NUM_COUNTER_SQ          0x04
346 /// \brief Number of available spi counters per sampling
347 #define GX2_NUM_COUNTER_SPI         0x04
348 /// \brief Number of available sx counters per sampling
349 #define GX2_NUM_COUNTER_SX          0x04
350 /// \brief Number of available smx counters per sampling
351 #define GX2_NUM_COUNTER_SMX         0x04
352 /// \brief Number of available td counters per sampling
353 #define GX2_NUM_COUNTER_TD          0x01
354 /// \brief Number of available ta counters per sampling
355 #define GX2_NUM_COUNTER_TA          0x02
356 /// \brief Number of available tcp counters per sampling
357 #define GX2_NUM_COUNTER_TCP         0x04
358 /// \brief Number of available tcc counters per sampling
359 #define GX2_NUM_COUNTER_TCC         0x04
360 /// \brief Number of available cb counters per sampling
361 #define GX2_NUM_COUNTER_CB          0x04
362 /// \brief Number of available db counters per sampling
363 #define GX2_NUM_COUNTER_DB          0x04
364 /// \brief Number of available pipeline counters per sampling.
365 ///  There is realy one set of 8 pipeline counter values.
366 #define GX2_NUM_COUNTER_PIPELINE    0x08
367 
368 /// \brief Number of times a pixel shader was invoked.
369 #define GX2_PIPELINE_COUNTERS_PSINVO_OFFSET  0
370 
371 /// \brief Number of primitives that were rendered. This may be larger or smaller than CInvocations
372 //         because after a primitive is clipped sometimes it is either broken up into more than
373 //         one primitive or completely culled.
374 #define GX2_PIPELINE_COUNTERS_CPRIM_OFFSET   1
375 
376 /// \brief Number of primitives that were sent to the rasterizer.
377 #define GX2_PIPELINE_COUNTERS_CINVO_OFFSET   2
378 
379 /// \brief Number of times a vertex shader was invoked.  Typically the number of vertices.
380 #define GX2_PIPELINE_COUNTERS_VSINVO_OFFSET  3
381 
382 /// \brief Number of times a geometry shader was invoked.
383 #define GX2_PIPELINE_COUNTERS_GSINVO_OFFSET  4
384 
385 /// \brief Number of primitives output by a geometry shader.
386 #define GX2_PIPELINE_COUNTERS_GSPRIM_OFFSET  5
387 
388 /// \brief Number of primitives read by the input assembler. This number can be different depending
389 ///        on the primitive topology used.
390 #define GX2_PIPELINE_COUNTERS_IAPRIM_OFFSET  6
391 
392 /// \brief Number of vertices read by input assembler.
393 #define GX2_PIPELINE_COUNTERS_IAVERT_OFFSET  7
394 
395 /// @}
396 
397 #ifdef __cplusplus
398 }
399 #endif // __cplusplus
400 
401 #endif // _CAFE_GX2_CONSTANT_H_
402