render/wiiu: Allocate normal textures from MEM2

MEM1 fills up very quickly and soon runs out of space for apps with many textures
This commit is contained in:
rw-r-r-0644 2019-03-18 23:11:18 +01:00 committed by Ash Logan
parent 14bbb4a0f1
commit 6ba2f62f38
3 changed files with 16 additions and 4 deletions

View File

@ -124,6 +124,7 @@ void WIIU_SDL_CreateWindowTex(SDL_Renderer * renderer, SDL_Window * window)
data->windowTex = (SDL_Texture) {
.format = SDL_PIXELFORMAT_RGBA8888,
.r = 255, .g = 255, .b = 255, .a = 255,
.driverdata = WIIU_TEXTURE_MEM1_MAGIC,
};
SDL_GetWindowSize(window, &data->windowTex.w, &data->windowTex.h);

View File

@ -101,6 +101,9 @@ struct WIIU_TextureData
int isRendering;
};
/* Ask texture driver to allocate texture's memory from MEM1 */
#define WIIU_TEXTURE_MEM1_MAGIC (void *)0xCAFE0001
/* SDL_render API implementation */
SDL_Renderer *WIIU_SDL_CreateRenderer(SDL_Window * window, Uint32 flags);
void WIIU_SDL_WindowEvent(SDL_Renderer * renderer,

View File

@ -38,8 +38,9 @@
int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
{
WIIUPixFmt gx2_fmt;
BOOL res;
WIIUPixFmt gx2_fmt;
GX2RResourceFlags surface_flags;
WIIU_TextureData *tdata = (WIIU_TextureData *) SDL_calloc(1, sizeof(*tdata));
if (!tdata) {
return SDL_OutOfMemory();
@ -74,12 +75,19 @@ int WIIU_SDL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture)
tdata->cbuf.viewNumSlices = 1;
GX2InitColorBufferRegs(&tdata->cbuf);
/* Texture's surface flags */
surface_flags = GX2R_RESOURCE_BIND_TEXTURE | GX2R_RESOURCE_BIND_COLOR_BUFFER |
GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_CPU_READ |
GX2R_RESOURCE_USAGE_GPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ;
/* Allocate normal textures from MEM2 */
if (texture->driverdata != WIIU_TEXTURE_MEM1_MAGIC)
surface_flags |= GX2R_RESOURCE_USAGE_FORCE_MEM2;
/* Allocate the texture's surface */
res = GX2RCreateSurface(
&tdata->texture.surface,
GX2R_RESOURCE_BIND_TEXTURE | GX2R_RESOURCE_BIND_COLOR_BUFFER |
GX2R_RESOURCE_USAGE_CPU_WRITE | GX2R_RESOURCE_USAGE_CPU_READ |
GX2R_RESOURCE_USAGE_GPU_WRITE | GX2R_RESOURCE_USAGE_GPU_READ
surface_flags
);
if (!res) {
SDL_free(tdata);