Skip to content

Fix framebuffer when loading states/branches with OpenGL-supporting cores #4333

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

SuuperW
Copy link
Contributor

@SuuperW SuuperW commented May 26, 2025

We used to load the framebuffer of savestates that had screenshots (including TAStudio branches) by copying (and potentially resizing) the image into the core's framebuffer. This does not work with the newer way for cores to provide video output (via OpenGL textures). This resulted in users seeing incorrect images after loading savestates on those cores.

This has been solved by creating a new, temporary IVideoProvider when loading states and using that instead of the core's IVideoProvider until the next frame advance.

Let me know if there are any potential issues with doing things this way. In particular, MainForm's new LoadStateCommon method does more things than TAStudio's branch loading did. I am not sure, but they seems like things that should happen. My Lua script that I regularly use appears to work correctly with this update, but I imagine there could be others that rely on the old behavior.

Check if completed:

@SuuperW SuuperW force-pushed the state_framebuffer branch from 6cad612 to d5b3de8 Compare May 26, 2025 06:56
…at should never happen since we moved to bmp states a very long time ago.
@SuuperW SuuperW force-pushed the state_framebuffer branch from d5b3de8 to 7b8351a Compare June 17, 2025 22:19
@SuuperW
Copy link
Contributor Author

SuuperW commented Jun 17, 2025

Any issues with merging this? @CasualPokePlayer you've been requested as reviewer.

@CasualPokePlayer
Copy link
Member

My original plan to fix this is to rather simply have the OpenGL texture be updated on state load. Even then, a more proper fix is to just have new API for setting the video buffer properly. Doing what's done here doesn't look correct here (mainly as there's a ton more changes than just doing a "fix" for the framebuffer, what's with the DiscardApiHawkSurfaces call changes? You're also calling CallLoadStateEvent potentially with a null userFriendlyStateName, not to mention doing a lot more things here. Also, how does this interact with screenshots/video dumping? Does that still work or end up breaking?)

@SuuperW
Copy link
Contributor Author

SuuperW commented Jun 18, 2025

what's with the DiscardApiHawkSurfaces call changes?

There are no changes, in terms of behavior. That was being called from TAStudio when loading a state with no framebuffer, and it still is being called in exactly those situations.

You're also calling CallLoadStateEvent potentially with a null userFriendlyStateName

So I am. That is an oversight by me and I will fix it.

doing a lot more things here

Such as? I realize there are behavior changes aside from just the bug fix, but as I said in the PR post "they seems like things that should happen". (Calling SetMainformMovieInfo can't hurt anything, but might be redundant. Running all the tool updates and state load events instead of just the ones TAStudio had it its own update method is also a bug fix, which you can observe with event.onloadstate(function() print("loaded a state") end) not showing load events in TAStudio in current master. InputManager.AutoFireController.ClearStarts I am not entirely sure of since I never use AutoFireController. Maybe it doesn't make sense when TAStudio is open, I don't know.)

how does this interact with screenshots/video dumping?

They both work correctly, and I did test them both. There is no special code that needs to be written for them since they use _currentVideoProvider same as the main display.

…ta belonging to the core, this ignores the other way that cores can provide video output, OpenGL. Instead, create a video provider for the state and use that.
@SuuperW SuuperW force-pushed the state_framebuffer branch from 7b8351a to 6f65697 Compare June 18, 2025 02:30
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.

2 participants