SDL: SDL2: PSP: Fixed render-to-texture larger than screen (d2995)

From d2995655d5967b378b46cb48c9f65b209a9397a4 Mon Sep 17 00:00:00 2001
From: Wohlstand <[EMAIL REDACTED]>
Date: Tue, 30 Sep 2025 01:34:17 +0300
Subject: [PATCH] SDL2: PSP: Fixed render-to-texture larger than screen

I found if I try to make texture bigger than screen and use it as a frame buffer, it gets cuts of content. To ensure that render will be valid, I making sure scissors were initialised properly.

P.S. This works on hardware, however, emulator PPSSPP seems has a bug in this case, so I going to report that and making the simple demo.

(cherry picked from commit 39a0fab4d79ccd622512d6028ea3733bd4085455)
---
 src/render/psp/SDL_render_psp.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/src/render/psp/SDL_render_psp.c b/src/render/psp/SDL_render_psp.c
index ad21bb15384ea..fb7a53e1f5ada 100644
--- a/src/render/psp/SDL_render_psp.c
+++ b/src/render/psp/SDL_render_psp.c
@@ -87,8 +87,6 @@ typedef struct
     SDL_bool cliprect_dirty;
     SDL_Rect cliprect;
 
-    SDL_Texture *target;
-
     float draw_offset_x;
     float draw_offset_y;
 
@@ -1100,7 +1098,8 @@ static void SetDrawState(PSP_RenderData *data)
 
     if (data->drawstate.cliprect_enabled_dirty) {
         if (!data->drawstate.cliprect_enabled && !data->drawstate.viewport_is_set) {
-            sceGuDisable(GU_SCISSOR_TEST);
+            sceGuScissor(0, 0, data->drawstate.drawablew, data->drawstate.drawableh);
+            sceGuEnable(GU_SCISSOR_TEST);
         }
         data->drawstate.cliprect_enabled_dirty = SDL_FALSE;
     }
@@ -1167,14 +1166,12 @@ static int PSP_RunCommandQueue(SDL_Renderer *renderer, SDL_RenderCommand *cmd, v
     }
     SDL_memcpy(gpumem, vertices, vertsize);
 
-    data->drawstate.target = renderer->target;
-    if (!data->drawstate.target) {
+    if (!data->boundTarget) {
         SDL_GL_GetDrawableSize(renderer->window, &w, &h);
     } else {
-        if (SDL_QueryTexture(renderer->target, NULL, NULL, &w, &h) < 0) {
-            w = data->drawstate.drawablew;
-            h = data->drawstate.drawableh;
-        }
+        PSP_TextureData *psp_texture = (PSP_TextureData *)data->boundTarget->driverdata;
+        w = psp_texture->width;
+        h = psp_texture->height;
     }
 
     if ((w != data->drawstate.drawablew) || (h != data->drawstate.drawableh)) {