This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch perf/map-span-simd
in repository efl.
View the commit online.
commit c4e8167f13049735bf73a99b4aec54cd32e08747
Author: Cedric BAIL <[email protected]>
AuthorDate: Sat Nov 28 22:23:02 2026 -0600
evas/map: draw anti-aliased maps with the vector span loops
The anti-aliased rasterizer sampled one pixel at a time in float, with
two calls to modff() each. Its scanlines now go through the SSE3 and
AVX2 span loops. Triangle edges put positions a hair outside the source,
which the flat loops never get, so these use a variant that takes the
blending weights from the limited position.
Without SSE3 the float loop draws as before. The vector loops round
positions and colors their own way: over 600 frames of random maps,
22% of pixels changed, 86% of those by one level, none by more than 6.
The cross-tier test holds that bound.
evas_bench Map, release build, Ryzen 7 6800U, ms per 800x600 frame,
before -> after, median of 3 runs (spread at most 2%):
AVX2 SSE MMX
anti-alias 3.64 -> 0.72 3.63 -> 1.31 3.64 -> 3.63
anti-alias-angled 2.81 -> 0.66 2.80 -> 1.13 2.81 -> 2.77
The other four cases are unchanged.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
src/lib/evas/common/evas_map_image_internal_high.c | 105 ++++++++++++
src/lib/evas/common/evas_map_image_span.h | 8 +-
src/lib/evas/common/evas_map_image_span_avx2.c | 36 ++--
src/lib/evas/common/evas_map_image_span_sse3.c | 22 ++-
src/lib/evas/common/evas_map_image_span_x86.h | 7 +-
src/tests/evas/evas_test_map_simd.c | 181 ++++++++++++++++-----
6 files changed, 292 insertions(+), 67 deletions(-)
diff --git a/src/lib/evas/common/evas_map_image_internal_high.c b/src/lib/evas/common/evas_map_image_internal_high.c
index a624c8682c..fca5cb6288 100644
--- a/src/lib/evas/common/evas_map_image_internal_high.c
+++ b/src/lib/evas/common/evas_map_image_internal_high.c
@@ -349,6 +349,97 @@ _map_triangle_channel(float value)
return (value <= 0) ? 0 : ((value >= 255) ? 255 : (DATA32)value);
}
+static inline DATA32
+_map_triangle_color(const float *c, const float *dcdx, float n, float z)
+{
+ return (_map_triangle_channel(((c[0] + (n * dcdx[0])) * z) + 0.5f) << 24) |
+ (_map_triangle_channel(((c[1] + (n * dcdx[1])) * z) + 0.5f) << 16) |
+ (_map_triangle_channel(((c[2] + (n * dcdx[2])) * z) + 0.5f) << 8) |
+ _map_triangle_channel(((c[3] + (n * dcdx[3])) * z) + 0.5f);
+}
+
+/* Draws len pixels of a scanline with the vector span loops. u, v, c and q
+ * are those of the first pixel, over depth at an angle, followed by their
+ * steps to the next one. */
+static inline void
+_map_triangle_span(DATA32 *d, int len, const Evas_Map_Span_Funcs *funcs,
+ Evas_Map_Span_Run *run,
+ float u, float v, float q, float dudx, float dvdx, float dqdx,
+ const float *c, const float *dcdx,
+ Eina_Bool col_blend, const Eina_Bool persp)
+{
+ Evas_Map_Span_Shade shade = EVAS_MAP_SPAN_PLAIN;
+ Evas_Map_Span_Func func;
+ /* colors go from those of the first pixel to those of the last one: one
+ * step further they may leave their range */
+ const int last = len - 1;
+ const int span = last ? last : 1;
+ float q_last = persp ? (q + (last * dqdx)) : 1;
+ int done;
+
+ if (col_blend)
+ {
+ float z = 1, z_last = 1;
+
+ if (persp)
+ {
+ z = (q > 1e-6f) ? (1 / q) : 1e6f;
+ z_last = (q_last > 1e-6f) ? (1 / q_last) : 1e6f;
+ }
+ run->c1 = _map_triangle_color(c, dcdx, 0, z);
+ run->c2 = _map_triangle_color(c, dcdx, last, z_last);
+ if (run->c1 != run->c2) shade = EVAS_MAP_SPAN_GRADIENT;
+ else if (run->c1 != 0xffffffff) shade = EVAS_MAP_SPAN_COLOR;
+ }
+
+ if (persp)
+ {
+ run->uq = u * 65536;
+ run->vq = v * 65536;
+ run->q = q;
+ run->duq = dudx * 65536;
+ run->dvq = dvdx * 65536;
+ run->dq = dqdx;
+ run->cq = 0;
+ run->dcq = (q_last * (255 << 16)) / span;
+ func = funcs->persp[1][shade];
+ }
+ else
+ {
+ run->u = u * 65536;
+ run->v = v * 65536;
+ run->ud = dudx * 65536;
+ run->vd = dvdx * 65536;
+ run->cv = 0;
+ run->cd = (255 << 16) / span;
+ func = funcs->outside[shade];
+ }
+
+ done = func(d, len, run);
+ if (done < len)
+ {
+ /* the last few through the same loop, so that a scanline is not
+ * rounded in two different ways */
+ DATA32 tail[4];
+
+ if (persp)
+ {
+ run->uq += done * run->duq;
+ run->vq += done * run->dvq;
+ run->cq += done * run->dcq;
+ run->q += done * run->dq;
+ }
+ else
+ {
+ run->u += done * run->ud;
+ run->v += done * run->vd;
+ run->cv += done * run->cd;
+ }
+ func(tail, 4, run);
+ memcpy(d + done, tail, (len - done) * sizeof(DATA32));
+ }
+}
+
/* Inlined once with persp false and once with it true, so that flat faces
* do not pay for the division. */
static EFL_ALWAYS_INLINE void
@@ -375,12 +466,19 @@ _map_triangle_scanlines(RGBA_Image *src, RGBA_Image *dst,
float c[4] = {0, 0, 0, 0};
DATA32 *buf, *tmp;
DATA8 *mbuf;
+ const Evas_Map_Span_Funcs *span_funcs = _map_span_funcs_get();
+ Evas_Map_Span_Run run;
//Range exception handling
if (ystart >= (cy + ch)) return;
if (ystart < cy) ystart = cy;
if (yend > (cy + ch)) yend = (cy + ch);
+ run.texels = sbuf;
+ run.stride = sw;
+ run.u_end = sw << 16;
+ run.v_end = sh << 16;
+
if (col_blend)
for (int i = 0; i < 4; i++)
{
@@ -429,6 +527,13 @@ _map_triangle_scanlines(RGBA_Image *src, RGBA_Image *dst,
x = x1;
+ if (span_funcs)
+ {
+ _map_triangle_span(buf, x2 - x1, span_funcs, &run, u, v, q,
+ _dudx, _dvdx, _dqdx, c, _dcdx, col_blend, persp);
+ x = x2;
+ }
+
//Draw horizontal line
while (x++ < x2)
{
diff --git a/src/lib/evas/common/evas_map_image_span.h b/src/lib/evas/common/evas_map_image_span.h
index 8d884da4b3..6811c5a804 100644
--- a/src/lib/evas/common/evas_map_image_span.h
+++ b/src/lib/evas/common/evas_map_image_span.h
@@ -35,11 +35,17 @@ typedef struct _Evas_Map_Span_Run
* leaving the rest to the caller. */
typedef int (*Evas_Map_Span_Func)(DATA32 *d, int w, const Evas_Map_Span_Run *run);
-/* Indexed by [smooth][shade]: flat spans, then perspective ones. */
+/* Indexed by [smooth][shade]: flat spans, then perspective ones.
+ *
+ * Flat spans of the scanline loops never start before the source. Those of
+ * the anti-aliased triangles may, by a hair at their edges, and take their
+ * blending weights from the limited position: inexact, by shade only, for
+ * smooth ones. */
typedef struct _Evas_Map_Span_Funcs
{
Evas_Map_Span_Func flat[2][EVAS_MAP_SPAN_SHADE_LAST];
Evas_Map_Span_Func persp[2][EVAS_MAP_SPAN_SHADE_LAST];
+ Evas_Map_Span_Func outside[EVAS_MAP_SPAN_SHADE_LAST];
} Evas_Map_Span_Funcs;
extern const Evas_Map_Span_Funcs evas_common_map_span_sse3;
diff --git a/src/lib/evas/common/evas_map_image_span_avx2.c b/src/lib/evas/common/evas_map_image_span_avx2.c
index 064c4a77d5..efb42d7b96 100644
--- a/src/lib/evas/common/evas_map_image_span_avx2.c
+++ b/src/lib/evas/common/evas_map_image_span_avx2.c
@@ -70,7 +70,8 @@ _map_persp8(const Evas_Map_Span_Run *run, __m256 at, __m256i *u, __m256i *v,
static EFL_ALWAYS_INLINE int
_map_span8(DATA32 *d, int w, const Evas_Map_Span_Run *run,
- const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp)
+ const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp,
+ const Eina_Bool outside)
{
const __m256i zero = _mm256_setzero_si256();
const __m256i lane = _mm256_setr_epi32(0, 1, 2, 3, 4, 5, 6, 7);
@@ -138,8 +139,8 @@ _map_span8(DATA32 *d, int w, const Evas_Map_Span_Run *run,
bl = _map_fetch8(run->texels, _mm256_add_epi32(row2, x1));
br = _map_fetch8(run->texels, _mm256_add_epi32(row2, x2));
- _map_weights8(_mm256_and_si256(_mm256_srli_epi32(u, 8), byte), &ru_lo, &ru_hi);
- _map_weights8(_mm256_and_si256(_mm256_srli_epi32(v, 8), byte), &rv_lo, &rv_hi);
+ _map_weights8(_mm256_and_si256(_mm256_srli_epi32(outside ? u1 : u, 8), byte), &ru_lo, &ru_hi);
+ _map_weights8(_mm256_and_si256(_mm256_srli_epi32(outside ? v1 : v, 8), byte), &rv_lo, &rv_hi);
lo = _map_interp8(rv_lo,
_map_interp8(ru_lo, _mm256_unpacklo_epi8(br, zero),
_mm256_unpacklo_epi8(bl, zero)),
@@ -188,30 +189,34 @@ _map_span8(DATA32 *d, int w, const Evas_Map_Span_Run *run,
static EFL_ALWAYS_INLINE int
_map_span8_and_4(DATA32 *d, int w, const Evas_Map_Span_Run *run,
- const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp)
+ const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp,
+ const Eina_Bool outside)
{
- int done = _map_span8(d, w, run, smooth, shade, persp);
+ int done = _map_span8(d, w, run, smooth, shade, persp, outside);
- return done + _map_span4(d + done, done, w - done, run, smooth, shade, persp);
+ return done + _map_span4(d + done, done, w - done, run, smooth, shade, persp, outside);
}
-#define SPAN_FUNC(name, smooth, shade, persp) \
+#define SPAN_FUNC(name, smooth, shade, persp, outside) \
static int \
name(DATA32 *d, int w, const Evas_Map_Span_Run *run) \
{ \
- return _map_span8_and_4(d, w, run, smooth, shade, persp); \
+ return _map_span8_and_4(d, w, run, smooth, shade, persp, outside); \
}
#define SPAN_FUNCS(prefix, persp) \
- SPAN_FUNC(prefix##_nearest, EINA_FALSE, EVAS_MAP_SPAN_PLAIN, persp) \
- SPAN_FUNC(prefix##_nearest_color, EINA_FALSE, EVAS_MAP_SPAN_COLOR, persp) \
- SPAN_FUNC(prefix##_nearest_gradient, EINA_FALSE, EVAS_MAP_SPAN_GRADIENT, persp) \
- SPAN_FUNC(prefix##_smooth, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, persp) \
- SPAN_FUNC(prefix##_smooth_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, persp) \
- SPAN_FUNC(prefix##_smooth_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, persp)
+ SPAN_FUNC(prefix##_nearest, EINA_FALSE, EVAS_MAP_SPAN_PLAIN, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_nearest_color, EINA_FALSE, EVAS_MAP_SPAN_COLOR, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_nearest_gradient, EINA_FALSE, EVAS_MAP_SPAN_GRADIENT, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, persp, EINA_FALSE)
SPAN_FUNCS(_flat, EINA_FALSE)
SPAN_FUNCS(_persp, EINA_TRUE)
+SPAN_FUNC(_outside, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, EINA_FALSE, EINA_TRUE)
+SPAN_FUNC(_outside_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, EINA_FALSE, EINA_TRUE)
+SPAN_FUNC(_outside_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, EINA_FALSE, EINA_TRUE)
#define SPAN_TABLE(prefix) \
{ \
@@ -222,5 +227,6 @@ SPAN_FUNCS(_persp, EINA_TRUE)
const Evas_Map_Span_Funcs evas_common_map_span_avx2 =
{
SPAN_TABLE(_flat),
- SPAN_TABLE(_persp)
+ SPAN_TABLE(_persp),
+ { _outside, _outside_color, _outside_gradient }
};
diff --git a/src/lib/evas/common/evas_map_image_span_sse3.c b/src/lib/evas/common/evas_map_image_span_sse3.c
index bf74dbe2f9..fa17164bbe 100644
--- a/src/lib/evas/common/evas_map_image_span_sse3.c
+++ b/src/lib/evas/common/evas_map_image_span_sse3.c
@@ -10,23 +10,26 @@
#include "evas_map_image_span_x86.h"
-#define SPAN_FUNC(name, smooth, shade, persp) \
+#define SPAN_FUNC(name, smooth, shade, persp, outside) \
static int \
name(DATA32 *d, int w, const Evas_Map_Span_Run *run) \
{ \
- return _map_span4(d, 0, w, run, smooth, shade, persp); \
+ return _map_span4(d, 0, w, run, smooth, shade, persp, outside); \
}
#define SPAN_FUNCS(prefix, persp) \
- SPAN_FUNC(prefix##_nearest, EINA_FALSE, EVAS_MAP_SPAN_PLAIN, persp) \
- SPAN_FUNC(prefix##_nearest_color, EINA_FALSE, EVAS_MAP_SPAN_COLOR, persp) \
- SPAN_FUNC(prefix##_nearest_gradient, EINA_FALSE, EVAS_MAP_SPAN_GRADIENT, persp) \
- SPAN_FUNC(prefix##_smooth, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, persp) \
- SPAN_FUNC(prefix##_smooth_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, persp) \
- SPAN_FUNC(prefix##_smooth_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, persp)
+ SPAN_FUNC(prefix##_nearest, EINA_FALSE, EVAS_MAP_SPAN_PLAIN, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_nearest_color, EINA_FALSE, EVAS_MAP_SPAN_COLOR, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_nearest_gradient, EINA_FALSE, EVAS_MAP_SPAN_GRADIENT, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, persp, EINA_FALSE) \
+ SPAN_FUNC(prefix##_smooth_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, persp, EINA_FALSE)
SPAN_FUNCS(_flat, EINA_FALSE)
SPAN_FUNCS(_persp, EINA_TRUE)
+SPAN_FUNC(_outside, EINA_TRUE, EVAS_MAP_SPAN_PLAIN, EINA_FALSE, EINA_TRUE)
+SPAN_FUNC(_outside_color, EINA_TRUE, EVAS_MAP_SPAN_COLOR, EINA_FALSE, EINA_TRUE)
+SPAN_FUNC(_outside_gradient, EINA_TRUE, EVAS_MAP_SPAN_GRADIENT, EINA_FALSE, EINA_TRUE)
#define SPAN_TABLE(prefix) \
{ \
@@ -37,5 +40,6 @@ SPAN_FUNCS(_persp, EINA_TRUE)
const Evas_Map_Span_Funcs evas_common_map_span_sse3 =
{
SPAN_TABLE(_flat),
- SPAN_TABLE(_persp)
+ SPAN_TABLE(_persp),
+ { _outside, _outside_color, _outside_gradient }
};
diff --git a/src/lib/evas/common/evas_map_image_span_x86.h b/src/lib/evas/common/evas_map_image_span_x86.h
index 4d1aeeaa41..5b7a564a85 100644
--- a/src/lib/evas/common/evas_map_image_span_x86.h
+++ b/src/lib/evas/common/evas_map_image_span_x86.h
@@ -87,7 +87,8 @@ _map_persp4(const Evas_Map_Span_Run *run, __m128 at, __m128i *u, __m128i *v,
* not accumulated, so they do not depend on who drew the pixels before. */
static EFL_ALWAYS_INLINE int
_map_span4(DATA32 *d, int first, int w, const Evas_Map_Span_Run *run,
- const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp)
+ const Eina_Bool smooth, const Evas_Map_Span_Shade shade, const Eina_Bool persp,
+ const Eina_Bool outside)
{
const __m128i zero = _mm_setzero_si128();
const __m128i stride = _mm_set1_epi32(run->stride);
@@ -153,8 +154,8 @@ _map_span4(DATA32 *d, int first, int w, const Evas_Map_Span_Run *run,
bl = _map_fetch4(run->texels, _mm_add_epi32(row2, x1));
br = _map_fetch4(run->texels, _mm_add_epi32(row2, x2));
- _map_weights4(_mm_and_si128(_mm_srli_epi32(u, 8), byte), &ru_lo, &ru_hi);
- _map_weights4(_mm_and_si128(_mm_srli_epi32(v, 8), byte), &rv_lo, &rv_hi);
+ _map_weights4(_mm_and_si128(_mm_srli_epi32(outside ? u1 : u, 8), byte), &ru_lo, &ru_hi);
+ _map_weights4(_mm_and_si128(_mm_srli_epi32(outside ? v1 : v, 8), byte), &rv_lo, &rv_hi);
lo = _map_interp4(rv_lo,
_map_interp4(ru_lo, _mm_unpacklo_epi8(br, zero),
_mm_unpacklo_epi8(bl, zero)),
diff --git a/src/tests/evas/evas_test_map_simd.c b/src/tests/evas/evas_test_map_simd.c
index 07e7aa8ffa..1a0e399ef2 100644
--- a/src/tests/evas/evas_test_map_simd.c
+++ b/src/tests/evas/evas_test_map_simd.c
@@ -70,9 +70,19 @@ static const Shade shades[] =
#define COUNT(a) (sizeof(a) / sizeof((a)[0]))
/* by shape, shade, nearest or smooth, opaque or alpha, flat or at an angle */
-#define SCENES (COUNT(shapes) * COUNT(shades) * 2 * 2 * 2)
+#define MAP_SCENES (COUNT(shapes) * COUNT(shades) * 2 * 2 * 2)
/* the flat scenes come first */
-#define FLAT_SCENES (SCENES / 2)
+#define FLAT_SCENES (MAP_SCENES / 2)
+/* then smooth anti-aliased objects, which have their own rasterizer: by
+ * shape, shade, opaque or alpha, flat or at an angle */
+#define AA_SCENES (COUNT(shapes) * COUNT(shades) * 2 * 2)
+/* and anti-aliased turned faces: their mesh edges put pixels a hair outside
+ * the source */
+#define TURNED_SCENES 100
+#define SCENES (MAP_SCENES + AA_SCENES + TURNED_SCENES)
+/* the plain loop of the anti-aliased rasterizer rounds texture and color
+ * positions in its own way */
+#define AA_TOLERANCE 6
#define SCENE_PIXELS (CANVAS_W * CANVAS_H)
#define BYTES (SCENES * SCENE_PIXELS * sizeof(unsigned int))
@@ -98,6 +108,62 @@ _source_fill(unsigned int *pixels, Eina_Bool alpha)
}
}
+static void
+_scene_draw(Ecore_Evas *ee, Evas_Object *img, Evas_Map *map, const Shape *shape,
+ const Shade *shade, int angled, int smooth, unsigned int *out)
+{
+ const int u[4] = { 0, SRC_W, SRC_W, 0 };
+ const int v[4] = { 0, 0, SRC_H, SRC_H };
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ const unsigned char *c = shade->col[i];
+ int z = (angled && ((i == 1) || (i == 2))) ? 250 : 0;
+
+ evas_map_point_coord_set(map, i, shape->x[i], shape->y[i], z);
+ evas_map_point_image_uv_set(map, i, u[i], v[i]);
+ evas_map_point_color_set(map, i, c[0], c[1], c[2], c[3]);
+ }
+ if (angled)
+ evas_map_util_3d_perspective(map, CANVAS_W / 2, CANVAS_H / 2, 0, 100);
+ evas_map_smooth_set(map, smooth);
+ evas_object_map_set(img, map);
+ evas_object_map_enable_set(img, EINA_TRUE);
+ evas_object_show(img);
+ evas_damage_rectangle_add(ecore_evas_get(ee), 0, 0, CANVAS_W, CANVAS_H);
+ ecore_evas_manual_render(ee);
+ memcpy(out, ecore_evas_buffer_pixels_get(ee),
+ SCENE_PIXELS * sizeof(unsigned int));
+ evas_object_hide(img);
+}
+
+static void
+_turned_draw(Ecore_Evas *ee, Evas_Object *img, Evas_Map *map, const Shape *shape,
+ double degrees, unsigned int *out)
+{
+ const int u[4] = { 0, SRC_W, SRC_W, 0 };
+ const int v[4] = { 0, 0, SRC_H, SRC_H };
+ int i;
+
+ for (i = 0; i < 4; i++)
+ {
+ evas_map_point_coord_set(map, i, shape->x[i], shape->y[i], 0);
+ evas_map_point_image_uv_set(map, i, u[i], v[i]);
+ evas_map_point_color_set(map, i, 255, 255, 255, 255);
+ }
+ evas_map_util_rotate(map, degrees, CANVAS_W / 2, CANVAS_H / 2);
+ evas_map_smooth_set(map, EINA_TRUE);
+ evas_object_map_set(img, map);
+ evas_object_map_enable_set(img, EINA_TRUE);
+ evas_object_show(img);
+ evas_damage_rectangle_add(ecore_evas_get(ee), 0, 0, CANVAS_W, CANVAS_H);
+ ecore_evas_manual_render(ee);
+ memcpy(out, ecore_evas_buffer_pixels_get(ee),
+ SCENE_PIXELS * sizeof(unsigned int));
+ evas_object_hide(img);
+}
+
static void
_render(unsigned int *out)
{
@@ -107,7 +173,7 @@ _render(unsigned int *out)
Evas_Map *map;
unsigned int src[SRC_W * SRC_H];
size_t shape, shade;
- int angled, alpha, smooth, i;
+ int angled, alpha, smooth;
if (!ecore_evas_init()) _exit(2);
ee = ecore_evas_buffer_new(CANVAS_W, CANVAS_H);
@@ -139,33 +205,40 @@ _render(unsigned int *out)
for (shade = 0; shade < COUNT(shades); shade++)
for (shape = 0; shape < COUNT(shapes); shape++)
{
- const int u[4] = { 0, SRC_W, SRC_W, 0 };
- const int v[4] = { 0, 0, SRC_H, SRC_H };
-
- for (i = 0; i < 4; i++)
- {
- const unsigned char *c = shades[shade].col[i];
- int z = (angled && ((i == 1) || (i == 2))) ? 250 : 0;
-
- evas_map_point_coord_set(map, i, shapes[shape].x[i],
- shapes[shape].y[i], z);
- evas_map_point_image_uv_set(map, i, u[i], v[i]);
- evas_map_point_color_set(map, i, c[0], c[1], c[2], c[3]);
- }
- if (angled)
- evas_map_util_3d_perspective(map, CANVAS_W / 2, CANVAS_H / 2, 0, 100);
- evas_map_smooth_set(map, smooth);
- evas_object_map_set(img[alpha], map);
- evas_object_map_enable_set(img[alpha], EINA_TRUE);
- evas_object_show(img[alpha]);
- evas_damage_rectangle_add(e, 0, 0, CANVAS_W, CANVAS_H);
- ecore_evas_manual_render(ee);
- memcpy(out, ecore_evas_buffer_pixels_get(ee),
- SCENE_PIXELS * sizeof(unsigned int));
+ _scene_draw(ee, img[alpha], map, &shapes[shape], &shades[shade],
+ angled, smooth, out);
out += SCENE_PIXELS;
- evas_object_hide(img[alpha]);
}
evas_map_free(map);
+ map = evas_map_new(4);
+ for (angled = 0; angled < 2; angled++)
+ for (alpha = 0; alpha < 2; alpha++)
+ for (shade = 0; shade < COUNT(shades); shade++)
+ for (shape = 0; shape < COUNT(shapes); shape++)
+ {
+ evas_object_anti_alias_set(img[alpha], EINA_TRUE);
+ _scene_draw(ee, img[alpha], map, &shapes[shape], &shades[shade],
+ angled, 1, out);
+ out += SCENE_PIXELS;
+ }
+ evas_map_free(map);
+
+ map = evas_map_new(4);
+ evas_object_anti_alias_set(img[0], EINA_TRUE);
+ {
+ int i;
+
+ for (i = 0; i < TURNED_SCENES; i++)
+ {
+ const int w = 20 + ((i * 37) % 90), h = 15 + ((i * 23) % 80);
+ const int x = 10 + ((i * 13) % 50), y = 5 + ((i * 7) % 30);
+ Shape quad = { "turned", { x, x + w, x + w, x }, { y, y, y + h, y + h } };
+
+ _turned_draw(ee, img[0], map, &quad, 3.7 * (i + 1), out);
+ out += SCENE_PIXELS;
+ }
+ }
+ evas_map_free(map);
ecore_evas_free(ee);
ecore_evas_shutdown();
}
@@ -197,38 +270,66 @@ _tier_render(const char *disable)
return out;
}
+/* the largest difference between two pixels' channels, also kept in worst */
+static int
+_levels_apart(unsigned int a, unsigned int b, int *worst)
+{
+ int channel, off = 0;
+
+ for (channel = 0; channel < 32; channel += 8)
+ {
+ int d = abs((int)((a >> channel) & 0xff) - (int)((b >> channel) & 0xff));
+
+ if (d > off) off = d;
+ }
+ if (off > *worst) *worst = off;
+ return off;
+}
+
static int
_tier_compare(const char *tier, const unsigned int *got, const unsigned int *ref,
- size_t from, size_t to)
+ size_t from, size_t to, int tolerance)
{
size_t i, bad = 0;
+ int worst = 0;
for (i = from; i < to; i++)
{
const unsigned int *g = got + (i * SCENE_PIXELS);
const unsigned int *r = ref + (i * SCENE_PIXELS);
+ size_t in_aa = (i < MAP_SCENES) ? 0 : (i - MAP_SCENES);
+ size_t per_kind = COUNT(shapes) * COUNT(shades);
size_t shape = i % COUNT(shapes);
size_t shade = (i / COUNT(shapes)) % COUNT(shades);
- size_t smooth = (i / (COUNT(shapes) * COUNT(shades))) % 2;
- size_t alpha = (i / (COUNT(shapes) * COUNT(shades) * 2)) % 2;
- size_t angled = i / (COUNT(shapes) * COUNT(shades) * 4);
+ int smooth = (i >= MAP_SCENES) || ((i / per_kind) % 2);
+ size_t alpha = (i < MAP_SCENES) ? ((i / (per_kind * 2)) % 2) : ((in_aa / per_kind) % 2);
+ size_t angled = (i < MAP_SCENES) ? (i / (per_kind * 4)) : (in_aa / (per_kind * 2));
int p, count = 0, first = -1;
for (p = 0; p < SCENE_PIXELS; p++)
- if (g[p] != r[p])
+ if ((g[p] != r[p]) && (_levels_apart(g[p], r[p], &worst) > tolerance))
{
if (first < 0) first = p;
count++;
}
if (!count) continue;
+ if (i >= (MAP_SCENES + AA_SCENES))
+ {
+ if (bad++ < 8)
+ fprintf(stderr, "%s: turned face %zu: %d pixels differ, first at %d,%d "
+ "got %08x want %08x\n", tier, i - MAP_SCENES - AA_SCENES, count,
+ first % CANVAS_W, first / CANVAS_W, g[first], r[first]);
+ continue;
+ }
if (bad++ < 8)
- fprintf(stderr, "%s: %s %s %s %s %s: %d pixels differ, first at %d,%d "
- "got %08x want %08x\n", tier, shapes[shape].name,
- shades[shade].name, smooth ? "smooth" : "nearest",
+ fprintf(stderr, "%s:%s %s %s %s %s %s: %d pixels differ, first at %d,%d "
+ "got %08x want %08x\n", tier, (i >= MAP_SCENES) ? " anti-aliased" : "",
+ shapes[shape].name, shades[shade].name, smooth ? "smooth" : "nearest",
alpha ? "alpha" : "opaque", angled ? "angled" : "flat", count, first % CANVAS_W,
first / CANVAS_W, g[first], r[first]);
}
- if (bad) fprintf(stderr, "%s: %zu of %zu scenes differ\n", tier, bad, to - from);
+ if (bad) fprintf(stderr, "%s: %zu of %zu scenes differ, by up to %d levels\n",
+ tier, bad, to - from, worst);
return !!bad;
}
@@ -256,9 +357,11 @@ main(void)
return 1;
}
- failed = _tier_compare("without avx2", mid, ref, 0, FLAT_SCENES);
- failed |= _tier_compare("native", full, ref, 0, FLAT_SCENES);
- failed |= _tier_compare("native against without avx2", full, mid, FLAT_SCENES, SCENES);
+ failed = _tier_compare("without avx2", mid, ref, 0, FLAT_SCENES, 0);
+ failed |= _tier_compare("native", full, ref, 0, FLAT_SCENES, 0);
+ failed |= _tier_compare("native against without avx2", full, mid,
+ FLAT_SCENES, SCENES, 0);
+ failed |= _tier_compare("without avx2", mid, ref, MAP_SCENES, SCENES, AA_TOLERANCE);
printf("%zu scenes, %zu drawn pixels, reference hash %016llx\n",
(size_t)SCENES, drawn, hash);
return failed;
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.