-
Notifications
You must be signed in to change notification settings - Fork 49
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 unneeded allocations #50
Comments
I agree, but if you look at https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L1127-L1158 - It's simply not feasable to do. You would need to store half of the content in local variables and access the other half on the fly (matrix[x][y]). That just generates a huge blob of unreadable code. My hope is/was that the generator somehow can optimize that to a static array (so you don't have the runtime allocation + memcpy). |
i am not sure about this, i always thought a multidimensional array literal is constructed using gc allocations. i could be wrong. |
Tbh, I have no idea, I was simply assuming the optimizer has gotten good enough ... Then again, it's D/dmd. But we wont know for sure until someone runs it through a debugger/looks at the asm. If you wanna go for it and create the ugly code required for replacing it, I will merge it. But please add unittests beforehand (the code required will be really ugly, I assume, easy to make mistakes). |
a simple test with array literals on http://d.godbolt.org/ reveil that these create a call to _d_arrayLiteralTX that actually uses a gc_allocation: so at least we now know that literals create heap traffic :( |
Yeah that sucks ... if even gcc doesn't optimize it. |
all Matrix.invert():
currently the mixin AFAIK creates a dynamic array even though the matrix already contains one, just assignments would be enough.
for example: https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L1036
Matrix.perspective() with FOV:
https://github.com/Dav1dde/gl3n/blob/master/gl3n/linalg.d#L1179
The text was updated successfully, but these errors were encountered: