Use compiler __SSE2__ definitions and C++11 alignas

Summary:
Since C++11 alignas is a keyword, so we don't need to create our own.
All relevant compilers (gcc, clang, icc) define __SSE2__, so just use that.

There seem to be frequent crashes in the quad version of this code, but
this change should not make any difference from what I can tell.

Reviewers: #kwin, zzag

Reviewed By: #kwin, zzag

Subscribers: zzag, kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D23120
icc-effect-5.17.5
Frederik Gladhorn 2019-08-14 09:31:16 +02:00
parent ac702ff2dc
commit 25ec024ab5
1 changed files with 7 additions and 19 deletions

View File

@ -49,19 +49,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <xcb/xfixes.h>
#endif
#if defined(__GNUC__)
# define KWIN_ALIGN(n) __attribute((aligned(n)))
# if defined(__SSE2__)
# define HAVE_SSE2
# endif
#elif defined(__INTEL_COMPILER)
# define KWIN_ALIGN(n) __declspec(align(n))
# define HAVE_SSE2
#else
# define KWIN_ALIGN(n)
#endif
#ifdef HAVE_SSE2
#if defined(__SSE2__)
# include <emmintrin.h>
#endif
@ -1146,11 +1134,11 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
switch (type)
{
case GL_QUADS:
#ifdef HAVE_SSE2
#if defined(__SSE2__)
if (!(intptr_t(vertex) & 0xf)) {
for (int i = 0; i < count(); i++) {
const WindowQuad &quad = at(i);
KWIN_ALIGN(16) GLVertex2D v[4];
alignas(16) GLVertex2D v[4];
for (int j = 0; j < 4; j++) {
const WindowVertex &wv = quad[j];
@ -1170,7 +1158,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
vertex += 4;
}
} else
#endif // HAVE_SSE2
#endif // __SSE2__
{
for (int i = 0; i < count(); i++) {
const WindowQuad &quad = at(i);
@ -1189,11 +1177,11 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
break;
case GL_TRIANGLES:
#ifdef HAVE_SSE2
#if defined(__SSE2__)
if (!(intptr_t(vertex) & 0xf)) {
for (int i = 0; i < count(); i++) {
const WindowQuad &quad = at(i);
KWIN_ALIGN(16) GLVertex2D v[4];
alignas(16) GLVertex2D v[4];
for (int j = 0; j < 4; j++) {
const WindowVertex &wv = quad[j];
@ -1224,7 +1212,7 @@ void WindowQuadList::makeInterleavedArrays(unsigned int type, GLVertex2D *vertic
vertex += 6;
}
} else
#endif // HAVE_SSE2
#endif // __SSE2__
{
for (int i = 0; i < count(); i++) {
const WindowQuad &quad = at(i);