Rinnegatamante / vitaGL

openGL wrapper for PSVITA.
GNU Lesser General Public License v3.0
459 stars 46 forks source link

Runtime shader compiler support #38

Closed OsirizX closed 4 years ago

OsirizX commented 4 years ago

Hello @Rinnegatamante, first of all thank you for the nice work you've done with vitaGL!

I've managed to get SceShaccCg working in VitaQuakeII. (Thanks to @frangarcj, I used his vitahelloshader as a starting point). You can view my changes here.

What are the current blocks from integrating runtime shader compiler support in vitaGL and have glCompileShader? I'm guessing it's how users can obtain the needed module. Maybe we can have an installer app that can extract the module from official fw pub file? The PSM compatibility packs seem to have it too.

Also while working on this, I did notice that SceShaccCg is a stripped down version of psp2cgc. It doesn't support Cg extensions like defining column_major for storage. We can use transpose function in the shader as an alternative though.

Can let me know what's needed. I'd like to help!

frangarcj commented 4 years ago

Where have you extracted the suprx? There are different versions with different nids. And you are right, the blocking is a user friendly install app.

Rinnegatamante commented 4 years ago

Yes, the issue with shacccg is the lack of a legal and legit installer for the module. Ideally useers should download PSM runtime and an installer should extract + decrypt + place in a proper spot of the fs (vs0? ur0?) the module.

Once this is achieved, adding SceShaccCg support to vitaGL (and on Gxm apps in general too) should be trivial and benefit a lot development in general.

OsirizX commented 4 years ago

@frangarcj I tried from different versions. FW 1.69 - didn't work, FW 2.02 - worked, PSM 2.01 - worked

@Rinnegatamante I think all needed tools are there, just need to put them together. I will try to get installer going for this!

Rinnegatamante commented 4 years ago

I've wrote an helper library to use SceShaccCg: https://github.com/Rinnegatamante/vitaShaRK . I've sticked to "ur0:data/libshacccg.suprx" for the default path so hopefully if that can be used in the extractor, it would be ideal. Going to run some tests and then add glCompileSource + glShaderSource implementations.

Rinnegatamante commented 4 years ago

Added glCompileSource + glShaderSource + glGetShaderiv implementations using vitaShaRK, waiting for the extractor to close this issue.

OsirizX commented 4 years ago

Thanks Rinnegatamante, I tested vitaShaRK sample and output looks good! I can see the shaders compiled in ux0:/data.

I'll post back when I can get the extractor ready for testing.

OsirizX commented 4 years ago

I have built first version of the installer. https://github.com/OsirizX/ShaRKF00D/releases/tag/1.0.0

Please test this out and see if you get the module under ur0:/data. You may have to delete the one you already have to make sure new one was extracted. I have only built the app within 2 days so there is no user dialog or anything yet.

Thanks!

Rinnegatamante commented 4 years ago

Seems like it doesn't fully work. I get two libshacccg.suprx be extracted. One in ur0:data of few kbs (4 kbs) and one in ux0:data of 1,7 mbs however both seems to not work with vitaShaRK samples.

OsirizX commented 4 years ago

Thanks for testing. 1,7 mbs looks correct for ux0:/data/libshacccg.suprx (This is file size for when it is extracted but still encrypted). How big is your ux0:/ShaRKF00D/libshacccg.suprx.elf file? It should be about 3,4 mbs. Trying to see if problem is coming from file decrypt part or fself sign part.

Also I've only tested on 3.60 FW with taiHEN enabled.

Rinnegatamante commented 4 years ago

That one is 5 KBs. (there's also a elf file of 1 kb and a sha256 file of 1 kb. I'm also running fw 3.60.

OsirizX commented 4 years ago

Looks like there is something off with decryption part however I'm unable to reproduce the issue even after disabling all plugins. I will look at it more closely.

Ideally if decryption works with https://github.com/CelesteBlue-dev/PSVita-RE-tools/tree/master/FAGDec then it should work with the installer too.

Rinnegatamante commented 4 years ago

As for plugins, i do have only PSVshell in my config.txt.

OsirizX commented 4 years ago

I've also tried with PSVshell enabled but is still working on my end. Anyway I'm working on 2nd decryption method based off self2elf. Hoping it will be more compatible.

OsirizX commented 4 years ago

I've included other decryption method. Hopefully will work this time. Output will still be at ur0:/data/libshacccg.suprx

https://github.com/OsirizX/ShaRKF00D/releases/download/1.1/ShaRKF00D.vpk

Rinnegatamante commented 4 years ago

It did crash when running it psp2core-1593775444-0x00018220af-eboot.bin.zip

OsirizX commented 4 years ago

Thanks for the dump file. It looks like it's crashing right before it returns from decompress_segments where it tries to dereference something null. I'll see if I can fix this.

OsirizX commented 4 years ago

I was able to reproduce the issue. This happens when klicense is invalid and decryption errors out. I've now embedded valid one so decryption should work this time. I've also added log file in ux0:/ShaRKF00D/ShaRKF00D.txt

https://github.com/OsirizX/ShaRKF00D/releases/download/1.2/ShaRKF00D.vpk

Rinnegatamante commented 4 years ago

Did work perfectly fine this time! The only thing i would add is the remotion of temp files (.suprx, .suprx.elf, .suprx.ext etc in ux0:SharkF00D)

OsirizX commented 4 years ago

Great! Glad it works this time.
This one removes the intermediate files. https://github.com/OsirizX/ShaRKF00D/releases/download/1.3/ShaRKF00D.vpk

Rinnegatamante commented 4 years ago

The installer works great, can i add it to VitaDB too or are you planning to do a public release later? Closing this issue.

OsirizX commented 4 years ago

No prob, you can go ahead and add it! Thanks!