mirror of
https://github.com/pspdev/pspsdk.git
synced 2025-10-03 16:51:27 +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_SIGNAL (1)
|
||||||
#define GU_CALLBACK_FINISH (4)
|
#define GU_CALLBACK_FINISH (4)
|
||||||
|
|
||||||
/* Signal behavior */
|
/* Signal behavior (deprecated) */
|
||||||
#define GU_BEHAVIOR_SUSPEND (1)
|
#define GU_BEHAVIOR_SUSPEND (1)
|
||||||
#define GU_BEHAVIOR_CONTINUE (2)
|
#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
|
* 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_WAIT - Wait for callback to finish
|
||||||
* - GU_SIGNAL_NOWAIT - Do not wait for callback to finish
|
* - GU_SIGNAL_NOWAIT - Do not wait for callback to finish
|
||||||
* - GU_SIGNAL_PAUSE - Pause execution until callback is finished
|
* - GU_SIGNAL_PAUSE - Pause execution until callback is finished
|
||||||
*
|
*
|
||||||
* Available behaviors are:
|
* @param mode - Signal interrupt mode
|
||||||
* - GU_BEHAVIOR_SUSPEND - Stops display list execution until callback function finished
|
* @param id - Signal id
|
||||||
* - GU_BEHAVIOR_CONTINUE - Do not stop display list execution during callback
|
|
||||||
*
|
|
||||||
* @param signal - Signal to trigger
|
|
||||||
* @param behavior - Behavior type
|
|
||||||
**/
|
**/
|
||||||
void sceGuSignal(int signal, int behavior);
|
void sceGuSignal(int mode, int id);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send raw float-command to the GE
|
* 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.
|
* 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.
|
* normal calls instead.
|
||||||
**/
|
**/
|
||||||
void sceGuCallMode(int mode);
|
void sceGuCallMode(int mode);
|
||||||
|
@@ -15,7 +15,7 @@ int sceGuCallList(const void *list)
|
|||||||
|
|
||||||
if (gu_call_mode == GU_CALL_SIGNAL)
|
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);
|
sendCommandi(END, list_addr & 0xffff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -33,7 +33,7 @@ int sceGuFinishId(unsigned int id)
|
|||||||
case GU_CALL:
|
case GU_CALL:
|
||||||
if (gu_call_mode == GU_CALL_SIGNAL)
|
if (gu_call_mode == GU_CALL_SIGNAL)
|
||||||
{
|
{
|
||||||
sendCommandi(SIGNAL, 0x120000);
|
sendCommandi(SIGNAL, 0x12 << 16);
|
||||||
sendCommandi(END, 0);
|
sendCommandi(END, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@@ -8,12 +8,12 @@
|
|||||||
|
|
||||||
#include "guInternal.h"
|
#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);
|
sendCommandi(END, 0);
|
||||||
|
|
||||||
if (signal == GU_SIGNAL_PAUSE)
|
if (mode == GU_SIGNAL_PAUSE)
|
||||||
{
|
{
|
||||||
sendCommandi(FINISH, 0);
|
sendCommandi(FINISH, 0);
|
||||||
sendCommandi(END, 0);
|
sendCommandi(END, 0);
|
||||||
|
@@ -193,7 +193,7 @@ int main(int argc, char* argv[]) {
|
|||||||
sceGuBeginObject(GU_VERTEX_32BITF, 8, 0, bbox);
|
sceGuBeginObject(GU_VERTEX_32BITF, 8, 0, bbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
sceGuSignal(1, GU_BEHAVIOR_SUSPEND);
|
sceGuSignal(GU_SIGNAL_WAIT, i);
|
||||||
|
|
||||||
sceGumPushMatrix();
|
sceGumPushMatrix();
|
||||||
sceGumRotateX(time * 0.5324f);
|
sceGumRotateX(time * 0.5324f);
|
||||||
|
@@ -214,10 +214,8 @@ int main(int argc, char* argv[])
|
|||||||
// init GU and set callbacks
|
// init GU and set callbacks
|
||||||
sceGuInit();
|
sceGuInit();
|
||||||
|
|
||||||
// 0x01 - user callback
|
sceGuSetCallback(GU_CALLBACK_SIGNAL, &mySignalHandler);
|
||||||
// 0x04 - 'rendering finished' callback
|
sceGuSetCallback(GU_CALLBACK_FINISH, &myFinishHandler);
|
||||||
sceGuSetCallback(1, &mySignalHandler);
|
|
||||||
sceGuSetCallback(4, &myFinishHandler);
|
|
||||||
|
|
||||||
// setup GU
|
// setup GU
|
||||||
sceGuStart(GU_DIRECT,list);
|
sceGuStart(GU_DIRECT,list);
|
||||||
@@ -246,7 +244,7 @@ int main(int argc, char* argv[])
|
|||||||
// run sample
|
// run sample
|
||||||
|
|
||||||
#ifdef USING_SIGNALS
|
#ifdef USING_SIGNALS
|
||||||
sceGuCallMode(1);
|
sceGuCallMode(GU_CALL_SIGNAL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// generate callable command-list with texture setup
|
// generate callable command-list with texture setup
|
||||||
@@ -439,8 +437,7 @@ void render_billboards(unsigned int i)
|
|||||||
|
|
||||||
#ifdef USING_SIGNALS
|
#ifdef USING_SIGNALS
|
||||||
// send a signal when rendering was completed
|
// send a signal when rendering was completed
|
||||||
// signals 0x01..0x03 - seems to be available for custom usage
|
sceGuSignal(GU_SIGNAL_WAIT, nextI);
|
||||||
sceGuSignal( 1, nextI );
|
|
||||||
|
|
||||||
// HACK: keeps CPU waiting until all jobs were submitted for GPU
|
// HACK: keeps CPU waiting until all jobs were submitted for GPU
|
||||||
if (nextI == g_context.iterationCount)
|
if (nextI == g_context.iterationCount)
|
||||||
|
@@ -236,43 +236,43 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
switch(mode) {
|
switch(mode) {
|
||||||
case 0 :
|
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);
|
sceGumDrawArray(GU_TRIANGLES, GU_VERTEX_32BITF, TORUS_SEGMENTS * TORUS_SLICES * 6, 0, triangleTorus);
|
||||||
sceGuSignal(GU_BEHAVIOR_SUSPEND, 2);
|
sceGuSignal(GU_SIGNAL_WAIT, 2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1 :
|
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);
|
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;
|
break;
|
||||||
|
|
||||||
case 2 :
|
case 2 :
|
||||||
sceGuPatchDivide(1, 1);
|
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);
|
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;
|
break;
|
||||||
|
|
||||||
case 3 :
|
case 3 :
|
||||||
sceGuPatchDivide(2, 2);
|
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);
|
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;
|
break;
|
||||||
|
|
||||||
case 4 :
|
case 4 :
|
||||||
sceGuPatchDivide(4, 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);
|
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;
|
break;
|
||||||
|
|
||||||
default :
|
default :
|
||||||
sceGuPatchDivide(8, 8);
|
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);
|
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;
|
break;
|
||||||
}
|
}
|
||||||
sceGuFinish();
|
sceGuFinish();
|
||||||
|
Reference in New Issue
Block a user