GRAPHICS: Fix BlendBlit additive blending mode

This commit is contained in:
Wyatt Radkiewicz 2023-08-11 16:37:10 -07:00 committed by Eugene Sandulenko
parent 1b752d6a62
commit 41815c9816
3 changed files with 9 additions and 18 deletions

View File

@ -20,7 +20,6 @@
*/
#include "common/scummsys.h"
#ifdef SCUMMVM_AVX2
#include <immintrin.h>
#include "graphics/blit.h"
@ -194,7 +193,7 @@ struct AdditiveBlend {
srcg = _mm256_and_si256(_mm256_add_epi32(dstg, _mm256_mullo_epi32(srcg, _mm256_mullo_epi32(_mm256_set1_epi32(cg), ina))), _mm256_set1_epi32(BlendBlit::kGModMask));
srcr = _mm256_and_si256(_mm256_add_epi32(dstr, _mm256_srli_epi32(_mm256_mullo_epi32(srcr, _mm256_mullo_epi32(_mm256_set1_epi32(cr), ina)), BlendBlit::kRModShift - 16)), _mm256_set1_epi32(BlendBlit::kRModMask));
src = _mm256_and_si256(src, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_and_si256(dst, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_or_si256(src, _mm256_or_si256(srcb, _mm256_or_si256(srcg, srcb)));
} else if (alphamod) {
__m256i srcg = _mm256_and_si256(src, _mm256_set1_epi32(BlendBlit::kGModMask));
@ -205,7 +204,7 @@ struct AdditiveBlend {
srcg = _mm256_and_si256(_mm256_add_epi32(dstg, _mm256_srli_epi32(_mm256_mullo_epi32(srcg, ina), 8)), _mm256_set1_epi32(BlendBlit::kGModMask));
srcrb = _mm256_and_si256(_mm256_add_epi32(dstrb, _mm256_mullo_epi32(srcrb, ina)), _mm256_set1_epi32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = _mm256_and_si256(src, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_and_si256(dst, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_or_si256(src, _mm256_or_si256(srcrb, srcg));
} else {
__m256i srcg = _mm256_and_si256(src, _mm256_set1_epi32(BlendBlit::kGModMask));
@ -216,7 +215,7 @@ struct AdditiveBlend {
srcg = _mm256_and_si256(_mm256_add_epi32(dstg, srcg), _mm256_set1_epi32(BlendBlit::kGModMask));
srcrb = _mm256_and_si256(_mm256_slli_epi32(_mm256_add_epi32(dstrb, srcrb), 8), _mm256_set1_epi32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = _mm256_and_si256(src, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_and_si256(dst, _mm256_set1_epi32(BlendBlit::kAModMask));
src = _mm256_or_si256(src, _mm256_or_si256(srcrb, srcg));
}
@ -466,5 +465,3 @@ void BlendBlit::blitAVX2(Args &args, const TSpriteBlendMode &blendMode, const Al
}
} // End of namespace Graphics
#endif // SCUMMVM_AVX2

View File

@ -20,7 +20,6 @@
*/
#include "common/scummsys.h"
#ifdef SCUMMVM_NEON
#include <arm_neon.h>
#include "graphics/blit.h"
@ -194,7 +193,7 @@ struct AdditiveBlend {
srcg = vandq_u32(vaddq_u32(dstg, vmulq_u32(srcg, vmulq_u32(vmovq_n_u32(cg), ina))), vmovq_n_u32(BlendBlit::kGModMask));
srcr = vandq_u32(vaddq_u32(dstr, vshrq_n_u32(vmulq_u32(srcr, vmulq_u32(vmovq_n_u32(cr), ina)), BlendBlit::kRModShift - 16)), vmovq_n_u32(BlendBlit::kRModMask));
src = vandq_u32(src, vmovq_n_u32(BlendBlit::kAModMask));
src = vandq_u32(dst, vmovq_n_u32(BlendBlit::kAModMask));
src = vorrq_u32(src, vorrq_u32(srcb, vorrq_u32(srcg, srcr)));
} else if (alphamod) {
uint32x4_t srcg = vandq_u32(src, vmovq_n_u32(BlendBlit::kGModMask));
@ -205,7 +204,7 @@ struct AdditiveBlend {
srcg = vandq_u32(vaddq_u32(dstg, vshrq_n_u32(vmulq_u32(srcg, ina), 8)), vmovq_n_u32(BlendBlit::kGModMask));
srcrb = vandq_u32(vaddq_u32(dstrb, vmulq_u32(srcrb, ina)), vmovq_n_u32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = vandq_u32(src, vmovq_n_u32(BlendBlit::kAModMask));
src = vandq_u32(dst, vmovq_n_u32(BlendBlit::kAModMask));
src = vorrq_u32(src, vorrq_u32(srcrb, srcg));
} else {
uint32x4_t srcg = vandq_u32(src, vmovq_n_u32(BlendBlit::kGModMask));
@ -216,7 +215,7 @@ struct AdditiveBlend {
srcg = vandq_u32(vaddq_u32(dstg, srcg), vmovq_n_u32(BlendBlit::kGModMask));
srcrb = vandq_u32(vshlq_n_u32(vaddq_u32(dstrb, srcrb), 8), vmovq_n_u32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = vandq_u32(src, vmovq_n_u32(BlendBlit::kAModMask));
src = vandq_u32(dst, vmovq_n_u32(BlendBlit::kAModMask));
src = vorrq_u32(src, vorrq_u32(srcrb, srcg));
}
@ -464,5 +463,3 @@ void BlendBlit::blitNEON(Args &args, const TSpriteBlendMode &blendMode, const Al
}
} // end of namespace Graphics
#endif // SCUMMVM_NEON

View File

@ -20,7 +20,6 @@
*/
#include "common/scummsys.h"
#ifdef SCUMMVM_SSE2
#include <immintrin.h>
#include "graphics/blit.h"
@ -200,7 +199,7 @@ struct AdditiveBlend {
srcg = _mm_and_si128(_mm_add_epi32(dstg, sse2_mul32(srcg, sse2_mul32(_mm_set1_epi32(cg), ina))), _mm_set1_epi32(BlendBlit::kGModMask));
srcr = _mm_and_si128(_mm_add_epi32(dstr, _mm_srli_epi32(sse2_mul32(srcr, sse2_mul32(_mm_set1_epi32(cr), ina)), BlendBlit::kRModShift - 16)), _mm_set1_epi32(BlendBlit::kRModMask));
src = _mm_and_si128(src, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_and_si128(dst, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_or_si128(src, _mm_or_si128(srcb, _mm_or_si128(srcg, srcr)));
} else if (alphamod) {
__m128i srcg = _mm_and_si128(src, _mm_set1_epi32(BlendBlit::kGModMask));
@ -211,7 +210,7 @@ struct AdditiveBlend {
srcg = _mm_and_si128(_mm_add_epi32(dstg, _mm_srli_epi32(sse2_mul32(srcg, ina), 8)), _mm_set1_epi32(BlendBlit::kGModMask));
srcrb = _mm_and_si128(_mm_add_epi32(dstrb, sse2_mul32(srcrb, ina)), _mm_set1_epi32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = _mm_and_si128(src, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_and_si128(dst, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_or_si128(src, _mm_or_si128(srcrb, srcg));
} else {
__m128i srcg = _mm_and_si128(src, _mm_set1_epi32(BlendBlit::kGModMask));
@ -222,7 +221,7 @@ struct AdditiveBlend {
srcg = _mm_and_si128(_mm_add_epi32(dstg, srcg), _mm_set1_epi32(BlendBlit::kGModMask));
srcrb = _mm_and_si128(_mm_slli_epi32(_mm_add_epi32(dstrb, srcrb), 8), _mm_set1_epi32(BlendBlit::kRModMask | BlendBlit::kBModMask));
src = _mm_and_si128(src, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_and_si128(dst, _mm_set1_epi32(BlendBlit::kAModMask));
src = _mm_or_si128(src, _mm_or_si128(srcrb, srcg));
}
@ -467,5 +466,3 @@ void BlendBlit::blitSSE2(Args &args, const TSpriteBlendMode &blendMode, const Al
}
} // End of namespace Graphics
#endif // SSE2