Add C3D_GetDrawingTime/C3D_GetProcessingTime
This commit is contained in:
parent
033c600e20
commit
5e156dd719
@ -39,6 +39,9 @@ bool C3D_FrameBegin(u8 flags);
|
|||||||
bool C3D_FrameDrawOn(C3D_RenderTarget* target);
|
bool C3D_FrameDrawOn(C3D_RenderTarget* target);
|
||||||
void C3D_FrameEnd(u8 flags);
|
void C3D_FrameEnd(u8 flags);
|
||||||
|
|
||||||
|
float C3D_GetDrawingTime(void);
|
||||||
|
float C3D_GetProcessingTime(void);
|
||||||
|
|
||||||
#if defined(__GNUC__) && !defined(__cplusplus)
|
#if defined(__GNUC__) && !defined(__cplusplus)
|
||||||
typedef union __attribute__((__transparent_union__))
|
typedef union __attribute__((__transparent_union__))
|
||||||
{
|
{
|
||||||
|
@ -10,6 +10,8 @@ static C3D_RenderTarget *firstTarget, *lastTarget;
|
|||||||
static C3D_RenderTarget *linkedTarget[3];
|
static C3D_RenderTarget *linkedTarget[3];
|
||||||
static C3D_RenderTarget *transferQueue, *clearQueue;
|
static C3D_RenderTarget *transferQueue, *clearQueue;
|
||||||
|
|
||||||
|
static TickCounter gpuTime, cpuTime;
|
||||||
|
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
C3D_RenderTarget* targetList;
|
C3D_RenderTarget* targetList;
|
||||||
@ -31,6 +33,7 @@ static void performDraw(void)
|
|||||||
{
|
{
|
||||||
gspSetEventCallback(GSPGPU_EVENT_P3D, onRenderFinish, NULL, true);
|
gspSetEventCallback(GSPGPU_EVENT_P3D, onRenderFinish, NULL, true);
|
||||||
GX_ProcessCommandList(queuedFrame[queueSwap].cmdBuf, queuedFrame[queueSwap].cmdBufSize, queuedFrame[queueSwap].flags);
|
GX_ProcessCommandList(queuedFrame[queueSwap].cmdBuf, queuedFrame[queueSwap].cmdBufSize, queuedFrame[queueSwap].flags);
|
||||||
|
osTickCounterStart(&gpuTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void performTransfer(void)
|
static void performTransfer(void)
|
||||||
@ -170,6 +173,7 @@ static void onVBlank1(C3D_UNUSED void* unused)
|
|||||||
void onRenderFinish(C3D_UNUSED void* unused)
|
void onRenderFinish(C3D_UNUSED void* unused)
|
||||||
{
|
{
|
||||||
C3D_RenderTarget *a, *next;
|
C3D_RenderTarget *a, *next;
|
||||||
|
osTickCounterUpdate(&gpuTime);
|
||||||
|
|
||||||
// The following check should never trigger
|
// The following check should never trigger
|
||||||
if (queuedState!=1) svcBreak(USERBREAK_PANIC);
|
if (queuedState!=1) svcBreak(USERBREAK_PANIC);
|
||||||
@ -312,6 +316,7 @@ bool C3D_FrameBegin(u8 flags)
|
|||||||
return false;
|
return false;
|
||||||
gspWaitForP3D();
|
gspWaitForP3D();
|
||||||
}
|
}
|
||||||
|
osTickCounterStart(&cpuTime);
|
||||||
inFrame = true;
|
inFrame = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -343,6 +348,7 @@ void C3D_FrameEnd(u8 flags)
|
|||||||
{
|
{
|
||||||
if (!inFrame) return;
|
if (!inFrame) return;
|
||||||
inFrame = false;
|
inFrame = false;
|
||||||
|
osTickCounterUpdate(&cpuTime);
|
||||||
|
|
||||||
int pos = queueSwap^queuedCount;
|
int pos = queueSwap^queuedCount;
|
||||||
if (!queuedFrame[pos].targetList) return;
|
if (!queuedFrame[pos].targetList) return;
|
||||||
@ -365,6 +371,16 @@ void C3D_FrameEnd(u8 flags)
|
|||||||
updateFrameQueue();
|
updateFrameQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float C3D_GetDrawingTime(void)
|
||||||
|
{
|
||||||
|
return osTickCounterRead(&gpuTime);
|
||||||
|
}
|
||||||
|
|
||||||
|
float C3D_GetProcessingTime(void)
|
||||||
|
{
|
||||||
|
return osTickCounterRead(&cpuTime);
|
||||||
|
}
|
||||||
|
|
||||||
static C3D_RenderTarget* C3Di_RenderTargetNew(void)
|
static C3D_RenderTarget* C3Di_RenderTargetNew(void)
|
||||||
{
|
{
|
||||||
C3D_RenderTarget* target = (C3D_RenderTarget*)malloc(sizeof(C3D_RenderTarget));
|
C3D_RenderTarget* target = (C3D_RenderTarget*)malloc(sizeof(C3D_RenderTarget));
|
||||||
|
Loading…
Reference in New Issue
Block a user