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

EFB2RAM Speedhack #1952

Closed
wants to merge 1 commit into from
Closed

EFB2RAM Speedhack #1952

wants to merge 1 commit into from

Conversation

mimimi085181
Copy link
Contributor

Please do not review coding style issues yet! Also, the efb2ram cache option is used for now, if this PR has an actual change to be merged, it will be changed. This PR is supposed to be merged after PR #1948.

This hack tries to make efb2ram faster, by skipping the efb to ram copy under the following conditions:

  • The texture was loaded at least once
  • The texture is not one of the paletted textures that are efb copies

Obviously this won't work on games that read or change the efb data after it was copied to RAM. But some games require efb2ram right now, without doing this.

This hack is mostly intended to be used for those paletted textures that are efb copies, but it does work on some others as well. Examples for this are the spinning coins in New Super Mario Bros and the garbage on screen that happens in RS2 after loading a profile.

TODO:

  • Check if the other uses of efb2ram in RS2 work with this. This is at least some effect on torpedoes and some heat effect.
  • Test if New Super Mario Bros really works fine with this

Please do not review coding style issues yet! Also, the efb2ram cache option is used for now, if this PR has an actual change to be merged, it will be changed. This PR is supposed to be merged after PR #1948.

This hack tries to make efb2ram faster, by skipping the efb to ram copy under the following conditions:
- The texture was loaded at least once
- The texture is not one of the paletted textures that are efb copies

Obviously this won't work on games that read or change the efb data after it was copied to RAM. But some games require efb2ram right now, without doing this.

This hack is mostly intended to be used for those paletted textures that are efb copies, but it does work on some others as well. Examples for this are the spinning coins in New Super Mario Bros and the garbage on screen that happens in RS2 after loading a profile.

TODO:
- Check if the other uses of efb2ram in RS2 work with this. This is at least some effect on torpedoes and some heat effect.
@@ -500,7 +500,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
SettingCheckBox* efbcopy_disable = CreateCheckBox(page_hacks, _("Disable"), wxGetTranslation(efb_copy_desc), vconfig.bEFBCopyEnable, true);
efbcopy_texture = CreateRadioButton(page_hacks, _("Texture"), wxGetTranslation(efb_copy_texture_desc), vconfig.bCopyEFBToTexture, false, wxRB_GROUP);
efbcopy_ram = CreateRadioButton(page_hacks, _("RAM"), wxGetTranslation(efb_copy_ram_desc), vconfig.bCopyEFBToTexture, true);
cache_efb_copies = CreateCheckBox(page_hacks, _("Enable Cache"), wxGetTranslation(cache_efb_copies_desc), vconfig.bEFBCopyCacheEnable);
cache_efb_copies = CreateCheckBox(page_hacks, _("Speedhack"), wxGetTranslation(cache_efb_copies_desc), vconfig.bEFBCopyCacheEnable);

This comment was marked as off-topic.

This comment was marked as off-topic.

@magumagu
Copy link
Contributor

So, if I'm understanding correctly, this assumes games either read an EFB2RAM copy from the CPU or use it from the GPU, but not both, and that EFB copies with the same destination address will get used the same way. I'm a bit skeptical that it's actually a good idea; it seems like it will cause subtle errors which will be difficult to track down.

The palette EFB copy part mostly harmless, I guess, but I'm not sure it's worth exposing the option just for a few games.

@Xcedf
Copy link

Xcedf commented Jan 23, 2015

Tested on Metroid Games, Super Mario Sunshine, ZTP,ZWW(pictobox), Okami, Silent Hill SM, Resident Evil Darkside chronicles for these games works fine and gives quite a boost plays almost like EFB to Texture speed.
StarFox Adventures, Dead Space, De Blob these three of my games don't like this hack and act like EFB to Tex with it
Anyway huge thanks for this hack, no matter will it be merged or not

@mimimi085181
Copy link
Contributor Author

What exactly do those games use efb2ram for? I could test Metroid and Okami myself, if i knew what i was looking for. About the others, some explanation which textures are broken with efb2tex and work with this PR would be nice.

