Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rendering of non zero src rect #1

Merged
merged 1 commit into from
Feb 3, 2024
Merged

Conversation

Beyley
Copy link
Contributor

@Beyley Beyley commented Jan 27, 2024

Found this when trying to implement text rendering, tested working now in RPCS3, still needs to be tested on real hardware though.

At least in my testing, the PSL1GHT documentation is wrong here, inW/H is actually X2/Y2, not width and height. But maybe this is an inaccuracy in RPCS3?

@ultra0000
Copy link
Owner

hey there. i haven't actually worked with psl1ght in a while, so i'll need to get that set up again first. i'll report back on what happens on real hardware once i get around to testing it.

@Beyley
Copy link
Contributor Author

Beyley commented Jan 27, 2024

Heres the code for the project im currently working on, if it helps to be able to have a existing reproduction app
https://github.com/Beyley/RefresherPS3/
It uses SDL_RenderCopy to draw text glyphs, it should just display the list of installed games on the hard drive when you open it, without this PR it would display all black, since it would only draw the top-left of the atlas due to the incorrect values

heres what it should look like:
image

@Beyley
Copy link
Contributor Author

Beyley commented Jan 30, 2024

so i got my own ps3 hooked up to boot my homebrew, but when attempting to run my app on real hardware, i just get a black screen, and cant open the XMB (i can tell the main thread isnt dying because the app seems to still accept interaction and is at least getting into the main loop)
im guessing the framebuffer just isnt being init properly by SDL2
heres how i init SDL in my app https://github.com/Beyley/RefresherPS3/blob/3cff6fcc46b4966d2bad1463893d728974563a1e/src/main.c#L163 is there something obvious im doing wrong here?

@ultra0000
Copy link
Owner

hello again. i apologize for leaving you hanging there, the ps3toolchain would error out when setting it up for some reason and i got a bit distracted with other projects.

i remember how for some odd reason the compiler would get weird with the -O2 optimization flag. so the result was that it worked as expected on rpcs3 but not on real hardware. maybe try lowering it to -O1?

@Beyley
Copy link
Contributor Author

Beyley commented Jan 30, 2024

I tried -O1 and -Og, and same behaviour on real hardware

@ultra0000
Copy link
Owner

weird... i'm not sure if this is related, but i remember how some people were talking about a similar issue happening on an unfinished port i made of the RSDKv5 decompilation (a.k.a., the engine Sonic Mania uses). in particular when they tried compiling it themselves, it would do a similar thing here. but there was something about my setup that just made it... work? the executables i had compiled worked on real hardware, but the executables everyone else compiled just didn't. unfortunately, i don't have said setup anymore, i think i erased the virtual machine's hard drive image long ago.

it seems like someone made a fork of the port, so it might be worth seeing what's going on there...

@Beyley
Copy link
Contributor Author

Beyley commented Jan 31, 2024

Looking at the fork, they have quite a few changes to the build flags, but overall it looks like they just use -O1 with a bunch of extra flags added ontop to get as close to -O2 as possible without the issue on real hardware
i tried using their flags directly and it still is broken on my project

I also tried reducing my all the way down to just "init sdl, create window, create renderer, enter SDL loop, running RenderPresent every frame" and it still does not init correctly on real hardware

im honestly not sure how to do debugging here, im quite new to PS3 homebrew

@StrawFox64
Copy link

this port they have problems with the current toolchain. I while working with the rsdkv5 port based on the ultra noticed this. for some reason it does not run on real hardware. But looking at the files contained in this repository, it contains a patch file, would this be necessary to make it work on hardware?

@Beyley
Copy link
Contributor Author

Beyley commented Feb 3, 2024

this port they have problems with the current toolchain. I while working with the rsdkv5 port based on the ultra noticed this. for some reason it does not run on real hardware. But looking at the files contained in this repository, it contains a patch file, would this be necessary to make it work on hardware?

I think that patch file was the base of this port, given it seems to just be an early version of the current code (and doesnt seem to apply anyway, none of the paths line up)

@StrawFox64
Copy link

StrawFox64 commented Feb 3, 2024

Okay. I didn't go very deep into this port. in my profile has another port of sdl2, which was used in RSDKv5. It is quite stable and works on real hardware

@Beyley
Copy link
Contributor Author

Beyley commented Feb 3, 2024

the official PSL1GHT samples dont work on my PS3 either, so i've opened ps3dev/PSL1GHT#144, real hardware being broken seems to be an upstream bug

@StrawFox64
Copy link

I also had problems when trying to run some graphical samples of psl1ght, the only one I could get it to work was blitting, which I had to change in its Makefile so that it compiled with -O2 levels, otherwise it wouldn't work.

@ultra0000
Copy link
Owner

I think that patch file was the base of this port, given it seems to just be an early version of the current code (and doesnt seem to apply anyway, none of the paths line up)

that is correct.

the official PSL1GHT samples dont work on my PS3 either, so i've opened ps3dev/PSL1GHT#144, real hardware being broken seems to be an upstream bug

makes sense.

@ultra0000
Copy link
Owner

in the meantime, i suppose i can merge this pr now? since we know it's an issue with the SDK and not the code itself.

@Beyley
Copy link
Contributor Author

Beyley commented Feb 3, 2024

I also had problems when trying to run some graphical samples of psl1ght, the only one I could get it to work was blitting, which I had to change in its Makefile so that it compiled with -O2 levels, otherwise it wouldn't work.

huh, yeah now it boots (but looks incorrect)
image

i'm not sure why i cant get SDL2 to work then, i have both it and my app compiled with -O2

@Beyley
Copy link
Contributor Author

Beyley commented Feb 3, 2024

in the meantime, i suppose i can merge this pr now? since we know it's an issue with the SDK and not the code itself.

seems that way, if theres any changes required in this project to make it work with whatever changed/broke upstream, i'll open another PR to fix it

@ultra0000
Copy link
Owner

alright.

@ultra0000 ultra0000 merged commit 5e0874f into ultra0000:main Feb 3, 2024
@Beyley
Copy link
Contributor Author

Beyley commented Feb 6, 2024

i finally was able to properly test this on real hardware

after ~3 hours of poking about, deleting single lines of code to see exactly where things break, and crashing my ps3 about 50 times, i have learned the following:

as it turns out it just flat out crashes the whole console if i render with certain source rects (both before and after my patch, so it wasnt something introduced in this PR)

rpcs3 says nothing about it, so im not sure how to debug this crash

as a temporary solution, i just forced software rendering and everything works perfectly and my own apps finally open on my PS3 (although obviously i dont get very good performance, but thats fine for a small text-based app)
image

@StrawFox64
Copy link

WOOOOOOW, congratulations.

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.

3 participants