From 7d4b2e75627b7966eb3186b9c3a43eb3b39d6fbc Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Mon, 2 Jan 2017 02:10:19 -0800 Subject: roto: skip lerp of identical colors With the current checkerboard pattern the majority of the interpolation being performed is pointless. Of course with a more complex texture this won't be as beneficial, but for now it makes a significant FPS improvement. --- modules/roto/roto.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/modules/roto/roto.c b/modules/roto/roto.c index bf92df4..a7d1750 100644 --- a/modules/roto/roto.c +++ b/modules/roto/roto.c @@ -92,8 +92,22 @@ static uint32_t bilerp_color(uint8_t texture[256][256], color_t *palette, int tx } } - n_color = lerp_color(&palette[nw], &palette[ne], x_alpha); - s_color = lerp_color(&palette[sw], &palette[se], x_alpha); + /* Skip interpolation of same colors, a substantial optimization with plain textures like the checker pattern */ + if (nw == ne) { + if (ne == sw && sw == se) { + return (FIXED_TO_INT(palette[sw].r) << 16) | (FIXED_TO_INT(palette[sw].g) << 8) | FIXED_TO_INT(palette[sw].b); + } + n_color = palette[nw]; + } else { + n_color = lerp_color(&palette[nw], &palette[ne], x_alpha); + } + + if (sw == se) { + s_color = palette[sw]; + } else { + s_color = lerp_color(&palette[sw], &palette[se], x_alpha); + } + color = lerp_color(&n_color, &s_color, y_alpha); return (FIXED_TO_INT(color.r) << 16) | (FIXED_TO_INT(color.g) << 8) | FIXED_TO_INT(color.b); -- cgit v1.2.1