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

Overlapping framebuffer issue #2308

Closed
unknownbrackets opened this issue Jun 16, 2013 · 22 comments · Fixed by #2569
Closed

Overlapping framebuffer issue #2308

unknownbrackets opened this issue Jun 16, 2013 · 22 comments · Fixed by #2569

Comments

@unknownbrackets
Copy link
Collaborator

It appears that Tales of Destiny 2 would work fine except for this one issue.

Like most games, it uses framebuffers at 0x04000000 and 0x04088000. During the intro, they are displayed great and everything works fine.

However, once it goes in game, everything is black. It turns out the reason for this is simple... sometimes it renders to a 512x512 FBO, and sometimes it renders to a 480x272 FBO, both at the same address.

Both have the same stride, so it really doesn't even matter. If it were VRAM, either way would write and read the same pixels anyhow.

Changing it to this:

if (MaskedEqual(v->fb_address, fb_address) && v->fb_stride == fb_stride && v->format == fmt) {

Makes the game work great, at least into the first scene of the game. Unfortunately, this would probably break render to texture affects I think, and might break other stuff.

It seems like what might help is to:

  • If a larger FBO is set at an address, replace it with a new one (not have a duplicate.)
  • If a smaller FBO is set at an address with the same stride, just change its active region.
  • In anything that cares about the size, respect the active region.
  • Always render the top left region of the framebuffer at 480x272 (or equivalent internal resolution), regardless of its height.

But then, some games may play tricks, so I'm not sure if that would be enough?

I think the above would definitely improve Tales of Destiny 2, Shadow of Destiny, and Valkyrie Profile, which all have this issue.

-[Unknown]

@hrydgard
Copy link
Owner

Yeah, this is an issue indeed. I believe it would also help the occasional black screen issues in the GTA games.

A related question is if we estimate the size of the FBOs correctly, there are a whole bunch of factors that affect the actual rectangle of RAM that is rendered to, and games can be sloppy not setting all of them (for example, not setting viewport right if having set scissor to cut to a smaller rectangle, or whatever).

@Nezarn
Copy link
Contributor

Nezarn commented Jun 16, 2013

that change fixes star ocean 1 worldmap too
Edit: and fixes battles too (no more black flickering)

@unknownbrackets
Copy link
Collaborator Author

Well, I think we definitely estimate the size of the FBOs wrong in some cases, but it's almost a separate issue.

I'm just wondering if there's ever a good reason to have two FBOs at the same address. At best if the game reuses that memory for rendering things at different sides a lot I guess?

-[Unknown]

@hrydgard
Copy link
Owner

Yeah.

In theory it's also possible to use arbitrary subrectangles of FBOs as textures (by setting a small texture size and texture bufw the same as the fbo bufw) and annoying things like that, but I don't know if games do that.

@rpglord
Copy link

rpglord commented Jun 17, 2013

I cant belive Star Ocean is finally fixed, why did nobody post in the issue :)

@unknownbrackets
Copy link
Collaborator Author

Well, it's not fixed just yet, but at least we know the cause for sure now.

-[Unknown]

@hrydgard
Copy link
Owner

@rpglord Hm? We haven't commited a fix yet. Or do you mean to say that the change Unknown proposes above fixes it?

@rpglord
Copy link

rpglord commented Jun 17, 2013

Well I am going to belive Nezarn he just said it fixes star ocean world map :)
I haven't tested it myself, I can compile and test if needed, haven't downloaded required programs but I have compiled other emulators before so I would probably know how.

But I don't think there is any need, we can belive Nazarn, and I think Unknown also has Star Ocean so he can test too :)

@Nezarn
Copy link
Contributor

Nezarn commented Jun 17, 2013

@dbz400
Copy link
Contributor

dbz400 commented Jun 17, 2013

Just seen the youtube , looks like Star Ocean 1 renders all graphics now .

@unknownbrackets
Copy link
Collaborator Author

Well, outside the stencil problem.

-[Unknown]

@hrydgard
Copy link
Owner

That might do the trick, can you guys please test on all the games mentioned in this and the related issues?

@Nezarn
Copy link
Contributor

Nezarn commented Jun 19, 2013

@hrydgard Star Ocean 1 worldmap\battle doesnt work with your fix (blackscreen)

@brujo5
Copy link

brujo5 commented Jun 19, 2013

@hrydgard

please remove this fix,because cause ocacionally black screens in dragon ball z tenkiachi

@solarmystic
Copy link
Contributor

@hrydgard

This does not fix the overlapping framebuffer issue in Valkyrie Profile:Lenneth (one of the games mentioned in the issue page)

Tested with 0.7.6-1481-gf2b7096

capture

hrydgard added a commit that referenced this issue Jun 19, 2013
…! Fixes black screens in GTA when pausing for example."

This reverts commit f2b7096.
@hrydgard
Copy link
Owner

Reverted. I see why it doesn't work and think I might have an idea of how to fix it.

@brujo5
Copy link

brujo5 commented Jun 20, 2013

thanks you

@dbz400
Copy link
Contributor

dbz400 commented Jun 20, 2013

I just got time to test it this commit .However , i tested with Dragon Ball Z Tenkiachi , i didn't see any ocacionally black screens throughout the game . Meanwhile , i tested other games and seems to be no broken as well .

@hrydgard
Copy link
Owner

Made a new attempt that should not cause "embiggening loops". However I'm pretty sure it doesn't solve all problems. Fixes GTA though.

@Nezarn
Copy link
Contributor

Nezarn commented Jun 20, 2013

@hrydgard your current fix fixes star ocean 1 worldmap (but battle is still bugged, these are with buffered rendering off) and characters are not invisible anymore with buffered rendering on but screen looks funny (and strangly battle works too with buffered rendering, but screen is smaller like in this screenshot)
so1

@solarmystic
Copy link
Contributor

Still no luck in VP:Lenneth in 1508, at least no other previously working games I have are broken:-

capture

@unknownbrackets
Copy link
Collaborator Author

The problem is, Star Ocean creates an FBO that is 512x512, but it (of course) only renders to the top left 480x272 of it. But the FBO itself is huge, so it's currently scaled to fit the screen.

I did some testing on a PSP. AFAICT, no matter how or what stride or mode/width/height I set or etc., it always draws 480 pixels per line. Then it advances by the stride (which might cause it to overlap), and does that 272 times. It doesn't ever seem to draw to the screen anything other than the top left 480x272 of the buffer.

But I remember someone saying some game rendered at > 480x272 for improved graphics or something...

-[Unknown]

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 a pull request may close this issue.

7 participants