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

remove unnecessary glUseProgram(0) #5944

Merged
merged 2 commits into from Mar 11, 2020
Merged

Conversation

@mgsx-dev
Copy link
Contributor

mgsx-dev commented Mar 10, 2020

Unbinding a shader program is not necessary, it was useful to enable the old fixed-function pipeline which libgdx don't use.

ShaderProgram begin and end method are deprecated for a smooth transition.

I made a quick dumb test to see how my GPU was impacted (if my GPU driver optimize it or not) :

here is the code:

    private ShaderProgram sp;
    public void render () {
        int N = 1000;
        for(int i=0 ; i<N ; i++){
            sp.begin();
            sp.end();
        }
        logger.log();
    }

by commenting begin/end in all combinations i get:

  • calling none of them (baseline): ~ 10 500 FPS
  • calling only end: ~ 9500 FPS
  • calling only begin: ~ 2000 FPS
  • calling both begin and end: ~ 1000 FPS

GPU : Nvidia GTX 950m

I'm not calling this a benchmark, i just wanted to highlight this small optimization and ensure there was no drawbacks. Most of games try to minimize shader switches to only a few anyway, so i don't think it would improve perf. noticeably. But it still better to not call it at all.

Note that my original issue was GLProfiler counting a shader switch as twice because of it. This issue is then fixed by this PR as well.

@yuripourre

This comment has been minimized.

Copy link
Contributor

yuripourre commented Mar 10, 2020

Nice finding!

@NathanSweet NathanSweet merged commit 01ea5b1 into libgdx:master Mar 11, 2020
1 check passed
1 check passed
continuous-integration/travis-ci/pr The Travis CI build passed
Details
NathanSweet added a commit to EsotericSoftware/spine-runtimes that referenced this pull request Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.