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 render-to-texture: Midnight Club L.A. Remix #3578

Closed
dbz400 opened this issue Sep 2, 2013 · 20 comments
Closed

Fix render-to-texture: Midnight Club L.A. Remix #3578

dbz400 opened this issue Sep 2, 2013 · 20 comments

Comments

@dbz400
Copy link
Contributor

dbz400 commented Sep 2, 2013

Responsible line :

    // Ensure it's in the framebuffer cache.
    if (std::find(fbCache_.begin(), fbCache_.end(), framebuffer) == fbCache_.end()) {
        fbCache_.push_back(framebuffer);
    }

screen00007

Correct one should be
screen00006

@unknownbrackets
Copy link
Collaborator

Well, that's basically disabling the hookup (which is in SetTexture().) But I think this will break Brave Story and Mana Khemia (may have to double check later.)

Is the framebuffer it grabs not being rendered to?

-[Unknown]

@papel
Copy link

papel commented Sep 2, 2013

The buildings are not good yet. The image on PSP should be:
screen00001

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 2, 2013

How i can check the framebuffer it grabs not being rendered to in this case ?

@unknownbrackets
Copy link
Collaborator

Here's where it grabs it:

    // If we ended up with a framebuffer, attach it - no texture decoding needed.
    if (entry->framebuffer) {
        SetTextureFramebuffer(entry);
        lastBoundTexture = -1;
        entry->lastFrame = gpuStats.numFlips;
        return;
    }

But maybe the most relevant way would be to stop keeping it alive:

            // Keep the framebuffer alive.
            // TODO: Dangerous if it sets a new one?
            entry->framebuffer->last_frame_used = gpuStats.numFlips;

Comment that out, and it'll decimate the framebuffer at some point if it's not being rendered to.

-[Unknown]

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 2, 2013

I did try to comment out that one keep the frambuffer alive but it didn't help

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 2, 2013

I just checked Brave story still seems to be fine with this change.

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 3, 2013

@unknownbrackets , just wonder if comment this out , does it break Mana Khemia ?

@unknownbrackets
Copy link
Collaborator

Yes. Here's a screenshot:

mana-khemia-render-to-texture

-[Unknown]

@unknownbrackets
Copy link
Collaborator

To clarify, this is what it seemed to be doing from looking at the renders:

  1. Render normal game screen to framebuffer A (the part it's gonna blur for this effect in dialog.)
  2. Use render-to-texture to render this to framebuffer B.
  3. From now on, use render-to-texture from framebuffer B to draw to screen on framebuffer C.

Basically, you have a once in a lifetime chance of getting the correct framebuffer at step 1. It never uses A again. Once it draws B, it assumes B is good. So we can't just be lazy and get it wrong the first time and rely on the game redrawing it over and over to make it right.

-[Unknown]

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 3, 2013

I see. Render-to-texture is really tricky and difficult to handle it correctly .

For the fbCahce_ change , it is a significant improvement for Mana Khemia

@unknownbrackets
Copy link
Collaborator

Yeah.. very tricky.

To be fair, the blurred part is only during dialog, and it doesn't move (e.g. the dialog goes away and it unblurs when people walk around.) The game at least from what I've played seems fine otherwise. But it's pretty jarring.

-[Unknown]

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 3, 2013

Just checked softgpu for this Midnight L.A. Mix and seems to be rendered close to real PSP

screen00010

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 3, 2013

Just few more testing on GLES, it is stencil issue and disable part of the stencil ops and looks far better

screen00011

@arcade1977
Copy link

Oh, it looks good ! it is better than 0.8.1.1678

@arcade1977
Copy link

But there are a lot of black block in the background?

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 4, 2013

Yes , it is becasue the stencil test is still incorrect .It should hide those trees

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 4, 2013

Few more attempt to try and get a correct one though it is a combination trial of ZFail/ZPass .

Try compare with the above pic from real PSP.

screen00015

@arcade1977
Copy link

This picture looks almost with real PSP ,good job!

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 6, 2013

This is my testing combination of zfail/zpass

        if (gstate.isDepthWriteEnabled()) {
            zfail = GL_KEEP;
            zpass = GL_KEEP;
        } else { 
            zfail = GL_ALWAYS;
            zpass = GL_ALWAYS;
        }
        glstate.stencilOp.set(stencilOps[gstate.getStencilOpSFail()],  // stencil fail
            zfail,  // depth fail
            zpass); // depth pass

@dbz400
Copy link
Contributor Author

dbz400 commented Sep 7, 2013

This has been fixed by latest build .Closed

@dbz400 dbz400 closed this as completed Sep 7, 2013
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

No branches or pull requests

4 participants