Commit a4442476dfdfaec23a24c19e213ab4e9101264d1

Ivan Epifanov 2021-06-10T12:14:14

Cleanup dead and duplicate code

diff --git a/src/render/vitagxm/SDL_render_vita_gxm.c b/src/render/vitagxm/SDL_render_vita_gxm.c
index f346cc6..9376d12 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm.c
@@ -1144,20 +1144,8 @@ VITA_GXM_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture)
 
     sceGxmFinish(data->gxm_context);
 
-    if (vita_texture->tex->gxm_rendertarget) {
-        sceGxmDestroyRenderTarget(vita_texture->tex->gxm_rendertarget);
-    }
-
-    if (vita_texture->tex->depth_UID) {
-        mem_gpu_free(vita_texture->tex->depth_UID);
-    }
-
-    if (vita_texture->tex->palette_UID) {
-        mem_gpu_free(vita_texture->tex->palette_UID);
-    }
+    free_gxm_texture(vita_texture->tex);
 
-    mem_gpu_free(vita_texture->tex->data_UID);
-    SDL_free(vita_texture->tex);
     SDL_free(vita_texture);
 
     texture->driverdata = NULL;
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_tools.c b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
index 349e48f..3ce7c14 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_tools.c
+++ b/src/render/vitagxm/SDL_render_vita_gxm_tools.c
@@ -1001,9 +1001,6 @@ free_gxm_texture(gxm_texture *texture)
         if (texture->depth_UID) {
             mem_gpu_free(texture->depth_UID);
         }
-        if (texture->palette_UID) {
-            mem_gpu_free(texture->palette_UID);
-        }
         mem_gpu_free(texture->data_UID);
         SDL_free(texture);
     }
@@ -1070,29 +1067,6 @@ create_gxm_texture(VITA_GXM_RenderData *data, unsigned int w, unsigned int h, Sc
     /* Create the gxm texture */
     sceGxmTextureInitLinear( &texture->gxm_tex, texture_data, format, w, h, 0);
 
-    if ((format & 0x9f000000U) == SCE_GXM_TEXTURE_BASE_FORMAT_P8) {
-        const int pal_size = 256 * sizeof(uint32_t);
-
-        void *texture_palette = mem_gpu_alloc(
-            SCE_KERNEL_MEMBLOCK_TYPE_USER_CDRAM_RW,
-            pal_size,
-            SCE_GXM_PALETTE_ALIGNMENT,
-            SCE_GXM_MEMORY_ATTRIB_READ,
-            &texture->palette_UID);
-
-        if (!texture_palette) {
-            texture->palette_UID = 0;
-            free_gxm_texture(texture);
-            return NULL;
-        }
-
-        SDL_memset(texture_palette, 0, pal_size);
-
-        sceGxmTextureSetPalette(&texture->gxm_tex, texture_palette);
-    } else {
-        texture->palette_UID = 0;
-    }
-
     if (isRenderTarget) {
         void *depthBufferData;
         const uint32_t alignedWidth = ALIGN(w, SCE_GXM_TILE_SIZEX);
diff --git a/src/render/vitagxm/SDL_render_vita_gxm_types.h b/src/render/vitagxm/SDL_render_vita_gxm_types.h
index fa146ac..d1cb249 100644
--- a/src/render/vitagxm/SDL_render_vita_gxm_types.h
+++ b/src/render/vitagxm/SDL_render_vita_gxm_types.h
@@ -76,7 +76,6 @@ typedef struct texture_vertex {
 typedef struct gxm_texture {
     SceGxmTexture gxm_tex;
     SceUID data_UID;
-    SceUID palette_UID;
     SceGxmRenderTarget *gxm_rendertarget;
     SceGxmColorSurface gxm_colorsurface;
     SceGxmDepthStencilSurface gxm_depthstencil;