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

Avoid alpha test when vertexFullAlpha && textureFullAlpha #5710

Merged
merged 8 commits into from
Mar 24, 2014

Conversation

hrydgard
Copy link
Owner

This reduces the amount of alpha tested draws calls from 98% to about 20% in Grand Theft Auto - LCS.

Won't have as drastic results in all games but will help some.

This is important because alpha testing is terribly expensive on mobile chips, especially PowerVR and Tegra 3 but also others. PSP games just use it willy nilly without caring because on PSP it's free, so we need to rule out when it will have an effect and disable it as often as possible without breaking graphics.

This is not yet taking into account that the lighting equation could possibly change alpha. All games I've tested still draw fine though, but this will also need to be addressed.

@solarmystic
Copy link
Contributor

The important thing is to ensure that no graphical breakage occurs in as many games as possible.

I'll do the usual testing for functionality regressions and performance on my game suite when the pull request has been finalized, kinda at work at the moment.

@unknownbrackets
Copy link
Collaborator

In the not equal case, if the ref is 255, then we should actually skip full alpha verts. So I think we need a check there.

As far as ambient, I think:

if (throughmode) {
    stillFullAlpha = hasColor || gstate.getMaterialAmbientA() == 255;
} else {
    stillFullAlpha = ((hasColor && (gstate.materialupdate & 1)) || gstate.getMaterialAmbientA() == 255) && (!gstate.isLightingEnabled() || gstate.getAmbientA() == 255);
}

Or something like that.

-[Unknown]

@hrydgard
Copy link
Owner Author

Not-equal with REF=255 is likely to be rare, might as well let the alpha test take care of that (returning false). Doing that.

@solarmystic
Copy link
Contributor

@hrydgard @unknownbrackets

Alright, I've decided to compile a test build (v0.9.8-108-gdc07d34) based on the avoid-alpha-test branch for game suite testing anyway.

Preliminary results indicate no graphical regressions in any game, which is good.

Performance gains are minimal to nil, but that is to be expected on a desktop/laptop graphics card architecture where the impact of Alpha Tested Draws weren't as heavy to begin with.

Seems alright, at least with the games tested and using my Core 2/ATI 4670 based laptop.

@hrydgard
Copy link
Owner Author

Thanks for your testing solarmystic.

I think I'll just merge it.

hrydgard added a commit that referenced this pull request Mar 24, 2014
Avoid alpha test when vertexFullAlpha && textureFullAlpha
@hrydgard hrydgard merged commit ff498ed into master Mar 24, 2014
@VIRGINKLM
Copy link
Contributor

Thanx alot! You can consider this a similar idea to what I requested here:
http://forums.ppsspp.org/showthread.php?tid=10903&pid=78590#pid78590

@hrydgard
Copy link
Owner Author

@VIRGINKLM , yes it's an old idea, it's a tricky one to get right though :)

@VIRGINKLM
Copy link
Contributor

Helps ALOT on PowerVR SGX 544MP on games and scenes that contain ALOT of object textures that pass through alpha. Almost the same performance as disabling it via hack. Great Job!

@hrydgard
Copy link
Owner Author

Great! Maybe can kill the hack soon.

@VIRGINKLM , if you find a game where the hack still helps a lot, let me know.

@VIRGINKLM
Copy link
Contributor

The hack and this commit usually help those games that have objects that their textures have alpha on all of their axes, usually that's elements like trees, leaves and particles. Having in mind that usually these come at a huge population when they get used, the games that get huge slowdowns are the ones that the have alot of them rendered onscreen. Now, if you disable it with the hack, you will break alot of things (since the population is high) so, I don't know how much sense the hack makes having in mind this fact, since you will end up with a pretty weird visual result, maybe even game-breaking. You could experiment for now using it as a full/half check if you want, half for the optimized and full for disabled.

@hrydgard
Copy link
Owner Author

Actually, this commit helps many games that just leave alpha testing enabled when rendering solid geometry. It doesn't actually speed up alpha testing, it just makes sure it's turned off when not needed. While the hack helps games that do use alpha testing for real, but just breaks them :)

I think I'll just kill the hack soon.

@dbz400
Copy link
Contributor

dbz400 commented Apr 22, 2014

Fro this issue , revert 2c76e6d exactly will show the missing stuff again.

@unknownbrackets unknownbrackets deleted the avoid-alpha-test branch May 10, 2014 15:11
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.

5 participants