3DS: Allocate memory for textures in VRAM

This commit is contained in:
Yuri Kunde Schlesner 2015-09-16 22:27:05 -03:00
parent 58f97980e7
commit a623bcadc3
2 changed files with 15 additions and 7 deletions

View File

@ -26,18 +26,20 @@ struct GUIFont* GUIFontCreate(void) {
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);
}

View File

@ -363,8 +363,14 @@ int main() {
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();