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

softgpu: Apply optimizations to states generically #16486

Merged
merged 6 commits into from
Dec 3, 2022

Conversation

unknownbrackets
Copy link
Collaborator

This moves the flat state optimizations to typically happen earlier on, and adds fog to them.

Triangles can and do benefit from these, and I'm considering doing more things here. Specifically, I think it might make sense to do some heuristics and precompute texture data in a buffer. When linear is used, we end up sampling a ton, so getting rid of the gather would really help even if it was a mostly 1:1 draw. There are also annoying cases where games texture a large draw from a single texel to get a solid color, which would be helped greatly by that (Valkyria Chronicles 3 is a good example.)

Other things too, for example alpha checking while doing the above might allow disabling alpha test often, which would help given how often games pointlessly enable it.

Anyway, this usually helps a couple percent but isn't consistent - some runs it's flat, not sure why. At least doesn't make anything worse, and I think it'll make other optimizations easier as noted.

The DenseHashMap change helped some microbenchmarks (headless --bench runs), but didn't seem to help FPS much. But it seemed to help an issue where sometimes optimizing and looking up a new cache key was quite slow.

At first I tried adding a new state when optimizing the current one, but that caused a lot of churn and seemed slower sometimes. So I decided better to just make all optimizations reversible.

-[Unknown]

Probably fixes a line shading bug, and clearer anyway.
Might be some other ways, like doing this directly in a vertex reader.
Also am thinking about doing things regarding UVs or positions.

Flags not yet used, keeping separate for perf checks.
This is for optimizations we can only do when we know the vertex values.
This makes more sense to read.
@hrydgard hrydgard merged commit 4589473 into hrydgard:master Dec 3, 2022
@unknownbrackets unknownbrackets deleted the softgpu-opt branch December 3, 2022 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants