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

Issue while using new release of GLM (0.9.6.0) : quaternion & align #283

Closed
MarkTheFox opened this issue Dec 4, 2014 · 15 comments
Closed
Assignees
Labels
Milestone

Comments

@MarkTheFox
Copy link

We are updating GLM from 0.9.5.4 (everything went well with #define GLM_FORCE_RADIANS) to 0.9.6.0 and it seems something goes wrong : Here is the message given by Visual 2012:

GLM: Windows platform detected
GLM: Visual C++ compiler detected
GLM: 32 bits model
GLM: C++ with language extensions
GLM: #define GLM_FORCE_CXX98, GLM_FORCE_CXX03, GLM_LANG_CXX11 or GLM_FORCE_CXX1Y to force using a specific version of the C++ language
GLM: SSE2 instruction set
GLM: #define GLM_FORCE_PURE to avoid using platform specific instruction sets
GLM: Swizzling operators enabled
GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification
GLM: #define GLM_FORCE_SIZE_T_LENGTH for .length() to return a size_t
GLM: Core library included
GLM: GLM_GTC_constants extension included
GLM: GLM_GTC_matrix_transform extension included
GLM: GLM_GTC_matrix_inverse extension included
GLM: GLM_GTC_quaternion extension included
XXXXXXX\glm-0.9.6.0\glm\gtc\quaternion.hpp(116): error C2071: 'glm::tquat<T,P>::operator glm::tmat3x3<T,P>' : classe de stockage non conforme
XXXXXXX\glm-0.9.6.0\glm\gtc\quaternion.hpp(138) : voir la référence à l'instanciation de la classe modèle 'glm::tquat<T,P>' en cours de compilation
XXXXXXXXX\glm-0.9.6.0\glm\gtc\quaternion.hpp(117): error C2071: 'glm::tquat<T,P>::operator glm::tmat4x4<T,P>' : classe de stockage non conforme

Other issue appeared : the data won't be aligned if not given as reference ?
le paramètre formel avec __declspec(align('16')) ne sera pas aligné

Thanks in advance,

@Groovounet
Copy link
Member

Hi,

The first issue has been resolved in #282.

The second one... erm, I don't know.

Does current 0.9.6 branch https:/g-truc/glm/archive/0.9.6.zip resolve your issues?

Thanks,
Christophe

@MarkTheFox
Copy link
Author

Hi,

Thanks for the first issue fix !
But the second one is still present ☹. We will use the 0.9.5.4 and try the 0.9.6.0 on Visual 2013 next.
Best regards,

Marc

De : Christophe Riccio [mailto:[email protected]]
Envoyé : jeudi 4 décembre 2014 10:21
À : g-truc/glm
Cc : LERENARD Marc
Objet : Re: [glm] Issue while using new release of GLM (0.9.6.0) : quaternion & align (#283)

Hi,

The first issue has been resolved in #282#282.

The second one... erm, I don't know.

Does current 0.9.6 branch https:/g-truc/glm/archive/0.9.6.zip resolve your issues?

Thanks,
Christophe


ReHi,

ply to this email directly or view it on GitHubhttps://issues/283#issuecomment-65556450.

@Groovounet
Copy link
Member

I reproduced it: 32 bit issue!
A temporary workaround is to define GLM_FORCE_PURE.
I'll fix it for GLM 0.9.6.1 release.

Thanks,
Christophe

@Groovounet Groovounet self-assigned this Dec 5, 2014
@Groovounet Groovounet added this to the GLM 0.9.6 milestone Dec 5, 2014
@Groovounet Groovounet added the bug label Dec 5, 2014
@MarkTheFox
Copy link
Author

Hi,

Thanks a lot for your quick answers !
Sorry, but I still have an issue while deleting an array of vec4 ☹ :

glm ::vec4 * array = new glm ::vec4[4] ;
delete array ; // <<< this does not work

Best regards,

Marc LE RENARD

De : Christophe Riccio [mailto:[email protected]]
Envoyé : vendredi 5 décembre 2014 01:22
À : g-truc/glm
Cc : LERENARD Marc
Objet : Re: [glm] Issue while using new release of GLM (0.9.6.0) : quaternion & align (#283)

I reproduced it: 32 bit issue!
A temporary workaround is to define GLM_FORCE_PURE.
I'll fix it for GLM 0.9.6.1 release.

Thanks,
Christophe


Reply to this email directly or view it on GitHubhttps://issues/283#issuecomment-65728362.

@Groovounet
Copy link
Member

Maybe that's your fault here, try with delete[] instead. :p

On 05 Dec 2014, at 15:30, MarkTheFox [email protected] wrote:

Hi,

Thanks a lot for your quick answers !
Sorry, but I still have an issue while deleting an array of vec4 ☹ :

glm ::vec4 * array = new glm ::vec4[4] ;
delete array ; // <<< this does not work

Best regards,

Marc LE RENARD
ESIEA
38 Rue des docteurs Calmette & Guérin
53000 LAVAL
Tel : 02.43.59.46.26

De : Christophe Riccio [mailto:[email protected]]
Envoyé : vendredi 5 décembre 2014 01:22
À : g-truc/glm
Cc : LERENARD Marc
Objet : Re: [glm] Issue while using new release of GLM (0.9.6.0) : quaternion & align (#283)

I reproduced it: 32 bit issue!
A temporary workaround is to define GLM_FORCE_PURE.
I'll fix it for GLM 0.9.6.1 release.

Thanks,
Christophe


Reply to this email directly or view it on GitHubhttps://issues/283#issuecomment-65728362.

Reply to this email directly or view it on GitHub.

@MarkTheFox
Copy link
Author

That’s it ! I have made a vector instead since my last email, everything is working now with the FORCE defines.
Thanks a lot.
Best regards,

Marc LE RENARD

De : Christophe Riccio [mailto:[email protected]]
Envoyé : vendredi 5 décembre 2014 17:32
À : g-truc/glm
Cc : LERENARD Marc
Objet : Re: [glm] Issue while using new release of GLM (0.9.6.0) : quaternion & align (#283)

Maybe that's your fault here, try with delete[] instead. :p

On 05 Dec 2014, at 15:30, MarkTheFox <[email protected]mailto:[email protected]> wrote:

Hi,

Thanks a lot for your quick answers !
Sorry, but I still have an issue while deleting an array of vec4 ☹ :

glm ::vec4 * array = new glm ::vec4[4] ;
delete array ; // <<< this does not work

Best regards,

Marc LE RENARD

De : Christophe Riccio [mailto:[email protected]]
Envoyé : vendredi 5 décembre 2014 01:22
À : g-truc/glm
Cc : LERENARD Marc
Objet : Re: [glm] Issue while using new release of GLM (0.9.6.0) : quaternion & align (#283)

I reproduced it: 32 bit issue!
A temporary workaround is to define GLM_FORCE_PURE.
I'll fix it for GLM 0.9.6.1 release.

Thanks,
Christophe


Reply to this email directly or view it on GitHubhttps://issues/283#issuecomment-65728362.

Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHubhttps://issues/283#issuecomment-65814817.

Groovounet pushed a commit that referenced this issue Dec 8, 2014
@Groovounet
Copy link
Member

This issue should be fixed in GLM 0.9.6 branch for GLM 0.9.6.1 release without the need of GLM_FORCE_PURE.

Thanks for reporting,
Christophe

@sth519
Copy link

sth519 commented Dec 15, 2014

Just wanted to let you know that this is still a problem in glm 0.9.6.1.
Visual Studio 2013 with a 32bit build target.

@Groovounet
Copy link
Member

Hi,

Can you post what GLM_MESSAGES is giving you?
Also, what are the error messages?

Thanks,
Christophe

@sth519
Copy link

sth519 commented Dec 16, 2014

1>  GLM: Windows platform detected
1>  GLM: Visual C++ compiler detected
1>  GLM: 32 bits model
1>  GLM: C++0x
1>  GLM: Language extensions enabled
1>  GLM: SSE2 instruction set
1>  GLM: Swizzling operators disabled, #define GLM_SWIZZLE to enable swizzle operators
1>  GLM: .length() returns glm::length_t, a typedef of int following the GLSL specification
1>  GLM: Core library included
1>  GLM: All extensions included (not recommanded)
1>  GLM: GLM_GTC_bitfield extension included
1>  GLM: GLM_GTC_constants extension included
1>  GLM: GLM_GTC_epsilon extension included
1>  GLM: GLM_GTC_quaternion extension included
1>  GLM: GLM_GTC_integer extension included
1>  GLM: GLM_GTC_matrix_access extension included
1>  GLM: GLM_GTC_matrix_integer extension included
1>  GLM: GLM_GTC_matrix_inverse extension included
1>  GLM: GLM_GTC_matrix_transform extension included
1>  GLM: GLM_GTC_noise extension included
1>  GLM: GLM_GTC_vec1 extension included
1>  GLM: GLM_GTC_type_precision extension included
1>  GLM: GLM_GTC_packing extension included
1>  GLM: GLM_GTC_random extension included
1>  GLM: GLM_GTC_reciprocal extension included
1>  GLM: GLM_GTC_integer extension included
1>  GLM: GLM_GTC_type_ptr extension included
1>  GLM: GLM_GTC_ulp extension included
1>  GLM: GLM_GTX_associated_min_max extension included
1>  GLM: GLM_GTX_bit extension is deprecated, include GLM_GTC_bitfield and GLM_GTC_integer instead
1>  GLM: GLM_GTX_closest_point extension included
1>  GLM: GLM_GTX_color_space extension included
1>  GLM: GLM_GTX_color_space_YCoCg extension included
1>  GLM: GLM_GTX_compatibility extension included
1>  GLM: GLM_GTX_component_wise extension included
1>  GLM: GLM_GTX_dual_quaternion extension included
1>  GLM: GLM_GTX_euler_angles extension included
1>  GLM: GLM_GTX_extend extension included
1>  GLM: GLM_GTX_extented_min_max extension included
1>  GLM: GLM_GTX_fast_exponential extension included
1>  GLM: GLM_GTX_fast_square_root extension included
1>  GLM: GLM_GTX_fast_trigonometry extension included
1>  GLM: GLM_GTX_optimum_pow extension included
1>  GLM: GLM_GTX_gradient_paint extension included
1>  GLM: GLM_GTX_handed_coordinate_space extension included
1>  GLM: GLM_GTX_integer extension included
1>  GLM: GLM_GTX_closest_point extension included
1>  GLM: GLM_GTX_log_base extension included
1>  GLM: GLM_GTX_matrix_cross_product extension included
1>  GLM: GLM_GTX_matrix_interpolation extension included
1>  GLM: GLM_GTX_matrix_major_storage extension included
1>  GLM: GLM_GTX_matrix_operation extension included
1>  GLM: GLM_GTX_vector_query extension included
1>  GLM: GLM_GTX_matrix_query extension included
1>  GLM: GLM_GTX_mixed_product extension included
1>  GLM: GLM_GTX_quaternion extension included
1>  GLM: GLM_GTX_norm extension included
1>  GLM: GLM_GTX_normal extension included
1>  GLM: GLM_GTX_normalize_dot extension included
1>  GLM: GLM_GTX_number_precision extension included
1>  GLM: GLM_GTX_orthonormalize extension included
1>  GLM: GLM_GTX_projection extension included
1>  GLM: GLM_GTX_perpendicular extension included
1>  GLM: GLM_GTX_polar_coordinates extension included
1>  GLM: GLM_GTX_raw_data extension included
1>  GLM: GLM_GTX_transform extension included
1>  GLM: GLM_GTX_rotate_vector extension included
1>  GLM: GLM_GTX_spline extension included
1>  GLM: GLM_GTX_std_based_type extension included
1>  GLM: GLM_GTX_string_cast extension included
1>  GLM: GLM_GTX_transform2 extension included
1>  GLM: GLM_GTX_type_aligned extension included
1>  GLM: GLM_GTX_vector_angle extension included
1>  GLM: GLM_GTX_wrap extension included
1>[...]\lib\platforms\windows-x86\include\glm\./gtx/scalar_multiplication.hpp(85): error C2719: 'rh': formal parameter with __declspec(align('16')) won't be aligned
1>[...]\lib\platforms\windows-x86\include\glm\./gtx/scalar_multiplication.hpp(85): error C2719: 'lh': formal parameter with __declspec(align('16')) won't be aligned
1>  GLM: GLM_GTX_simd_vec4 extension included
1>  GLM: GLM_GTX_simd_mat4 extension included

followed by dozens of lines of:

1>[...]\src\common\../rendering/Scene.h(77): error C2719: 'view_matrix': formal parameter with __declspec(align('16')) won't be aligned
1>[...]\src\common\../world/TerrainChunk.h(81): error C2719: 'color': formal parameter with __declspec(align('16')) won't be aligned
1>[...]\src\common\../scripting/lua_helpers.h(32): error C2719: 'vector': formal parameter with __declspec(align('16')) won't be aligned
etc...

The errors go away when I #define GLM_FORCE_PURE.
Haven't encountered the problem on other platforms or compilers so far.

@amc522
Copy link

amc522 commented Jan 23, 2015

So I just got latest from the master branch of glm (0.9.7) and I too ran into the alignment issue. I'm compiling with vs2013 november ctp. I compile for both x86 and x64. When I do my compiling I run with /W4, which spit out a lot of warnings about non standard extensions.

warning C4201: nonstandard extension used : nameless struct/union (..\..\source\RenderAL\Color.cpp)

This warning has to do with anonymous structs inside another anonymous struct or union. Whenever this was introduced into the vector types, is when the alignment issue popped up.

Only the x86 architecture is showing errors about alignment. After figuring that out, I commented out the following line in glm/detail/setup.hpp

#define GLM_HAS_ANONYMOUS_UNION !defined(GLM_FORCE_CXX98) && !defined(GLM_FORCE_CXX03) && (GLM_LANG & GLM_LANG_CXXMS_FLAG)

That fixed all the issues. Ill do some digging into why the msvc compiler has alignment issues with that code. Possibly file a bug with microsoft. For now I changed the line to following

#define GLM_HAS_ANONYMOUS_UNION !defined(GLM_FORCE_CXX98) && !defined(GLM_FORCE_CXX03) && (GLM_LANG & GLM_LANG_CXXMS_FLAG) && !(GLM_COMPILER & GLM_COMPILER_VC)

(added '&& !(GLM_COMPILER & GLM_COMPILER_VC' to the end)
Hope this helps some people.

@tm4n
Copy link

tm4n commented May 14, 2015

I'm still having the same problem with glm 0.9.6.3 when compiling x86 code with Visual Studio Community 2013:

error C2719: 'mVPMatrix': formal parameter with __declspec(align('16')) won't be aligned

in the code:

virtual void draw(glm::mat4 mVPMatrix);

@noizex
Copy link

noizex commented May 14, 2015

Try passing by reference.

@tm4n
Copy link

tm4n commented May 14, 2015

@noizex I can do that as a workaround, but then I get other problems:

warning C4316: 'Mesh' : object allocated on the heap may not be aligned 16

for the object Mesh which has two glm:mat4 members. My code also hits a breakpoint in ntdll on deleting another object with glm::mat4 members. There is still something wrong here.
Linux 32 Bit build with gcc works fine. The glm version I was using before was also fine with visual studio (glm 9.5.x, dont know exactly right now). I also couldn't get GLM_FORCE_PURE to work.

EDIT: cinder/Cinder@56fd399
This fixes the issue for me, including the breakpoint.

@noizex
Copy link

noizex commented May 14, 2015

For classes that use glm's aligned members I just inherit from a special allocator which allows allocating on heap without warnings. It works and does not cause crashes or memory leaks so I think it's okay. Link to that class is here: https://dl.dropboxusercontent.com/u/1040763/aligned_allocator.h. Then:

typedef AlignedAllocator<16> AlignedAllocator16;
class Mesh: public AlignedAllocator16
{
   glm::mat4   foo;
   glm::mat3   bar;
}

That's what I found after some reasearch about aligned members, but treat it with some reserve as I'm not C++ expert :)

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

No branches or pull requests

6 participants