Branchless array initialization; faster rounding; other minor enhancements#496
Open
solarunes wants to merge 6 commits intotoji:masterfrom
Open
Branchless array initialization; faster rounding; other minor enhancements#496solarunes wants to merge 6 commits intotoji:masterfrom
solarunes wants to merge 6 commits intotoji:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Array Initialization
Currently, all
create()methods checkglMatrix.ARRAY_TYPEto determine if the Array needs to manually be initialized to zero or not.This can be avoided by creating a "zero-initializer class" that is a subclass of
glMatrix.ARRAY_TYPE, if and only if it doesn't inherit a typed array.Implementation
I added a subclass generator for
Array-like objects that adds zero initialization to their constructor. This subclass is available as a public field in theglMatrixnamespace (ARRAY_ZERO_INIT_TYPE).Invoking
glMatrix.setMatrixArrayType(type)now does the following:glMatrix.ARRAY_TYPEtotypetypeisArray-like but not a typed array;ArrayInitZerooftypethat initializes it's elements to zeroARRAY_ZERO_INIT_TYPEtoArrayInitZeroARRAY_ZERO_INIT_TYPEtotypeBenchmarks
A full benchmark and comparison is available here.
Symmetric Rounding
The current
glMatrix.round()implementation has branching- and modulo operations. None of this is required for symmetric rounding.Implementation
I replaced the old
glMatrix.round()with a much faster, single line implementation, using only methods of the built-inMathnamespace.Benchmarks
A full benchmark and comparison is available here.
Other Enhancements
I shortened a few methods and introduced modern built-in functions where applicable. These should hopefully provide a minor performance boost.