Restoring GPU Register Settings

Overview

You need to restore the state of GPU register settings, or reset them, immediately after returning from the HOME Menu or an applet, or when switching from one graphics library to another.

This is because the GPU register settings that the library assumes and the actual state of the settings differ when there is a library that generates commands based on the difference from when it was previously generated, such as the GL library.

Returning to the Application from an Applet (including the HOME Menu)

When rendering by switching between multiple graphics libraries as discussed below, after returning, conform to the method of the library that was used first.

When the Application uses GL

By calling the nngxUpdateState (NN_GX_STATE_ALL) function, when the next Draw is executed, all commands will be generated.

Then, by calling the nngxValidateState function, you can generate all functions then and there, but unless they are bound to a command list and program objects are set (see Note), caution is needed as an error code will be generated. Note: Introduced from CTR-SDK 4.2 onward.

When the Application uses GD

By calling the nn::gd::System::ForceDirty (nn::gd::MODULE_ALL) function, when the next Draw is executed, all commands will be generated.

When the Application uses GR

Since settings information is not maintained within the GR library, there is no API to restore the settings.
When performing the next render, call the function needed to generate all the needed commands.
Or, use a command buffer that includes all the needed commands.

Using Application-Specific Libraries

Reset all necessary registers for the first render after returning.
If that library does not maintain settings information internally, handle it as indicated for the GR library.

When Switching from Another Graphics Library to the Library Used

Switching among multiple graphic libraries is like when you are rendering one frame.
Other graphic libraries include the CTR Face Library.

It is possible to handle it in basically the same way as when returning from an applet.
The volume of commands for register restoration increases with frequent switching of libraries, so try to keep the number of switches to a minimum.

Other Information

From CTR-SDK 4.2 on, the nngxGetInitializationCommand function, which can get initialization commands generated by the nngxInitialize function, has been made public.

When there is an issue with rendering not working correctly when returning from an applet, confirm whether the behavior changes when initialization commands are executed after the return.

Revision History

2012/05/28
Initial version.

CONFIDENTIAL