diff --git a/src/platform/3ds/ctr-gpu.c b/src/platform/3ds/ctr-gpu.c index a17362fd2..14446b79d 100644 --- a/src/platform/3ds/ctr-gpu.c +++ b/src/platform/3ds/ctr-gpu.c @@ -27,7 +27,7 @@ struct ctrUIVertex { 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 @@ void ctrActivateTexture(C3D_Tex* texture) { } activeTexture = texture; + C3D_TexBind(0, activeTexture); C3D_TexEnv* env = C3D_GetTexEnv(0); C3D_TexEnvOp(env, C3D_Both, 0, 0, 0); @@ -175,15 +176,20 @@ void ctrFlushBatch(void) { 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; +} diff --git a/src/platform/3ds/ctr-gpu.h b/src/platform/3ds/ctr-gpu.h index 37fae8087..5f4cb6d3b 100644 --- a/src/platform/3ds/ctr-gpu.h +++ b/src/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 diff --git a/src/platform/3ds/main.c b/src/platform/3ds/main.c index 6e9ca6488..131a6c64c 100644 --- a/src/platform/3ds/main.c +++ b/src/platform/3ds/main.c @@ -178,8 +178,7 @@ static void _drawStart(void) { } 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();