Improve sceGuSignal usage

This commit is contained in:
Francisco Javier Trujillo Mata
2025-06-20 16:26:20 +02:00
parent 9f6f4c0c10
commit b5c93d8598
5 changed files with 26 additions and 33 deletions

View File

@@ -324,7 +324,7 @@ extern "C" {
#define GU_CALLBACK_SIGNAL (1)
#define GU_CALLBACK_FINISH (4)
/* Signal behavior */
/* Signal behavior (deprecated) */
#define GU_BEHAVIOR_SUSPEND (1)
#define GU_BEHAVIOR_CONTINUE (2)
@@ -503,19 +503,15 @@ void* sceGuSetCallback(int signal, void (*callback)(int));
/**
* Trigger signal to call code from the command stream
*
* Available signals are:
* Available signal interrupt modes are:
* - GU_SIGNAL_WAIT - Wait for callback to finish
* - GU_SIGNAL_NOWAIT - Do not wait for callback to finish
* - GU_SIGNAL_PAUSE - Pause execution until callback is finished
*
* Available behaviors are:
* - GU_BEHAVIOR_SUSPEND - Stops display list execution until callback function finished
* - GU_BEHAVIOR_CONTINUE - Do not stop display list execution during callback
*
* @param signal - Signal to trigger
* @param behavior - Behavior type
* @param mode - Signal interrupt mode
* @param id - Signal id
**/
void sceGuSignal(int signal, int behavior);
void sceGuSignal(int mode, int id);
/**
* Send raw float-command to the GE
@@ -604,7 +600,7 @@ int sceGuCallList(const void* list);
/**
* Set wether to use stack-based calls or signals to handle execution of called lists.
*
* @param mode - GU_TRUE(1) to enable signals, GU_FALSE(0) to disable signals and use
* @param mode - GU_CALL_SIGNAL(1) to enable signals, GU_CALL_NORMAL(0) to disable signals and use
* normal calls instead.
**/
void sceGuCallMode(int mode);

View File

@@ -8,12 +8,12 @@
#include "guInternal.h"
void sceGuSignal(int signal, int argument)
void sceGuSignal(int mode, int id)
{
sendCommandi(SIGNAL, ((signal & 0xff) << 16) | (argument & 0xffff));
sendCommandi(SIGNAL, ((mode & 0xff) << 16) | (id & 0xffff));
sendCommandi(END, 0);
if (signal == GU_SIGNAL_PAUSE)
if (mode == GU_SIGNAL_PAUSE)
{
sendCommandi(FINISH, 0);
sendCommandi(END, 0);

View File

@@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
sceGuBeginObject(GU_VERTEX_32BITF, 8, 0, bbox);
}
sceGuSignal(1, GU_BEHAVIOR_SUSPEND);
sceGuSignal(GU_SIGNAL_WAIT, i);
sceGumPushMatrix();
sceGumRotateX(time * 0.5324f);

View File

@@ -214,10 +214,8 @@ int main(int argc, char* argv[])
// init GU and set callbacks
sceGuInit();
// 0x01 - user callback
// 0x04 - 'rendering finished' callback
sceGuSetCallback(1, &mySignalHandler);
sceGuSetCallback(4, &myFinishHandler);
sceGuSetCallback(GU_CALLBACK_SIGNAL, &mySignalHandler);
sceGuSetCallback(GU_CALLBACK_FINISH, &myFinishHandler);
// setup GU
sceGuStart(GU_DIRECT,list);
@@ -246,7 +244,7 @@ int main(int argc, char* argv[])
// run sample
#ifdef USING_SIGNALS
sceGuCallMode(1);
sceGuCallMode(GU_CALL_SIGNAL);
#endif
// generate callable command-list with texture setup
@@ -439,8 +437,7 @@ void render_billboards(unsigned int i)
#ifdef USING_SIGNALS
// send a signal when rendering was completed
// signals 0x01..0x03 - seems to be available for custom usage
sceGuSignal( 1, nextI );
sceGuSignal(GU_SIGNAL_WAIT, nextI);
// HACK: keeps CPU waiting until all jobs were submitted for GPU
if (nextI == g_context.iterationCount)

View File

@@ -236,43 +236,43 @@ int main(int argc, char** argv) {
switch(mode) {
case 0 :
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawArray(GU_TRIANGLES, GU_VERTEX_32BITF, TORUS_SEGMENTS * TORUS_SLICES * 6, 0, triangleTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
case 1 :
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawArrayN(GU_TRIANGLE_STRIP, GU_VERTEX_32BITF, TORUS_SLICES*2+2, TORUS_SEGMENTS, 0, tristripTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
case 2 :
sceGuPatchDivide(1, 1);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawSpline(GU_VERTEX_32BITF, TORUS_SEGMENTS + 3, TORUS_SLICES + 3, GU_FILL_FILL, GU_FILL_FILL, 0, splineTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
case 3 :
sceGuPatchDivide(2, 2);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawSpline(GU_VERTEX_32BITF, TORUS_SEGMENTS + 3, TORUS_SLICES + 3, GU_FILL_FILL, GU_FILL_FILL, 0, splineTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
case 4 :
sceGuPatchDivide(4, 4);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawSpline(GU_VERTEX_32BITF, TORUS_SEGMENTS + 3, TORUS_SLICES + 3, GU_FILL_FILL, GU_FILL_FILL, 0, splineTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
default :
sceGuPatchDivide(8, 8);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 1);
sceGuSignal(GU_SIGNAL_WAIT, 1);
sceGumDrawSpline(GU_VERTEX_32BITF, TORUS_SEGMENTS + 3, TORUS_SLICES + 3, GU_FILL_FILL, GU_FILL_FILL, 0, splineTorus);
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
sceGuSignal(GU_SIGNAL_WAIT, 2);
break;
}
sceGuFinish();