1 /*---------------------------------------------------------------------------*
2 
3   Copyright (C) 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 // gx2Display.h
14 //
15 // Declares display-related types & functions for gx2 library.
16 
17 #ifndef _CAFE_GX2_DISPLAY_H_
18 #define _CAFE_GX2_DISPLAY_H_
19 
20 #ifdef __cplusplus
21 extern "C"
22 {
23 #endif // __cplusplus
24 /*
25  * These are aliases for the MOV APIs which are deprecated
26  */
27 #define GX2GetSystemMOVMode     GX2GetSystemDRCMode
28 #define GX2CalcMOVSize          GX2CalcDRCSize
29 #define GX2SetMOVBuffer         GX2SetDRCBuffer
30 #define GX2SetMOVScale          GX2SetDRCScale
31 #define GX2SetMOVGamma          GX2SetDRCGamma
32 #define GX2SetMOVEnable         GX2SetDRCEnable
33 
34 /// @addtogroup GX2DisplayGroup
35 /// @{
36 
37 /// @addtogroup GX2DisplayInfoGroup
38 /// @{
39 
40 // ----------------------------------------------------------------------
41 // 1. Describing the system-set TV output mode (read-only)
42 
43 /// \brief Query current TV video output mode (set by system control panel).
44 ///
45 /// \return Current TV video scan (output) mode (read-only)
46 ///
47 /// \donotcall \threadsafe \devonly \enddonotcall
48 ///
49 GX2TVScanMode GX2API GX2GetSystemTVScanMode(void);
50 
51 /// \brief Query current TV aspect ratio (set by system control panel).
52 ///
53 /// \return Current TV aspect ratio (read-only)
54 ///
55 /// \donotcall \threadsafe \devonly \enddonotcall
56 ///
57 GX2AspectRatio GX2API GX2GetSystemTVAspectRatio(void);
58 
59 /// \brief Query if HDMI/Analog output setting for TV output is finished.
60 ///
61 /// \return GX2_TRUE if Video setting done and ready for output, else GX2_FALSE.
62 ///
63 /// \donotcall \threadsafe \devonly \enddonotcall
64 ///
65 GX2Boolean GX2API GX2IsVideoOutReady(void);
66 
67 /// \brief Query current DRC output mode.
68 ///
69 /// \note This function nominally checks for the number of attached DRCs.
70 ///       It may also indicate if a single DRC is in 30Hz update mode,
71 ///       if this mode had been configured previously (by calling \ref
72 ///       GX2SetDRCBuffer).
73 ///
74 /// \return Current DRC output mode
75 ///
76 /// \donotcall \threadsafe \devonly \enddonotcall
77 ///
78 GX2DRCMode GX2API GX2GetSystemDRCMode(void);
79 
80 /// \brief Query current DRC video scan mode.
81 ///
82 /// \note This function indicates current DRC scan mode regardless the DRC connection status.
83 ///       DRC scan mode is configured by GX2SetDRCBuffer to match with DRC render mode.
84 /// \return Current DRC scan mode
85 ///
86 /// \donotcall \threadsafe \devonly \enddonotcall
87 ///
88 GX2DRCMode GX2API GX2GetSystemDRCScanMode(void);
89 
90 #define GX2_DRC_DETACH 0
91 #define GX2_DRC_ATTACH 1
92 
93 /// \brief The callback function that notifies DRC is connected or disconnected for the specified channel.
94 ///
95 /// \param chan  DRC channel number is passed
96 /// \param reason  When DRC is connected, GX2_DRC_ATTACH is passed; at disconnection, GX2_DRC_DETACH is passed.
97 /// \note \#define GX2_DRC_DETACH 0
98 /// \note \#define GX2_DRC_ATTACH 1
99 ///
100 typedef void (*GX2DRCConnectCB) (s32 chan, s32 reason);
101 
102 /// \brief Register the callback function that notifies whether DRC is connected/disconnected.
103 ///
104 /// \note The disconnection event is notified when application releases foreground at process switch.
105 /// \note The callback function registered with this function is canceled at process switch. Application needs to re-register
106 /// callback function when it gains foreground.
107 ///
108 /// \param chan  DRC channel number.
109 /// \param callback  The callback function that notifies DRC attach for the specified channel.
110 ///
111 /// \return Pointer to the most recently registered callback function
112 ///
113 /// \donotcall \notcallback \notthreadsafe \notinterrupt \notexception \devonly \enddonotcall
114 ///
115 GX2DRCConnectCB GX2API GX2SetDRCConnectCallback(s32 chan, GX2DRCConnectCB callback);
116 
117 /// \brief Return info about current DRC scan-out status.
118 ///
119 /// \note Normally, you do not need to use this function.  However, it can be helpful to
120 ///       avoid glitches when transitioning from TV-only to TV+DRC display mode.
121 /// \note This function call returns the current status.  However, to use it correctly,
122 ///       you must know the relationship between now and when a scan buffer flip will occur
123 ///       (i.e., you must know the exact depth of the display pipeline).
124 ///
125 /// \param pVcount Will return the DRC current vertical count.
126 /// \param pVphase Will return 0 or 1 indicating if in the 1st or 2nd field of a DRC 30hz mode.
127 ///                Always returns 0 if DRC mode is 60hz.
128 ///
129 /// \donotcall \fgonly \threadsafe \devonly \enddonotcall
130 ///
131 void GX2API GX2GetDRCVerticalInfo( u32 *pVcount, u32 *pVphase );
132 
133 /// \brief Return whether or not GX2 is using 1/4-size scan buffers.
134 ///
135 /// This happens when performing 60/50 pull-down and using 720p or larger scan buffers.
136 /// You must call \ref GX2SetTVBuffer before this function can return useful results.
137 ///
138 /// \return GX2_TRUE if scale-down mode is enabled, GX2_FALSE otherwise.
139 ///
140 /// \donotcall \fgonly \threadsafe \devonly \enddonotcall
141 ///
142 GX2Boolean GX2GetScaleDownModeEnabled(void);
143 
144 // ----------------------------------------------------------------------
145 // 2. Describing the desired output mode
146 
147 /// \brief Function to calculate framebuffer size needed for TV.
148 ///
149 /// It takes into account double/triple buffering, as well as
150 /// the desired surface format.  Besides returning the size,
151 /// it also returns a parameter indicating if an automatic 2:1
152 /// reduction will be performed during copy-out.
153 ///
154 /// \note If the current TV scan mode is 480i or 576i, then the scan
155 ///       buffer resolution cannot be higher than 1280x720.
156 ///
157 /// \note The buffering mode option may be removed in future releases.
158 ///       Only double scan buffers are supported at the moment.
159 ///
160 /// \param tvRenderMode  Desired TV render mode to support.
161 /// \param fmt           Desired surface format to use.
162 /// \param bufferingMode Specifies double or triple buffering.
163 /// \param size          Ptr for value containing returned size.
164 /// \param scaleNeeded   Returns if 2:1 reduction is needed during copy-out.
165 ///
166 /// \donotcall \fgonly \threadsafe \devonly \enddonotcall
167 ///
168 void GX2API GX2CalcTVSize(GX2TVRenderMode tvRenderMode, GX2SurfaceFormat fmt,
169                           GX2BufferingMode bufferingMode,
170                           u32 *size, GX2Boolean *scaleNeeded);
171 
172 /// \brief Function to calculate framebuffer size needed for DRC.
173 ///
174 /// It takes into account double/triple buffering, as well as
175 /// the desired surface format.  Besides returning the size,
176 /// it also returns a parameter indicating if an automatic 2:1
177 /// reduction will be performed during copy-out (FYI).
178 ///
179 /// \note The buffering mode option may be removed in future releases.
180 ///       Only double scan buffers are supported at the moment.
181 ///
182 /// \param mode          Desired DRC render mode to support.
183 /// \param fmt           Desired surface format to use.
184 /// \param bufferingMode Specifies double or triple buffering.
185 /// \param size          Ptr for value containing returned size.
186 /// \param scaleNeeded   Returns if 2:1 reduction is needed during copy-out.
187 ///
188 /// \donotcall \fgonly \threadsafe \devonly \enddonotcall
189 ///
190 void GX2API GX2CalcDRCSize(GX2DRCMode mode, GX2SurfaceFormat fmt,
191                            GX2BufferingMode bufferingMode,
192                            u32 *size, GX2Boolean *scaleNeeded);
193 
194 /// @}
195 /// @addtogroup GX2DisplayConfigGroup
196 /// @{
197 
198 // ----------------------------------------------------------------------
199 // 3. Passing in scan buffers
200 
201 /// \brief Function to set up the framebuffers for use for TV.
202 ///
203 /// Sets up all necessary GX2 state to use the given memory area for
204 /// double/triple frame buffer output.
205 /// Calling this requires fade-out/disable/change/enable/fade-in sequence.
206 /// (if called from start, video should already be black & disabled.)
207 /// These functions will adjust the Display Controller (DC) scaler/output
208 /// registers as needed.
209 ///
210 ///
211 /// \note The buffering mode option may be removed in future releases.
212 ///       Only double scan buffers are supported at the moment.
213 ///
214 /// \param buffer        Ptr to memory area used to store scan buffers.
215 /// \param size          Size of the memory area in bytes.
216 /// \param tvRenderMode  Desired TV render mode to support.
217 /// \param fmt           Desired surface format to use.
218 /// \param bufferingMode Specifies double or triple buffering.
219 ///
220 /// \donotcall \gx2_typical \enddonotcall
221 ///
222 /// \writesgpu
223 /// \directwritesgpu
224 ///
225 void GX2API GX2SetTVBuffer(void *buffer, u32 size, GX2TVRenderMode tvRenderMode,
226                            GX2SurfaceFormat fmt, GX2BufferingMode bufferingMode);
227 
228 /// \brief Function to set up the framebuffers for use for DRC.
229 ///
230 /// Sets up all necessary GX2 state to use the given memory area for
231 /// double/triple frame buffer output.
232 /// Calling this requires fade-out/disable/change/enable/fade-in sequence.
233 /// (if called from start, video should already be black & disabled.)
234 /// These functions will adjust the Display Controller (DC) scaler/output
235 /// registers as needed.
236 ///
237 /// DRC camera needs to be turned off before calling this API to avoid the display corruption.
238 ///
239 /// \note The buffering mode option may be removed in future releases.
240 ///       Only double scan buffers are supported at the moment.
241 ///
242 /// \param buffer        Ptr to memory area used to store scan buffers.
243 /// \param size          Size of the memory area in bytes.
244 /// \param mode          Desired DRC render mode to support.
245 /// \param fmt           Desired surface format to use.
246 /// \param bufferingMode Specifies double or triple buffering.
247 ///
248 /// \donotcall \gx2_typical \enddonotcall
249 ///
250 /// \writesgpu
251 /// \directwritesgpu
252 ///
253 void GX2API GX2SetDRCBuffer(void *buffer, u32 size, GX2DRCMode mode,
254                             GX2SurfaceFormat fmt, GX2BufferingMode bufferingMode);
255 
256 // ----------------------------------------------------------------------
257 // 4. Other set up functions
258 
259 /// \brief Function to call if app wants to vary effective framebuffer size for TV.
260 ///
261 /// Size must be less than or equal to current mode, but greater than next lower mode.
262 /// (You must stay within 4:1 limit of the Display Controller (DC) scaler, but also within limit of what looks okay.)
263 /// These functions will adjust the DC scaler/output registers.
264 /// In all cases, the entire framebuffer (as specified by this API) is mapped to the entire display,
265 /// except when the output device is a 4:3 SDTV and the mode is 16:9.
266 /// In that case, the framebuffer rectangle is mapped to the 16:9 letterboxed portion.
267 ///
268 /// \note This function should only be called when the output is not enabled.
269 ///       Otherwise, you will see the image jitter during changes.
270 ///
271 /// \param actualWidth  Width of scan buffer image
272 /// \param actualHeight Height of scan buffer image
273 ///
274 /// \donotcall \gx2_typical \enddonotcall
275 ///
276 /// \writesgpu
277 /// \directwritesgpu
278 ///
279 void GX2API GX2SetTVScale(u32 actualWidth, u32 actualHeight);
280 
281 /// \brief Function to call if app wants to vary effective framebuffer size for DRC.
282 ///
283 /// Size must be less than or equal to DRC resolution.
284 /// (You must stay within 4:1 limit of the Display Controller (DC) scaler, but also within limit of what looks okay.)
285 /// These functions will adjust the DC scaler/output registers.
286 /// In all cases, the entire framebuffer (as specified by this API) is mapped to the entire display.
287 ///
288 /// \note This function should only be called when the output is not enabled.
289 ///       Otherwise, you will see the image jitter during changes.
290 ///
291 /// \param actualWidth  Width of scan buffer image
292 /// \param actualHeight Height of scan buffer image
293 ///
294 /// \donotcall \gx2_typical \enddonotcall
295 ///
296 /// \writesgpu
297 /// \directwritesgpu
298 ///
299 void GX2API GX2SetDRCScale(u32 actualWidth, u32 actualHeight);
300 
301 /// \brief Function for adjusting the Display Controller (DC) gamma for TV.
302 ///
303 /// Note that there are multiple ways to adjust gamma.  Be sure they are coordinated.
304 /// This API adjusts the display controller setting.
305 ///
306 /// Note: This function sets the display pipeline's response to: I' = I^(1/gamma).
307 /// [Larger values yield a brighter result on the display.]
308 ///
309 /// Note: When TV scan resolution is 576I, the scan buffer format must be
310 /// 8bit(GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_SRGB or GX2_SURFACE_FORMAT_TCS_R8_G8_B8_A8_UNORM),
311 /// otherwise changing gamma cause flicker.
312 ///
313 /// System preferences define a value as well.  The given argument is multiplied
314 /// by the system preference value before it is applied in the display controller.
315 /// Thus, this value should just be a relative modifier rather than an absolute value.
316 ///
317 /// Note: the final display gamma is set to :display gamma = system preference(1.0)/gamma
318 /// and it is made discrete by using the range (0.7f - 1.3f) with 0.05 steps as below.
319 /// gamma = 1.428571,  display_gamma = 0.70
320 /// gamma = 1.333333,  display_gamma = 0.75
321 /// gamma = 1.250000,  display_gamma = 0.80
322 /// gamma = 1.176471,  display_gamma = 0.85
323 /// gamma = 1.111111,  display_gamma = 0.90
324 /// gamma = 1.052631,  display_gamma = 0.95
325 /// gamma = 1.000000,  display_gamma = 1.00
326 /// gamma = 0.952381,  display_gamma = 1.05
327 /// gamma = 0.909091,  display_gamma = 1.10
328 /// gamma = 0.869565,  display_gamma = 1.15
329 /// gamma = 0.833333,  display_gamma = 1.20
330 /// gamma = 0.800000,  display_gamma = 1.25
331 /// gamma = 0.769231,  display_gamma = 1.30
332 ///
333 /// \param gamma Gamma value to use. Must be positive. Typical range (0.7f, 1.3f).
334 ///
335 /// \donotcall \gx2_typical \enddonotcall
336 ///
337 /// \writesgpu
338 /// \directwritesgpu
339 ///
340 void GX2API GX2SetTVGamma(f32 gamma);
341 
342 /// \brief Query the current Display Controller (DC) gamma for TV.
343 ///
344 /// This function indicates current DC gamma for TV.
345 /// Note: When application acquires foreground from process switching,
346 /// DC gamma obtained with this API might be the value set by previous foreground process.
347 /// The gamma is reverted to the application's gamma at the first flip to application's scan buffer.
348 /// To get the gamma set by the application before the first flip happens,
349 /// please use GX2GetTVGammaEx API.
350 //
351 /// \param  gamma         Ptr for value containing returned gamma.
352 ///
353 /// \donotcall \threadsafe \devonly \enddonotcall
354 ///
355 void GX2API GX2GetTVGamma(f32* gamma);
356 
357 /// \brief Query current gamma for TV.
358 ///
359 /// This function indicates gamma for TV which is set by the application.
360 /// Note: When application acquires foreground from process switching,
361 /// the gamma obtained with this API is different from actual the Display Controller (DC) gamma.
362 /// The gamma is reverted to the application's gamma at the first flip to application's scan buffer.
363 //
364 /// \param  gamma         Ptr for value containing returned gamma.
365 ///
366 /// \donotcall \threadsafe \devonly \enddonotcall
367 ///
368 void GX2API GX2GetTVGammaEx(f32* gamma);
369 
370 /// \brief Query current Display Controller (DC) gamma for DRC.
371 ///
372 /// This function indicates current DC gamma for DRC.
373 /// Note: When application acquires foreground from process switching,
374 /// DC gamma obtained with this API might be the value set by previous foreground process.
375 /// The gamma is reverted to the application's gamma at the first flip to application's scan buffer.
376 /// To get the gamma set by the application before the first flip happens,
377 /// please use GX2GetDRCGammaEx API.
378 //
379 /// \param  gamma         Ptr for value containing returned gamma.
380 ///
381 /// \donotcall \threadsafe \devonly \enddonotcall
382 ///
383 void GX2API GX2GetDRCGamma(f32* gamma);
384 
385 /// \brief Query current gamma for DRC.
386 ///
387 /// This function indicates gamma for DRC which is set by the application.
388 /// Note: When application acquires foreground from process switching,
389 /// the gamma obtained with this API is different from actual the Display Controller (DC) gamma.
390 /// The gamma is reverted to the application's gamma at the first flip to application's scan buffer.
391 //
392 /// \param  gamma         Ptr for value containing returned gamma.
393 ///
394 
395 /// \donotcall \threadsafe \devonly \enddonotcall
396 ///
397 void GX2API GX2GetDRCGammaEx(f32* gamma);
398 
399 /// \brief Function for adjusting the Display Controller (DC) gamma for DRC.
400 ///
401 /// Note that there are multiple ways to adjust gamma.  Be sure they are coordinated.
402 /// This API adjusts the display controller setting.
403 ///
404 /// Note: This function sets the display pipeline's response to: I' = I^(1/gamma).
405 /// [Larger values yield a brighter result on the display.]
406 ///
407 /// System preferences define a value as well.  The given argument is multiplied
408 /// by the system preference value before it is applied in the display controller.
409 /// Thus, this value should just be a relative modifier rather than an absolute value.
410 ///
411 /// Note: the final display gamma is set to :display gamma = system preference(1.0)/gamma
412 /// and it is made discrete by using the range (0.7f - 1.3f) with 0.05 steps as below.
413 /// gamma = 1.428571,  display_gamma = 0.70
414 /// gamma = 1.333333,  display_gamma = 0.75
415 /// gamma = 1.250000,  display_gamma = 0.80
416 /// gamma = 1.176471,  display_gamma = 0.85
417 /// gamma = 1.111111,  display_gamma = 0.90
418 /// gamma = 1.052631,  display_gamma = 0.95
419 /// gamma = 1.000000,  display_gamma = 1.00
420 /// gamma = 0.952381,  display_gamma = 1.05
421 /// gamma = 0.909091,  display_gamma = 1.10
422 /// gamma = 0.869565,  display_gamma = 1.15
423 /// gamma = 0.833333,  display_gamma = 1.20
424 /// gamma = 0.800000,  display_gamma = 1.25
425 /// gamma = 0.769231,  display_gamma = 1.30
426 ///
427 /// \param gamma Gamma value to use. Must be positive. Typical range (0.7f, 1.3f).
428 ///
429 /// \donotcall \gx2_typical \enddonotcall
430 ///
431 /// \writesgpu
432 /// \directwritesgpu
433 ///
434 void GX2API GX2SetDRCGamma(f32 gamma);
435 
436 /// \brief Function to enable/disable the TV display (like VISetBlack).
437 ///
438 /// Disabling the display tells the Display Controller (DC) to output black.
439 /// Disabling also disassociates the DC output from a frame buffer.
440 /// This function must be called when changing framebuffer modes.
441 /// Upon startup, the blank is released but this function must still be called to enable the DC.
442 /// When GX2 releases foreground, it saves the last frame only when the DC is enabled.
443 ///
444 /// \warning This function must be called when application acquires foreground,
445 /// otherwise last frame will not be saved on next foreground release.
446 ///
447 /// \param enable True to scan out video data to TV; false to output black.
448 ///
449 /// \donotcall \gx2_typical \enddonotcall
450 ///
451 /// \writesgpu
452 /// \directwritesgpu
453 ///
454 void GX2API GX2SetTVEnable(GX2Boolean enable);
455 
456 /// \brief Function to enable/disable the DRC display (like VISetBlack).
457 ///
458 /// Disabling the display tells the Display Controller (DC) to output black.
459 /// Disabling also disassociates the DC output from a frame buffer.
460 /// This function must be called when changing framebuffer modes.
461 /// Upon startup, the blank is released but this function must still be called to enable the DC.
462 /// When GX2 releases foreground, it saves the last frame only when the DC is enabled.
463 ///
464 /// \warning This function must be called when application acquires foreground,
465 /// otherwise last frame will not be saved on next foreground release.
466 ///
467 /// \param enable True to scan out video data to DRC(s); false to output black.
468 ///
469 /// \donotcall \gx2_typical \enddonotcall
470 ///
471 /// \writesgpu
472 /// \directwritesgpu
473 ///
474 void GX2API GX2SetDRCEnable(GX2Boolean enable);
475 
476 /// @}
477 /// @addtogroup GX2DisplaySwapGroup
478 /// @{
479 
480 // ----------------------------------------------------------------------
481 // 5. Copying & swapping buffers
482 
483 // GX2SwapBuffers is now:
484 
485 /// \brief Function to copy a render buffer surface to a scan buffer.
486 ///
487 /// Call this once per available scan target per frame.
488 ///
489 /// \note This API changes rendering states and disables state shadowing.
490 ///       If you are using state shadowing, you must call
491 ///       \ref GX2SetContextState() afterward.
492 ///
493 /// \param renderBuffer Ptr to color buffer structure containing final rendered image.
494 /// \param target The desired scan buffer target that should output the rendered image.
495 ///
496 /// \donotcall \nomulticore \gx2_dl \enddonotcall
497 ///
498 /// \clobberstate
499 /// \disablesstateshadow
500 /// \notincompute
501 ///
502 /// \writesgpu
503 /// \alwayswritesgpu
504 ///
505 void GX2API GX2CopyColorBufferToScanBuffer(const GX2ColorBuffer *renderBuffer,
506                                            GX2ScanTarget target);
507 
508 /// \brief Function to call after all copying done for this frame.
509 ///
510 /// It swaps all configured displays (scan targets).
511 ///
512 /// \donotcall \nomulticore \gx2_dl \enddonotcall
513 ///
514 /// \writesgpu
515 /// \alwayswritesgpu
516 ///
517 /// \warning If a GPU hang condition is detected, this will call \ref GX2ResetGPU.
518 ///
519 void GX2API GX2SwapScanBuffers(void);
520 
521 /// \brief Get information about how many swaps/flips have happened and when
522 ///        the last buffer flip and vsync occurred.
523 ///
524 /// \note A "swap" in this context means a request was made.  A "flip" is when
525 ///       the requested swap actually happens.  The swap is delayed according
526 ///       to the swap interval and the vsync period.
527 ///
528 /// Also see notes at \ref GX2SetSwapInterval.
529 ///
530 /// \param pSwapCount     place to store number of times GX2SwapScanBuffers() was called
531 /// \param pFlipCount     place to store number of times buffer flip has happened
532 /// \param pLastFlipTime  place to store time that last flip happened
533 /// \param pLastVsyncTime place to store time that last vsync happened
534 ///
535 /// \donotcall \fgonly \notthreadsafe \devonly \enddonotcall
536 ///
537 void GX2API GX2GetSwapStatus(u32 *pSwapCount, u32 *pFlipCount,
538                              OSTime *pLastFlipTime, OSTime *pLastVsyncTime);
539 
540 /// \brief Wait until the next buffer flip happens.
541 ///
542 /// \note If the flip happens while the thread is being put to sleep, then
543 ///       the function will not return until the next vertical sync period.
544 ///       Also, this function cannot detect GPU hangs.  It's suggested to
545 ///       use \ref GX2WaitForVsync (in a check loop) instead.
546 ///
547 /// \donotcall \nomulticore \gx2_typical \enddonotcall
548 ///
549 void GX2API GX2WaitForFlip(void);
550 
551 /// \brief Wait until the next vertical sync happens.
552 ///
553 /// \donotcall \gx2_typical \enddonotcall
554 ///
555 void GX2API GX2WaitForVsync(void);
556 
557 /// \brief Set the interval for how quickly buffer flips may happen
558 ///        (based on number of 60hz vsync intervals).
559 ///
560 /// A value of 0 is valid, and it means to enable single buffering and
561 /// disable any waiting for vsync to occur.  In this mode, the flipCount
562 /// is still valid, but the LastFlipTime is no longer valid.
563 ///
564 /// \note Before setting the swap interval to 0, you *must* configure all
565 /// scan buffers using \ref GX2SetTVBuffer() and/or \ref GX2SetDRCBuffer().
566 ///
567 /// \note Warning: Setting GX2SetSwapInterval() to 0 should only be used for
568 /// debugging. A swap interval of 0 is supported for immediate flipping.
569 /// Use of this setting will cause tearing, and is also not compatible with
570 /// PAL output. Do not set GX2SetSwapInterval() to 0 in game submissions.
571 ///
572 /// \donotcall \gx2_typical \enddonotcall
573 ///
574 void GX2API GX2SetSwapInterval(u32 swapInterval);
575 
576 /// \brief Return the current setting for swap interval.
577 ///
578 /// \donotcall \fgonly \threadsafe \devonly \enddonotcall
579 ///
580 u32 GX2API GX2GetSwapInterval(void);
581 
582 /// \brief A helper function to perform the most common swap operation.
583 ///
584 /// (That is: copy the given render buffer to the TV, then swap.)
585 /// \note No waiting for the swap is performed here.  For that, use
586 /// \ref GX2WaitForFlip, \ref GX2WaitForVsync, and/or \ref GX2GetSwapStatus.
587 ///
588 /// \note This API changes rendering states and disables state shadowing.
589 ///       If you are using state shadowing, you must call
590 ///       \ref GX2SetContextState() afterward.
591 ///
592 /// \param renderBuffer Ptr to color buffer structure containing final rendered image.
593 ///
594 /// \donotcall \nomulticore \gx2_dl \enddonotcall
595 ///
596 /// \clobberstate
597 /// \disablesstateshadow
598 /// \notincompute
599 ///
600 /// \writesgpu
601 /// \alwayswritesgpu
602 ///
GX2SwapBuffers(const GX2ColorBuffer * renderBuffer)603 GX2_INLINE void GX2SwapBuffers(const GX2ColorBuffer *renderBuffer)
604 {
605     GX2CopyColorBufferToScanBuffer(renderBuffer, GX2_SCAN_TARGET_TV);
606     GX2SwapScanBuffers();
607 }
608 
609 /// \brief This API tells DRC hardware explicitly about motion vector changes or enforces I-frame refresh.
610 ///
611 /// Some application like web browser or 2D action game knows how application behaves in temporal frames. In such case, application can tell motion vector to hardware directly and increase DRC image quality by decreasing unnecessary computations.
612 ///
613 /// \param hint_bitmap indicate which hint is valid in this command.
614 /// \param motion_vector_x Cluster motion vector for X axis. Precision is per 4 pixels. Direction referenced from new position to the old frame.
615 /// \param motion_vector_y Cluster motion vector for Y axis. Precision is per 4 pixels. Direction referenced from new position to the old frame.
616 ///
617 /// \donotcall \gx2_typical \enddonotcall
618 ///
619 /// \writesgpu
620 /// \directwritesgpu
621 ///
622 GX2Boolean GX2API GX2SetVideoEncodingHint( GX2DRCEncodingHint hint_bitmap, s8  motion_vector_x, s8  motion_vector_y );
623 
624 /// \brief Retrieves the last frame image displayed by the previous process.
625 ///
626 /// This API is used to transition between apps, launchers, and the home-button menu.
627 /// Whenever GX2 transitions to the background from one process, it will save the last
628 /// rendered frames away.  The new process that comes into the foreground can then
629 /// retrieve those images using this API.  They can then be worked into a nice
630 /// transition sequence as the new app starts up.
631 ///
632 /// Parameters are provided to indicate whether the TV or DRC image should be retrieved.
633 /// If no image was available from the previous process, this API will return false.
634 /// In an image is available, then the provided texture structure is filled out.
635 /// Note that the returned image will always be in GX2_TILE_MODE_LINEAR_ALIGNED.
636 ///
637 /// Note that the size of the returned last frame varies depending on the render mode of the previous process and TV scan resolution.
638 /// For example, when the system performs automatic 2:1 reduction during copy-out for 576I or 480I 4:3, the last frame size will be the 2:1 on horizontal and vertical.
639 
640 /// \param target  Indicates whether TV or DRC image should be retrieved.
641 /// \param texture Pointer to structure that will be filled out with the appropriate data.
642 /// \return        Boolean indicating true if a frame was available, or false otherwise.
643 ///
644 /// \donotcall \fgonly \threadsafe \notinterrupt \devonly \nomulticore \enddonotcall
645 ///
646 GX2Boolean GX2API GX2GetLastFrame(GX2ScanTarget target, GX2Texture * texture);
647 
648 /// \brief Retrieves gamma value of the last frame displayed by the previous process.
649 ///
650 /// The new process that comes into the foreground can retrieve the gamma value of those images.
651 /// Using the value retrieved by this API, application can apply reverse gamma when it use the last frame
652 /// image if the gamma value of the last frame is different from the gamma application is using.
653 /// Parameters are provided to indicate whether the TV or DRC image should be retrieved.
654 /// If no image was available from the previous process, this API will return false.
655 /// In an image is available, then the gamma value is filled out.
656 ///
657 /// \param target  Indicates whether TV or DRC image should be retrieved.
658 /// \param gamma   Pointer to value that will be filled out with the appropriate data.
659 /// \return        Boolean indicating true if a gamma was available, or false otherwise.
660 ///
661 /// \donotcall \fgonly \threadsafe \notinterrupt \nomulticore \devonly \enddonotcall
662 ///
663 GX2Boolean GX2API GX2GetLastFrameGamma(GX2ScanTarget target, f32* gamma);
664 
665 /// @}
666 /// @}
667 
668 #ifdef __cplusplus
669 }
670 #endif // __cplusplus
671 
672 #endif // _CAFE_GX2_DISPLAY_H_
673