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

Read framebuffers pixel data to memory #2463

Merged
merged 4 commits into from
Jun 26, 2013

Conversation

arnastia
Copy link
Contributor

Rather simple (but large?) code using glReadPixels and Memcpy to read pixel data from framebuffers to where the game expects it to be memory-wise. I also committed a small fix for the debugger since it was referencing an undefined macro in 64 bits Windows, but that one should have gone on master; just forgot to checkout before committing.

As I think I said in issue #1686, I only tested this with Danganronpa (an English-translated demo for the game can be found at http://danganronpa.wordpress.com/downloads/ if something needs checking).

@arnastia
Copy link
Contributor Author

And I totally forgot to mention this, but this will only work with buffered rendering enabled.

@hrydgard
Copy link
Owner

It's a good start but needs a little bit of work.

For example, there are games that use 16-bit framebuffers. For those, we need to convert to 16-bit while writing to VRAM.

Also, if there's functionality missing in native, please just add it (send pull requests to the native project, http://www.github.com/hrydgard/native .

@PeterTh
Copy link
Contributor

PeterTh commented Jun 25, 2013

Great work on this, I just found it as I was about to look into Dangan Ronpa myself.

Two remarks:

  • I believe that the flipping could be done more efficiently on the GPU. I don't know if glBlitFramebuffer supports it, but if not the original FB could simply be bound as a texture and rendered as a screen-aligned quad with reversed texture coordinates
  • The same thing should apply for format conversion, it should be possible to just create the FBO on the GPU with the correct format and convert by rendering into that

@unknownbrackets
Copy link
Collaborator

This will fix #1778, but I still think we want to try to make it as efficient/smart as possible, or at least an option.

Actual performance numbers on Windows, gathered quickly:
Crisis Core: video without this: 1400 VPS, 450 with. In game: 320 vps without, 180 vps with.
Lunar: 3500 vps while stationary without, 740 vps with.
God of War: 20 vps or less on my big bad i7. No longer playable (was only barely before.)
Fat Princess: 15-20 vps in menus, but in game is still okay.

-[Unknown]

@arnastia
Copy link
Contributor Author

I didn't even notice the bTrueColor flag and together with looking at the switches in the code I assumed framebuffers were being rendered with the correct format.

Actually, Danganronpa from what I've seen uses either 16-bit ABGR (1-5-5-5) or 32-bit ABGR (8-8-8-8) framebuffers, but now I'm guessing it worked eitherway because (after some reading) some OpenGL implementations seem to convert to the specified format in glReadPixels (not really sure).

This being implementation-dependent is obviously not a good solution, so I'll try to sneak in a way to explicitly perform the conversion, as well as a a GPU-side flip of the framebuffer (I had a quick look but doesn't seem I can do this with glBlitFramebuffer).

Also, this only copies the color buffer. Depth/stencil don't seem to be needed for Danganronpa, but probably are for some games.

Performance-wise, I only tested with Danganronpa, but looking at actual numbers the hit seems to be bigger than I thought it was, and while I'd like to, I'm not all that confident I can find a good way to only do this when strictly necessary (or even if it'd help much; Danganronpa's investigation mode probably needs this constantly for instance), but yes, an option is obviously possible.

@hrydgard
Copy link
Owner

Actually, we are currently cheating - no matter which color depth the game requests, we create 32-bit framebuffers for better color quality. But when writing back to PSP VRAM, it needs to be in the format the game expects.

As it's such a big hit and 98% of games work fine without it, an option is really the only thing that makes sense unless we can reliably detect the need for it, which seems unlikely.

@ghost
Copy link

ghost commented Jun 25, 2013

It may solve some problems.

  1. The photo does not work in character creation in Soul Calibur. I get a black photo.
  2. The icon with screenshots of saved games does not work. It is black.
    http://forums.ppsspp.org/attachment.php?aid=652

@unknownbrackets
Copy link
Collaborator

Yes, this will most likely solve those problems too. I think they are detectable, though (especially screenshots.) Danganronpa is probably the hardest case.

I'm still hopeful that we can detect most of the cases and do things automatically without much performance hit. But definitely having an option to force it on will make figuring things out easier. Could probably make it an inverted option to make it clear it's for improving performance, e.g. "Skip updating PSP memory on render."

By the way, thanks for the demo link, I didn't realize there was a demo until recently.

-[Unknown]

