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 "../video/video_driver.hpp"
#include "../zoom_func.h"
#include "32bpp_anim.hpp"
#include "../table/sprites.h"
@@ -25,10 +26,11 @@ Blitter_32bppAnim::~Blitter_32bppAnim()
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)
{
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 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;
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++) {
Colour *dst_ln = dst + bp->pitch;
uint16 *anim_ln = anim + this->anim_buf_pitch;
for (int y = 0; y < height; y++) {
Colour *dst_ln = dst + pitch;
uint16 *anim_ln = anim + anim_pitch;
const Colour *src_px_ln = (const Colour *)((const byte *)src_px + *(const uint32 *)src_px);
src_px++;
@@ -53,10 +60,13 @@ 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);
src_n += 2;
Colour *dst_end = dst + bp->skip_left;
Colour *dst_end = dst;
uint n;
if (!fast_path) {
dst_end += skip_left;
while (dst < dst_end) {
n = *src_n++;
@@ -72,10 +82,10 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
src_px += d;
src_n += d;
dst = dst_end - bp->skip_left;
dst_end = dst + bp->width;
dst = dst_end - skip_left;
dst_end = dst + width;
n = min<uint>(n - d, (uint)bp->width);
n = min<uint>(n - d, (uint)width);
goto draw;
}
dst += n;
@@ -84,13 +94,18 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
}
}
dst -= bp->skip_left;
dst_end -= bp->skip_left;
dst -= skip_left;
dst_end -= skip_left;
}
dst_end += bp->width;
dst_end += width;
while (dst < dst_end) {
if (fast_path) {
n = *src_n++;
} else {
n = min<uint>(*src_n++, (uint)(dst_end - dst));
}
if (src_px->a == 0) {
anim += n;
@@ -217,7 +232,7 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
break;
default:
if (no_anim_translucent) {
if (fast_path || (src_px->a == 255 && (sprite_flags & SF_NO_ANIM))) {
do {
*anim++ = 0;
*dst++ = src_px->data;
@@ -280,7 +295,8 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
/* FALL THROUGH */
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);
} else {
Draw<BM_NORMAL, false>(bp, zoom);