PS: Twilight Princess is one of the games, the PR was created for

@Xcedf
Copy link

Xcedf commented Jan 23, 2015

Well...
Metroid 1 Thermal and X-Ray visors
Metroid 2 Scan and Dark visors
Metrid 3 Scan and Thermal visors
ZTP the map
Okami the Paint mode
Super Mario Sunshine for goo cleaning
Silent Hill very rare effects like images in the mirror or drawing for the therapist

about broken
Dead Scace some sort of screen effect which is everywhere
StarFox (menu when pressing START ingame) for blue Aura around the menu objects

@Linktothepast
Copy link
Contributor

@dolphin-emu-bot rebuild

@Linktothepast
Copy link
Contributor

New Super Mario Bros from 90 to 110 fps. Coins work fine.
ZTP Wii from 74 to 89 fps. Map works fine.
Metroid Prime 3 from 106 to 118 fps. Scan visor works fine, haven't tested other visors though.
My Sims and My Sims Kingdom from 72 to 88 fps. They work fine (you can change character clothes by clicking).
Mario Party 9 Flinger painting minigame works fine.
With the Last Story it partially works after loading an ingame save in the tavern. Weirdly clothes with characters looked fine but only in a distance and not up close. If you are close they were black, move away and they show fine.
Pokepark 1 and 2 ingame photos were half messed up.
Goldeneye 007 has issues.
Shadow The Hedgehog 2p mode has issues.

@mimimi085181
Copy link
Contributor Author

I think i will change this from a speed hack option for efb2ram to a compatibility option for efb2tex. An option that makes the fast and incompatible mode more compatible, is a better idea than a mode that makes THE compatible mode more incompatible. This will reduce the amount of confusion and user error.

Can i use the name "Hybrid Mode" for this? Even though, efb2ram is a hybrid mode already? The speed and compatibilty of this mode does lie between efb2tex and efb2ram.

About The Last Story:
The game seems to use 2 sets of textures for all clothes, one close up and one for distance. The distance textures even support recoloring in the menu, the close up ones are 100% broken with this hack. The Last Story seems to be one of the games that really need efb2ram and actually do something with the efb copy in ram.

@degasus
Copy link
Member

degasus commented Jan 24, 2015

I wouldn't call it a hack for efb2ram, just call it a more saver way for efb2tex. For efb2tex only games, this should have no performance impact (but small stuttering on the first frame). But lots of games are working with this setup without the full efb2ram configuration:

"""
Also do the efb2ram operation if we don't know if we can reuse this texture from vram directly. So we won't loose its content forever.
"""

@mimimi085181
Copy link
Contributor Author

Hmm, if that's true, could it just replace efb2tex? I'm not really sure about that, some games do some stupid stuff. If a game "spams" just ONE new efb copy per frame, the speed is reduced a lot.

Your explanation of what this mode does is much more precise that what i had and what i could have come up with.

@mimimi085181
Copy link
Contributor Author

I'm closing this, because i managed to kill the repository it is based on, and also those "paletted efb copies" might get properly fixed within the new few weeks. When that happens, those paletted efb copies might work in efb2tex, rendering this PR useless.

Xcedf referenced this pull request in mimimi085181/dolphin Feb 15, 2015
This is the same trick which is used for Metroid's fonts/texts, but for all textures. If 2 different textures at the same address are loaded during the same frame, create a 2nd entry instead of overwriting the existing one. If the entry was overwritten in this case, there wouldn't be any caching, which results in a big performance drop.

The restriction to textures, which are loaded during the same frame, prevents creating lots of textures when textures are used in the regular way. This restriction is new. Overwriting textures, instead of creating new ones is faster, if the old ones are unlikely to be used again.

Since this would break efb copies, don't do it for efb copies.

Castlevania 3 goes from 80 fps to 115 fps for me.

There might be games that need a higher texture cache accuracy with this, but those games should also see a performance boost from this PR.

Some games, which use paletted textures, which are not efb copies, might be faster now. And also not require a higher texture cache accuracy anymore. (similar sitation as PR dolphin-emu#1916)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

6 participants