http://rej.50megs.com/psp/signals
(back to psp coding) This experiment shows the possible usage of GU signals both for double-buffering and command-lists calls.
EDIT: Sample fully using libgu API is here: http://rej.50megs.com/psp/libgu_signals/
GU signals can be used implementing double buffering approach for sending dynamic geometry to GPU. Double buffering allows to save memory, while sending large amounts of dynamic data. Experiment shows rendering 64K dynamic billboards per frame (25fps) - 24 bytes per vertex - naive allocation would require 3MB.
At the start of each frame 2 vertex buffers are allocated, filled with data and submitted to command buffer. As soon as GPU finishes rendering from one of the buffer, signal is raised and interrupt handler is able to reuse the same buffer by filling it with data and submitting back to command buffer. Meanwhile GPU is busy rendering from another buffer.
Such approach can be usefull for managing texture cache in the VRAM as well. Texture can be evicted as soon as rendering job which uses it is done without CPU waiting for GPU to end the job.
Some notes on signals:
* User data passed as an argument signal-listening callbacks must be defined as a global variable, otherwise app will crash (presumably in sceGeSetCallback() ).
* In order to send a signal code 14 followed by 12 must be pushed into command buffer (pushing only 14 doesn't raise a signal):
Code: Select all
14 0E SIGNAL Raise Signal Interrupt
0-15: hi 16 bits of signal arg
16-23: signal id
12 0C END Stop execution (Finish Raise Signal Interrupt)
0-15: lo 16 bits of signal arg
Code: Select all
0x01..0x03 Custom signals (looking at the sceGuSignal, 0x03 has special path sending FINISH code after signal)
0x11 Call command list (arg specifies address of command list to be executed)
0x12 Return from command list
* Only signals in the range 0x01..0x03 are passed to custom signal handler. Signal id is passed to handler as the 1st argument. No idea is it possible to pass the signal argument into the handler or it is meant to be used with 0x11 only.
* sceGuCallMode(1) sets the signals to be used when calling pregenerated command-lists. Since these signals are 'invisible' to custom signal handler,
I wonder what is the difference between CALL command or using 0x11 signal instead.
PS: source code is based on chp's sprite sample.