all repos — mgba @ f25a7f7778bcd1f3d7c0ff755bc5d475f546a978

mGBA Game Boy Advance Emulator

3DS: Improve menu performance
Jeffrey Pfau jeffrey@endrift.com
Thu, 28 Jul 2016 22:00:47 -0700
commit

f25a7f7778bcd1f3d7c0ff755bc5d475f546a978

parent

376c3e715e1b849077febe956aa954be53fad810

3 files changed, 12 insertions(+), 6 deletions(-)

jump to
M src/platform/3ds/ctr-gpu.csrc/platform/3ds/ctr-gpu.c

@@ -27,7 +27,7 @@ short uw, vh;

u32 abgr; }; -#define MAX_NUM_QUADS 2048 +#define MAX_NUM_QUADS 1024 #define VERTEX_BUFFER_SIZE MAX_NUM_QUADS * sizeof(struct ctrUIVertex) static struct ctrUIVertex* ctrVertexBuffer = NULL;

@@ -121,6 +121,7 @@ ctrFlushBatch();

} activeTexture = texture; + C3D_TexBind(0, activeTexture); C3D_TexEnv* env = C3D_GetTexEnv(0); C3D_TexEnvOp(env, C3D_Both, 0, 0, 0);

@@ -175,15 +176,20 @@ if (ctrNumVerts == 0) {

return; } - C3D_TexBind(0, activeTexture); - C3D_BufInfo* bufInfo = C3D_GetBufInfo(); BufInfo_Init(bufInfo); 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); ctrVertStart += ctrNumVerts; ctrNumVerts = 0; } + +void ctrFinalize(void) { + ctrFlushBatch(); + C3D_Flush(); + ctrNumVerts = 0; + ctrVertStart = 0; +}
M src/platform/3ds/ctr-gpu.hsrc/platform/3ds/ctr-gpu.h

@@ -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 ctrAddRect(u32 color, s16 x, s16 y, s16 u, s16 v, s16 w, s16 h); void ctrFlushBatch(void); +void ctrFinalize(void); #endif
M src/platform/3ds/main.csrc/platform/3ds/main.c

@@ -178,8 +178,7 @@ C3D_RenderBufClear(&topScreen);

} static void _drawEnd(void) { - ctrFlushBatch(); - C3D_Flush(); + ctrFinalize(); 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)); gfxSwapBuffersGpu();