Skip to content

Conversation

brianchirls
Copy link
Contributor

The painterSortStable function sorts objects to be rendered by material to minimize switching between materials. However, it doesn't consider that now different materials can share a common shader program. The result is that the renderer may be switching out shader programs more often than necessary.

I put together a rough benchmark to test this patch. Here is one using the existing code:
http://output.jsbin.com/tuneso

And here is one using the patched code:
http://output.jsbin.com/nogovi

In Chrome on my Late 2013 MacBook Pro, with 10,000 objects, I'm seeing ~4 fps unpatched and ~13 fps patched. On my new PC w/ GeForce 980, I get ~26 fps vs ~38 fps. Please adjust the object count on your system accordingly.

This is related to #8849.

@bhouston
Copy link
Contributor

Sweet. This doesn't affect the draw order of the transparent objects does it?

@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2016

Sweet. This doesn't affect the draw order of the transparent objects does it?

It doesn't. Those are sorted using reversePainterSortStable().

@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2016

@tschw looks good?

@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2016

Hmm, I've just checked WebGLProgram and I think this shouldn't have side effects.

@mrdoob mrdoob merged commit 570499d into mrdoob:dev Jun 17, 2016
@mrdoob
Copy link
Owner

mrdoob commented Jun 17, 2016

Many thanks!

@brianchirls
Copy link
Contributor Author

@mrdoob Thanks for the lightning-fast review and merge!

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.

3 participants