@arnastia
Copy link
Contributor Author

I didn't have the time I thought I would to try bigger stuff, so for now I just added an option to the .ini file to disable the call (FramebuffersToMem).

I made it default to false so people wouldn't complain about a sudden performance hit in other games, which for now should be enough, but yes, something like this should be somewhere in the settings menu (would have added but I don't know where those are in the project and didn't really have the time to find out).

@supervamp78
Copy link

So what exactly am i supposed to do with all of this?

@solarmystic
Copy link
Contributor

@supervamp78

Wait for it to be merged into master, then download the compiled build from the orphis build bot if you don't know how to compile it yourself.

@dbz400
Copy link
Contributor

dbz400 commented Jun 26, 2013

Good to see if it fixes the artifact issue in 3rd birthday .Will test it out for Sword Art Online as well .

I'm wondering if we can detect the scene and apply this GE texture to memory automatically and switch back to original if not needed

@dbz400
Copy link
Contributor

dbz400 commented Jun 26, 2013

For Sword Art Online , artifact has gone so it is a good move however texts are missing somehow

screen00022

@VIRGINKLM
Copy link
Contributor

Does this affect Android? It would kill game performance on games that require Buffered Rendering.

@dbz400
Copy link
Contributor

dbz400 commented Jun 26, 2013

It should affect all platforms although i'm not yet tested on Android.

@HermitCrap
Copy link

OP should just create an option to choose whether to save graphics to memory instead of relying on the buffered rendering option so Hrydgard will merge this and make the people intending to play Dangan Ronpa happy since the patch is just released :P

@dbz400
Copy link
Contributor

dbz400 commented Jun 26, 2013

This fixes the issue #2273 as well

@hrydgard
Copy link
Owner

OK, I'll merge now that we have an option.

@hrydgard hrydgard merged commit 98b9acf into hrydgard:master Jun 26, 2013
@ghost ghost mentioned this pull request Jun 26, 2013
@HermitCrap
Copy link

bug
As you can see, it's the newest Dev build and interaction is not possible. Downloaded a build uploaded by an anonymous using Anastia's source and it worked. The intro movie with the "Spike" logo and monobear is also lagging a lot, it have to be set at 900+ VPS for it to look normal.

@RickGamer
Copy link

Hey everyone!
First off i want to clear that i dont understand anything about programming or any that is being discussed here... sorry about that.
But I recently started playing Dangan Ronpa and I'm anxious to play it but I have the same issue as everyone using PPSSPP... the objects are undetectable.
I looked and found this post ( #1686 ) that redirected me here as everyone was saying this worked... but as i said, I don't understand anything of this..
Sorry to bother but could anyone help me and explain how do i apply this in order to play the game?
Thank you in advance!

@hrydgard
Copy link
Owner

@HermitCrap , did you use the ini setting?

@HermitCrap
Copy link

Oh yeah, looked through it and found it a few days ago.

@HermitCrap
Copy link

@RickGamer, get a Nvidia Computer. Download newest dev build. Go to ppsspp.INI and change framebufferstomem from false to true. Enable Buffered Rendering in Graphics settings. Profit. Currently, this doesn't work on an AMD GPU. Not that it doesn't exactly, just that there is a bug that makes the game unplayable. The demo works fine though. There is currently no fix for this.

@hrydgard, yeah. Figured that out but thanks.

@RickGamer
Copy link

@HermitCrap Thanks alot! I already was using an Nvidia computer but i didnt know about any dev builds. Found it and will now play! Again many thanks! :)

@supervamp78
Copy link

loij

That's the biggest problem I'm having now i don't really get why I'm getting amd and ati problems when i have intel graphics, though it only happens when i load this save i even started a new game and it worked just fine so I'm not sure if i just broke the save file or if it just does that when you save at that point.
I've got my log file too so i put that in 4shared.

http://www.4shared.com/file/6d4_VB3e/ppsspp.html?

@HermitCrap
Copy link

@RickGamer, Sorry if I sounded rude :P Was in the middle of a Nonstop Debate in Chapter 5. So I gotta replied ASAP :P You're about to have your mind blown just like I did. AND, I actually read some spoilers revealing the murdered and mastermind etc beforehand. Still, this game blew me away... Good luck.

