Skip to content

Conversation

Wohlstand
Copy link
Contributor

@Wohlstand Wohlstand commented Sep 28, 2025

Description

Since it's no known way to use geuine viewport with PSP SDK, I implemented the workaround using manually added/subtracted offsets to vertices passing to the render API. To assign viewport and cliprect in valid way, I copied part of code from the Vita's module and adjusted it to work on PSP.

Just a small note to author of #13314, @fjtrujy, please take changes that I done into your work since the viewport via existing way just doesn't work at all.

There are showcases made on emulator (it's absoutely same on hardware):

How it worked before my changes:

Снимок экрана от 2025-09-28 18-47-29

How it works together with my changes:

EDIT: This valid on emulator, on hardware it glitchies because quick alternation of values seems unsafe.
Снимок экрана от 2025-09-28 18-49-10

What I did exactly

Since existing API calls of sceGuOffset and sceGuViewport give no effect in order to set the viewport, however, scissors works as charm, I found that I can replicate viewport functionality by appending viewport's offset of x and y to every vertex that gets used while drawing the stuff. Scissors do help to limit drawing of content in the given scope that allows to prevent drawing of the stuff outside the given scope.

Existing Issue(s)

Nothing

@Wohlstand
Copy link
Contributor Author

Tested on hardware: heck, seems glitches are comming, I probably should keep alternated values somewhere also since their alternation on the fly just ruins the drawn result... (seems immediate alternation of passed values is just unsafe)
2025-09-28_18-54-44

@Wohlstand
Copy link
Contributor Author

Wohlstand commented Sep 28, 2025

Okay, I fixed the problem by removing "subtraction" operation, but this seems unsafe in the case if same queue list will be re-used 🤔

EDIT: I made full sure it's SAFE: since every time I run queue, the new buffer gets allocated to store vertices to draw in this run.

2025-09-28_19-07-01

Since it's no known way to use genuine viewport with PSP SDK, I implemented the workaround using manually added/subtracted offsets to vertices passing to the render API. To assign viewport and cliprect in valid way, I copied part of code from the Vita's module and adjusted it to work on PSP.
@Wohlstand
Copy link
Contributor Author

Okay, I fixed it so it works on hardware properly.

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.
@slouken
Copy link
Collaborator

slouken commented Sep 29, 2025

Can you make a separate PR for the SDL main branch?

@Wohlstand
Copy link
Contributor Author

Wohlstand commented Sep 29, 2025

Can you make a separate PR for the SDL main branch?

Of course, I just wanted to make sure it's no notices to me, so I want to fix any notices, and then I making full replica of this to main. Just, I don't want to do the same job twice (i.e. fixing the same notice at two branches). If everything is fine, then I doing the second PR immediately.

@slouken
Copy link
Collaborator

slouken commented Sep 30, 2025

Offhand, it looks good to me. Do any of these changes need to go into the vita code too?

@Wohlstand
Copy link
Contributor Author

Wohlstand commented Sep 30, 2025

Vita right now is fine in this case, it was been fixed before, and then once I got PSP to port my thing to it, and I obtained such thingies that requires a fixing. So, backporting the thing now... (I mean this to main)

@Wohlstand
Copy link
Contributor Author

I made for SDL3 this: #14081

@slouken slouken merged commit 39a0fab into libsdl-org:SDL2 Sep 30, 2025
34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants