mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-10-03 08:41:34 +00:00
Merge pull request #306 from fjtrujy/fix_sceguSignal
Improve `sceGuSignal` usage
This commit is contained in:
@@ -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);
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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)
|
||||
|
@@ -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();
|
||||
|
Reference in New Issue
Block a user