@supervamp78, don't assume it's an AMD GPU problem. It's a problem with Intel Integrated GPUs. They don't support OpenGL. So you're pretty much f*** and you can only play if you get a Nvidia Computer or a PSP. The only fix which you SHOULD HAVE READ as stated above will fix your problem by implementing a Software renderer. But that will take very long and I dount your CPU will even be support the game seeing how my Dedicated 555M even have problem playing this at bare minimum to get Dangan Ronpa going.

@AshuraSan
Copy link

The altered version of ppsspp(and latest versions) let me actually click on things, but having buffer rendering enabled slows down game play. Disabling it, wont let me click anything. Is there a way to fix that yet?
The altered version is for the problem with dangan ronpa where you couldn't click anything.

@HermitCrap
Copy link

@AshuraSan, nope. I guess the only way to play it on full speed is to play with a good GPU. Other than that, nope. You can disable every other video option except Buffered Rendering to speed things up a little. Level 2 onwards of the school compound tends to lag a lot as well.

@supervamp78
Copy link

@HermitCrap
I don't know if it really is a amd/ati problem but when i looked up that specific problem that's what came up.

I don't get how this has anything to do with opengl when it's just save file based, i can load up a new save file fine it's only when i try to continue from this one that it does that.

@HermitCrap
Copy link

@supervamp78, if you can start a new game, then it's not a problem is it? If you can start a new game but not play it, then it's a problem with your computer itself. AMD Problems is that the doors and items are mapped wrongly, so don't assume it yourself unless you read everything. Plus, this isn't even where you should post this bug. Go to #1686.

@RickGamer
Copy link

@HermitCrap you didnt sound rude at all, dont worry! And yeah the game is great! I've been playing it so sorry for the late reply. I just have this issue where in naegi's room i cant investigate the drawer idk why it redirects to the lint roller and in other locations it also redirects me tho another object instead of investigating that.. is there any fix for that?

@HermitCrap
Copy link

@RickGamer, it's suppose to be a problem only with AMD. Are you sure you are using a Nvidia? If not, I'n sure providing system specs and log will help Anastia in his future development as this is a first.

@RickGamer
Copy link

@HermitCrap yes I'm using an Nvidia. But idk if it's relevant but my computer has 2 graphics cards. An IntelHD and an Nvidia but when i run games i always choose to run them with the Nvidia one so i dont think that should be the problem. Anyways i'm bypassing that problem by using JCPSP when i can't advance in the game because of that and go back to using PPSSPP, because it's smoother and i prefer it, but i would like to stick to PPSSPP without having to do that.

As i said i rly don't understand much of all this but I would like to help. How can i find the log?

@HermitCrap
Copy link

The IntelHD is built in and it will only work when your computer doesn't detect the card or when you set your computer to use it instead of the Dedicated GPU. What's your Nvidia card? Double click Log.bat and it should appear in your USER/LOG folder which is in your PPSSPP Directory.

@RickGamer
Copy link

@HermitCrap My Nvidia is an GeForce GT 520MX with 1GB. And I double clicked the Log.bat file and it opened a command window and PPSSPP. What do I do of that?

@RickGamer
Copy link

@HermitCrap yes i now have an ppsspp.log file. I assume you need the log at the part where i can't investigate the drawer?

@HermitCrap
Copy link

Yeah, upload it on some site and link it here. The game works on my Nvidia GT525M with no problems, completed the game. Only some Text glitches that requires me to save the game to correct it. Floor 2 onwards of the Academy is will tend to slow down the game, especially Floor 3/4, the one with a lot of pillars, the Art Room and the Physics Room.

@RickGamer
Copy link

@HermitCrap ok whenever i try to investigate the drawer this is written in the log

32:25:044 idle0 I[HLE]: GLES\Framebuffer.cpp:958 Decimating FBO for 00154000 (128 x 72 x 1), age 6
32:26:862 user_main I[HLE]: GLES\Framebuffer.cpp:499 Creating FBO for 00154000 : 128 x 72 x 1

is this enough or is it necessary more of the log?

Also i have those text glitches too but they either go beck to normal after 2 secs or i save state with F2 and it goes back to normal

@HermitCrap
Copy link

@RickGamer, upload your Log file to a filehosting website and link it here.

@RickGamer
Copy link

@HermitCrap ok so i started a new game and skiped everything until the room part and investigated the drawer that redirects to the lint roller and also the notepad that redirects to the paper on the wall. heres the log: http://www.mediafire.com/download/s8j2tyyl5ihjvs1/ppsspp.log

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.