3DS: Allocate memory for textures in VRAM
Yuri Kunde Schlesner yuriks@yuriks.net
Wed, 16 Sep 2015 22:27:05 -0300
2 files changed,
15 insertions(+),
7 deletions(-)
M
src/platform/3ds/gui-font.c
→
src/platform/3ds/gui-font.c
@@ -26,18 +26,20 @@ }
struct ctrTexture* tex = &guiFont->texture; ctrTexture_Init(tex); - tex->data = linearAlloc(256 * 128 * 2); + tex->data = vramAlloc(256 * 128 * 2); tex->format = GPU_RGBA5551; tex->width = 256; tex->height = 128; - memcpy(tex->data, font, font_size); - GSPGPU_FlushDataCache(NULL, tex->data, font_size); + + GSPGPU_FlushDataCache(NULL, (u8*)font, font_size); + GX_RequestDma(NULL, (u32*)font, tex->data, font_size); + gspWaitForDMA(); return guiFont; } void GUIFontDestroy(struct GUIFont* font) { - linearFree(font->texture.data); + vramFree(font->texture.data); free(font); }
M
src/platform/3ds/main.c
→
src/platform/3ds/main.c
@@ -363,8 +363,14 @@ gbaOutputTexture.format = GPU_RGB565;
gbaOutputTexture.filter = GPU_LINEAR; gbaOutputTexture.width = 256; gbaOutputTexture.height = 256; - gbaOutputTexture.data = linearAlloc(256 * 256 * 2); - memset(gbaOutputTexture.data, 0, 256 * 256 * 2); + gbaOutputTexture.data = vramAlloc(256 * 256 * 2); + void* outputTextureEnd = (u8*)gbaOutputTexture.data + 256 * 256 * 2; + + // Zero texture data to make sure no garbage around the border interferes with filtering + GX_SetMemoryFill(NULL, + gbaOutputTexture.data, 0x0000, outputTextureEnd, GX_FILL_16BIT_DEPTH | GX_FILL_TRIGGER, + NULL, 0, NULL, 0); + gspWaitForPSC0(); sdmcArchive = (FS_archive) { ARCH_SDMC,@@ -410,7 +416,7 @@ cleanup:
linearFree(renderer.outputBuffer); ctrDeinitGpu(); - linearFree(gbaOutputTexture.data); + vramFree(gbaOutputTexture.data); gfxExit();