Changeset View
Changeset View
Standalone View
Standalone View
libkwineffects/kwineffects.cpp
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | #include <cassert> | 44 | #include <cassert> | ||
45 | 45 | | |||
46 | #include <KWayland/Server/surface_interface.h> | 46 | #include <KWayland/Server/surface_interface.h> | ||
47 | 47 | | |||
48 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | 48 | #ifdef KWIN_HAVE_XRENDER_COMPOSITING | ||
49 | #include <xcb/xfixes.h> | 49 | #include <xcb/xfixes.h> | ||
50 | #endif | 50 | #endif | ||
51 | 51 | | |||
52 | #if defined(__GNUC__) | | |||
53 | # define KWIN_ALIGN(n) __attribute((aligned(n))) | | |||
54 | # if defined(__SSE2__) | 52 | #if defined(__SSE2__) | ||
55 | # define HAVE_SSE2 | | |||
56 | # endif | | |||
57 | #elif defined(__INTEL_COMPILER) | | |||
58 | # define KWIN_ALIGN(n) __declspec(align(n)) | | |||
59 | # define HAVE_SSE2 | | |||
60 | #else | | |||
61 | # define KWIN_ALIGN(n) | | |||
62 | #endif | | |||
63 | | ||||
64 | #ifdef HAVE_SSE2 | | |||
65 | # include <emmintrin.h> | 53 | # include <emmintrin.h> | ||
66 | #endif | 54 | #endif | ||
67 | 55 | | |||
68 | 56 | | |||
69 | namespace KWin | 57 | namespace KWin | ||
70 | { | 58 | { | ||
71 | 59 | | |||
72 | void WindowPrePaintData::setTranslucent() | 60 | void WindowPrePaintData::setTranslucent() | ||
▲ Show 20 Lines • Show All 1068 Lines • ▼ Show 20 Line(s) | 1124 | { | |||
1141 | 1129 | | |||
1142 | GLVertex2D *vertex = vertices; | 1130 | GLVertex2D *vertex = vertices; | ||
1143 | 1131 | | |||
1144 | assert(type == GL_QUADS || type == GL_TRIANGLES); | 1132 | assert(type == GL_QUADS || type == GL_TRIANGLES); | ||
1145 | 1133 | | |||
1146 | switch (type) | 1134 | switch (type) | ||
1147 | { | 1135 | { | ||
1148 | case GL_QUADS: | 1136 | case GL_QUADS: | ||
1149 | #ifdef HAVE_SSE2 | 1137 | #if defined(__SSE2__) | ||
zzag: Stick only with either ifdef or if defined. Mixing both can be confusing for some people. | |||||
gladhorn: Agree, that was sloppy. | |||||
1150 | if (!(intptr_t(vertex) & 0xf)) { | 1138 | if (!(intptr_t(vertex) & 0xf)) { | ||
1151 | for (int i = 0; i < count(); i++) { | 1139 | for (int i = 0; i < count(); i++) { | ||
1152 | const WindowQuad &quad = at(i); | 1140 | const WindowQuad &quad = at(i); | ||
1153 | KWIN_ALIGN(16) GLVertex2D v[4]; | 1141 | alignas(16) GLVertex2D v[4]; | ||
1154 | 1142 | | |||
1155 | for (int j = 0; j < 4; j++) { | 1143 | for (int j = 0; j < 4; j++) { | ||
1156 | const WindowVertex &wv = quad[j]; | 1144 | const WindowVertex &wv = quad[j]; | ||
1157 | 1145 | | |||
1158 | v[j].position = QVector2D(wv.x(), wv.y()); | 1146 | v[j].position = QVector2D(wv.x(), wv.y()); | ||
1159 | v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | 1147 | v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | ||
1160 | } | 1148 | } | ||
1161 | 1149 | | |||
1162 | const __m128i *srcP = reinterpret_cast<const __m128i *>(&v); | 1150 | const __m128i *srcP = reinterpret_cast<const __m128i *>(&v); | ||
1163 | __m128i *dstP = reinterpret_cast<__m128i *>(vertex); | 1151 | __m128i *dstP = reinterpret_cast<__m128i *>(vertex); | ||
1164 | 1152 | | |||
1165 | _mm_stream_si128(&dstP[0], _mm_load_si128(&srcP[0])); // Top-left | 1153 | _mm_stream_si128(&dstP[0], _mm_load_si128(&srcP[0])); // Top-left | ||
1166 | _mm_stream_si128(&dstP[1], _mm_load_si128(&srcP[1])); // Top-right | 1154 | _mm_stream_si128(&dstP[1], _mm_load_si128(&srcP[1])); // Top-right | ||
1167 | _mm_stream_si128(&dstP[2], _mm_load_si128(&srcP[2])); // Bottom-right | 1155 | _mm_stream_si128(&dstP[2], _mm_load_si128(&srcP[2])); // Bottom-right | ||
1168 | _mm_stream_si128(&dstP[3], _mm_load_si128(&srcP[3])); // Bottom-left | 1156 | _mm_stream_si128(&dstP[3], _mm_load_si128(&srcP[3])); // Bottom-left | ||
1169 | 1157 | | |||
1170 | vertex += 4; | 1158 | vertex += 4; | ||
1171 | } | 1159 | } | ||
1172 | } else | 1160 | } else | ||
1173 | #endif // HAVE_SSE2 | 1161 | #endif // __SSE2__ | ||
1174 | { | 1162 | { | ||
1175 | for (int i = 0; i < count(); i++) { | 1163 | for (int i = 0; i < count(); i++) { | ||
1176 | const WindowQuad &quad = at(i); | 1164 | const WindowQuad &quad = at(i); | ||
1177 | 1165 | | |||
1178 | for (int j = 0; j < 4; j++) { | 1166 | for (int j = 0; j < 4; j++) { | ||
1179 | const WindowVertex &wv = quad[j]; | 1167 | const WindowVertex &wv = quad[j]; | ||
1180 | 1168 | | |||
1181 | GLVertex2D v; | 1169 | GLVertex2D v; | ||
1182 | v.position = QVector2D(wv.x(), wv.y()); | 1170 | v.position = QVector2D(wv.x(), wv.y()); | ||
1183 | v.texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | 1171 | v.texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | ||
1184 | 1172 | | |||
1185 | *(vertex++) = v; | 1173 | *(vertex++) = v; | ||
1186 | } | 1174 | } | ||
1187 | } | 1175 | } | ||
1188 | } | 1176 | } | ||
1189 | break; | 1177 | break; | ||
1190 | 1178 | | |||
1191 | case GL_TRIANGLES: | 1179 | case GL_TRIANGLES: | ||
1192 | #ifdef HAVE_SSE2 | 1180 | #if defined(__SSE2__) | ||
1193 | if (!(intptr_t(vertex) & 0xf)) { | 1181 | if (!(intptr_t(vertex) & 0xf)) { | ||
1194 | for (int i = 0; i < count(); i++) { | 1182 | for (int i = 0; i < count(); i++) { | ||
1195 | const WindowQuad &quad = at(i); | 1183 | const WindowQuad &quad = at(i); | ||
1196 | KWIN_ALIGN(16) GLVertex2D v[4]; | 1184 | alignas(16) GLVertex2D v[4]; | ||
1197 | 1185 | | |||
1198 | for (int j = 0; j < 4; j++) { | 1186 | for (int j = 0; j < 4; j++) { | ||
1199 | const WindowVertex &wv = quad[j]; | 1187 | const WindowVertex &wv = quad[j]; | ||
1200 | 1188 | | |||
1201 | v[j].position = QVector2D(wv.x(), wv.y()); | 1189 | v[j].position = QVector2D(wv.x(), wv.y()); | ||
1202 | v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | 1190 | v[j].texcoord = QVector2D(wv.u(), wv.v()) * coeff + offset; | ||
1203 | } | 1191 | } | ||
1204 | 1192 | | |||
Show All 14 Lines | |||||
1219 | // Second triangle | 1207 | // Second triangle | ||
1220 | _mm_stream_si128(&dstP[3], src[3]); // Bottom-left | 1208 | _mm_stream_si128(&dstP[3], src[3]); // Bottom-left | ||
1221 | _mm_stream_si128(&dstP[4], src[2]); // Bottom-right | 1209 | _mm_stream_si128(&dstP[4], src[2]); // Bottom-right | ||
1222 | _mm_stream_si128(&dstP[5], src[1]); // Top-right | 1210 | _mm_stream_si128(&dstP[5], src[1]); // Top-right | ||
1223 | 1211 | | |||
1224 | vertex += 6; | 1212 | vertex += 6; | ||
1225 | } | 1213 | } | ||
1226 | } else | 1214 | } else | ||
1227 | #endif // HAVE_SSE2 | 1215 | #endif // __SSE2__ | ||
1228 | { | 1216 | { | ||
1229 | for (int i = 0; i < count(); i++) { | 1217 | for (int i = 0; i < count(); i++) { | ||
1230 | const WindowQuad &quad = at(i); | 1218 | const WindowQuad &quad = at(i); | ||
1231 | GLVertex2D v[4]; // Four unique vertices / quad | 1219 | GLVertex2D v[4]; // Four unique vertices / quad | ||
1232 | 1220 | | |||
1233 | for (int j = 0; j < 4; j++) { | 1221 | for (int j = 0; j < 4; j++) { | ||
1234 | const WindowVertex &wv = quad[j]; | 1222 | const WindowVertex &wv = quad[j]; | ||
1235 | 1223 | | |||
▲ Show 20 Lines • Show All 722 Lines • Show Last 20 Lines |
Stick only with either ifdef or if defined. Mixing both can be confusing for some people.