From b5c93d85981cef1d811146f3048acb19a2fd444f Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Fri, 20 Jun 2025 16:26:20 +0200 Subject: [PATCH 1/2] Improve sceGuSignal usage --- src/gu/pspgu.h | 16 ++++++---------- src/gu/sceGuSignal.c | 6 +++--- src/samples/gu/beginobject/beginobject.c | 2 +- src/samples/gu/signals/signals.c | 11 ++++------- src/samples/gu/timing/timing.c | 24 ++++++++++++------------ 5 files changed, 26 insertions(+), 33 deletions(-) diff --git a/src/gu/pspgu.h b/src/gu/pspgu.h index 95bba994..35b274c6 100644 --- a/src/gu/pspgu.h +++ b/src/gu/pspgu.h @@ -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); diff --git a/src/gu/sceGuSignal.c b/src/gu/sceGuSignal.c index df691cc0..58dbc531 100644 --- a/src/gu/sceGuSignal.c +++ b/src/gu/sceGuSignal.c @@ -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); diff --git a/src/samples/gu/beginobject/beginobject.c b/src/samples/gu/beginobject/beginobject.c index a18e08bf..022a5777 100644 --- a/src/samples/gu/beginobject/beginobject.c +++ b/src/samples/gu/beginobject/beginobject.c @@ -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); diff --git a/src/samples/gu/signals/signals.c b/src/samples/gu/signals/signals.c index 94892088..75133922 100644 --- a/src/samples/gu/signals/signals.c +++ b/src/samples/gu/signals/signals.c @@ -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) diff --git a/src/samples/gu/timing/timing.c b/src/samples/gu/timing/timing.c index de60975d..4bffc185 100644 --- a/src/samples/gu/timing/timing.c +++ b/src/samples/gu/timing/timing.c @@ -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(); From ac445612d4e64fbb5683e22dacec247178c4f034 Mon Sep 17 00:00:00 2001 From: Francisco Javier Trujillo Mata Date: Fri, 20 Jun 2025 17:16:46 +0200 Subject: [PATCH 2/2] Some other SIGNAL usage improvement --- src/gu/sceGuCallList.c | 2 +- src/gu/sceGuFinishId.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gu/sceGuCallList.c b/src/gu/sceGuCallList.c index 8d403b26..7633c1b2 100644 --- a/src/gu/sceGuCallList.c +++ b/src/gu/sceGuCallList.c @@ -15,7 +15,7 @@ int sceGuCallList(const void *list) if (gu_call_mode == GU_CALL_SIGNAL) { - sendCommandi(SIGNAL, (list_addr >> 16) | 0x110000); + sendCommandi(SIGNAL, (0x11 << 16) | (list_addr >> 16)); sendCommandi(END, list_addr & 0xffff); } else diff --git a/src/gu/sceGuFinishId.c b/src/gu/sceGuFinishId.c index ad5e638f..2d63ca8c 100644 --- a/src/gu/sceGuFinishId.c +++ b/src/gu/sceGuFinishId.c @@ -33,7 +33,7 @@ int sceGuFinishId(unsigned int id) case GU_CALL: if (gu_call_mode == GU_CALL_SIGNAL) { - sendCommandi(SIGNAL, 0x120000); + sendCommandi(SIGNAL, 0x12 << 16); sendCommandi(END, 0); } else