mirror of https://github.com/mgba-emu/mgba.git
3DS: Improve menu performance
This commit is contained in:
parent
376c3e715e
commit
f25a7f7778
|
@ -27,7 +27,7 @@ struct ctrUIVertex {
|
||||||
u32 abgr;
|
u32 abgr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MAX_NUM_QUADS 2048
|
#define MAX_NUM_QUADS 1024
|
||||||
#define VERTEX_BUFFER_SIZE MAX_NUM_QUADS * sizeof(struct ctrUIVertex)
|
#define VERTEX_BUFFER_SIZE MAX_NUM_QUADS * sizeof(struct ctrUIVertex)
|
||||||
|
|
||||||
static struct ctrUIVertex* ctrVertexBuffer = NULL;
|
static struct ctrUIVertex* ctrVertexBuffer = NULL;
|
||||||
|
@ -121,6 +121,7 @@ void ctrActivateTexture(C3D_Tex* texture) {
|
||||||
}
|
}
|
||||||
|
|
||||||
activeTexture = texture;
|
activeTexture = texture;
|
||||||
|
C3D_TexBind(0, activeTexture);
|
||||||
|
|
||||||
C3D_TexEnv* env = C3D_GetTexEnv(0);
|
C3D_TexEnv* env = C3D_GetTexEnv(0);
|
||||||
C3D_TexEnvOp(env, C3D_Both, 0, 0, 0);
|
C3D_TexEnvOp(env, C3D_Both, 0, 0, 0);
|
||||||
|
@ -175,15 +176,20 @@ void ctrFlushBatch(void) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
C3D_TexBind(0, activeTexture);
|
|
||||||
|
|
||||||
C3D_BufInfo* bufInfo = C3D_GetBufInfo();
|
C3D_BufInfo* bufInfo = C3D_GetBufInfo();
|
||||||
BufInfo_Init(bufInfo);
|
BufInfo_Init(bufInfo);
|
||||||
BufInfo_Add(bufInfo, &ctrVertexBuffer[ctrVertStart], sizeof(struct ctrUIVertex), 3, 0x210);
|
BufInfo_Add(bufInfo, &ctrVertexBuffer[ctrVertStart], sizeof(struct ctrUIVertex), 3, 0x210);
|
||||||
|
|
||||||
GSPGPU_FlushDataCache(ctrVertexBuffer, VERTEX_BUFFER_SIZE);
|
GSPGPU_FlushDataCache(&ctrVertexBuffer[ctrVertStart], sizeof(struct ctrUIVertex) * ctrNumVerts);
|
||||||
C3D_DrawArrays(GPU_GEOMETRY_PRIM, 0, ctrNumVerts);
|
C3D_DrawArrays(GPU_GEOMETRY_PRIM, 0, ctrNumVerts);
|
||||||
|
|
||||||
ctrVertStart += ctrNumVerts;
|
ctrVertStart += ctrNumVerts;
|
||||||
ctrNumVerts = 0;
|
ctrNumVerts = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ctrFinalize(void) {
|
||||||
|
ctrFlushBatch();
|
||||||
|
C3D_Flush();
|
||||||
|
ctrNumVerts = 0;
|
||||||
|
ctrVertStart = 0;
|
||||||
|
}
|
||||||
|
|
|
@ -20,5 +20,6 @@ void ctrActivateTexture(C3D_Tex* texture);
|
||||||
void ctrAddRectScaled(u32 color, s16 x, s16 y, s16 w, s16 h, s16 u, s16 v, s16 uw, s16 vh);
|
void ctrAddRectScaled(u32 color, s16 x, s16 y, s16 w, s16 h, s16 u, s16 v, s16 uw, s16 vh);
|
||||||
void ctrAddRect(u32 color, s16 x, s16 y, s16 u, s16 v, s16 w, s16 h);
|
void ctrAddRect(u32 color, s16 x, s16 y, s16 u, s16 v, s16 w, s16 h);
|
||||||
void ctrFlushBatch(void);
|
void ctrFlushBatch(void);
|
||||||
|
void ctrFinalize(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -178,8 +178,7 @@ static void _drawStart(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _drawEnd(void) {
|
static void _drawEnd(void) {
|
||||||
ctrFlushBatch();
|
ctrFinalize();
|
||||||
C3D_Flush();
|
|
||||||
C3D_RenderBufTransfer(&topScreen, (u32*) gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
|
C3D_RenderBufTransfer(&topScreen, (u32*) gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
|
||||||
C3D_RenderBufTransfer(&bottomScreen, (u32*) gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
|
C3D_RenderBufTransfer(&bottomScreen, (u32*) gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL), GX_TRANSFER_IN_FORMAT(GX_TRANSFER_FMT_RGB8) | GX_TRANSFER_OUT_FORMAT(GX_TRANSFER_FMT_RGB8));
|
||||||
gfxSwapBuffersGpu();
|
gfxSwapBuffersGpu();
|
||||||
|
|
Loading…
Reference in New Issue