Blitter: Performance adjustments to 32bpp anim non-SSE blitter

This commit is contained in:
Jonathan G Rennison
2018-01-20 01:58:28 +00:00
parent 11a10299d1
commit f8193578c1

View File

@@ -11,6 +11,7 @@
#include "../stdafx.h" #include "../stdafx.h"
#include "../video/video_driver.hpp" #include "../video/video_driver.hpp"
#include "../zoom_func.h"
#include "32bpp_anim.hpp" #include "32bpp_anim.hpp"
#include "../table/sprites.h" #include "../table/sprites.h"
@@ -25,10 +26,11 @@ Blitter_32bppAnim::~Blitter_32bppAnim()
free(this->anim_alloc); free(this->anim_alloc);
} }
template <BlitterMode mode, bool no_anim_translucent> template <BlitterMode mode, bool fast_path>
inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom) inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
{ {
const SpriteData *src = (const SpriteData *)bp->sprite; const SpriteData *src = (const SpriteData *)bp->sprite;
const BlitterSpriteFlags sprite_flags = src->flags;
const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]); const Colour *src_px = (const Colour *)(src->data + src->offset[zoom][0]);
const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]); const uint16 *src_n = (const uint16 *)(src->data + src->offset[zoom][1]);
@@ -42,10 +44,15 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left; uint16 *anim = this->anim_buf + this->ScreenToAnimOffset((uint32 *)bp->dst) + bp->top * this->anim_buf_pitch + bp->left;
const byte *remap = bp->remap; // store so we don't have to access it via bp everytime const byte *remap = bp->remap; // store so we don't have to access it via bp everytime
const int width = bp->width;
const int pitch = bp->pitch;
const int anim_pitch = this->anim_buf_pitch;
const int skip_left = bp->skip_left;
const int height = bp->height;
for (int y = 0; y < bp->height; y++) { for (int y = 0; y < height; y++) {
Colour *dst_ln = dst + bp->pitch; Colour *dst_ln = dst + pitch;
uint16 *anim_ln = anim + this->anim_buf_pitch; uint16 *anim_ln = anim + anim_pitch;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px); const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_px++; src_px++;
@@ -53,44 +60,52 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n); const uint16 *src_n_ln = (const uint16 *)((const byte *)src_n + *(const uint32 *)src_n);
src_n += 2; src_n += 2;
Colour *dst_end = dst + bp->skip_left; Colour *dst_end = dst;
uint n; uint n;
while (dst < dst_end) { if (!fast_path) {
n = *src_n++; dst_end += skip_left;
if (src_px->a == 0) { while (dst < dst_end) {
dst += n; n = *src_n++;
src_px ++;
src_n++;
if (dst > dst_end) anim += dst - dst_end; if (src_px->a == 0) {
} else { dst += n;
if (dst + n > dst_end) { src_px ++;
uint d = dst_end - dst; src_n++;
src_px += d;
src_n += d;
dst = dst_end - bp->skip_left; if (dst > dst_end) anim += dst - dst_end;
dst_end = dst + bp->width; } else {
if (dst + n > dst_end) {
uint d = dst_end - dst;
src_px += d;
src_n += d;
n = min<uint>(n - d, (uint)bp->width); dst = dst_end - skip_left;
goto draw; dst_end = dst + width;
n = min<uint>(n - d, (uint)width);
goto draw;
}
dst += n;
src_px += n;
src_n += n;
} }
dst += n;
src_px += n;
src_n += n;
} }
dst -= skip_left;
dst_end -= skip_left;
} }
dst -= bp->skip_left; dst_end += width;
dst_end -= bp->skip_left;
dst_end += bp->width;
while (dst < dst_end) { while (dst < dst_end) {
n = min<uint>(*src_n++, (uint)(dst_end - dst)); if (fast_path) {
n = *src_n++;
} else {
n = min<uint>(*src_n++, (uint)(dst_end - dst));
}
if (src_px->a == 0) { if (src_px->a == 0) {
anim += n; anim += n;
@@ -217,7 +232,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
break; break;
default: default:
if (no_anim_translucent) { if (fast_path || (src_px->a == 255 && (sprite_flags & SF_NO_ANIM))) {
do { do {
*anim++ = 0; *anim++ = 0;
*dst++ = src_px->data; *dst++ = src_px->data;
@@ -280,7 +295,8 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
/* FALL THROUGH */ /* FALL THROUGH */
case BM_NORMAL: case BM_NORMAL:
if ((sprite_flags & SF_NO_ANIM) && !(sprite_flags & SF_TRANSLUCENT)) { if ((sprite_flags & (SF_NO_ANIM | SF_TRANSLUCENT)) == SF_NO_ANIM &&
bp->skip_left == 0 && bp->width == UnScaleByZoom(bp->sprite_width, zoom)) {
Draw<BM_NORMAL, true>(bp, zoom); Draw<BM_NORMAL, true>(bp, zoom);
} else { } else {
Draw<BM_NORMAL, false>(bp, zoom); Draw<BM_NORMAL, false>(bp, zoom);