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
Enable comparing sf::Transform and optimize resetting OpenGL back to the identity matrix #1298
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are my comments:
- Why both
equals
andoperator==
? - If
operator==
is defined, I like to haveoperator!=
as well - You compare 16 floats while only 9 are used
And is it so obvious that using glLoadIdentity + the added float comparisons is more optimized than glLoadMatrix? (just wondering)
2402d1f
to
6e0d213
Compare
Fixed in new version.
The values of the matrix will very likely be in the L1 cache since they were passed into draw() and applyTransform() by reference. Float comparisons are super fast, much faster than copying memory from one address space into another and then over the PCIe interface. Who knows, maybe the driver compares our data with the identity matrix and optimizes this itself, but if we do it ourselves we are on the safer side. |
src/SFML/Graphics/Transform.cpp
Outdated
@@ -26,6 +26,7 @@ | |||
// Headers | |||
//////////////////////////////////////////////////////////// | |||
#include <SFML/Graphics/Transform.hpp> | |||
#include <algorithm> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one can be removed now.
6e0d213
to
e11a5a4
Compare
Fixed. |
… of data every time we want to reset the OpenGL matrix back to identity.
e11a5a4
to
898c235
Compare
In cases where the RenderTarget is forced to go in and out of "cache mode", it will end up constantly uploading the matrix of Transform::Identity to OpenGL even though this is most likely a built in constant (and probably highly optimized). This patch makes use of the built-in and reduces CPU/RAM load in cases where the copying is happening excessively.