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

Trivial types #263

Closed
zargot opened this issue Nov 3, 2014 · 8 comments
Closed

Trivial types #263

zargot opened this issue Nov 3, 2014 · 8 comments
Assignees
Milestone

Comments

@zargot
Copy link

zargot commented Nov 3, 2014

Is it possible to make the vec types trivially constructable? (std::is_trivial)
If so; are there any plans for this?

@Groovounet
Copy link
Member

How would that possible?

@chbaker0
Copy link

chbaker0 commented Nov 3, 2014

Not sure about trivially constructible, but they could easily be trivially copyable (if they aren't already). Then you'd be able to use memcpy and memmove on them.

@zargot
Copy link
Author

zargot commented Nov 3, 2014

I suppose it would be unreasonable to make them trivially constructible. But I propose trivially copyable as an enhancement.
std::has_trivial_copy_constructor and std::has_trivial_copy_assign both fail with glm::dvec3 on GCC 4.9.1.

Groovounet pushed a commit that referenced this issue Nov 3, 2014
@Groovounet
Copy link
Member

I think you had std::is_trivially_copy_assignable and std::is_trivially_copyable in mind.

With a short experiment I should make vec4 being trivially copyable.

I am not familiar with this, what's the value of doing it?

@Groovounet
Copy link
Member

Erm safe copy with memcpy... I never ever seen any issue with it before...

Groovounet pushed a commit that referenced this issue Nov 4, 2014
@zargot
Copy link
Author

zargot commented Nov 4, 2014

GCC doesn't have those functions yet, but they should be equal.
I think it's mostly about performance, and beeing able to use it in containers that require the type to be trivially copyable, etc. ("Trivial" types may be optimized more, skipping initialization, afaik.)
Thanks!

@chbaker0
Copy link

chbaker0 commented Nov 4, 2014

@Groovounet Having them be trivially copyable would mean that users of the library could, with appropriate padding, use memcpy directly to load an array of structs containing vectors/matrices into a buffer for GL following the std140 or std430 format. Otherwise you'd be invoking undefined behavior.

Groovounet pushed a commit that referenced this issue Nov 9, 2014
Groovounet pushed a commit that referenced this issue Nov 10, 2014
Groovounet pushed a commit that referenced this issue Nov 14, 2014
@Groovounet Groovounet added this to the GLM 0.9.6 milestone Nov 14, 2014
@Groovounet Groovounet self-assigned this Nov 14, 2014
@Groovounet
Copy link
Member

Correct me if I am wrong but it seems to me that all GLM types can be is trivially copyable which they all are now so i am closing the bug.

Don't hesitate to open another bug or reopen the bug if you see additional opportunities.

Thanks for reporting,
Christophe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants