Skip to content

Commit 4743678

Browse files
committed
Improvements around STALL
1 parent 2ecbb9d commit 4743678

9 files changed

+62
-27
lines changed

src/gu/guInternal.h

+12-6
Original file line numberDiff line numberDiff line change
@@ -645,12 +645,18 @@ static inline void sendCommandf(GECommand cmd, float argument)
645645
sendCommandi(cmd, t.i >> 8);
646646
}
647647

648-
static inline void sendCommandiStall(GECommand cmd, int argument)
649-
{
650-
sendCommandi(cmd, argument);
651-
652-
if (!gu_object_stack_depth && !gu_curr_context)
653-
sceGeListUpdateStallAddr(ge_list_executed[0], gu_list->current);
648+
static inline int _sceGuUpdateStallAddr(void) {
649+
if (gu_curr_context == GU_DIRECT) {
650+
// Just if there are no objects in the stack (no guBeginObject)
651+
if (!gu_object_stack_depth) {
652+
int res;
653+
res = sceGeListUpdateStallAddr(ge_list_executed[0], gu_list->current);
654+
if (res < 0) {
655+
return res;
656+
}
657+
}
658+
}
659+
return 0;
654660
}
655661

656662
#endif

src/gu/pspgu.h

+7-1
Original file line numberDiff line numberDiff line change
@@ -477,6 +477,11 @@ void* sceGuSetCallback(int signal, void (*callback)(int));
477477

478478
/**
479479
* Trigger signal to call code from the command stream
480+
*
481+
* Available signals are:
482+
* - GU_SIGNAL_WAIT - Wait for callback to finish
483+
* - GU_SIGNAL_NOWAIT - Do not wait for callback to finish
484+
* - GU_SIGNAL_PAUSE - Pause execution until callback is finished
480485
*
481486
* Available behaviors are:
482487
* - GU_BEHAVIOR_SUSPEND - Stops display list execution until callback function finished
@@ -566,8 +571,9 @@ int sceGuFinishId(unsigned int id);
566571
* Call previously generated display-list
567572
*
568573
* @param list - Display list to call
574+
* @return 0 for success, < 0 for failure
569575
**/
570-
void sceGuCallList(const void* list);
576+
int sceGuCallList(const void* list);
571577

572578
/**
573579
* Set wether to use stack-based calls or signals to handle execution of called lists.

src/gu/sceGuCallList.c

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,25 @@
88

99
#include "guInternal.h"
1010

11-
void sceGuCallList(const void *list)
11+
int sceGuCallList(const void *list)
1212
{
13+
int res;
1314
unsigned int list_addr = (unsigned int)list;
1415

1516
if (gu_call_mode == GU_CALL_SIGNAL)
1617
{
1718
sendCommandi(SIGNAL, (list_addr >> 16) | 0x110000);
1819
sendCommandi(END, list_addr & 0xffff);
19-
sendCommandiStall(NOP, 0);
2020
}
2121
else
2222
{
2323
sendCommandi(BASE, (list_addr >> 8) & 0xf0000);
24-
sendCommandiStall(CALL, list_addr);
24+
sendCommandi(CALL, list_addr);
2525
}
26+
27+
res = _sceGuUpdateStallAddr();
28+
if (res < 0) {
29+
return res;
30+
}
31+
return 0;
2632
}

src/gu/sceGuDrawArray.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ void sceGuDrawArray(int prim, int vtype, int count, const void *indices, const v
2525
sendCommandi(VADDR, ((unsigned int)vertices));
2626
}
2727

28-
sendCommandiStall(PRIM, (prim << 16) | count);
28+
sendCommandi(PRIM, (prim << 16) | count);
29+
_sceGuUpdateStallAddr();
2930
}

src/gu/sceGuDrawArrayN.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void sceGuDrawArrayN(int primitive_type, int vertex_type, int vcount, int primco
3030
int i;
3131
for (i = 0; i < primcount; i++)
3232
sendCommandi(PRIM, (primitive_type << 16) | vcount);
33-
34-
sendCommandiStall(PRIM, (primitive_type << 16) | vcount);
3533
}
34+
35+
_sceGuUpdateStallAddr();
3636
}

src/gu/sceGuFinishId.c

+20-9
Original file line numberDiff line numberDiff line change
@@ -7,39 +7,50 @@
77
*/
88

99
#include "guInternal.h"
10+
#include <pspdisplay.h>
11+
#include <pspuser.h>
1012

1113
int sceGuFinishId(unsigned int id)
1214
{
15+
int ret;
16+
int intr;
17+
1318
switch (gu_curr_context)
1419
{
1520
case GU_DIRECT:
21+
sendCommandi(FINISH, id & 0xffff);
22+
sendCommandi(END, 0);
23+
ret = _sceGuUpdateStallAddr();
24+
if (ret < 0)
25+
{
26+
return ret;
27+
}
28+
break;
1629
case GU_SEND:
17-
{
1830
sendCommandi(FINISH, id & 0xffff);
19-
sendCommandiStall(END, 0);
20-
}
21-
break;
22-
31+
sendCommandi(END, 0);
32+
break;
2333
case GU_CALL:
24-
{
2534
if (gu_call_mode == GU_CALL_SIGNAL)
2635
{
2736
sendCommandi(SIGNAL, 0x120000);
2837
sendCommandi(END, 0);
29-
sendCommandiStall(NOP, 0);
3038
}
3139
else
3240
{
3341
sendCommandi(RET, 0);
3442
}
35-
}
36-
break;
43+
break;
44+
default:
45+
return SCE_DISPLAY_ERROR_ARGUMENT;
3746
}
3847

3948
unsigned int size = ((unsigned int)gu_list->current) - ((unsigned int)gu_list->start);
4049

4150
// go to parent list
51+
intr = sceKernelCpuSuspendIntr();
4252
gu_curr_context = gu_list->parent_context;
4353
gu_list = &gu_contexts[gu_curr_context].list;
54+
sceKernelCpuResumeIntr(intr);
4455
return size;
4556
}

src/gu/sceGuInit.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ int sceGuInit(void)
283283
gu_settings.ge_callback_id = res;
284284

285285
// initialize graphics hardware
286-
res = sceGeListEnQueue((void *)((unsigned int)ge_init_list & 0x1fffffff), 0, gu_settings.ge_callback_id, 0);
286+
res = sceGeListEnQueue((void *)((unsigned int)ge_init_list & 0x1fffffff), NULL, gu_settings.ge_callback_id, NULL);
287287
if (res < 0)
288288
{
289289
sceKernelDeleteEventFlag(gu_settings.kernel_event_flag);

src/gu/sceGuSignal.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ void sceGuSignal(int signal, int argument)
1313
sendCommandi(SIGNAL, ((signal & 0xff) << 16) | (argument & 0xffff));
1414
sendCommandi(END, 0);
1515

16-
if (GU_SIGNAL_PAUSE == 3)
16+
if (signal == GU_SIGNAL_PAUSE)
1717
{
1818
sendCommandi(FINISH, 0);
1919
sendCommandi(END, 0);
2020
}
2121

22-
sendCommandiStall(NOP, 0);
23-
}
22+
_sceGuUpdateStallAddr();
23+
}

src/gu/sceGuStart.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,16 @@
1010

1111
#include <pspkernel.h>
1212
#include <pspge.h>
13+
#include <pspuser.h>
1314

1415
void sceGuStart(int ctype, void *list)
1516
{
17+
int intr;
1618
GuContext *context = &gu_contexts[ctype];
1719
unsigned int *local_list = (unsigned int *)(((unsigned int)list) | 0x40000000);
1820

21+
intr = sceKernelCpuSuspendIntr();
22+
1923
// setup display list
2024

2125
context->list.start = local_list;
@@ -26,10 +30,11 @@ void sceGuStart(int ctype, void *list)
2630
// store current context
2731

2832
gu_curr_context = ctype;
33+
sceKernelCpuResumeIntr(intr);
2934

3035
if (ctype == GU_DIRECT)
3136
{
32-
ge_list_executed[0] = sceGeListEnQueue(local_list, local_list, gu_settings.ge_callback_id, 0);
37+
ge_list_executed[0] = sceGeListEnQueue(local_list, local_list, gu_settings.ge_callback_id, NULL);
3338
gu_settings.signal_offset = 0;
3439
}
3540

0 commit comments

Comments
 (0)