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

Projects
None yet
5 participants
@hrydgard
Copy link
Owner

commented Mar 24, 2014

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.

unknownbrackets and others added some commits Mar 24, 2014

Initial stab at tracking vertex alpha.
Not sure what efficient method to use on x86...
Merge branch 'unknownbrackets-vertexalpha' into avoid-alpha-test
Conflicts:
	GPU/GLES/VertexDecoderX86.cpp
@solarmystic

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2014

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.

hrydgard added some commits Mar 24, 2014

@unknownbrackets

This comment has been minimized.

Copy link
Collaborator

commented on GPU/GLES/FragmentShaderGenerator.cpp in f33ddad Mar 24, 2014

Technically also, if !gstate.isTextureMapEnabled(), but maybe not common enough to bother.

-[Unknown]

This comment has been minimized.

Copy link
Owner Author

replied Mar 24, 2014

Yeah, that might cost more than it's saves, non-textured geometry other than clears is quite rare.

@unknownbrackets

This comment has been minimized.

Copy link
Collaborator

commented on f30d0d8 Mar 24, 2014

Sorry.

-[Unknown]

@unknownbrackets

This comment has been minimized.

Copy link
Collaborator

commented Mar 24, 2014

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2014

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

This comment has been minimized.

Copy link
Contributor

commented Mar 24, 2014

@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

This comment has been minimized.

Copy link
Owner Author

commented Mar 24, 2014

Thanks for your testing solarmystic.

I think I'll just merge it.

hrydgard added a commit that referenced this pull request Mar 24, 2014

Merge pull request #5710 from hrydgard/avoid-alpha-test
Avoid alpha test when vertexFullAlpha && textureFullAlpha

@hrydgard hrydgard merged commit ff498ed into master Mar 24, 2014

1 check passed

default The Travis CI build passed
Details
@VIRGINKLM

This comment has been minimized.

Copy link
Contributor

commented Mar 25, 2014

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 25, 2014

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

@hrydgard

This comment has been minimized.

Copy link
Owner Author

commented on f33ddad Mar 25, 2014

@VIRGINKLM

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2014

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 26, 2014

Great! Maybe can kill the hack soon.

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

@VIRGINKLM

This comment has been minimized.

Copy link
Contributor

commented Mar 26, 2014

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

This comment has been minimized.

Copy link
Owner Author

commented Mar 26, 2014

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.

@raven02

This comment has been minimized.

Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.