Commit 7080bc2a91f2290120d31f2ad0bc6a36c8a54837

Northfear 2021-09-20T23:02:01

Fallback to SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE if CDRAM texture allocation fails

diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index 2190b66..f4133a9 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -1027,6 +1027,18 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
         &texture->data_UID
     );
 
+    /* Try SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE in case we're out of VRAM */
+    if (!texture_data) {
+        SDL_LogWarn(SDL_LOG_CATEGORY_RENDER, "CDRAM texture allocation failed\n");
+        texture_data = mem_gpu_alloc(
+            SCE_KERNEL_MEMBLOCK_TYPE_USER_RW_UNCACHE,
+            tex_size,
+            SCE_GXM_TEXTURE_ALIGNMENT,
+            SCE_GXM_MEMORY_ATTRIB_READ | SCE_GXM_MEMORY_ATTRIB_WRITE,
+            &texture->data_UID
+        );
+    }
+
     if (!texture_data) {
         free(texture);
         return NULL;