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

[EmulGL] Software rendering performance can be significantly improved by optimising blend_pixel #261

Open
valb3r opened this issue Apr 30, 2022 · 4 comments

Comments

@valb3r
Copy link
Contributor

valb3r commented Apr 30, 2022

switch - case inside blend_pixel causes almost 2x performance degradation due to mixing of branching and numeric pipeline

Pipeline flame graph:
Screenshot 2022-04-30 at 17 11 46

As BlendFunc rarely changes during polygon rendering, one can try to use lambdas to optimise pixel blending performance

@jzy3d
Copy link
Owner

jzy3d commented Apr 30, 2022

Good catch! Is this x2 factor an estimate or did you already try?

One thing you may be interested in is BenchmarkRun and BenchmarkPlot in module jzy3d-tests-java9. It evaluates rendering time based on content to render. I used it to show how sensitive EmulGL and jGL are to the number of polygons to render, assuming these polygons (either a single, 10 or 100) always cover the same number of pixels.

Capture d’écran 2022-04-30 à 18 38 36

@valb3r
Copy link
Contributor Author

valb3r commented Apr 30, 2022

Is this x2 factor an estimate or did you already try?

I've tested that on M1 Air with Apple Silicon, went from 120ms to 60ms per frame when I removed switch-case and kept only actual branch
Will try BenchmarkRun for better consistency

@jzy3d
Copy link
Owner

jzy3d commented Apr 30, 2022

You will see that this test only involves black pixel on a flat surface. The idea was mainly to have a guess on sensitivity to number of pixels to paint vs. polygon you’re draw.
It should not be hard to derive it and evaluate blending cost on a colored surface.

One point worth mentioning : EmulGL has an unsatisfying way of handling blending. The less alpha you configure, the darker polygon you have. I’ll send you links about it.

@jzy3d
Copy link
Owner

jzy3d commented Apr 30, 2022

Quality.Advanced() with alpha has faded colors.

image

Quality.Intermediate with no alpha has vivid colors

image

I am willing to understand where this fading effect comes from. Using alpha = 0 creates black pixels instead of background color pixels.

@jzy3d jzy3d changed the title Software rendering performance can be significantly improved by optimising blend_pixel [EmulGL] Software rendering performance can be significantly improved by optimising blend_pixel May 1, 2022
@jzy3d jzy3d added this to the 2.2.0 milestone May 24, 2022
@jzy3d jzy3d modified the milestones: 2.2.0, 2.3.0 Aug 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants